From a2493b993c41557010644c2ae3d6d696ffe1375a Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Thu, 3 Jan 2019 18:40:34 +0100 Subject: [PATCH] FEAT #8489 begin sendmail test --- .../sendmail-administration.component.html | 65 ++++++++++++++----- .../sendmail-administration.component.ts | 37 +++++++++-- src/frontend/lang/lang-en.ts | 4 +- src/frontend/lang/lang-fr.ts | 6 +- src/frontend/lang/lang-nl.ts | 4 +- 5 files changed, 84 insertions(+), 32 deletions(-) diff --git a/src/frontend/app/administration/sendmail/sendmail-administration.component.html b/src/frontend/app/administration/sendmail/sendmail-administration.component.html index 880988557ce..2bd150ff32d 100644 --- a/src/frontend/app/administration/sendmail/sendmail-administration.component.html +++ b/src/frontend/app/administration/sendmail/sendmail-administration.component.html @@ -35,11 +35,11 @@ </mat-form-field> </div> </div> - <div class="form-group" [style.opacity]="sendmail.type != 'internalParam' ? '0.5' : '1'"> + <div class="form-group" [style.opacity]="sendmail.type != 'smtp' ? '0.5' : '1'"> <div class="col-md-2"> <mat-form-field> <mat-select name="SMTPSecure" placeholder="Méthode d'authentification" - [disabled]="sendmail.type != 'internalParam'" [(ngModel)]="sendmail.secure"> + [disabled]="sendmail.type != 'smtp'" [(ngModel)]="sendmail.secure"> <mat-option *ngFor="let security of smtpSecList" [value]="security"> {{security}} </mat-option> @@ -48,48 +48,52 @@ </div> <div class="col-md-9"> <mat-form-field> - <input matInput name="host" [disabled]="sendmail.type != 'internalParam'" [(ngModel)]="sendmail.host" placeholder="{{lang.host}}"> + <input matInput name="host" [disabled]="sendmail.type != 'smtp'" + [(ngModel)]="sendmail.host" placeholder="{{lang.host}}"> </mat-form-field> </div> <div class="col-md-1"> <mat-form-field> <input name="port" type="number" matInput [(ngModel)]="sendmail.port" - [disabled]="sendmail.type != 'internalParam'" placeholder="{{lang.port}}"> + [disabled]="sendmail.type != 'smtp'" placeholder="{{lang.port}}"> </mat-form-field> </div> </div> - <div class="form-group" [style.opacity]="sendmail.type != 'internalParam' ? '0.5' : '1'"> + <div class="form-group" [style.opacity]="sendmail.type != 'smtp' ? '0.5' : '1'"> <div class="col-md-12"> <mat-slide-toggle color="primary" name="SMTPAuth" [(ngModel)]="sendmail.auth" - [disabled]="sendmail.type != 'internalParam'">{{lang.enableAuth}}</mat-slide-toggle> + [disabled]="sendmail.type != 'smtp'">{{lang.enableAuth}}</mat-slide-toggle> </div> </div> - <div class="form-group" [style.opacity]="sendmail.type != 'internalParam' ? '0.5' : '1'"> + <div class="form-group" [style.opacity]="sendmail.type != 'smtp' ? '0.5' : '1'"> <div class="col-md-12"> <mat-form-field> - <input name="user" [(ngModel)]="sendmail.user" [disabled]="!sendmail.auth || sendmail.type != 'internalParam'" + <input name="user" [(ngModel)]="sendmail.user" [disabled]="!sendmail.auth || sendmail.type != 'smtp'" matInput placeholder="{{lang.id}}"> </mat-form-field> </div> <div class="col-md-12"> <mat-form-field> - <input name="password" [type]="hidePassword ? 'password' : 'text'" [(ngModel)]="sendmail.password" [disabled]="!sendmail.auth || sendmail.type != 'internalParam'" - matInput placeholder="{{lang.password}}"> - <mat-icon style="cursor: pointer;" matSuffix (click)="hidePassword = !hidePassword" class="fa fa-2x" [ngClass]="[hidePassword ? 'fa-eye-slash' : 'fa-eye']"></mat-icon> + <input name="password" [type]="hidePassword ? 'password' : 'text'" [(ngModel)]="sendmail.password" + [disabled]="!sendmail.auth || sendmail.type != 'smtp'" matInput + placeholder="{{lang.password}}"> + <mat-icon color="primary" style="cursor: pointer;" matSuffix (click)="hidePassword = !hidePassword" + class="fa fa-2x" [ngClass]="[hidePassword ? 'fa-eye-slash' : 'fa-eye']"></mat-icon> </mat-form-field> </div> </div> - <div class="form-group" [style.opacity]="sendmail.type != 'internalParam' ? '0.5' : '1'"> + <div class="form-group" [style.opacity]="sendmail.type != 'smtp' ? '0.5' : '1'"> <div class="col-md-12"> <mat-form-field> - <input name="mailFrom" [(ngModel)]="sendmail.from" [disabled]="sendmail.type != 'internalParam'" + <input name="mailFrom" [(ngModel)]="sendmail.from" [disabled]="sendmail.type != 'smtp'" matInput placeholder="{{lang.mailFrom}}"> </mat-form-field> </div> </div> <div class="col-md-12 text-center" style="padding:10px;"> - <button mat-raised-button type="submit" color="primary" [disabled]="checkModif()" >{{lang.validate}}</button> - <button mat-raised-button type="button" color="default" [disabled]="checkModif()" (click)="cancelModification()">{{lang.cancel}}</button> + <button mat-raised-button type="submit" color="primary" [disabled]="checkModif()">{{lang.validate}}</button> + <button mat-raised-button type="button" color="default" [disabled]="checkModif()" + (click)="cancelModification()">{{lang.cancel}}</button> </div> </form> </mat-tab> @@ -97,9 +101,36 @@ </mat-card> </mat-sidenav-content> <mat-sidenav #snav2 [mode]="mobileQuery.matches ? 'over' : 'side'" [fixedInViewport]="mobileQuery.matches" - fixedTopGap="56" position='end' [opened]="mobileQuery.matches ? false : false" style="overflow-x:hidden;max-width:500px;"> - <mat-nav-list> + fixedTopGap="56" position='end' [opened]="mobileQuery.matches ? false : false" style="overflow-x:hidden;width:500px;" + (opened)="initServerConnection()"> + <mat-nav-list disableRipple="true"> <h3 mat-subheader>État du serveur</h3> + <mat-list-item *ngIf="serverConnectionLoading"> + <mat-icon mat-list-icon fontSet="far" fontIcon="fa-circle fa-2x"></mat-icon> + <p mat-line> En cours de connexion... </p> + </mat-list-item> + <mat-list-item *ngIf="!serverConnectionLoading"> + <mat-icon mat-list-icon fontSet="fas" style="color:green" fontIcon="fa-circle fa-2x"></mat-icon> + <p mat-line> Connexion établie </p> + </mat-list-item> + <h3 mat-subheader>Test d'envoi</h3> + <div class="form-group" [style.opacity]="sendmail.type != 'smtp' ? '0.5' : '1'"> + <div class="col-md-12"> + <mat-form-field> + <input matInput placeholder="Adresse d'envoi" [disabled]="serverConnectionLoading"> + <mat-icon *ngIf="!serverConnectionLoading" title="Commencer le test" (click)="initEmailSend()" color="primary" style="cursor: pointer;" matSuffix + class="fa fa-paper-plane fa-2x"></mat-icon> + </mat-form-field> + </div> + </div> + <mat-list-item *ngIf="emailSendLoading"> + <mat-icon mat-list-icon fontSet="fas" fontIcon="fa-paper-plane fa-2x"></mat-icon> + <p mat-line> En cours d'envoi... </p> + </mat-list-item> + <mat-list-item *ngIf="!emailSendLoading"> + <mat-icon mat-list-icon fontSet="fas" style="color:green" fontIcon="fa-check fa-2x"></mat-icon> + <p mat-line> Envoi réussi </p> + </mat-list-item> </mat-nav-list> </mat-sidenav> </mat-sidenav-container> diff --git a/src/frontend/app/administration/sendmail/sendmail-administration.component.ts b/src/frontend/app/administration/sendmail/sendmail-administration.component.ts index 72b0e002355..00a6e63e2b6 100644 --- a/src/frontend/app/administration/sendmail/sendmail-administration.component.ts +++ b/src/frontend/app/administration/sendmail/sendmail-administration.component.ts @@ -13,6 +13,7 @@ declare var angularGlobals: any; @Component({ templateUrl: "sendmail-administration.component.html", + styleUrls: ['sendmail-administration.component.scss'], providers: [NotificationService] }) export class SendmailAdministrationComponent implements OnInit { @@ -28,7 +29,7 @@ export class SendmailAdministrationComponent implements OnInit { loading : boolean = false; sendmail: any = { - 'type': 'internalParam', + 'type': 'smtp', 'host': '', 'auth': true, 'user': '', @@ -41,18 +42,25 @@ export class SendmailAdministrationComponent implements OnInit { smtpTypeList = [ { - id : 'internalParam', - label : this.lang.internalParam - } - ,{ - id : 'smtpRelay', - label : this.lang.smtpRelay + id : 'smtp', + label : this.lang.smtp + }, + { + id : 'sendmail', + label : 'Sendmail' + }, + { + id : 'qmail', + label : 'Qmail' } ]; smtpTypeDesc = ''; smtpSecList = ['ssl', 'tls']; sendmailClone: any = {}; hidePassword: boolean = true; + serverConnectionLoading: boolean = false; + emailSendLoading: boolean = false; + constructor(changeDetectorRef: ChangeDetectorRef, media: MediaMatcher, public http: HttpClient, private notify: NotificationService, private headerService: HeaderService) { @@ -102,4 +110,19 @@ export class SendmailAdministrationComponent implements OnInit { checkModif() { return (JSON.stringify(this.sendmailClone) === JSON.stringify(this.sendmail)); } + + + initServerConnection() { + this.serverConnectionLoading = true; + setTimeout(() => { + this.serverConnectionLoading = false; + }, 5000); + } + + initEmailSend() { + this.emailSendLoading = true; + setTimeout(() => { + this.emailSendLoading = false; + }, 5000); + } } diff --git a/src/frontend/lang/lang-en.ts b/src/frontend/lang/lang-en.ts index 1448d6823c0..75fc602df1c 100755 --- a/src/frontend/lang/lang-en.ts +++ b/src/frontend/lang/lang-en.ts @@ -720,8 +720,8 @@ export const LANG_EN = { "undefinedStatus" : "Undefined status", "subEntities" : "Entities (and sub-entities)", "category_id" : "Category", - "smtpRelay" : "Smtp relay", - "internalParam" : "Internal configuration", + "smtp" : "Internal configuration", + "smtpDesc" : "Internal configuration", "enableAuth" : "Activate authentication", "checkSendmail" : "Check mail server status", "mustReconnect" : "Please reconnect", diff --git a/src/frontend/lang/lang-fr.ts b/src/frontend/lang/lang-fr.ts index 59d3e648f59..0b9f225f796 100755 --- a/src/frontend/lang/lang-fr.ts +++ b/src/frontend/lang/lang-fr.ts @@ -746,10 +746,8 @@ export const LANG_FR = { "undefinedStatus" : "Statut non défini", "subEntities" : "Entités (et sous-entités)", "category_id" : "Catégorie", - "smtpRelay" : "Relai smtp", - "smtpRelayDesc" : "Utilisation d'un relai smtp du serveur (ssmtp par exemple), configuration externe à l'application", - "internalParam" : "Configuration interne", - "internalParamDesc" : "Utilisateur du module interne phpmailer de l'application", + "smtp" : "Configuration interne", + "stmpDesc" : "Utilisateur du module interne phpmailer de l'application", "enableAuth" : "Activer l'authentification", "checkSendmail" : "Vérifier l'état du serveur", "mustReconnect" : "Veuillez vous reconnecter", diff --git a/src/frontend/lang/lang-nl.ts b/src/frontend/lang/lang-nl.ts index ce9ba9d8e56..c276ac418ac 100755 --- a/src/frontend/lang/lang-nl.ts +++ b/src/frontend/lang/lang-nl.ts @@ -748,8 +748,8 @@ export const LANG_NL = { "undefinedStatus" : "_TO_TRANSLATE", "subEntities" : "_TO_TRANSLATE", "category_id" : "_TO_TRANSLATE", - "smtpRelay" : "_TO_TRANSLATE", - "internalParam" : "_TO_TRANSLATE", + "smtp" : "_TO_TRANSLATE", + "smtpDesc" : "_TO_TRANSLATE", "enableAuth" : "_TO_TRANSLATE", "checkSendmail" : "_TO_TRANSLATE", "mustReconnect" : "_TO_TRANSLATE", -- GitLab