|
|
@ -3,6 +3,7 @@ import {ApiService, ResourceNotAvailableOfflineError} from '../../../service/api
|
|
|
|
import { APP_BASE_HREF } from '@angular/common';
|
|
|
|
import { APP_BASE_HREF } from '@angular/common';
|
|
|
|
import {EditorService} from '../../../service/editor.service';
|
|
|
|
import {EditorService} from '../../../service/editor.service';
|
|
|
|
import {EditorNodeContract} from '../../nodes/EditorNode.contract';
|
|
|
|
import {EditorNodeContract} from '../../nodes/EditorNode.contract';
|
|
|
|
|
|
|
|
import {HttpClient} from '@angular/common/http';
|
|
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@Component({
|
|
|
|
selector: 'editor-files',
|
|
|
|
selector: 'editor-files',
|
|
|
@ -13,6 +14,7 @@ export class FilesComponent extends EditorNodeContract implements OnInit {
|
|
|
|
@Input() nodeId: string;
|
|
|
|
@Input() nodeId: string;
|
|
|
|
@Input() editorUUID: string;
|
|
|
|
@Input() editorUUID: string;
|
|
|
|
@ViewChild('uploadForm') uploadForm: ElementRef;
|
|
|
|
@ViewChild('uploadForm') uploadForm: ElementRef;
|
|
|
|
|
|
|
|
@ViewChild('fileUploader') fileUploader: ElementRef;
|
|
|
|
|
|
|
|
|
|
|
|
public fileRecords: Array<any> = [];
|
|
|
|
public fileRecords: Array<any> = [];
|
|
|
|
public pendingSetup = true;
|
|
|
|
public pendingSetup = true;
|
|
|
@ -26,6 +28,7 @@ export class FilesComponent extends EditorNodeContract implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
constructor(
|
|
|
|
protected api: ApiService,
|
|
|
|
protected api: ApiService,
|
|
|
|
|
|
|
|
protected http: HttpClient,
|
|
|
|
public editorService: EditorService,
|
|
|
|
public editorService: EditorService,
|
|
|
|
@Inject(APP_BASE_HREF) private baseHref: string
|
|
|
|
@Inject(APP_BASE_HREF) private baseHref: string
|
|
|
|
) { super(); }
|
|
|
|
) { super(); }
|
|
|
@ -69,6 +72,7 @@ export class FilesComponent extends EditorNodeContract implements OnInit {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.pendingSetup = false;
|
|
|
|
this.pendingSetup = false;
|
|
|
|
|
|
|
|
this.fileUploader.nativeElement.value = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async performDelete(): Promise<void> {
|
|
|
|
public async performDelete(): Promise<void> {
|
|
|
@ -91,9 +95,34 @@ export class FilesComponent extends EditorNodeContract implements OnInit {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.uploadForm.nativeElement.submit();
|
|
|
|
const fileList: FileList = this.fileUploader?.nativeElement?.files;
|
|
|
|
|
|
|
|
if ( !fileList ) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( fileList.length > 0 ) {
|
|
|
|
|
|
|
|
const formData: FormData = new FormData();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// tslint:disable-next-line:prefer-for-of
|
|
|
|
|
|
|
|
for ( let i = 0; i < fileList.length; i += 1 ) {
|
|
|
|
|
|
|
|
const file = fileList[i];
|
|
|
|
|
|
|
|
formData.append(`uploaded_file_${i}`, file, file.name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.http.post(this.getApiSubmit(), formData).subscribe({
|
|
|
|
|
|
|
|
next: data => {
|
|
|
|
|
|
|
|
this.performLoad();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
error: error => {
|
|
|
|
|
|
|
|
console.error(error);
|
|
|
|
|
|
|
|
this.performLoad();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
onFileChange(event) {}
|
|
|
|
|
|
|
|
|
|
|
|
getReturnUrl() {
|
|
|
|
getReturnUrl() {
|
|
|
|
return `${this.baseHref}editor;id=${this.page.UUID}`;
|
|
|
|
return `${this.baseHref}editor;id=${this.page.UUID}`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|