diff --git a/src/app/_dialogs/file-meta-dialog/file-meta-dialog.component.ts b/src/app/_dialogs/file-meta-dialog/file-meta-dialog.component.ts index 9ec4b66..49acdcd 100644 --- a/src/app/_dialogs/file-meta-dialog/file-meta-dialog.component.ts +++ b/src/app/_dialogs/file-meta-dialog/file-meta-dialog.component.ts @@ -1,5 +1,8 @@ import {Component, Inject} from '@angular/core'; +import {FormGroup} from '@angular/forms'; import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; +import {FormlyFieldConfig, FormlyFormOptions} from '@ngx-formly/core'; +import {FileType} from 'sartography-workflow-lib'; import {FileMetaDialogData} from '../../_interfaces/dialog-data'; import {cleanUpFilename} from '../../_util/string-clean'; @@ -9,11 +12,56 @@ import {cleanUpFilename} from '../../_util/string-clean'; styleUrls: ['./file-meta-dialog.component.scss'] }) export class FileMetaDialogComponent { + form: FormGroup = new FormGroup({}); + model: any = {}; + options: FormlyFormOptions = {}; + fields: FormlyFieldConfig[] = []; constructor( public dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) public data: FileMetaDialogData ) { + const fileTypeOptions = Object.entries(FileType).map(ft => { + return { + label: ft[0], + value: ft[1] + }; + }); + + this.fields = [ + { + key: 'fileName', + type: 'input', + defaultValue: this.data.fileName, + templateOptions: { + label: 'File Name', + placeholder: 'Name of workflow specification', + description: 'Enter a name, in lowercase letters, separated by underscores, that is easy for you to remember.' + + 'It will be converted to all_lowercase_with_underscores when you save.', + required: true, + }, + }, + { + key: 'fileType', + type: 'select', + defaultValue: this.data.fileType, + templateOptions: { + label: 'File Type', + placeholder: 'Extension of file', + required: true, + options: fileTypeOptions, + }, + }, + { + key: 'file', + type: 'file', + defaultValue: this.data.file, + templateOptions: { + label: 'File', + required: true, + }, + } + ]; } onNoClick() { diff --git a/src/app/_dialogs/open-file-dialog/open-file-dialog.component.spec.ts b/src/app/_dialogs/open-file-dialog/open-file-dialog.component.spec.ts index b912961..48fa7b7 100644 --- a/src/app/_dialogs/open-file-dialog/open-file-dialog.component.spec.ts +++ b/src/app/_dialogs/open-file-dialog/open-file-dialog.component.spec.ts @@ -60,6 +60,12 @@ describe('OpenFileDialogComponent', () => { fixture.detectChanges(); }); + afterEach(() => { + httpMock.verify(); + fixture.destroy(); + }); + + it('should create', () => { expect(component).toBeTruthy(); }); diff --git a/src/app/_dialogs/workflow-spec-category-dialog/workflow-spec-category-dialog.component.spec.ts b/src/app/_dialogs/workflow-spec-category-dialog/workflow-spec-category-dialog.component.spec.ts index bf6eec1..ae3ad13 100644 --- a/src/app/_dialogs/workflow-spec-category-dialog/workflow-spec-category-dialog.component.spec.ts +++ b/src/app/_dialogs/workflow-spec-category-dialog/workflow-spec-category-dialog.component.spec.ts @@ -1,3 +1,4 @@ +import {HttpClientTestingModule, HttpTestingController} from '@angular/common/http/testing'; import {async, ComponentFixture, TestBed} from '@angular/core/testing'; import {FormsModule, ReactiveFormsModule} from '@angular/forms'; import {MAT_DIALOG_DATA, MatDialogModule, MatDialogRef} from '@angular/material/dialog'; @@ -7,11 +8,12 @@ import {MatInputModule} from '@angular/material/input'; import {BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations'; import {FormlyModule} from '@ngx-formly/core'; import {FormlyMaterialModule} from '@ngx-formly/material'; -import {mockWorkflowSpecCategory0} from 'sartography-workflow-lib'; +import {ApiService, MockEnvironment, mockWorkflowSpecCategory0} from 'sartography-workflow-lib'; import {WorkflowSpecCategoryDialogData} from '../../_interfaces/dialog-data'; import {WorkflowSpecCategoryDialogComponent} from './workflow-spec-category-dialog.component'; describe('WorkflowSpecDialogComponent', () => { + let httpMock: HttpTestingController; let component: WorkflowSpecCategoryDialogComponent; let fixture: ComponentFixture; @@ -22,6 +24,7 @@ describe('WorkflowSpecDialogComponent', () => { FormlyModule.forRoot(), FormlyMaterialModule, FormsModule, + HttpClientTestingModule, MatDialogModule, MatFormFieldModule, MatIconModule, @@ -31,6 +34,8 @@ describe('WorkflowSpecDialogComponent', () => { ], declarations: [WorkflowSpecCategoryDialogComponent], providers: [ + ApiService, + {provide: 'APP_ENVIRONMENT', useClass: MockEnvironment}, { provide: MatDialogRef, useValue: { @@ -45,11 +50,17 @@ describe('WorkflowSpecDialogComponent', () => { })); beforeEach(() => { + httpMock = TestBed.inject(HttpTestingController); fixture = TestBed.createComponent(WorkflowSpecCategoryDialogComponent); component = fixture.componentInstance; fixture.detectChanges(); }); + afterEach(() => { + httpMock.verify(); + fixture.destroy(); + }); + it('should create', () => { expect(component).toBeTruthy(); }); diff --git a/src/app/_interfaces/dialog-data.ts b/src/app/_interfaces/dialog-data.ts index 47da37e..84c85ff 100644 --- a/src/app/_interfaces/dialog-data.ts +++ b/src/app/_interfaces/dialog-data.ts @@ -3,6 +3,7 @@ import {FileMeta, FileType, WorkflowSpec, WorkflowSpecCategory} from 'sartograph export interface FileMetaDialogData { fileName: string; fileType: FileType; + file?: File; } export interface NewFileDialogData { diff --git a/src/app/_pipes/get-icon-code.pipe.ts b/src/app/_pipes/get-icon-code.pipe.ts index 54ce11b..94c3a63 100644 --- a/src/app/_pipes/get-icon-code.pipe.ts +++ b/src/app/_pipes/get-icon-code.pipe.ts @@ -14,6 +14,8 @@ export class GetIconCodePipe implements PipeTransform { return 'image'; case FileType.DMN: return 'view_list'; + default: + return 'insert_drive_file'; } } } diff --git a/src/app/file-list/file-list.component.html b/src/app/file-list/file-list.component.html index c4b7388..e1e5d08 100644 --- a/src/app/file-list/file-list.component.html +++ b/src/app/file-list/file-list.component.html @@ -5,7 +5,7 @@ [attr.data-file-meta-id]="fm.id" [attr.data-workflow-spec-id]="workflowSpec.id" > - {{fm.type | getIconCode}} + {{fm.type | getIconCode}} -

{{fm.name}}

-

{{fm.last_updated | date}}

-