update license structures and init to setup image uploader

This commit is contained in:
2026-04-16 22:19:46 +03:30
parent 28575bd3d1
commit ac23d47b79
36 changed files with 379 additions and 142 deletions
+4
View File
@@ -0,0 +1,4 @@
export interface onSelectArgs {
data: FormData;
file: File;
}
@@ -0,0 +1,8 @@
<p-fileupload [name]="name" [accept]="accept" [maxFileSize]="maxSize" (onSelect)="onSelectedFile($event)">
<ng-template #header let-chooseCallback="chooseCallback">
<div class="flex items-center justify-center flex-col cursor-pointer py-5 w-full" (click)="chooseCallback()">
<i class="pi pi-cloud-upload border-2! rounded-full! p-8! text-4xl! text-muted-color!"></i>
<p class="mt-6 mb-0">فایل مورد نظر خود را در اینجا رها کنید</p>
</div>
</ng-template>
</p-fileupload>
@@ -0,0 +1,31 @@
import { Maybe } from '@/core';
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { FileSelectEvent, FileUpload } from 'primeng/fileupload';
import { onSelectArgs } from './model';
@Component({
selector: 'app-shared-upload-file',
templateUrl: './upload-file.component.html',
imports: [FileUpload],
})
export class SharedUploadFileComponent {
@Input() currentImage: Maybe<string> = null;
@Input() loading: boolean = false;
@Input() name: string = 'file';
@Input() accept: string = 'image/*';
@Input() maxSize: Maybe<number> = 5 * 1024;
@Input() error: Maybe<string> = null;
@Input() hint: Maybe<string> = null;
@Output() onSelect = new EventEmitter<onSelectArgs>();
onSelectedFile($event: FileSelectEvent) {
const file = $event.files?.[0];
if (!file) {
return;
}
const payload = new FormData();
payload.append(this.name, file, file.name);
this.onSelect.emit({ data: payload, file });
}
}