remake init data
json dump Small bug fix
This commit is contained in:
+32
-3
@@ -2,7 +2,7 @@
|
||||
<h2>JSON Dump Management</h2>
|
||||
|
||||
<!-- Entity-specific Export/Import -->
|
||||
<div class="entity-actions" *ngFor="let entity of entityTypes">
|
||||
<!-- <div class="entity-actions" *ngFor="let entity of entityTypes">
|
||||
<h3>{{ entity | titlecase }}</h3>
|
||||
<button mat-raised-button color="primary" (click)="exportEntity(entity)">
|
||||
<mat-icon>download</mat-icon> Export {{ entity }}
|
||||
@@ -11,8 +11,37 @@
|
||||
<mat-icon>upload</mat-icon> Import {{ entity }}
|
||||
<input type="file" hidden accept=".json" (change)="onFileSelected($event, entity)">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<button mat-icon-button (click)="restore(entity)" matTooltip="Restore from latest file">
|
||||
<mat-icon>restore_from_trash</mat-icon>
|
||||
</button>
|
||||
<label mat-i color="accent">
|
||||
<mat-icon>upload</mat-icon> Import {{ entity }}
|
||||
<input type="file" hidden accept=".json" (change)="onFileSelected($event, entity)">
|
||||
</label>
|
||||
</div>-->
|
||||
<mat-toolbar>
|
||||
@for (entity of entityTypes; track entity) {
|
||||
<mat-toolbar-row>
|
||||
<mat-label>{{ entity | titlecase }}</mat-label>
|
||||
<button mat-icon-button (click)="exportEntity(entity)" matTooltip="Export {{ entity }}">
|
||||
<mat-icon>download</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button (click)="fileInput.click()" matTooltip=" Import {{ entity }}">
|
||||
<mat-icon>restore_from_trash</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button (click)="restore(entity)" matTooltip="Restore from latest file">
|
||||
<mat-icon>upload</mat-icon>
|
||||
</button>
|
||||
<input
|
||||
type="file"
|
||||
#fileInput
|
||||
accept=".json"
|
||||
(change)="onFileSelected($event, entity)"
|
||||
hidden
|
||||
/>
|
||||
</mat-toolbar-row>
|
||||
}
|
||||
</mat-toolbar>
|
||||
<!-- Files Table -->
|
||||
<h3>Available JSON Files</h3>
|
||||
<mat-table [dataSource]="files">
|
||||
|
||||
+13
-2
@@ -17,6 +17,8 @@ import {MatProgressSpinner} from '@angular/material/progress-spinner';
|
||||
import {MatIcon} from '@angular/material/icon';
|
||||
import {MatTooltip} from '@angular/material/tooltip';
|
||||
import {ArchivesResponse, FileInfo, FilesResponse, JsonDumpService} from '../../json-dump.service';
|
||||
import {MatToolbar, MatToolbarRow} from '@angular/material/toolbar';
|
||||
import {MatLabel} from '@angular/material/input';
|
||||
|
||||
@Component({
|
||||
selector: 'app-json-dump',
|
||||
@@ -40,7 +42,10 @@ import {ArchivesResponse, FileInfo, FilesResponse, JsonDumpService} from '../../
|
||||
MatTable,
|
||||
TitleCasePipe,
|
||||
NgIf,
|
||||
NgForOf
|
||||
NgForOf,
|
||||
MatToolbar,
|
||||
MatToolbarRow,
|
||||
MatLabel
|
||||
],
|
||||
styleUrls: ['./json-dump.component.scss'],
|
||||
schemas:[CUSTOM_ELEMENTS_SCHEMA]
|
||||
@@ -99,7 +104,9 @@ export class JsonDumpComponent implements OnInit {
|
||||
|
||||
importEntity(entity: string, file: File): void {
|
||||
this.jsonDumpService.importEntity(entity, file).subscribe({
|
||||
next: () => this.showMessage(`Imported ${entity} successfully`),
|
||||
next: () => {
|
||||
this.showMessage(`Imported ${entity} successfully`)
|
||||
},
|
||||
error: (err: { message: any; }) => this.showMessage(`Import ${entity} failed: ${err.message}`)
|
||||
});
|
||||
}
|
||||
@@ -132,4 +139,8 @@ export class JsonDumpComponent implements OnInit {
|
||||
private showMessage(msg: string): void {
|
||||
this.snackBar.open(msg, 'Close', { duration: 3000 });
|
||||
}
|
||||
|
||||
restore(fileName: string) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ export class JsonDumpService {
|
||||
importEntity(entity: string, file: File) {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
return this.http.post(`${this.baseUrl}/import/${entity}`, formData);
|
||||
return this.http.post(`${this.baseUrl}/import/${entity}/file`, formData);
|
||||
}
|
||||
|
||||
// ==================== EXPORT METHODS ====================
|
||||
|
||||
Reference in New Issue
Block a user