Browse Source

Add support import label

pull/2096/head
Vladyslav_Prykhodko 7 years ago
parent
commit
f8bb2839aa
  1. 3
      ui/src/app/api/entity.service.js
  2. 4
      ui/src/app/common/types.constant.js
  3. 6
      ui/src/app/import-export/import-dialog-csv.controller.js
  4. 6
      ui/src/app/import-export/table-columns-assignment.directive.js
  5. 1
      ui/src/app/import-export/table-columns-assignment.tpl.html
  6. 1
      ui/src/app/locale/locale.constant-en_US.json
  7. 1
      ui/src/app/locale/locale.constant-ru_RU.json
  8. 1
      ui/src/app/locale/locale.constant-uk_UA.json

3
ui/src/app/api/entity.service.js

@ -1130,7 +1130,8 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
let statisticalInfo = {}; let statisticalInfo = {};
let newEntity = { let newEntity = {
name: entityParameters.name, name: entityParameters.name,
type: entityParameters.type type: entityParameters.type,
label: entityParameters.label
}; };
let promise; let promise;
switch (entityType) { switch (entityType) {

4
ui/src/app/common/types.constant.js

@ -369,6 +369,10 @@ export default angular.module('thingsboard.types', [])
name: 'import.column-type.type', name: 'import.column-type.type',
value: 'type' value: 'type'
}, },
label: {
name: 'import.column-type.label',
value: 'label'
},
clientAttribute: { clientAttribute: {
name: 'import.column-type.client-attribute', name: 'import.column-type.client-attribute',
value: 'CLIENT_ATTRIBUTE' value: 'CLIENT_ATTRIBUTE'

6
ui/src/app/import-export/import-dialog-csv.controller.js

@ -98,7 +98,7 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo
vm.columnsParam = []; vm.columnsParam = [];
var columnParam = {}; var columnParam = {};
for (var i = 0; i < parseData.headers.length; i++) { for (var i = 0; i < parseData.headers.length; i++) {
if (vm.importParameters.isHeader && parseData.headers[i].search(/^(name|type)$/im) === 0) { if (vm.importParameters.isHeader && parseData.headers[i].search(/^(name|type|label)$/im) === 0) {
columnParam = { columnParam = {
type: types.importEntityColumnType[parseData.headers[i].toLowerCase()].value, type: types.importEntityColumnType[parseData.headers[i].toLowerCase()].value,
key: parseData.headers[i].toLowerCase(), key: parseData.headers[i].toLowerCase(),
@ -126,6 +126,7 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo
var entityData = { var entityData = {
name: "", name: "",
type: "", type: "",
label: "",
accessToken: "", accessToken: "",
attributes: { attributes: {
server: [], server: [],
@ -162,6 +163,9 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo
case types.importEntityColumnType.type.value: case types.importEntityColumnType.type.value:
entityData.type = importData.rows[i][j]; entityData.type = importData.rows[i][j];
break; break;
case types.importEntityColumnType.label.value:
entityData.label = importData.rows[i][j];
break;
} }
} }
entitiesData.push(entityData); entitiesData.push(entityData);

6
ui/src/app/import-export/table-columns-assignment.directive.js

@ -44,6 +44,7 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
vm.columnTypes.name = types.importEntityColumnType.name; vm.columnTypes.name = types.importEntityColumnType.name;
vm.columnTypes.type = types.importEntityColumnType.type; vm.columnTypes.type = types.importEntityColumnType.type;
vm.columnTypes.label = types.importEntityColumnType.label;
switch (vm.entityType) { switch (vm.entityType) {
case types.entityType.device: case types.entityType.device:
@ -62,6 +63,7 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
if (newVal) { if (newVal) {
var isSelectName = false; var isSelectName = false;
var isSelectType = false; var isSelectType = false;
var isSelectLabel = false;
var isSelectCredentials = false; var isSelectCredentials = false;
for (var i = 0; i < newVal.length; i++) { for (var i = 0; i < newVal.length; i++) {
switch (newVal[i].type) { switch (newVal[i].type) {
@ -71,6 +73,9 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
case types.importEntityColumnType.type.value: case types.importEntityColumnType.type.value:
isSelectType = true; isSelectType = true;
break; break;
case types.importEntityColumnType.label.value:
isSelectLabel = true;
break;
case types.importEntityColumnType.accessToken.value: case types.importEntityColumnType.accessToken.value:
isSelectCredentials = true; isSelectCredentials = true;
break; break;
@ -84,6 +89,7 @@ function TableColumnsAssignmentController($scope, types, $timeout) {
$timeout(function () { $timeout(function () {
vm.columnTypes.name.disable = isSelectName; vm.columnTypes.name.disable = isSelectName;
vm.columnTypes.type.disable = isSelectType; vm.columnTypes.type.disable = isSelectType;
vm.columnTypes.label.disable = isSelectLabel;
if (angular.isDefined(vm.columnTypes.accessToken)) { if (angular.isDefined(vm.columnTypes.accessToken)) {
vm.columnTypes.accessToken.disable = isSelectCredentials; vm.columnTypes.accessToken.disable = isSelectCredentials;
} }

1
ui/src/app/import-export/table-columns-assignment.tpl.html

@ -41,6 +41,7 @@
<md-input-container md-no-float <md-input-container md-no-float
ng-if="column.type != vm.columnTypes.name.value && ng-if="column.type != vm.columnTypes.name.value &&
column.type != vm.columnTypes.type.value && column.type != vm.columnTypes.type.value &&
column.type != vm.columnTypes.label.value &&
column.type != vm.columnTypes.accessToken.value"> column.type != vm.columnTypes.accessToken.value">
<input required name="columnKeyName" <input required name="columnKeyName"
placeholder="{{ 'import.column-value' | translate }}" placeholder="{{ 'import.column-value' | translate }}"

1
ui/src/app/locale/locale.constant-en_US.json

@ -1139,6 +1139,7 @@
"column-type": { "column-type": {
"name": "Name", "name": "Name",
"type": "Type", "type": "Type",
"label": "Label",
"column-type": "Column type", "column-type": "Column type",
"client-attribute": "Client attribute", "client-attribute": "Client attribute",
"shared-attribute": "Shared attribute", "shared-attribute": "Shared attribute",

1
ui/src/app/locale/locale.constant-ru_RU.json

@ -1113,6 +1113,7 @@
"column-type": { "column-type": {
"name": "Название", "name": "Название",
"type": "Тип", "type": "Тип",
"label": "Метка",
"column-type": "Тип колонки", "column-type": "Тип колонки",
"client-attribute": "Клиентский атрибут", "client-attribute": "Клиентский атрибут",
"shared-attribute": "Общий атрибут", "shared-attribute": "Общий атрибут",

1
ui/src/app/locale/locale.constant-uk_UA.json

@ -1365,6 +1365,7 @@
"column-type": { "column-type": {
"name": "Назва", "name": "Назва",
"type": "Тип", "type": "Тип",
"label": "Мітка",
"column-type": "Тип колонки", "column-type": "Тип колонки",
"client-attribute": "Атрибут клієнта", "client-attribute": "Атрибут клієнта",
"shared-attribute": "Спільний атрибут", "shared-attribute": "Спільний атрибут",

Loading…
Cancel
Save