post-merge changes

This commit is contained in:
Jonas Winkler
2020-11-22 23:12:24 +01:00
parent 3893a23852
commit e9f55d9b3d
10 changed files with 437 additions and 99 deletions

View File

@@ -1,10 +1,10 @@
<h4 class="mt-3">Document consumer status</h4>
<div class="mb-2 border-bottom" *ngFor="let s of getStatus()">
<div class="mb-1"><strong>{{s.filename}}:</strong> {{s.message}}</div>
<ngb-progressbar [type]="getType(s.status)" [value]="s.current_progress" [max]="s.max_progress" class="mb-2"></ngb-progressbar>
<div *ngIf="isFinished(s)" class="mb-2">
<button *ngIf="s.document_id" class="btn btn-sm btn-outline-primary mr-2" routerLink="/documents/{{s.document_id}}" (click)="dismiss(s)">Open document</button>
<button class="btn btn-sm btn-outline-secondary" (click)="dismiss(s)">Dismiss</button>
<app-widget-frame title="Document consumer status">
<div class="mb-2 border-bottom" *ngFor="let s of getStatus()">
<div class="mb-1"><strong>{{s.filename}}:</strong> {{s.message}}</div>
<ngb-progressbar [type]="getType(s.status)" [value]="s.current_progress" [max]="s.max_progress" class="mb-2"></ngb-progressbar>
<div *ngIf="isFinished(s)" class="mb-2">
<button *ngIf="s.document_id" class="btn btn-sm btn-outline-primary mr-2" routerLink="/documents/{{s.document_id}}" (click)="dismiss(s)">Open document</button>
<button class="btn btn-sm btn-outline-secondary" (click)="dismiss(s)">Dismiss</button>
</div>
</div>
</div>
</app-widget-frame>

View File

@@ -4,7 +4,7 @@ import { ConsumerStatusService, FileStatus } from 'src/app/services/consumer-sta
@Component({
selector: 'app-consumer-status-widget',
templateUrl: './consumer-status-widget.component.html',
styleUrls: ['./consumer-status-widget.component.css']
styleUrls: ['./consumer-status-widget.component.scss']
})
export class ConsumerStatusWidgetComponent implements OnInit {

View File

@@ -1,11 +0,0 @@
<h4>Upload new Document</h4>
<form>
<ngx-file-drop
dropZoneLabel="Drop documents here"
(onFileDrop)="dropped($event)"
(onFileOver)="fileOver($event)"
(onFileLeave)="fileLeave($event)"
dropZoneClassName="bg-light mt-4 card">
</ngx-file-drop>
</form>

View File

@@ -1,25 +0,0 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FileUploadWidgetComponent } from './file-upload-widget.component';
describe('FileUploadWidgetComponent', () => {
let component: FileUploadWidgetComponent;
let fixture: ComponentFixture<FileUploadWidgetComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ FileUploadWidgetComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(FileUploadWidgetComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -1,44 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { FileSystemFileEntry, NgxFileDropEntry } from 'ngx-file-drop';
import { DocumentService } from 'src/app/services/rest/document.service';
import { ToastService } from 'src/app/services/toast.service';
@Component({
selector: 'app-file-upload-widget',
templateUrl: './file-upload-widget.component.html',
styleUrls: ['./file-upload-widget.component.css']
})
export class FileUploadWidgetComponent implements OnInit {
constructor(private documentService: DocumentService, private toastService: ToastService) { }
ngOnInit(): void {
}
public fileOver(event){
console.log(event);
}
public fileLeave(event){
console.log(event);
}
public dropped(files: NgxFileDropEntry[]) {
for (const droppedFile of files) {
if (droppedFile.fileEntry.isFile) {
const fileEntry = droppedFile.fileEntry as FileSystemFileEntry;
console.log(fileEntry)
fileEntry.file((file: File) => {
console.log(file)
const formData = new FormData()
formData.append('document', file, file.name)
this.documentService.uploadDocument(formData).subscribe(result => {
this.toastService.showInfo("The document has been uploaded and will be processed by the consumer shortly.")
}, error => {
this.toastService.showError("An error has occured while uploading the document. Sorry!")
})
});
}
}
}
}

View File

@@ -33,9 +33,9 @@ export class UploadFileWidgetComponent implements OnInit {
const formData = new FormData()
formData.append('document', file, file.name)
this.documentService.uploadDocument(formData).subscribe(result => {
this.toastService.showToast(Toast.make("Information", "The document has been uploaded and will be processed by the consumer shortly."))
this.toastService.showInfo("The document has been uploaded and will be processed by the consumer shortly.")
}, error => {
this.toastService.showToast(Toast.makeError("An error has occured while uploading the document. Sorry!"))
this.toastService.showError("An error has occured while uploading the document. Sorry!")
})
});
}