Commit cdbb37da authored by Hamza HRAMCHI's avatar Hamza HRAMCHI
Browse files

FEAT #17436 TIME 1:30 WIP: choose the groups of authorized assignments

parent d9976370
......@@ -625,6 +625,7 @@
"signatureScaling": "Taux de mise à l'échelle du bloc de signature",
"originaleize": "Taille originale",
"scalingDocWith": "{{value}} % de la largeur du document",
"azure_samlConnection": "Azure SAML"
"azure_samlConnection": "Azure SAML",
"groupsToManage": "Choisir les groupes d'affectations autorisés"
}
}
......@@ -22,6 +22,11 @@
<ion-toggle slot="start" [name]="privilege.id" color="primary" [checked]="privilege.checked"
[(ngModel)]="privilege.checked" (click)="togglePrivilege(privilege, true)"></ion-toggle>
<ion-label (click)="togglePrivilege(privilege, false)">{{'lang.' + privilege.id + 'Admin' | translate}}</ion-label>
<ion-button *ngIf="privilege.id === 'manage_users' && privilege.checked" style="margin-right: 43%; margin-bottom: 10px;" fill="clear" shape="round"
(click)="$event.stopPropagation(); openGroupList()"
[title]="'lang.groupsToManage' | translate">
<ion-icon name="people" [color]="getChecked() > 0 ? 'secondary' : 'primary'" style="font-size: 20px;"></ion-icon>
</ion-button>
</ion-item>
</div>
<ion-item lines="none" *ngIf="!creationMode">
......
......@@ -12,6 +12,7 @@ import { AuthService } from '../../service/auth.service';
import { AlertController, ModalController, PopoverController } from '@ionic/angular';
import { UsersComponent } from './list/users.component';
import { of } from 'rxjs';
import { GroupModalComponent } from './modal/group-modal.component';
export interface Group {
......@@ -40,6 +41,7 @@ export class GroupComponent implements OnInit {
displayedColumns: string[];
usersList: any[];
sortedData: any[];
groups: any[] = [];
constructor(
public http: HttpClient,
......@@ -128,6 +130,54 @@ export class GroupComponent implements OnInit {
}
}
async openGroupList() {
await this.getGroups();
const modal = await this.modalController.create({
component: GroupModalComponent,
componentProps: {
groups: this.groups
}
});
await modal.present();
const { data } = await modal.onWillDismiss();
if (data !== undefined) {
this.groups = data;
}
}
getGroups() {
return new Promise((resolve) => {
this.http.get('../rest/groups').pipe(
map((data: any) => {
data = data.groups.map((item: any) => ({
id: item.id,
label: item.label,
checked: false
}));
return data;
}),
tap((data: any) => {
const result: any[] = data;
const ids: number[] = this.groups.map((el: any) => el.id);
result.forEach((element: any) => {
if (ids.indexOf(element.id) === -1) {
this.groups.push(element);
}
});
resolve(true);
}),
catchError((err: any) => {
this.notificationService.handleErrors(err);
return of(false);
})
).subscribe();
});
}
getChecked() {
return this.groups.filter((item: any) => item.checked).length;
}
canValidate() {
if (this.group.label === this.groupClone.label) {
return false;
......
<ion-header [translucent]="true">
<ion-toolbar color="primary">
<ion-title>{{'lang.groupsToManage' | translate}}</ion-title>
</ion-toolbar>
</ion-header>
<ion-content>
<ion-list>
<ion-virtual-scroll [items]="groups" approxItemHeight="50px" style="height: 450px;">
<ion-item *virtualItem="let element">
<ion-label>
{{element.label}}
</ion-label>
<ion-checkbox slot="end" [value]="element.id" [checked]="element.checked" (ionChange)="element.checked = !element.checked"></ion-checkbox>
</ion-item>
</ion-virtual-scroll>
</ion-list>
</ion-content>
<ion-footer class="ion-no-border">
<ion-toolbar>
<ion-buttons class="ion-justify-content-center">
<ion-button type="submit" color="primary" (click)="saveChanges()">
<ion-label>{{'lang.save' | translate}}</ion-label>
</ion-button>
</ion-buttons>
</ion-toolbar>
</ion-footer>
\ No newline at end of file
import { Component, Input, OnInit } from '@angular/core';
import { ModalController } from '@ionic/angular';
@Component({
templateUrl: 'group-modal.component.html',
styleUrls: ['group-modal.component.scss'],
})
export class GroupModalComponent implements OnInit {
@Input() groups: any;
constructor(
public modalController: ModalController,
) {}
async ngOnInit() {
}
saveChanges() {
this.modalController.dismiss(this.groups);
}
}
......@@ -85,6 +85,7 @@ import { HistoryListComponent } from './administration/history/history-list.comp
import { OtpListComponent } from './administration/otp/otp-list.component';
import { OtpComponent } from './administration/otp/otp.component';
import { CustomizationComponent } from './administration/customization/customization.component';
import { GroupModalComponent } from './administration/group/modal/group-modal.component';
// SERVICES
......@@ -170,7 +171,8 @@ registerLocaleData(localeFr, 'fr-FR');
NotificationComponent,
GridButtonComponent,
NotificationsListComponent,
MessageBoxComponent
MessageBoxComponent,
GroupModalComponent
],
imports: [
FormsModule,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment