Update admin and admin-info components
This commit is contained in:
parent
5b109da648
commit
a4024f6f72
|
@ -10,4 +10,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<router-outlet></router-outlet>
|
<div class="m-4">
|
||||||
|
<router-outlet></router-outlet>
|
||||||
|
</div>
|
||||||
|
|
|
@ -1 +1,9 @@
|
||||||
Info
|
<form>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="dl_scan" class="form-label">LIFM distaccamento</label>
|
||||||
|
<input class="form-control" type="file" id="dl_scan" (change)="onLIFMSelected($event)" #LIFMFileUpload>
|
||||||
|
<button type="button" class="btn btn-primary m-2" *ngIf="LIFMNotUploadedYet" (click)="uploadLIFM(LIFMFileUpload)">
|
||||||
|
<i class="fas fa-upload"></i> Carica LIFM
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
|
import { ApiClientService } from 'src/app/_services/api-client.service';
|
||||||
|
import Swal from 'sweetalert2';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-admin-info',
|
selector: 'app-admin-info',
|
||||||
|
@ -6,10 +9,67 @@ import { Component, OnInit } from '@angular/core';
|
||||||
styleUrls: ['./admin-info.component.scss']
|
styleUrls: ['./admin-info.component.scss']
|
||||||
})
|
})
|
||||||
export class AdminInfoComponent implements OnInit {
|
export class AdminInfoComponent implements OnInit {
|
||||||
|
allowedImageTypes = ["application/pdf"];
|
||||||
|
maxImageSize = 1024 * 1024 * 50; //50MB
|
||||||
|
|
||||||
constructor() { }
|
LIFMNotUploadedYet = false;
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private translateService: TranslateService,
|
||||||
|
private api: ApiClientService
|
||||||
|
) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onLIFMSelected(event: any) {
|
||||||
|
const file: File = event.target.files[0];
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
if(!this.allowedImageTypes.includes(file.type)) {
|
||||||
|
event.target.value = null;
|
||||||
|
Swal.fire({
|
||||||
|
title: this.translateService.instant("error_title"),
|
||||||
|
text: this.translateService.instant("validation.document_format_not_supported"),
|
||||||
|
icon: 'error',
|
||||||
|
confirmButtonText: 'Ok'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(file.size > this.maxImageSize) {
|
||||||
|
event.target.value = null;
|
||||||
|
Swal.fire({
|
||||||
|
title: this.translateService.instant("error_title"),
|
||||||
|
text: this.translateService.instant("validation.file_too_big"),
|
||||||
|
icon: 'error',
|
||||||
|
confirmButtonText: 'Ok'
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.LIFMNotUploadedYet = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uploadLIFM(input: HTMLInputElement) {
|
||||||
|
if(!input.files || !input.files[0]) return;
|
||||||
|
|
||||||
|
console.log(input.files[0]);
|
||||||
|
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', input.files[0], input.files[0].name);
|
||||||
|
|
||||||
|
this.api.post("admin/lifm", formData).then((response: any) => {
|
||||||
|
console.log(response);
|
||||||
|
this.LIFMNotUploadedYet = false;
|
||||||
|
}).catch((err: any) => {
|
||||||
|
console.log(err);
|
||||||
|
Swal.fire({
|
||||||
|
title: this.translateService.instant("error_title"),
|
||||||
|
text: err.error.message,
|
||||||
|
icon: 'error',
|
||||||
|
confirmButtonText: 'Ok'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -193,8 +193,6 @@ export class EditUserComponent implements OnInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
uploadDrivingLicenseScan(input: HTMLInputElement) {
|
uploadDrivingLicenseScan(input: HTMLInputElement) {
|
||||||
const filename = "test.png"
|
|
||||||
|
|
||||||
if(!input.files || !input.files[0]) return;
|
if(!input.files || !input.files[0]) return;
|
||||||
|
|
||||||
console.log(input.files[0]);
|
console.log(input.files[0]);
|
||||||
|
|
Loading…
Reference in New Issue