Merge pull request #128 from sartography/files-to-filesystem-572

Files to filesystem 572
This commit is contained in:
Dan Funk 2022-01-26 10:21:04 -05:00 committed by GitHub
commit 805c3b414c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 56 additions and 42 deletions

14
package-lock.json generated
View File

@ -43,7 +43,7 @@
"ngx-markdown": "^12.0.1",
"protractor": "^7.0.0",
"rxjs": "^6.5.3",
"sartography-workflow-lib": "0.0.587",
"sartography-workflow-lib": "0.0.589",
"tslib": "^2.3.0",
"uuid": "^8.3.2",
"zone.js": "~0.11.4"
@ -16865,9 +16865,9 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"node_modules/sartography-workflow-lib": {
"version": "0.0.587",
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.587.tgz",
"integrity": "sha512-e8XrOX+GiCW8DGTGfFdEnzB6nh8NniaVpFFeT3evL736yCcYgVIVOyxBFPFARBgfWtXGjZ2ay/b7Rag4V5KT5g==",
"version": "0.0.589",
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.589.tgz",
"integrity": "sha512-0riSQhmP2HK96Vz+lnvtiEVI/ofBXUg3eopmH0ZkwaLHc8VGMfqdtOGE/5sfFPWsHiggXtJxlSm/3IA8vJvI8Q==",
"dependencies": {
"tslib": "^2.2.0"
}
@ -33368,9 +33368,9 @@
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="
},
"sartography-workflow-lib": {
"version": "0.0.587",
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.587.tgz",
"integrity": "sha512-e8XrOX+GiCW8DGTGfFdEnzB6nh8NniaVpFFeT3evL736yCcYgVIVOyxBFPFARBgfWtXGjZ2ay/b7Rag4V5KT5g==",
"version": "0.0.589",
"resolved": "https://registry.npmjs.org/sartography-workflow-lib/-/sartography-workflow-lib-0.0.589.tgz",
"integrity": "sha512-0riSQhmP2HK96Vz+lnvtiEVI/ofBXUg3eopmH0ZkwaLHc8VGMfqdtOGE/5sfFPWsHiggXtJxlSm/3IA8vJvI8Q==",
"requires": {
"tslib": "^2.2.0"
}

View File

@ -63,7 +63,7 @@
"ngx-markdown": "^12.0.1",
"protractor": "^7.0.0",
"rxjs": "^6.5.3",
"sartography-workflow-lib": "0.0.587",
"sartography-workflow-lib": "0.0.589",
"tslib": "^2.3.0",
"uuid": "^8.3.2",
"zone.js": "~0.11.4"

View File

@ -81,7 +81,7 @@ describe('FileListComponent', () => {
fixture.detectChanges();
const fmsReq = httpMock.expectOne(`apiRoot/file?workflow_spec_id=${mockWorkflowSpec0.id}`);
const fmsReq = httpMock.expectOne(`apiRoot/spec_file?workflow_spec_id=${mockWorkflowSpec0.id}`);
expect(fmsReq.request.method).toEqual('GET');
fmsReq.flush(mockFileMetas);
expect(component.fileMetas.length).toBeGreaterThan(0);
@ -133,7 +133,7 @@ describe('FileListComponent', () => {
it('should delete a file', () => {
const loadFileMetasSpy = spyOn((component as any), '_loadFileMetas').and.stub();
(component as any)._deleteFile(mockFileMeta0);
const fmsReq = httpMock.expectOne(`apiRoot/file/${mockFileMeta0.id}`);
const fmsReq = httpMock.expectOne(`apiRoot/spec_file/${mockFileMeta0.id}`);
expect(fmsReq.request.method).toEqual('DELETE');
fmsReq.flush(null);
@ -181,7 +181,7 @@ describe('FileListComponent', () => {
type: mockDocMeta.content_type,
lastModified: timeCode
});
const fReq = httpMock.expectOne(`apiRoot/file/${mockDocMeta.id}/data`);
const fReq = httpMock.expectOne(`apiRoot/spec_file/${mockDocMeta.id}/data`);
const mockHeaders = new HttpHeaders()
.append('last-modified', expectedFile.lastModified.toString())
@ -204,7 +204,7 @@ describe('FileListComponent', () => {
component.workflowSpec = mockWorkflowSpec0;
(component as any)._openFileDialog();
const addReq = httpMock.expectOne(`apiRoot/file?workflow_spec_id=${mockWorkflowSpec0.id}`);
const addReq = httpMock.expectOne(`apiRoot/spec_file?workflow_spec_id=${mockWorkflowSpec0.id}`);
expect(addReq.request.method).toEqual('POST');
addReq.flush(mockFileMeta0);
@ -219,7 +219,7 @@ describe('FileListComponent', () => {
component.workflowSpec = mockWorkflowSpec0;
(component as any)._openFileDialog(mockFileMeta0, mockFile0);
const updateReq = httpMock.expectOne(`apiRoot/file/${mockFileMeta0.id}/data`);
const updateReq = httpMock.expectOne(`apiRoot/spec_file/${mockFileMeta0.id}/data`);
expect(updateReq.request.method).toEqual('PUT');
updateReq.flush(mockFileMeta0);

View File

@ -55,7 +55,7 @@ export class FileListComponent implements OnInit, OnChanges {
editFileMeta(fm: FileMeta) {
if (fm && isNumberDefined(fm.id)) {
this.api.getFileData(fm.id).subscribe(response => {
this.api.getSpecFileData(fm.id).subscribe(response => {
const file = newFileFromResponse(fm, response);
this._openFileDialog(fm, file);
});
@ -85,9 +85,8 @@ export class FileListComponent implements OnInit, OnChanges {
// Fixme: This buisness rule does not belong here.
this.fileMetas.forEach(fm => {
fm.primary = (fmPrimary.id === fm.id);
this.api.updateFileMeta(fm).subscribe(() => {
this.api.updateSpecFileMeta(fm).subscribe(() => {
numUpdated++;
// Reload all fileMetas when all have been updated.
if (numUpdated === this.fileMetas.length) {
this._loadFileMetas();
@ -125,16 +124,11 @@ export class FileListComponent implements OnInit, OnChanges {
if (isNumberDefined(data.fileMetaId)) {
// Update existing file
this.api.updateFileData(newFileMeta, data.file).subscribe(() => {
this.api.updateSpecFileData(newFileMeta, data.file).subscribe(() => {
this._loadFileMetas();
});
} else {
// Add new file
const fileParams: FileParams = {
workflow_spec_id: this.workflowSpec.id,
};
this.api.addFile(fileParams, newFileMeta, data.file).subscribe(dbFm => {
this.api.addSpecFile(this.workflowSpec, newFileMeta, data.file).subscribe(dbFm => {
this._loadFileMetas();
});
}
@ -143,14 +137,14 @@ export class FileListComponent implements OnInit, OnChanges {
}
private _deleteFile(fileMeta: FileMeta) {
this.api.deleteFileMeta(fileMeta.id).subscribe(() => {
this.api.deleteSpecFileMeta(fileMeta.id).subscribe(() => {
this._loadFileMetas();
this.snackBar.open(`Deleted file ${fileMeta.name}.`, 'Ok', {duration: 3000});
});
}
private _loadFileMetas() {
this.api.getFileMetas({workflow_spec_id: this.workflowSpec.id}).subscribe(fms => {
this.api.getSpecFileMetas(this.workflowSpec.id).subscribe(fms => {
this.fileMetas = fms.sort((a, b) => (a.name > b.name) ? 1 : -1);
});
}

View File

@ -129,11 +129,11 @@ describe('ModelerComponent', () => {
wfsReq.flush(mockWorkflowSpec0);
expect(component.workflowSpec).toEqual(mockWorkflowSpec0);
const req = httpMock.expectOne(`apiRoot/file?workflow_spec_id=${mockWorkflowSpec0.id}`);
const req = httpMock.expectOne(`apiRoot/spec_file?workflow_spec_id=${mockWorkflowSpec0.id}`);
expect(req.request.method).toEqual('GET');
req.flush(mockFileMetas);
const fmReq = httpMock.expectOne(`apiRoot/file/${mockFileMeta0.id}/data`);
const fmReq = httpMock.expectOne(`apiRoot/spec_file/${mockFileMeta0.id}/data`);
});
@ -279,7 +279,7 @@ describe('ModelerComponent', () => {
});
it('should save file changes', () => {
const updateFileDataSpy = spyOn(component.api, 'updateFileData').and.returnValue(of(mockFileMeta0));
const updateFileDataSpy = spyOn(component.api, 'updateSpecFileData').and.returnValue(of(mockFileMeta0));
const snackBarOpenSpy = spyOn(component.snackBar, 'open').and.stub();
component.workflowSpec = mockWorkflowSpec0;
@ -311,9 +311,9 @@ describe('ModelerComponent', () => {
fileName: mockFileMeta0.name,
fileType: FileType.BPMN,
};
const updateFileMetaSpy = spyOn(component.api, 'updateFileMeta')
const updateFileMetaSpy = spyOn(component.api, 'updateSpecFileMeta')
.and.returnValue(of(mockFileMeta0));
const updateFileDataSpy = spyOn(component.api, 'updateFileData')
const updateFileDataSpy = spyOn(component.api, 'updateSpecFileData')
.and.returnValue(of(mockFile0));
const loadFilesFromDbSpy = spyOn(component, 'loadFilesFromDb').and.stub();
const snackBarSpy = spyOn(component.snackBar, 'open').and.stub();
@ -349,7 +349,7 @@ describe('ModelerComponent', () => {
workflow_spec_id: mockFileMeta0.workflow_spec_id,
};
const addFileMetaSpy = spyOn(component.api, 'addFile')
const addFileMetaSpy = spyOn(component.api, 'addSpecFile')
.and.returnValue(of(mockFileMeta0));
const loadFilesFromDbSpy = spyOn(component, 'loadFilesFromDb').and.stub();
const routerNavigateSpy = spyOn(component.router, 'navigate').and.stub();
@ -361,7 +361,7 @@ describe('ModelerComponent', () => {
component.draftXml = newXml;
component._upsertFileMeta(data);
expect(component.xml).toEqual(newXml);
expect(addFileMetaSpy).toHaveBeenCalledWith({workflow_spec_id: mockWorkflowSpec0.id}, noDateOrVersion, mockFile0);
expect(addFileMetaSpy).toHaveBeenCalledWith(mockWorkflowSpec0, noDateOrVersion, mockFile0);
expect(loadFilesFromDbSpy).not.toHaveBeenCalled();
expect(routerNavigateSpy).toHaveBeenCalled();
expect(snackBarSpy).toHaveBeenCalled();
@ -378,15 +378,15 @@ describe('ModelerComponent', () => {
const getWorkflowSpecSpy = spyOn(component.api, 'getWorkflowSpecification')
.and.returnValue(of(mockWorkflowSpec0));
const getFileMetasSpy = spyOn(component.api, 'getFileMetas')
const getFileMetasSpy = spyOn(component.api, 'getSpecFileMetas')
.and.returnValue(of(mockFileMetas));
const getFileDataSpy = spyOn(component.api, 'getFileData')
const getFileDataSpy = spyOn(component.api, 'getSpecFileData')
.and.returnValue(of(mockResponse));
component.loadFilesFromDb();
expect(getWorkflowSpecSpy).toHaveBeenCalled();
expect(component.workflowSpec).toEqual(mockWorkflowSpec0);
expect(getFileMetasSpy).toHaveBeenCalledWith({workflow_spec_id: mockWorkflowSpec0.id});
expect(getFileMetasSpy).toHaveBeenCalledWith(mockWorkflowSpec0.id);
expect(component.bpmnFiles.length).toEqual(mockFileMetas.length);

View File

@ -357,7 +357,7 @@ export class ModelerComponent implements AfterViewInit {
private loadFilesFromDb() {
this.api.getWorkflowSpecification(this.workflowSpecId).subscribe(wfs => {
this.workflowSpec = wfs;
this.api.getFileMetas({workflow_spec_id: wfs.id}).subscribe(files => {
this.api.getSpecFileMetas(wfs.id).subscribe(files => {
this.bpmnFiles = [];
files.forEach(f => {
if ((f.type === FileType.BPMN) || (f.type === FileType.DMN)) {
@ -366,7 +366,7 @@ export class ModelerComponent implements AfterViewInit {
if (f.id === this.fileMetaId) {
this.diagramFileMeta = f;
this.api.getFileData(f.id).subscribe(response => {
this.api.getSpecFileData(f.id).subscribe(response => {
this.diagramFile = newFileFromResponse(f, response);
this.onSubmitFileToOpen();
});
@ -394,15 +394,15 @@ export class ModelerComponent implements AfterViewInit {
if (this.workflowSpec && isNumberDefined(fileMetaId)) {
// Update existing file meta
this.api.updateFileData(this.diagramFileMeta, this.diagramFile).subscribe(() => {
this.api.updateFileMeta(this.diagramFileMeta).subscribe(() => {
this.api.updateSpecFileData(this.diagramFileMeta, this.diagramFile).subscribe(() => {
this.api.updateSpecFileMeta(this.diagramFileMeta).subscribe(() => {
this.loadFilesFromDb();
this.snackBar.open(`Saved changes to file ${this.diagramFileMeta.name}.`, 'Ok', {duration: 5000});
});
});
} else {
// Add new file meta
this.api.addFile({workflow_spec_id: this.workflowSpec.id}, this.diagramFileMeta, this.diagramFile).subscribe(fileMeta => {
this.api.addSpecFile(this.workflowSpec, this.diagramFileMeta, this.diagramFile).subscribe(fileMeta => {
this.router.navigate(['/modeler', this.workflowSpec.id, fileMeta.id]);
this.snackBar.open(`Saved new file ${fileMeta.name} to workflow spec ${this.workflowSpec.display_name}.`, 'Ok', {duration: 5000});
}, () => {
@ -419,7 +419,7 @@ export class ModelerComponent implements AfterViewInit {
this.xml = this.draftXml;
this.diagramFile = new File([this.xml], this.diagramFileMeta.name, {type: 'text/xml'});
this.api.updateFileData(this.diagramFileMeta, this.diagramFile).subscribe(newFileMeta => {
this.api.updateSpecFileData(this.diagramFileMeta, this.diagramFile).subscribe(newFileMeta => {
this.diagramFileMeta = newFileMeta;
this.snackBar.open(`Saved changes to file metadata ${this.diagramFileMeta.name}.`, 'Ok', {duration: 5000});
});

View File

@ -83,7 +83,7 @@ export class ReferenceFilesComponent {
}
deleteFile(id: number, name: string) {
this.apiService.deleteFileMeta(id).subscribe(f => {
this.apiService.deleteRefFileMeta(id).subscribe(f => {
this.snackBar.open(`Deleted reference file ${name}.`, 'Ok', {duration: 3000});
this._loadReferenceFiles();
});

View File

@ -294,6 +294,26 @@ describe('WorkflowSpecListComponent', () => {
const _addWorkflowSpecCategorySpy = spyOn((component as any), '_addWorkflowSpecCategory').and.stub();
const _updateWorkflowSpecCategorySpy = spyOn((component as any), '_updateWorkflowSpecCategory').and.stub();
// This disaster keeps up from having to deal with the '"find" is not a function' error, it assures there is one.
if (typeof Array.prototype.find !== 'function') {
Array.prototype.find = function(iterator) {
var list = Object(this);
var length = list.length >>> 0;
var thisArg = arguments[1];
var value;
for (var i = 0; i < length; i++) {
value = list[i];
if (iterator.call(thisArg, value, i, list)) {
return value;
}
}
return undefined;
};
}
component.selectedCat = undefined;
mockWorkflowSpecCategory1.id = null;
(component as any)._upsertWorkflowSpecCategory(mockWorkflowSpecCategory1 as WorkflowSpecCategoryDialogData);