feat: update consumer and partner components for improved data handling and UI enhancements
- Refactor ConsumerPosListComponent to dynamically set cookie domain based on hostname. - Modify ConsumerUserFormContentComponent to correctly handle type selection and initialization. - Enhance single.component.html to conditionally display consumer details based on type. - Update ConsumerAccountListComponent to include nested role translation and pos details. - Adjust IConsumerAccountRawResponse to use IEnumTranslate for role and add pos details. - Refine ConsumersComponent to display translated status in the list view. - Revise single.component.html for superAdmin to show translated consumer type and details. - Improve AdminPartnerChargeAccountListComponent and AdminPartnerChargeLicenseTransactionListComponent by updating header labels. - Add file upload functionality in form.component.html for partner creation. - Enhance GuildFormComponent to handle file uploads and form data submission. - Update AdminPartnerLicensesComponent to display consumer names correctly. - Modify IPartnerActivatedLicenseResponse to include consumer_name for better clarity. - Add logo_url to IPartnerRawResponse for displaying partner logos. - Refactor PartnersService to handle FormData for partner creation and updates. - Enhance list.component.html to include partner logos in the display. - Update single.component.html for partners to show total counts for licenses and users. - Implement payment result handling in AuthComponent for improved payment integration. - Refactor SharedUploadFileComponent to manage file previews and uploads more effectively. - Introduce IEnumTranslate interface for better type handling in consumer models. - Update form-data utility to allow skipping specific fields during FormData construction. - Add RTL support styles for file upload and avatar components. - Change environment configuration for API base URL.
This commit is contained in:
@@ -1,31 +1,90 @@
|
||||
import { Maybe } from '@/core';
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import {
|
||||
Component,
|
||||
EventEmitter,
|
||||
Input,
|
||||
OnChanges,
|
||||
OnDestroy,
|
||||
Output,
|
||||
SimpleChanges,
|
||||
ViewChild,
|
||||
} from '@angular/core';
|
||||
import { ButtonDirective } from 'primeng/button';
|
||||
import { FileSelectEvent, FileUpload } from 'primeng/fileupload';
|
||||
import { onSelectFileArgs } from './model';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shared-upload-file',
|
||||
templateUrl: './upload-file.component.html',
|
||||
imports: [FileUpload],
|
||||
imports: [FileUpload, ButtonDirective],
|
||||
})
|
||||
export class SharedUploadFileComponent {
|
||||
@Input() currentImage: Maybe<string> = null;
|
||||
export class SharedUploadFileComponent implements OnChanges, OnDestroy {
|
||||
@Input() loading: boolean = false;
|
||||
@Input() name: string = 'file';
|
||||
@Input() accept: string = 'image/*';
|
||||
@Input() maxSize: Maybe<number> = 5 * 1024 * 1024;
|
||||
@Input() error: Maybe<string> = null;
|
||||
@Input() hint: Maybe<string> = null;
|
||||
@Input() initial_file_url: Maybe<string> = null;
|
||||
|
||||
@Output() onSelect = new EventEmitter<onSelectFileArgs>();
|
||||
|
||||
@ViewChild(FileUpload) uploader?: FileUpload;
|
||||
|
||||
filePreview: Maybe<string> = null;
|
||||
private objectUrl: Maybe<string> = null;
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) {
|
||||
if ('initial_file_url' in changes && !this.objectUrl) {
|
||||
this.filePreview = this.initial_file_url;
|
||||
}
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.revokeObjectUrl();
|
||||
console.log('first');
|
||||
|
||||
if (this.initial_file_url && !this.objectUrl) {
|
||||
this.filePreview = this.initial_file_url;
|
||||
}
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.revokeObjectUrl();
|
||||
}
|
||||
|
||||
onSelectedFile($event: FileSelectEvent) {
|
||||
const file = $event.files?.[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
this.setPreviewFromFile(file);
|
||||
const payload = new FormData();
|
||||
payload.append(this.name, file, file.name);
|
||||
this.onSelect.emit({ data: payload, file });
|
||||
}
|
||||
|
||||
onEditFile() {
|
||||
this.uploader?.choose();
|
||||
}
|
||||
|
||||
onDeleteFilePreview() {
|
||||
this.revokeObjectUrl();
|
||||
this.filePreview = null;
|
||||
}
|
||||
|
||||
private setPreviewFromFile(file: File) {
|
||||
this.revokeObjectUrl();
|
||||
this.objectUrl = URL.createObjectURL(file);
|
||||
this.filePreview = this.objectUrl;
|
||||
}
|
||||
|
||||
private revokeObjectUrl() {
|
||||
if (!this.objectUrl) {
|
||||
return;
|
||||
}
|
||||
this.filePreview = null;
|
||||
URL.revokeObjectURL(this.objectUrl);
|
||||
this.objectUrl = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user