File size: 5,466 Bytes
11452ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<div *ngIf="dataSource; else loading">
    <div style="padding: 15px">
    <div class="row">
        <div class="table table-responsive pb-4 pt-4">
        <div class="example-header">
            <mat-form-field appearance="outline">
                <mat-label i18n="Search">Search</mat-label>
                <input matInput (keyup)="applyFilter($event)">
            </mat-form-field>
        </div>
        
        <div class="mat-elevation-z8" style="margin-right: 15px;">
        
            <mat-table #table [dataSource]="dataSource" matSort>
        
            <!-- Name Column -->
            <ng-container matColumnDef="name">
                <mat-header-cell *matHeaderCellDef mat-sort-header><ng-container i18n="Username users table header"> User name </ng-container></mat-header-cell>

                <mat-cell *matCellDef="let row">
                <span *ngIf="editObject && editObject.uid === row.uid; else noteditingname">
                    <span style="width: 80%;">
                    <mat-form-field>
                        <input matInput [(ngModel)]="constructedObject['name']" type="text" style="font-size: 12px">
                    </mat-form-field>
                    </span>
                </span>
                <ng-template #noteditingname>
                    {{row.name}} 
                </ng-template>
                </mat-cell>
            </ng-container>
        
            <!-- Email Column -->
            <ng-container matColumnDef="role">
                <mat-header-cell *matHeaderCellDef mat-sort-header><ng-container i18n="Role users table header"> Role </ng-container></mat-header-cell>
                <mat-cell *matCellDef="let row">
                    <span *ngIf="editObject && editObject.uid === row.uid; else noteditingemail">
                    <span style="width: 80%;">
                        <mat-form-field>
                            <mat-select [(ngModel)]="constructedObject['role']">
                                <mat-option value="admin">Admin</mat-option>
                                <mat-option value="user">User</mat-option>
                            </mat-select>
                        </mat-form-field>
                    </span>
                    </span>
                    <ng-template #noteditingemail>
                        {{row.role}}
                    </ng-template>
                </mat-cell>
            </ng-container>

            <!-- Actions Column -->
            <ng-container matColumnDef="actions">
                <mat-header-cell *matHeaderCellDef mat-sort-header><ng-container i18n="Actions users table header"> Actions </ng-container></mat-header-cell>
                <mat-cell *matCellDef="let row">
                <span *ngIf="editObject && editObject.uid === row.uid; else notediting">
                    <button mat-icon-button color="primary" (click)="finishEditing(row.uid)" matTooltip="Save" i18n-matTooltip="save user edit action button tooltip">
                    <mat-icon>done</mat-icon>
                    </button>
                    <button mat-icon-button (click)="disableEditMode()" matTooltip="Cancel" i18n-matTooltip="cancel user edit action button tooltip">
                    <mat-icon>cancel</mat-icon>
                    </button>
                </span>
                <ng-template #notediting>
                    <button mat-icon-button (click)="enableEditMode(row.uid)" matTooltip="Edit user" i18n-matTooltip="edit user action button tooltip">
                    <mat-icon>edit</mat-icon>
                    </button>
                </ng-template>
                <button (click)="manageUser(row.uid)" mat-icon-button [disabled]="editObject && editObject.uid === row.uid" matTooltip="Manage user" i18n-matTooltip="manage user action button tooltip">
                    <mat-icon>settings</mat-icon>
                </button>
                <button mat-icon-button [disabled]="editObject && editObject.uid === row.uid || row.uid === postsService.user.uid" (click)="removeUser(row.uid)" matTooltip="Delete user" i18n-matTooltip="delete user action button tooltip">
                    <mat-icon>delete</mat-icon>
                </button>
                </mat-cell>
            </ng-container>
        
            <mat-header-row *matHeaderRowDef="displayedColumns"></mat-header-row>
            <mat-row *matRowDef="let row; columns: displayedColumns;">
            </mat-row>
            </mat-table>
        
            <mat-paginator #paginator [length]="length"
                [pageSize]="pageSize"
                [pageSizeOptions]="pageSizeOptions">
            </mat-paginator>

            <button color="primary" [disabled]="!this.users" mat-raised-button (click)="openAddUserDialog()" style="float: left; top: -45px; left: 15px">
                <ng-container i18n="Add users button">Add Users</ng-container>
            </button>
        </div>
        </div>
    </div>
    <button color="primary" [matMenuTriggerFor]="edit_roles_menu" class="edit-role" mat-raised-button><ng-container i18n="Edit role">Edit Role</ng-container></button>
    <mat-menu #edit_roles_menu="matMenu">
        <button (click)="openModifyRole(role)" mat-menu-item *ngFor="let role of roles">{{role.key}}</button>
    </mat-menu>
    </div>
    
  </div>
    
    <div style="position: absolute" class="centered">
      <ng-template #loading>
        <mat-spinner></mat-spinner>
      </ng-template>
    </div>