user.component.html 8.78 KB
Newer Older
1
2
3
<ion-header [translucent]="true">
    <ion-toolbar color="primary">
        <ion-buttons slot="start">
4
            <ion-menu-button menu="left-menu"></ion-menu-button>
5
6
7
8
9
10
11
12
            <ion-back-button></ion-back-button>
        </ion-buttons>
        <ion-title>{{title}}</ion-title>
        <ion-avatar slot="end">
            <img [src]="user.picture">
        </ion-avatar>
    </ion-toolbar>
</ion-header>
13
14
15
16
17
18
19
20

<ion-header>
    <ion-toolbar>
        <ion-segment [value]="currentTool" (ionChange)="initTab($event.detail.value)">
            <ion-segment-button value="info">
                <ion-label>{{'lang.informations' | translate}}</ion-label>
                <ion-icon name="information-circle"></ion-icon>
            </ion-segment-button>
21
            <ion-segment-button *ngIf="!creationMode" value="groups">
22
23
24
25
26
27
28
29
                <ion-label>{{'lang.manage_groups' | translate}}</ion-label>
                <ion-icon name="people-sharp"></ion-icon>
            </ion-segment-button>
        </ion-segment>
    </ion-toolbar>
</ion-header>

<ng-container *ngIf="currentTool === 'info'">
30
31
32
    <ion-card *ngIf="!authService.mailServerOnline">
        <ion-item color="danger">
            <ion-icon name="alert-circle" slot="start"></ion-icon>
33
            <ion-label [innerHTML]="'lang.mailServerOfflineMsg' | translate :{action: creationMode ? ('lang.receiveActivationNotification' | translate) : ('lang.sendActivationNotification' | translate)}"></ion-label>
34
35
        </ion-item>
    </ion-card>
36
37
38
39
    <form style="display: contents;" id="adminForm" (ngSubmit)="onSubmit()" #adminForm="ngForm">
        <ion-content>
            <ion-item>
                <ion-label color="secondary" position="floating">{{'lang.login' | translate}} *</ion-label>
40
                <ion-input name="login" [maxlength]="128" [readonly]="!creationMode" [(ngModel)]="user.login" required pattern="^[\w.@-]*$">
41
42
43
44
                </ion-input>
            </ion-item>
            <ion-item>
                <ion-label color="secondary" position="floating">{{'lang.firstname' | translate}} *</ion-label>
45
                <ion-input name="firstname" [maxlength]="128" [(ngModel)]="user.firstname" required></ion-input>
46
47
48
            </ion-item>
            <ion-item>
                <ion-label color="secondary" position="floating">{{'lang.lastname' | translate}} *</ion-label>
49
                <ion-input name="lastname" [maxlength]="128" [(ngModel)]="user.lastname" required></ion-input>
50
51
52
            </ion-item>
            <ion-item>
                <ion-label color="secondary" position="floating">{{'lang.email' | translate}} *</ion-label>
53
                <ion-input type="email" name="email" [maxlength]="128" [(ngModel)]="user.email" required
54
55
                    pattern="(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"></ion-input>
            </ion-item>
56
            <ion-item>
57
58
59
                <ion-label color="secondary" position="floating">{{'lang.phoneAlt' | translate}}</ion-label>
                <ion-input type="text" name="phone" [(ngModel)]="user.phone"
                    pattern="\+?((|\ |\.|\(|\)|\-)?(\d)*)*\d$"></ion-input>
60
            </ion-item>
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
            <ion-item>
                <ion-label>{{'lang.restUser' | translate}}</ion-label>
                <ion-toggle slot="start" color="primary" [disabled]="!creationMode" name="isRest" [(ngModel)]="user.isRest"
                    [checked]="user.isRest" (ionChange)="getPassRules($event)"></ion-toggle>
            </ion-item>
            <ion-list>
                <ion-list-header>
                    <ion-label color="secondary">{{'lang.signatureModes' | translate}}</ion-label>
                </ion-list-header>
                <ng-container *ngFor="let signMode of authService.signatureRoles">
                    <ion-item *ngIf="signMode.id !=='visa'">
                        <ion-label [style.color]="signMode.color">{{'lang.' + signMode.id | translate}}</ion-label>
                        <ion-checkbox slot="start" [checked]="user.signatureModes.indexOf(signMode.id) > -1" (ionChange)="toggleSignMode(signMode, $event.detail.checked)" [disabled]="signMode.id === 'stamp'"></ion-checkbox>
                    </ion-item>
                </ng-container>
            </ion-list>
            <ion-item style="align-items: center;" *ngIf="user.isRest">
                <ion-button slot="end" fill="clear" color="primary" (click)="hideNewPassword = !hideNewPassword">
                    <ion-icon color="primary" [name]="hideNewPassword ? 'eye-outline' : 'eye-off-outline'">
                    </ion-icon>
                </ion-button>
                <ion-label color="secondary" position="floating">{{'lang.newPassword' | translate}}</ion-label>
                <ion-input [type]="hideNewPassword ? 'password' : 'text'" name="newPasswordRest"
                    [(ngModel)]="passwordRest.newPassword" (ionChange)="checkPasswordValidity(passwordRest.newPassword)">
                </ion-input>
