Skip to content
Snippets Groups Projects
Verified Commit 38548cc6 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #10740 TIME 2 add substitue admin front

parent e33270e1
No related branches found
No related tags found
No related merge requests found
...@@ -147,6 +147,7 @@ ...@@ -147,6 +147,7 @@
"visaWorkflow": "Visa workflow", "visaWorkflow": "Visa workflow",
"noteUser": "Note user", "noteUser": "Note user",
"mainDocument": "main document", "mainDocument": "main document",
"search": "Search" "search": "Search",
"substitution": "Délégation"
} }
} }
...@@ -147,6 +147,7 @@ ...@@ -147,6 +147,7 @@
"visaWorkflow": "Circuit de visa", "visaWorkflow": "Circuit de visa",
"noteUser": "Annotateur", "noteUser": "Annotateur",
"mainDocument": "document principal", "mainDocument": "document principal",
"search": "Rechercher" "search": "Rechercher",
"substitution": "Délégation"
} }
} }
...@@ -60,6 +60,7 @@ class SignatureController ...@@ -60,6 +60,7 @@ class SignatureController
if ($signature['fingerprint'] == $fingerprint) { if ($signature['fingerprint'] == $fingerprint) {
$signatures[] = [ $signatures[] = [
'id' => $signature['id'], 'id' => $signature['id'],
'substituted' => $signature['substituted'],
'encodedSignature' => base64_encode(file_get_contents($pathToSignature)) 'encodedSignature' => base64_encode(file_get_contents($pathToSignature))
]; ];
} else { } else {
......
...@@ -384,7 +384,7 @@ class UserController ...@@ -384,7 +384,7 @@ class UserController
ValidatorModel::notEmpty($args, ['id']); ValidatorModel::notEmpty($args, ['id']);
ValidatorModel::intVal($args, ['id']); ValidatorModel::intVal($args, ['id']);
$user = UserModel::getById(['select' => ['id', 'login', 'email', 'firstname', 'lastname', 'picture', 'preferences'], 'id' => $args['id']]); $user = UserModel::getById(['select' => ['id', 'login', 'email', 'firstname', 'lastname', 'picture', 'preferences', 'substitute'], 'id' => $args['id']]);
if (empty($user['picture'])) { if (empty($user['picture'])) {
$user['picture'] = base64_encode(file_get_contents('src/frontend/assets/user_picture.png')); $user['picture'] = base64_encode(file_get_contents('src/frontend/assets/user_picture.png'));
......
...@@ -196,10 +196,9 @@ ...@@ -196,10 +196,9 @@
</div> </div>
</div> </div>
</mat-tab> </mat-tab>
<mat-tab label="{{'lang.administrations' | translate}}" <mat-tab label="{{'lang.administrations' | translate}}">
*ngIf="signaturesService.userLogged.canManageRestUsers">
<div class="profile-content"> <div class="profile-content">
<div class="input-row"> <div class="input-row" *ngIf="signaturesService.userLogged.canManageRestUsers">
<fieldset> <fieldset>
<legend align="left">{{'lang.wsUser' | translate}}</legend> <legend align="left">{{'lang.wsUser' | translate}}</legend>
<div class="form-container"> <div class="form-container">
...@@ -232,6 +231,33 @@ ...@@ -232,6 +231,33 @@
</div> </div>
</fieldset> </fieldset>
</div> </div>
<div class="input-row">
<fieldset>
<legend align="left">{{'lang.substitution' | translate}}</legend>
<div class="form-container">
<div class="form-2-col">
Utilisateur délégataire
</div>
<div class="form-2-col">
<mat-form-field>
<mat-select placeholder="Choisissez un remplaçant" name="usersRest"
[(ngModel)]="profileInfo.substitute">
<mat-option value=""></mat-option>
<ng-container *ngFor="let userRest of usersRest">
<mat-option *ngIf="userRest.id !== profileInfo.id"
[value]="userRest.id">
{{userRest.firstname}}
{{userRest.lastname}}</mat-option>
</ng-container>
</mat-select>
</mat-form-field>
</div>
</div>
<ng-container *ngIf="this.profileInfo.substitute !== '' && this.profileInfo.substitute !== undefined">
<button type="button" class="signListButton" mat-stroked-button *ngFor="let signature of signaturesService.signaturesList; let i=index" (click)="toggleSignature(i)" [class.selected]="signature.substituted"><img [src]="sanitizer.bypassSecurityTrustUrl('data:image/png;base64,' + signature.encodedSignature)"/></button>
</ng-container>
</fieldset>
</div>
</div> </div>
</mat-tab> </mat-tab>
</mat-tab-group> </mat-tab-group>
...@@ -239,7 +265,8 @@ ...@@ -239,7 +265,8 @@
<button class="validate" mat-button color="primary" type="submit" <button class="validate" mat-button color="primary" type="submit"
[disabled]="allowValidate() || !profileForm.form.valid">{{ [disabled]="allowValidate() || !profileForm.form.valid">{{
msgButton | translate}}</button> msgButton | translate}}</button>
<button *ngIf="signaturesService.mobileMode" class="cancel" mat-icon-button type="button" (tap)="closeProfile();"> <button *ngIf="signaturesService.mobileMode" class="cancel" mat-icon-button type="button"
(tap)="closeProfile();">
<mat-icon fontSet="fas" fontIcon="fa-arrow-left fa-2x"></mat-icon> <mat-icon fontSet="fas" fontIcon="fa-arrow-left fa-2x"></mat-icon>
</button> </button>
</span> </span>
......
...@@ -54,6 +54,7 @@ ...@@ -54,6 +54,7 @@
} }
.avatarProfile { .avatarProfile {
z-index: 2;
cursor: pointer; cursor: pointer;
position: absolute; position: absolute;
/*background: url(../../assets/user_sample.svg) $primary;*/ /*background: url(../../assets/user_sample.svg) $primary;*/
...@@ -187,4 +188,18 @@ legend { ...@@ -187,4 +188,18 @@ legend {
.mat-icon { .mat-icon {
height:auto; height:auto;
}
.signListButton {
margin:5px;
border: solid white;
img {
width: 150px;
}
}
.selected {
border: solid #F99830;
} }
\ No newline at end of file
...@@ -22,6 +22,7 @@ export class ProfileComponent implements OnInit { ...@@ -22,6 +22,7 @@ export class ProfileComponent implements OnInit {
@ViewChild('passwordContent') passwordContent: MatExpansionPanel; @ViewChild('passwordContent') passwordContent: MatExpansionPanel;
profileInfo: any = { profileInfo: any = {
substitute: '',
preferences: [] preferences: []
}; };
hideCurrentPassword: Boolean = true; hideCurrentPassword: Boolean = true;
...@@ -199,8 +200,14 @@ export class ProfileComponent implements OnInit { ...@@ -199,8 +200,14 @@ export class ProfileComponent implements OnInit {
'lastname': this.profileInfo.lastname, 'lastname': this.profileInfo.lastname,
'email': this.profileInfo.email, 'email': this.profileInfo.email,
'picture': this.profileInfo.picture, 'picture': this.profileInfo.picture,
'preferences': this.profileInfo.preferences 'preferences': this.profileInfo.preferences,
'substitute': this.profileInfo.substitute,
}; };
if (this.profileInfo.substitute.userId !== '') {
alert('Vous avez choisie une délégation, vous ne pourrez plus viser ou signer de courrier.');
}
if (this.profileInfo.picture === this.signaturesService.userLogged.picture) { if (this.profileInfo.picture === this.signaturesService.userLogged.picture) {
profileToSend.picture = ''; profileToSend.picture = '';
} else { } else {
...@@ -215,6 +222,7 @@ export class ProfileComponent implements OnInit { ...@@ -215,6 +222,7 @@ export class ProfileComponent implements OnInit {
this.signaturesService.userLogged.lastname = this.profileInfo.lastname; this.signaturesService.userLogged.lastname = this.profileInfo.lastname;
this.signaturesService.userLogged.picture = data.user.picture; this.signaturesService.userLogged.picture = data.user.picture;
this.signaturesService.userLogged.preferences = data.user.preferences; this.signaturesService.userLogged.preferences = data.user.preferences;
this.signaturesService.userLogged.substitute = data.user.substitute;
this.profileInfo.picture = data.user.picture; this.profileInfo.picture = data.user.picture;
this.setLang(this.signaturesService.userLogged.preferences.lang); this.setLang(this.signaturesService.userLogged.preferences.lang);
this.cookieService.set( 'maarchParapheurLang', this.signaturesService.userLogged.preferences.lang ); this.cookieService.set( 'maarchParapheurLang', this.signaturesService.userLogged.preferences.lang );
...@@ -248,6 +256,14 @@ export class ProfileComponent implements OnInit { ...@@ -248,6 +256,14 @@ export class ProfileComponent implements OnInit {
this.msgButton = 'lang.validate'; this.msgButton = 'lang.validate';
this.closeProfile(); this.closeProfile();
} }
if (this.profileInfo.substitute.userId !== '') {
this.http.patch('../rest/users/' + this.signaturesService.userLogged.id + '/signatures/substituted', {'signatures': this.signaturesService.signaturesList})
.subscribe(() => { }, (err) => {
this.notificationService.handleErrors(err);
});
}
}, (err) => { }, (err) => {
this.disableState = false; this.disableState = false;
this.msgButton = 'lang.validate'; this.msgButton = 'lang.validate';
...@@ -345,7 +361,7 @@ export class ProfileComponent implements OnInit { ...@@ -345,7 +361,7 @@ export class ProfileComponent implements OnInit {
} }
swithToAdmin() { swithToAdmin() {
if (this.usersRest.length === 0) { /*if (this.usersRest.length === 0) {
this.getPassRules(); this.getPassRules();
this.http.get('../rest/users?mode=rest') this.http.get('../rest/users?mode=rest')
.subscribe((data: any) => { .subscribe((data: any) => {
...@@ -355,6 +371,25 @@ export class ProfileComponent implements OnInit { ...@@ -355,6 +371,25 @@ export class ProfileComponent implements OnInit {
}, (err: any) => { }, (err: any) => {
this.notificationService.handleErrors(err); this.notificationService.handleErrors(err);
}); });
}*/
if (this.usersRest.length === 0) {
this.getPassRules();
this.http.get('../rest/users')
.subscribe((data: any) => {
this.usersRest = data.users;
}, (err: any) => {
this.notificationService.handleErrors(err);
});
}
if (this.signaturesService.signaturesList.length === 0) {
this.http.get('../rest/users/' + this.profileInfo.id + '/signatures')
.subscribe((data: any) => {
this.signaturesService.signaturesList = data.signatures;
}, (err: any) => {
this.notificationService.handleErrors(err);
});
} }
} }
...@@ -370,8 +405,11 @@ export class ProfileComponent implements OnInit { ...@@ -370,8 +405,11 @@ export class ProfileComponent implements OnInit {
}); });
} }
setLang(lang: any) { setLang(lang: any) {
this.translate.use(lang); this.translate.use(lang);
} }
toggleSignature(i: number) {
this.signaturesService.signaturesList[i].substituted = !this.signaturesService.signaturesList[i].substituted;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment