fix: return full url of assets in admin and mgmt api (#3157)

* fix: return full url of assets in admin and mgmt api

* remove asset loading over asset service

* remove unused code

Co-authored-by: Max Peintner <max@caos.ch>
This commit is contained in:
Livio Amstutz
2022-02-04 15:02:18 +01:00
committed by GitHub
parent 31bdd3f431
commit ab62f2d79d
10 changed files with 588 additions and 626 deletions

View File

@@ -1,6 +1,5 @@
import { Component, Inject } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { DomSanitizer } from '@angular/platform-browser';
import { AssetService } from 'src/app/services/asset.service';
import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
import { ToastService } from 'src/app/services/toast.service';
@@ -17,9 +16,7 @@ export class ProfilePictureComponent {
@Inject(MAT_DIALOG_DATA) public data: any,
private toast: ToastService,
private assetService: AssetService,
private sanitizer: DomSanitizer,
) {
}
) {}
public onDrop(event: any): Promise<any> | void {
const filelist: FileList = event.target.files;
@@ -33,25 +30,26 @@ export class ProfilePictureComponent {
}
public deletePic(): void {
this.authService.removeMyAvatar().then(() => {
this.toast.showInfo('USER.PROFILE.AVATAR.DELETESUCCESS', true);
this.data.profilePic = null;
}).catch(error => {
this.toast.showError(error);
});
this.authService
.removeMyAvatar()
.then(() => {
this.toast.showInfo('USER.PROFILE.AVATAR.DELETESUCCESS', true);
this.data.profilePic = null;
})
.catch((error) => {
this.toast.showError(error);
});
}
private handleUploadPromise(task: Promise<any>): Promise<any> {
return task.then(() => {
this.toast.showInfo('POLICY.TOAST.UPLOADSUCCESS', true);
this.assetService.load('users/me/avatar').then(data => {
const objectURL = URL.createObjectURL(data);
const pic = this.sanitizer.bypassSecurityTrustUrl(objectURL);
this.data.profilePic = pic;
}).catch(error => {
this.toast.showError(error);
});
}).catch(error => this.toast.showError(error));
return task
.then(() => {
this.toast.showInfo('POLICY.TOAST.UPLOADSUCCESS', true);
this.authService.getMyUser().then((resp) => {
this.data.profilePic = resp.user?.human?.profile?.avatarUrl ?? '';
});
})
.catch((error) => this.toast.showError(error));
}
public closeDialog(): void {