1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00

Add missing sharing listing #569

This commit is contained in:
Patrik J. Braun 2023-01-08 11:56:49 +01:00
parent c672b9823a
commit 13410b5d1c
6 changed files with 97 additions and 0 deletions

View File

@ -104,6 +104,7 @@ import { JobButtonComponent } from './ui/settings/workflow/button/job-button.set
import { JobProgressComponent } from './ui/settings/workflow/progress/job-progress.settings.component';
import {SettingsEntryComponent} from './ui/settings/template/settings-entry/settings-entry.component';
import { UsersComponent } from './ui/settings/users/users.component';
import { SharingsListComponent } from './ui/settings/sharings-list/sharings-list.component';
@Injectable()
export class MyHammerConfig extends HammerGestureConfig {
@ -238,6 +239,7 @@ Marker.prototype.options.icon = iconDefault;
FileDTOToPathPipe,
PhotoFilterPipe,
UsersComponent,
SharingsListComponent,
],
providers: [
{provide: HTTP_INTERCEPTORS, useClass: CSRFInterceptor, multi: true},

View File

@ -106,6 +106,7 @@
<app-settings-gallery-statistic></app-settings-gallery-statistic>
</ng-container>
<app-settings-users *ngIf="cp=='Users'"></app-settings-users>
<app-settigns-sharings-list *ngIf="cp=='Sharing'"></app-settigns-sharings-list>
</app-settings-template>
</div>
</div>

View File

@ -0,0 +1,26 @@
import {Injectable} from '@angular/core';
import {SharingDTO} from '../../../../../common/entities/SharingDTO';
import {NetworkService} from '../../../model/network/network.service';
import {SettingsService} from '../settings.service';
@Injectable({
providedIn: 'root'
})
export class SharingListService {
constructor(private networkService: NetworkService,
private settingsService: SettingsService) {
}
public getSharingList(): Promise<SharingDTO[]> {
if (!this.settingsService.settings.value.Sharing.enabled) {
return Promise.resolve([]);
}
return this.networkService.getJson('/share/list');
}
public deleteSharing(sharing: SharingDTO): Promise<void> {
return this.networkService.deleteJson('/share/' + sharing.sharingKey);
}
}

View File

@ -0,0 +1,33 @@
<ng-container *ngIf="shares && shares.length >0">
<table class="table table-hover">
<thead>
<tr>
<th i18n>Key</th>
<th i18n>Folder</th>
<th i18n>Creator</th>
<th i18n>Expires</th>
<th></th>
</tr>
</thead>
<tbody>
<tr *ngFor="let share of shares">
<td>{{share.sharingKey}}</td>
<td>{{share.path}}</td>
<td>{{share.creator.name}}</td>
<td>{{share.expires | date}}</td>
<td>
<button (click)="deleteSharing(share)" class="btn btn-danger float-end">
<span class="oi oi-trash" aria-hidden="true" aria-label="Delete"></span>
</button>
</td>
</tr>
</tbody>
</table>
</ng-container>
<ng-container *ngIf="!shares || shares.length == 0">
<div class="panel-info" i18n>
No sharing was created.
</div>
</ng-container>

View File

@ -0,0 +1,35 @@
import {Component, OnInit} from '@angular/core';
import {SharingDTO} from '../../../../../common/entities/SharingDTO';
import {SharingListService} from './sharing-list.service';
@Component({
selector: 'app-settigns-sharings-list',
templateUrl: './sharings-list.component.html',
styleUrls: ['./sharings-list.component.css']
})
export class SharingsListComponent implements OnInit {
public shares: SharingDTO[] = [];
constructor(public sharingList: SharingListService) {
}
ngOnInit(): void {
this.getSharingList();
}
async deleteSharing(sharing: SharingDTO): Promise<void> {
await this.sharingList.deleteSharing(sharing);
await this.getSharingList();
}
private async getSharingList(): Promise<void> {
try {
this.shares = await this.sharingList.getSharingList();
} catch (err) {
this.shares = [];
throw err;
}
}
}