Browse Source

Merge pull request #7758 from vvlladd28/bug/bulk-import/validation-name

[3.4.3] UI: Fixed validation in bulk import and improvement bulk import for Edge
pull/7815/head
Igor Kulikov 4 years ago
committed by GitHub
parent
commit
092a71dbb4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      ui-ngx/src/app/modules/home/components/import-export/import-export.models.ts
  2. 2
      ui-ngx/src/app/modules/home/components/import-export/table-columns-assignment.component.html
  3. 27
      ui-ngx/src/app/modules/home/components/import-export/table-columns-assignment.component.ts

3
ui-ngx/src/app/modules/home/components/import-export/import-export.models.ts

@ -70,9 +70,6 @@ export enum ImportEntityColumnType {
secret = 'SECRET' secret = 'SECRET'
} }
export const importEntityObjectColumns =
[ImportEntityColumnType.name, ImportEntityColumnType.type, ImportEntityColumnType.accessToken];
export const importEntityColumnTypeTranslations = new Map<ImportEntityColumnType, string>( export const importEntityColumnTypeTranslations = new Map<ImportEntityColumnType, string>(
[ [
[ImportEntityColumnType.name, 'import.column-type.name'], [ImportEntityColumnType.name, 'import.column-type.name'],

2
ui-ngx/src/app/modules/home/components/import-export/table-columns-assignment.component.html

@ -49,7 +49,7 @@
<mat-form-field floatLabel="always" hideRequiredMarker <mat-form-field floatLabel="always" hideRequiredMarker
*ngIf="isColumnTypeDiffers(column.type)"> *ngIf="isColumnTypeDiffers(column.type)">
<mat-label></mat-label> <mat-label></mat-label>
<input matInput required <input matInput [required]="isColumnTypeDiffers(column.type)"
[(ngModel)]="column.key" (ngModelChange)="columnsUpdated()" [(ngModel)]="column.key" (ngModelChange)="columnsUpdated()"
placeholder="{{ 'import.column-value' | translate }}"/> placeholder="{{ 'import.column-value' | translate }}"/>
</mat-form-field> </mat-form-field>

27
ui-ngx/src/app/modules/home/components/import-export/table-columns-assignment.component.ts

@ -22,8 +22,7 @@ import { EntityType } from '@shared/models/entity-type.models';
import { import {
CsvColumnParam, CsvColumnParam,
ImportEntityColumnType, ImportEntityColumnType,
importEntityColumnTypeTranslations, importEntityColumnTypeTranslations
importEntityObjectColumns
} from '@home/components/import-export/import-export.models'; } from '@home/components/import-export/import-export.models';
import { BehaviorSubject, Observable } from 'rxjs'; import { BehaviorSubject, Observable } from 'rxjs';
import { CollectionViewer, DataSource } from '@angular/cdk/collections'; import { CollectionViewer, DataSource } from '@angular/cdk/collections';
@ -117,7 +116,9 @@ export class TableColumnsAssignmentComponent implements OnInit, ControlValueAcce
case EntityType.EDGE: case EntityType.EDGE:
this.columnTypes.push( this.columnTypes.push(
{ value: ImportEntityColumnType.routingKey }, { value: ImportEntityColumnType.routingKey },
{ value: ImportEntityColumnType.secret } { value: ImportEntityColumnType.secret },
{ value: ImportEntityColumnType.serverAttribute },
{ value: ImportEntityColumnType.timeseries }
); );
break; break;
} }
@ -143,8 +144,6 @@ export class TableColumnsAssignmentComponent implements OnInit, ControlValueAcce
const isSelectType = this.columns.findIndex((column) => column.type === ImportEntityColumnType.type) > -1; const isSelectType = this.columns.findIndex((column) => column.type === ImportEntityColumnType.type) > -1;
const isSelectLabel = this.columns.findIndex((column) => column.type === ImportEntityColumnType.label) > -1; const isSelectLabel = this.columns.findIndex((column) => column.type === ImportEntityColumnType.label) > -1;
const isSelectDescription = this.columns.findIndex((column) => column.type === ImportEntityColumnType.description) > -1; const isSelectDescription = this.columns.findIndex((column) => column.type === ImportEntityColumnType.description) > -1;
const isSelectRoutingKey = this.columns.findIndex((column) => column.type === ImportEntityColumnType.routingKey) > -1;
const isSelectSecret = this.columns.findIndex((column) => column.type === ImportEntityColumnType.secret) > -1;
const hasInvalidColumn = this.columns.findIndex((column) => !this.columnValid(column)) > -1; const hasInvalidColumn = this.columns.findIndex((column) => !this.columnValid(column)) > -1;
this.valid = isSelectName && isSelectType && !hasInvalidColumn; this.valid = isSelectName && isSelectType && !hasInvalidColumn;
@ -167,14 +166,16 @@ export class TableColumnsAssignmentComponent implements OnInit, ControlValueAcce
}); });
} }
const routingKeyColumnType = this.columnTypes.find((columnType) => columnType.value === ImportEntityColumnType.routingKey); if (this.entityType === EntityType.EDGE) {
if (routingKeyColumnType) { const isSelectRoutingKey = this.columns.findIndex((column) => column.type === ImportEntityColumnType.routingKey) > -1;
routingKeyColumnType.disabled = isSelectRoutingKey; const isSelectSecret = this.columns.findIndex((column) => column.type === ImportEntityColumnType.secret) > -1;
}
const secretColumnType = this.columnTypes.find((columnType) => columnType.value === ImportEntityColumnType.secret); this.valid = this.valid && isSelectSecret && isSelectRoutingKey;
if (secretColumnType) {
secretColumnType.disabled = isSelectSecret; this.columnTypes.find((columnType) => columnType.value === ImportEntityColumnType.routingKey).disabled = isSelectRoutingKey;
this.columnTypes.find((columnType) => columnType.value === ImportEntityColumnType.secret).disabled = isSelectSecret;
} }
if (this.propagateChange) { if (this.propagateChange) {
this.propagateChange(this.columns); this.propagateChange(this.columns);
} else { } else {
@ -190,7 +191,7 @@ export class TableColumnsAssignmentComponent implements OnInit, ControlValueAcce
} }
private columnValid(column: CsvColumnParam): boolean { private columnValid(column: CsvColumnParam): boolean {
if (!importEntityObjectColumns.includes(column.type)) { if (this.isColumnTypeDiffers(column.type)) {
return column.key && column.key.trim().length > 0; return column.key && column.key.trim().length > 0;
} else { } else {
return true; return true;

Loading…
Cancel
Save