|
|
@ -7,10 +7,11 @@ import { Clipboard, ClipboardModule } from '@angular/cdk/clipboard'; |
|
|
import { |
|
|
import { |
|
|
ChangeDetectionStrategy, |
|
|
ChangeDetectionStrategy, |
|
|
Component, |
|
|
Component, |
|
|
|
|
|
computed, |
|
|
CUSTOM_ELEMENTS_SCHEMA, |
|
|
CUSTOM_ELEMENTS_SCHEMA, |
|
|
|
|
|
effect, |
|
|
inject, |
|
|
inject, |
|
|
Input, |
|
|
input, |
|
|
OnChanges, |
|
|
|
|
|
output |
|
|
output |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
import { MatButtonModule } from '@angular/material/button'; |
|
|
@ -46,17 +47,26 @@ import ms from 'ms'; |
|
|
templateUrl: './access-table.component.html', |
|
|
templateUrl: './access-table.component.html', |
|
|
styleUrls: ['./access-table.component.scss'] |
|
|
styleUrls: ['./access-table.component.scss'] |
|
|
}) |
|
|
}) |
|
|
export class GfAccessTableComponent implements OnChanges { |
|
|
export class GfAccessTableComponent { |
|
|
@Input() accesses: Access[]; |
|
|
public readonly accesses = input.required<Access[]>(); |
|
|
@Input() showActions: boolean; |
|
|
public readonly showActions = input<boolean>(false); |
|
|
@Input() user: User; |
|
|
public readonly user = input.required<User>(); |
|
|
|
|
|
|
|
|
public readonly accessDeleted = output<string>(); |
|
|
public readonly accessDeleted = output<string>(); |
|
|
public readonly accessToUpdate = output<string>(); |
|
|
public readonly accessToUpdate = output<string>(); |
|
|
|
|
|
|
|
|
public readonly baseUrl = window.location.origin; |
|
|
protected readonly baseUrl = window.location.origin; |
|
|
public dataSource: MatTableDataSource<Access>; |
|
|
protected readonly dataSource = new MatTableDataSource<Access>(); |
|
|
public displayedColumns: string[] = []; |
|
|
|
|
|
|
|
|
protected readonly displayedColumns = computed(() => { |
|
|
|
|
|
const columns = ['alias', 'grantee', 'type', 'details']; |
|
|
|
|
|
|
|
|
|
|
|
if (this.showActions()) { |
|
|
|
|
|
columns.push('actions'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return columns; |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
private readonly clipboard = inject(Clipboard); |
|
|
private readonly clipboard = inject(Clipboard); |
|
|
private readonly notificationService = inject(NotificationService); |
|
|
private readonly notificationService = inject(NotificationService); |
|
|
@ -72,27 +82,19 @@ export class GfAccessTableComponent implements OnChanges { |
|
|
lockOpenOutline, |
|
|
lockOpenOutline, |
|
|
removeCircleOutline |
|
|
removeCircleOutline |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public ngOnChanges() { |
|
|
effect(() => { |
|
|
this.displayedColumns = ['alias', 'grantee', 'type', 'details']; |
|
|
this.dataSource.data = this.accesses() ?? []; |
|
|
|
|
|
}); |
|
|
if (this.showActions) { |
|
|
|
|
|
this.displayedColumns.push('actions'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (this.accesses) { |
|
|
|
|
|
this.dataSource = new MatTableDataSource(this.accesses); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public getPublicUrl(aId: string): string { |
|
|
protected getPublicUrl(aId: string): string { |
|
|
const languageCode = this.user.settings.language; |
|
|
const languageCode = this.user().settings.language; |
|
|
|
|
|
|
|
|
return `${this.baseUrl}/${languageCode}/${publicRoutes.public.path}/${aId}`; |
|
|
return `${this.baseUrl}/${languageCode}/${publicRoutes.public.path}/${aId}`; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onCopyUrlToClipboard(aId: string): void { |
|
|
protected onCopyUrlToClipboard(aId: string): void { |
|
|
this.clipboard.copy(this.getPublicUrl(aId)); |
|
|
this.clipboard.copy(this.getPublicUrl(aId)); |
|
|
|
|
|
|
|
|
this.snackBar.open( |
|
|
this.snackBar.open( |
|
|
@ -104,7 +106,7 @@ export class GfAccessTableComponent implements OnChanges { |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onDeleteAccess(aId: string) { |
|
|
protected onDeleteAccess(aId: string) { |
|
|
this.notificationService.confirm({ |
|
|
this.notificationService.confirm({ |
|
|
confirmFn: () => { |
|
|
confirmFn: () => { |
|
|
this.accessDeleted.emit(aId); |
|
|
this.accessDeleted.emit(aId); |
|
|
@ -114,7 +116,7 @@ export class GfAccessTableComponent implements OnChanges { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public onUpdateAccess(aId: string) { |
|
|
protected onUpdateAccess(aId: string) { |
|
|
this.accessToUpdate.emit(aId); |
|
|
this.accessToUpdate.emit(aId); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|