X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=src%2Fservices%2FSharedService.ts;h=8aee5138217fd364e33b055954ec4d09c985022d;hb=d477b85279831f43f77d10acfc1912da1fbe6007;hp=bc4e71a834cc79f17db2dfd5b26ed788e0439839;hpb=208bef2cea31da5427861ac81817790e98851fe2;p=osm%2FNG-UI.git diff --git a/src/services/SharedService.ts b/src/services/SharedService.ts index bc4e71a..8aee513 100644 --- a/src/services/SharedService.ts +++ b/src/services/SharedService.ts @@ -221,21 +221,21 @@ export class SharedService { return true; } /** Clean the form before submit @public */ - public cleanForm(formGroup: FormGroup): void { + public cleanForm(formGroup: FormGroup, formName?: String): void { Object.keys(formGroup.controls).forEach((key: string) => { - if ((!isNullOrUndefined((formGroup.get(key) as FormArray | FormGroup).controls)) && key !== 'vimconfig') { + if ((!isNullOrUndefined((formGroup.get(key) as FormArray | FormGroup).controls)) && key !== 'config') { // tslint:disable-next-line: no-shadowed-variable for (const { item, index } of (formGroup.get(key).value).map((item: {}, index: number) => ({ item, index }))) { const newFormGroup: FormGroup = (formGroup.get(key) as FormArray).controls[index] as FormGroup; this.cleanForm(newFormGroup); } - } else if (formGroup.get(key).value !== undefined && formGroup.get(key).value !== null && key !== 'vimconfig') { + } else if (formGroup.get(key).value !== undefined && formGroup.get(key).value !== null && key !== 'config') { if (!Array.isArray(formGroup.get(key).value)) { if (typeof formGroup.get(key).value === 'string') { formGroup.get(key).setValue(formGroup.get(key).value.trim()); } } - } else if (key === 'vimconfig') { + } else if (key === 'config' && formName === 'vim') { const newFormGroup: FormGroup = formGroup.get(key) as FormGroup; this.cleanForm(newFormGroup); } @@ -284,11 +284,20 @@ export class SharedService { const z: number = Math.floor(Math.random() * this.colorStringLength); return 'rgb(' + x + ',' + y + ',' + z + ')'; } + + /** Add custom name/tag to the dropdown @public */ + public addCustomTag(tag: string): string { + return tag; + } + /** Method to validate file extension and size @private */ private vaildataFileInfo(fileInfo: File, fileType: string): boolean { const extension: string = fileInfo.name.substring(fileInfo.name.lastIndexOf('.') + 1); const packageSize: number = CONSTANTNUMBER.oneMB * environment.packageSize; - if (extension.toLowerCase() === fileType && fileInfo.size <= packageSize) { + if (fileType === 'yaml' && (extension.toLowerCase() === 'yaml' || extension.toLowerCase() === 'yml') + && fileInfo.size <= packageSize) { + return true; + } else if (extension.toLowerCase() === fileType && fileInfo.size <= packageSize) { return true; } return false;