86
                <ion-note color="danger" *ngIf="this.handlePassword.error && passwordRest.newPassword.length > 0"> {{ this.handlePassword.errorMsg | translate}}</ion-note>
87
88
89
90
91
92
93
94
95
96
            </ion-item>
            <ion-item style="align-items: center;" *ngIf="user.isRest">
                <ion-button slot="end" fill="clear" color="primary"
                    (click)="hideNewPasswordConfirm = !hideNewPasswordConfirm">
                    <ion-icon color="primary" [name]="hideNewPasswordConfirm ? 'eye-outline' : 'eye-off-outline'">
                    </ion-icon>
                </ion-button>
                <ion-label color="secondary" position="floating">{{'lang.passwordConfirmation' | translate}}</ion-label>
                <ion-input [type]="hideNewPasswordConfirm ? 'password' : 'text'" name="passwordConfirmation"
                    [(ngModel)]="passwordRest.passwordConfirmation"></ion-input>
97
                <ion-note color="danger" *ngIf="passwordRest.passwordConfirmation !== passwordRest.newPassword && passwordRest.passwordConfirmation.length > 0">
98
99
                    {{'lang.passwordNotMatch' | translate}}</ion-note>
                <ion-note color="success"
100
                    *ngIf="passwordRest.passwordConfirmation === passwordRest.newPassword && passwordRest.newPassword.length > 0 && passwordRest.passwordConfirmation.length> 0 && !this.handlePassword.error">
101
102
103
104
105
106
107
108
                    {{'lang.samePassword' | translate}}</ion-note>
            </ion-item>
            <ion-item text-center lines="none" style="position: sticky;bottom:0px;z-index:1;">
                <div style="display: flex;align-items: center;justify-content: center;width: 100%;background: white;">
                    <ion-button type="submit" shape="round" size="large" fill="outline" color="primary"
                        [disabled]="!adminForm.form.valid || !canValidate()">
                        <ion-label style="font-size: 13px;">{{'lang.validate' | translate}}</ion-label>
                    </ion-button>
109
110
111
112
                    <ion-button type="button" shape="round" size="large" fill="outline" color="primary"
                                *ngIf="user.canSendActivationNotification && !this.creationMode" [disabled]="!authService.mailServerOnline"  (click)="resendActivationNotification()">
                        <ion-label style="font-size: 13px;">{{'lang.sendActivationNotification' | translate}}</ion-label>
                    </ion-button>
113
114
115
116
117
118
119
                </div>
            </ion-item>
        </ion-content>
    </form>
</ng-container>

<ng-container *ngIf="currentTool === 'groups'">
120
    <ion-content>
121
122
123
124
125
126
127
128
129
        <ion-item lines="none" style="position: sticky;top:0px;z-index:1;">
            <ng-container style="display: flex;align-items: center;justify-content: center;width: 100%;background: white;">
                <div style="flex: 1;text-align: right;">
                    <ion-button slot="end" color="primary" fille="outline" shape="round" [disabled]="userGroupsClone.length === 0" (click)="openGroupsList()">
                        {{'lang.add' | translate}}
                    </ion-button>
                </div>
            </ng-container>
        </ion-item>
130
        <ion-list *ngIf="user.groups.length > 0">
131
            <ion-item *ngFor="let group of user.groups">
132
                <ion-label>{{group.label}}</ion-label>
133
134
                <ion-button  slot="end" fill="clear" shape="round"
                    (click)="unlinkGroup(group);" [title]="'lang.unlinkGroup' | translate">
135
136
                    <ion-icon color="danger" slot="icon-only" name="close-outline"></ion-icon>
                </ion-button>
137
138
139
140
            </ion-item>
        </ion-list>
        <ion-list class="no-result" *ngIf="user.groups.length === 0">
            <ion-item lines="none">
141
                <ion-label class="no-result-label" color="medium">{{(userGroupsClone.length === 0 ? 'lang.emptyGroups' : 'lang.noAssociatedGroup') | translate}}</ion-label>
142
            </ion-item>
143
        </ion-list>
144
    </ion-content>
145
</ng-container>