Commit 8d4d1070a45c815ab17bccab7460e22ba5fc8f43

Authored by Vladyslav_Prykhodko
1 parent 62186267

Add translation, help, refactorin

@@ -64,7 +64,7 @@ @@ -64,7 +64,7 @@
64 "jstree-bootstrap-theme": "^1.0.1", 64 "jstree-bootstrap-theme": "^1.0.1",
65 "leaflet": "^1.0.3", 65 "leaflet": "^1.0.3",
66 "leaflet-providers": "^1.1.17", 66 "leaflet-providers": "^1.1.17",
67 - "material-steppers": "git://github.com/vvlladd28/material-steppers.git#master", 67 + "material-steppers": "git://github.com/thingsboard/material-steppers.git#master",
68 "material-ui": "^0.16.1", 68 "material-ui": "^0.16.1",
69 "material-ui-number-input": "^5.0.16", 69 "material-ui-number-input": "^5.0.16",
70 "md-color-picker": "0.2.6", 70 "md-color-picker": "0.2.6",
@@ -1159,7 +1159,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device @@ -1159,7 +1159,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
1159 break; 1159 break;
1160 } 1160 }
1161 findIdEntity.then(function success(response) { 1161 findIdEntity.then(function success(response) {
1162 - saveEntityRelarion(response.id, entityType, entityParameters, config).then(function success() { 1162 + saveEntityRelarion(entityType, response.id, entityParameters, config).then(function success() {
1163 statisticalInfo.update = { 1163 statisticalInfo.update = {
1164 entity: 1 1164 entity: 1
1165 }; 1165 };
@@ -96,6 +96,7 @@ export default angular.module('thingsboard.help', []) @@ -96,6 +96,7 @@ export default angular.module('thingsboard.help', [])
96 assets: helpBaseUrl + "/docs/user-guide/ui/assets", 96 assets: helpBaseUrl + "/docs/user-guide/ui/assets",
97 devices: helpBaseUrl + "/docs/user-guide/ui/devices", 97 devices: helpBaseUrl + "/docs/user-guide/ui/devices",
98 entityViews: helpBaseUrl + "/docs/user-guide/ui/entity-views", 98 entityViews: helpBaseUrl + "/docs/user-guide/ui/entity-views",
  99 + entitiesImport: helpBaseUrl + "/docs/user-guide/bulk-provisioning",
99 dashboards: helpBaseUrl + "/docs/user-guide/ui/dashboards", 100 dashboards: helpBaseUrl + "/docs/user-guide/ui/dashboards",
100 users: helpBaseUrl + "/docs/user-guide/ui/users", 101 users: helpBaseUrl + "/docs/user-guide/ui/users",
101 widgetsBundles: helpBaseUrl + "/docs/user-guide/ui/widget-library#bundles", 102 widgetsBundles: helpBaseUrl + "/docs/user-guide/ui/widget-library#bundles",
@@ -16,7 +16,7 @@ @@ -16,7 +16,7 @@
16 import './import-dialog.scss'; 16 import './import-dialog.scss';
17 17
18 /*@ngInject*/ 18 /*@ngInject*/
19 -export default function ImportDialogCsvController($scope, $mdDialog, toast, importTitle, importFileLabel, entityType, importExport, types, $mdStepper) { 19 +export default function ImportDialogCsvController($scope, $mdDialog, toast, importTitle, importFileLabel, entityType, importExport, types, $mdStepper, $timeout) {
20 20
21 var vm = this; 21 var vm = this;
22 22
@@ -40,6 +40,7 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo @@ -40,6 +40,7 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo
40 vm.isLinear = true; 40 vm.isLinear = true;
41 vm.isAlternative = false; 41 vm.isAlternative = false;
42 vm.isMobileStepText = true; 42 vm.isMobileStepText = true;
  43 + vm.isImportData = false;
43 44
44 vm.parseData = []; 45 vm.parseData = [];
45 46
@@ -171,6 +172,7 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo @@ -171,6 +172,7 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo
171 }); 172 });
172 importExport.createMultiEntity(entitiesData, vm.entityType, vm.importParameters.isUpdate, config).then(function (response) { 173 importExport.createMultiEntity(entitiesData, vm.entityType, vm.importParameters.isUpdate, config).then(function (response) {
173 vm.statistical = response; 174 vm.statistical = response;
  175 + vm.isImportData = false;
174 $mdStepper('import-stepper').next(); 176 $mdStepper('import-stepper').next();
175 }); 177 });
176 } 178 }
@@ -186,7 +188,9 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo @@ -186,7 +188,9 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo
186 switch (step) { 188 switch (step) {
187 case 1: 189 case 1:
188 steppers.back(); 190 steppers.back();
189 - vm.theFormStep1.$setDirty(); 191 + $timeout(function () {
  192 + vm.theFormStep1.$setDirty();
  193 + });
190 break; 194 break;
191 default: 195 default:
192 steppers.back(); 196 steppers.back();
@@ -203,8 +207,10 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo @@ -203,8 +207,10 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo
203 case 3: 207 case 3:
204 parseData = parseCSV(vm.importData); 208 parseData = parseCSV(vm.importData);
205 if (parseData === -1) { 209 if (parseData === -1) {
206 - clearFile();  
207 steppers.back(); 210 steppers.back();
  211 + $timeout(function () {
  212 + clearFile();
  213 + });
208 } else { 214 } else {
209 createColumnsData(parseData); 215 createColumnsData(parseData);
210 steppers.next(); 216 steppers.next();
@@ -212,6 +218,7 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo @@ -212,6 +218,7 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo
212 break; 218 break;
213 case 4: 219 case 4:
214 steppers.next(); 220 steppers.next();
  221 + vm.isImportData = true;
215 addEntities(parseData, vm.columnsParam); 222 addEntities(parseData, vm.columnsParam);
216 break; 223 break;
217 case 6: 224 case 6:
@@ -15,13 +15,14 @@ @@ -15,13 +15,14 @@
15 limitations under the License. 15 limitations under the License.
16 16
17 --> 17 -->
18 -<md-dialog aria-label="{{ vm.importTitle | translate }}" class="tb-import-stepper" tb-help="'import-csv'" help-container-id="help-container"> 18 +<md-dialog aria-label="{{ vm.importTitle | translate }}" class="tb-import-stepper" tb-help="'entitiesImport'"
  19 + help-container-id="help-container">
19 <md-toolbar> 20 <md-toolbar>
20 <div class="md-toolbar-tools"> 21 <div class="md-toolbar-tools">
21 <h2 translate>{{ vm.importTitle }}</h2> 22 <h2 translate>{{ vm.importTitle }}</h2>
22 <span flex></span> 23 <span flex></span>
23 <div id="help-container"></div> 24 <div id="help-container"></div>
24 - <md-button class="md-icon-button" ng-click="vm.cancel()"> 25 + <md-button class="md-icon-button" ng-click="vm.cancel()" ng-disabled="vm.isImportData">
25 <ng-md-icon icon="close" aria-label="{{ 'dialog.close' | translate }}"></ng-md-icon> 26 <ng-md-icon icon="close" aria-label="{{ 'dialog.close' | translate }}"></ng-md-icon>
26 </md-button> 27 </md-button>
27 </div> 28 </div>
@@ -31,7 +32,7 @@ @@ -31,7 +32,7 @@
31 <md-dialog-content> 32 <md-dialog-content>
32 <md-stepper id="import-stepper" md-mobile-step-text="vm.isMobileStepText" md-vertical="vm.isVertical" 33 <md-stepper id="import-stepper" md-mobile-step-text="vm.isMobileStepText" md-vertical="vm.isVertical"
33 md-linear="vm.isLinear" md-alternative="vm.isAlternative"> 34 md-linear="vm.isLinear" md-alternative="vm.isAlternative">
34 - <md-step md-label="Select a file"> 35 + <md-step md-label="{{ 'import.stepper-text.select-file' | translate }}">
35 <md-step-body> 36 <md-step-body>
36 <form name="vm.theFormStep1"> 37 <form name="vm.theFormStep1">
37 <fieldset ng-disabled="$root.loading"> 38 <fieldset ng-disabled="$root.loading">
@@ -78,27 +79,28 @@ @@ -78,27 +79,28 @@
78 <md-button class="md-primary md-raised" 79 <md-button class="md-primary md-raised"
79 ng-disabled="$root.loading || !vm.theFormStep1.$dirty || !vm.theFormStep1.$valid || !vm.importData" 80 ng-disabled="$root.loading || !vm.theFormStep1.$dirty || !vm.theFormStep1.$valid || !vm.importData"
80 ng-click="vm.nextStep(2);"> 81 ng-click="vm.nextStep(2);">
81 - Continue 82 + {{ 'action.continue' | translate }}
82 </md-button> 83 </md-button>
83 </md-step-actions> 84 </md-step-actions>
84 </md-step> 85 </md-step>
85 86
86 - <md-step md-label="Import configuration"> 87 + <md-step md-label="{{ 'import.stepper-text.configuration' | translate }}">
87 <md-step-body> 88 <md-step-body>
88 <div layout="column"> 89 <div layout="column">
89 <md-input-container> 90 <md-input-container>
90 - <label translate>CSV delimiter</label> 91 + <label translate>import.csv-delimiter</label>
91 <md-select ng-model="vm.importParameters.delim"> 92 <md-select ng-model="vm.importParameters.delim">
92 <md-option ng-repeat="delimiter in vm.delimiters" ng-value="delimiter.key"> 93 <md-option ng-repeat="delimiter in vm.delimiters" ng-value="delimiter.key">
93 {{delimiter.value}} 94 {{delimiter.value}}
94 </md-option> 95 </md-option>
95 </md-select> 96 </md-select>
96 </md-input-container> 97 </md-input-container>
97 - <md-checkbox ng-model="vm.importParameters.isHeader" aria-label="First line contains column names">  
98 - First line contains column names 98 + <md-checkbox ng-model="vm.importParameters.isHeader"
  99 + aria-label="First line contains column names">
  100 + {{ 'import.csv-first-line-header' | translate }}
99 </md-checkbox> 101 </md-checkbox>
100 <md-checkbox ng-model="vm.importParameters.isUpdate" aria-label="Update attributes/telemetry"> 102 <md-checkbox ng-model="vm.importParameters.isUpdate" aria-label="Update attributes/telemetry">
101 - Update attributes/telemetry 103 + {{ 'import.csv-update-data' | translate }}
102 </md-checkbox> 104 </md-checkbox>
103 </div> 105 </div>
104 </md-step-body> 106 </md-step-body>
@@ -111,12 +113,12 @@ @@ -111,12 +113,12 @@
111 {{ 'action.cancel' | translate }} 113 {{ 'action.cancel' | translate }}
112 </md-button> 114 </md-button>
113 <md-button class="md-primary md-raised" ng-disabled="$root.loading" ng-click="vm.nextStep(3);"> 115 <md-button class="md-primary md-raised" ng-disabled="$root.loading" ng-click="vm.nextStep(3);">
114 - Continue 116 + {{ 'action.continue' | translate }}
115 </md-button> 117 </md-button>
116 </md-step-actions> 118 </md-step-actions>
117 </md-step> 119 </md-step>
118 120
119 - <md-step md-label="Select columns type"> 121 + <md-step md-label="{{ 'import.stepper-text.column-type' | translate }}">
120 <md-step-body> 122 <md-step-body>
121 <form name="vm.theFormStep3"> 123 <form name="vm.theFormStep3">
122 <tb-table-columns-assignment columns="vm.columnsParam" the-form="vm.theFormStep3" 124 <tb-table-columns-assignment columns="vm.columnsParam" the-form="vm.theFormStep3"
@@ -134,28 +136,32 @@ @@ -134,28 +136,32 @@
134 <md-button class="md-primary md-raised" 136 <md-button class="md-primary md-raised"
135 ng-disabled="$root.loading || !vm.theFormStep3.$dirty || !vm.theFormStep3.$valid" 137 ng-disabled="$root.loading || !vm.theFormStep3.$dirty || !vm.theFormStep3.$valid"
136 ng-click="vm.nextStep(4);"> 138 ng-click="vm.nextStep(4);">
137 - Continue 139 + {{ 'action.continue' | translate }}
138 </md-button> 140 </md-button>
139 </md-step-actions> 141 </md-step-actions>
140 </md-step> 142 </md-step>
141 143
142 - <md-step md-label="Creating new entities"> 144 + <md-step md-label="{{ 'import.stepper-text.creat-entities' | translate }}">
143 <md-step-body> 145 <md-step-body>
144 - <md-progress-linear class="md-warn tb-import-progress" md-mode="determinate" value="{{vm.progressCreate}}"></md-progress-linear> 146 + <md-progress-linear class="md-warn tb-import-progress" md-mode="determinate"
  147 + value="{{vm.progressCreate}}"></md-progress-linear>
145 </md-step-body> 148 </md-step-body>
146 </md-step> 149 </md-step>
147 - <md-step md-label="Done"> 150 + <md-step md-label="{{ 'import.stepper-text.done' | translate }}">
148 <md-step-body layout="column"> 151 <md-step-body layout="column">
149 <div> 152 <div>
150 - <p class="md-body-1" ng-if="vm.statistical.create && vm.statistical.create.entity">{{vm.statistical.create.entity}} new entities were successfully created.</p>  
151 - <p class="md-body-1" ng-if="vm.statistical.update && vm.statistical.update.entity">{{vm.statistical.update.entity}} entities were successfully updated.</p>  
152 - <p class="md-body-1" ng-if="vm.statistical.error && vm.statistical.error.entity">There was an error creating {{vm.statistical.error.entity}} entities.</p> 153 + <p class="md-body-1" translate translate-values="{count: vm.statistical.create.entity}"
  154 + ng-if="vm.statistical.create && vm.statistical.create.entity">import.message.create-entities</p>
  155 + <p class="md-body-1" translate translate-values="{count: vm.statistical.update.entity}"
  156 + ng-if="vm.statistical.update && vm.statistical.update.entity">import.message.update-entities</p>
  157 + <p class="md-body-1" translate translate-values="{count: vm.statistical.error.entity}"
  158 + ng-if="vm.statistical.error && vm.statistical.error.entity">import.message.error-entities</p>
153 </div> 159 </div>
154 </md-step-body> 160 </md-step-body>
155 <md-step-actions layout="row"> 161 <md-step-actions layout="row">
156 <span flex></span> 162 <span flex></span>
157 <md-button class="md-primary md-raised" ng-disabled="$root.loading" ng-click="vm.nextStep(6);"> 163 <md-button class="md-primary md-raised" ng-disabled="$root.loading" ng-click="vm.nextStep(6);">
158 - Ok 164 + {{ 'action.ok' | translate }}
159 </md-button> 165 </md-button>
160 </md-step-actions> 166 </md-step-actions>
161 </md-step> 167 </md-step>
@@ -802,7 +802,7 @@ export default function ImportExport($log, $translate, $q, $mdDialog, $document, @@ -802,7 +802,7 @@ export default function ImportExport($log, $translate, $q, $mdDialog, $document,
802 let csvlines = csvdata.split(/[\r\n]+/); 802 let csvlines = csvdata.split(/[\r\n]+/);
803 let csvheaders = splitCSV(csvlines[0], delim); 803 let csvheaders = splitCSV(csvlines[0], delim);
804 if (csvheaders.length < 2) { 804 if (csvheaders.length < 2) {
805 - toast.showError($translate.instant('entity.import-csv-number-columns-error')); 805 + toast.showError($translate.instant('import.import-csv-number-columns-error'));
806 return -1; 806 return -1;
807 } 807 }
808 let csvrows = header ? csvlines.slice(1, csvlines.length) : csvlines; 808 let csvrows = header ? csvlines.slice(1, csvlines.length) : csvlines;
@@ -819,7 +819,7 @@ export default function ImportExport($log, $translate, $q, $mdDialog, $document, @@ -819,7 +819,7 @@ export default function ImportExport($log, $translate, $q, $mdDialog, $document,
819 819
820 let rowitems = splitCSV(row, delim); 820 let rowitems = splitCSV(row, delim);
821 if (rowitems.length !== result.headers.length) { 821 if (rowitems.length !== result.headers.length) {
822 - toast.showError($translate.instant('entity.import-csv-invalid-format-error', {line: (header ? result.rows.length + 2: result.rows.length + 1)})); 822 + toast.showError($translate.instant('import.import-csv-invalid-format-error', {line: (header ? result.rows.length + 2: result.rows.length + 1)}));
823 return -1; 823 return -1;
824 } 824 }
825 for (let i = 0; i < rowitems.length; i++) { 825 for (let i = 0; i < rowitems.length; i++) {
@@ -20,9 +20,9 @@ @@ -20,9 +20,9 @@
20 <thead md-head> 20 <thead md-head>
21 <tr md-row> 21 <tr md-row>
22 <th md-column>&nbsp</th> 22 <th md-column>&nbsp</th>
23 - <th md-column>Example value data</th>  
24 - <th md-column>Column type</th>  
25 - <th md-column>Name attributes/telemetry</th> 23 + <th md-column>{{ 'import.column-example' | translate }}</th>
  24 + <th md-column>{{ 'import.column-type.column-type' | translate }}</th>
  25 + <th md-column>{{ 'import.column-key' | translate }}</th>
26 </tr> 26 </tr>
27 </thead> 27 </thead>
28 <tbody md-body> 28 <tbody md-body>
@@ -31,7 +31,7 @@ @@ -31,7 +31,7 @@
31 <td md-cell>{{column.sampleData}}</td> 31 <td md-cell>{{column.sampleData}}</td>
32 <td md-cell> 32 <td md-cell>
33 <md-select ng-model="column.type" required name="columnType" 33 <md-select ng-model="column.type" required name="columnType"
34 - aria-label="{{ 'entity-group.column-type' | translate }}"> 34 + aria-label="{{ 'import.column-type.column-type' | translate }}">
35 <md-option ng-repeat="type in vm.columnTypes" ng-value="type.value" ng-disabled="type.disable"> 35 <md-option ng-repeat="type in vm.columnTypes" ng-value="type.value" ng-disabled="type.disable">
36 {{type.name | translate}} 36 {{type.name | translate}}
37 </md-option> 37 </md-option>
@@ -43,9 +43,9 @@ @@ -43,9 +43,9 @@
43 column.type != vm.columnTypes.type.value && 43 column.type != vm.columnTypes.type.value &&
44 column.type != vm.columnTypes.accessToken.value"> 44 column.type != vm.columnTypes.accessToken.value">
45 <input required name="columnKeyName" 45 <input required name="columnKeyName"
46 - placeholder="{{ 'entity-group.column-value' | translate }}" 46 + placeholder="{{ 'import.column-value' | translate }}"
47 ng-model="column.key" 47 ng-model="column.key"
48 - aria-label="{{ 'entity-group.column-value' | translate }}"> 48 + aria-label="{{ 'import.column-value' | translate }}">
49 </md-input-container> 49 </md-input-container>
50 </td> 50 </td>
51 </tr> 51 </tr>
@@ -48,7 +48,8 @@ @@ -48,7 +48,8 @@
48 "paste-reference": "Paste reference", 48 "paste-reference": "Paste reference",
49 "import": "Import", 49 "import": "Import",
50 "export": "Export", 50 "export": "Export",
51 - "share-via": "Share via {{provider}}" 51 + "share-via": "Share via {{provider}}",
  52 + "continue": "Continue"
52 }, 53 },
53 "aggregation": { 54 "aggregation": {
54 "aggregation": "Aggregation", 55 "aggregation": "Aggregation",
@@ -778,27 +779,7 @@ @@ -778,27 +779,7 @@
778 "details": "Entity details", 779 "details": "Entity details",
779 "no-entities-prompt": "No entities found", 780 "no-entities-prompt": "No entities found",
780 "no-data": "No data to display", 781 "no-data": "No data to display",
781 - "columns-to-display": "Columns to Display",  
782 - "import-csv-number-columns-error": "A file should contain at least two columns",  
783 - "import-csv-invalid-format-error": "Invalid file format. Line: '{{line}}'"  
784 - },  
785 - "entity-group": {  
786 - "column-value": "Value",  
787 - "column-title": "Title",  
788 - "column-type": {  
789 - "column-type": "Column type",  
790 - "client-attribute": "Client attribute",  
791 - "shared-attribute": "Shared attribute",  
792 - "server-attribute": "Server attribute",  
793 - "timeseries": "Timeseries",  
794 - "entity-field": "Entity field",  
795 - "access-token": "Access token"  
796 - },  
797 - "entity-field": {  
798 - "name": "Name",  
799 - "type": "Type",  
800 - "assigned_customer": "Assigned Customer"  
801 - } 782 + "columns-to-display": "Columns to Display"
802 }, 783 },
803 "entity-view": { 784 "entity-view": {
804 "entity-view": "Entity View", 785 "entity-view": "Entity View",
@@ -1118,7 +1099,39 @@ @@ -1118,7 +1099,39 @@
1118 "import": { 1099 "import": {
1119 "no-file": "No file selected", 1100 "no-file": "No file selected",
1120 "drop-file": "Drop a JSON file or click to select a file to upload.", 1101 "drop-file": "Drop a JSON file or click to select a file to upload.",
1121 - "drop-file-csv": "Drop a CSV file or click to select a file to upload." 1102 + "drop-file-csv": "Drop a CSV file or click to select a file to upload.",
  1103 + "column-value": "Value",
  1104 + "column-title": "Title",
  1105 + "column-example": "Example value data",
  1106 + "column-key": "Attribute/telemetry key",
  1107 + "csv-delimiter": "CSV delimiter",
  1108 + "csv-first-line-header": "First line contains column names",
  1109 + "csv-update-data": "Update attributes/telemetry",
  1110 + "import-csv-number-columns-error": "A file should contain at least two columns",
  1111 + "import-csv-invalid-format-error": "Invalid file format. Line: '{{line}}'",
  1112 + "column-type": {
  1113 + "name": "Name",
  1114 + "type": "Type",
  1115 + "column-type": "Column type",
  1116 + "client-attribute": "Client attribute",
  1117 + "shared-attribute": "Shared attribute",
  1118 + "server-attribute": "Server attribute",
  1119 + "timeseries": "Timeseries",
  1120 + "entity-field": "Entity field",
  1121 + "access-token": "Access token"
  1122 + },
  1123 + "stepper-text":{
  1124 + "select-file": "Select a file",
  1125 + "configuration": "Import configuration",
  1126 + "column-type": "Select columns type",
  1127 + "creat-entities": "Creating new entities",
  1128 + "done": "Done"
  1129 + },
  1130 + "message": {
  1131 + "create-entities": "'{{count}}' new entities were successfully created.",
  1132 + "update-entities": "'{{count}}' entities were successfully updated.",
  1133 + "error-entities": "There was an error creating '{{count}}' entities."
  1134 + }
1122 }, 1135 },
1123 "item": { 1136 "item": {
1124 "selected": "Selected" 1137 "selected": "Selected"