From 27ac1918fc9d8d90f4aa8c4bffe70b1c1a615981 Mon Sep 17 00:00:00 2001 From: Vladyslav_Prykhodko Date: Wed, 29 May 2019 19:35:32 +0300 Subject: [PATCH] Clear code and style --- ui/package.json | 2 +- ui/src/app/api/device.service.js | 8 ++- .../import-dialog-csv.controller.js | 2 +- .../import-export/import-dialog-csv.tpl.html | 68 ++++++++++--------- ui/src/app/import-export/import-dialog.scss | 11 +++ .../import-export/import-export.service.js | 49 +++---------- .../table-columns-assignment.directive.js | 21 +++--- .../table-columns-assignment.tpl.html | 2 +- 8 files changed, 78 insertions(+), 85 deletions(-) diff --git a/ui/package.json b/ui/package.json index 24b38545ec..ed54580b19 100644 --- a/ui/package.json +++ b/ui/package.json @@ -64,7 +64,7 @@ "jstree-bootstrap-theme": "^1.0.1", "leaflet": "^1.0.3", "leaflet-providers": "^1.1.17", - "material-steppers": "^2.0.0", + "material-steppers": "git://github.com/vvlladd28/material-steppers.git#master", "material-ui": "^0.16.1", "material-ui-number-input": "^5.0.16", "md-color-picker": "0.2.6", diff --git a/ui/src/app/api/device.service.js b/ui/src/app/api/device.service.js index d9eb326144..84f9a8aee2 100644 --- a/ui/src/app/api/device.service.js +++ b/ui/src/app/api/device.service.js @@ -241,11 +241,15 @@ function DeviceService($http, $q, $window, userService, attributeService, custom deferred.resolve(statisticalInfo); }); }, function fail() { - statisticalInfo.error.device = newDevice; + statisticalInfo.error = { + device: 1 + }; deferred.resolve(statisticalInfo); }); } else { - statisticalInfo.error.device = newDevice; + statisticalInfo.error = { + device: 1 + }; deferred.resolve(statisticalInfo); } }); diff --git a/ui/src/app/import-export/import-dialog-csv.controller.js b/ui/src/app/import-export/import-dialog-csv.controller.js index 0155c86ec1..4dcce4a276 100644 --- a/ui/src/app/import-export/import-dialog-csv.controller.js +++ b/ui/src/app/import-export/import-dialog-csv.controller.js @@ -199,7 +199,7 @@ export default function ImportDialogCsvController($scope, $mdDialog, toast, impo break; case 4: steppers.next(); - addDevices(parseData, vm.columnsParam) + addDevices(parseData, vm.columnsParam); break; } diff --git a/ui/src/app/import-export/import-dialog-csv.tpl.html b/ui/src/app/import-export/import-dialog-csv.tpl.html index b847c753bd..add2ede42f 100644 --- a/ui/src/app/import-export/import-dialog-csv.tpl.html +++ b/ui/src/app/import-export/import-dialog-csv.tpl.html @@ -15,7 +15,7 @@ limitations under the License. --> - +

{{ vm.importTitle }}

@@ -27,7 +27,7 @@ - + @@ -83,7 +83,7 @@ - +
@@ -95,13 +95,13 @@ - + First line is header - - Update parameters + + Update attributes/telemetry
@@ -122,8 +122,10 @@ - +
+ +
@@ -133,35 +135,35 @@ {{ 'action.cancel' | translate }} - + Continue
- + - - -
- - {{key}} - -
-

{{ info }}: {{ infoValue }}

-
-
-
+ + +
+
+
{{key}}
+
+ {{ info }}: {{ infoValue }} +
+
- + - - {{ 'action.cancel' | translate }} - + + + Ok @@ -171,13 +173,13 @@ - - - - - - - - + + + + + + + + diff --git a/ui/src/app/import-export/import-dialog.scss b/ui/src/app/import-export/import-dialog.scss index 7e8e203050..9a807b67d7 100644 --- a/ui/src/app/import-export/import-dialog.scss +++ b/ui/src/app/import-export/import-dialog.scss @@ -13,6 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +@import "../../scss/constants.scss"; + $previewSize: 100px !default; .tb-file-select-container { @@ -50,3 +52,12 @@ $previewSize: 100px !default; } } } + +.md-stepper-indicator-wrapper{ + background-color: transparent; +} +// +//.md-stepper-indicator.md-THEME_NAME-theme.md-completed .md-stepper-number, +//.md-stepper-indicator.md-THEME_NAME-theme.md-active .md-stepper-number{ +// color: '{{primary-100}}'; +//} diff --git a/ui/src/app/import-export/import-export.service.js b/ui/src/app/import-export/import-export.service.js index dbb1ea148b..5c10e48f92 100644 --- a/ui/src/app/import-export/import-export.service.js +++ b/ui/src/app/import-export/import-export.service.js @@ -582,46 +582,10 @@ export default function ImportExport($log, $translate, $q, $mdDialog, $document, var deferred = $q.defer(); openImportDialogCSV($event, entityType,'device.import', 'device.device-file').then( function success() { - // if (!validateImportedDashboard(dashboard)) { - // toast.showError($translate.instant('dashboard.invalid-dashboard-file-error')); - // deferred.reject(); - // } else { - // dashboard = dashboardUtils.validateAndUpdateDashboard(dashboard); - // var entityAliases = dashboard.configuration.entityAliases; - // if (entityAliases) { - // var aliasIds = Object.keys( entityAliases ); - // if (aliasIds.length > 0) { - // processEntityAliases(entityAliases, aliasIds).then( - // function(missingEntityAliases) { - // if (Object.keys( missingEntityAliases ).length > 0) { - // editMissingAliases($event, dashboard.configuration.widgets, - // false, 'dashboard.dashboard-import-missing-aliases-title', missingEntityAliases).then( - // function success(updatedEntityAliases) { - // for (var aliasId in updatedEntityAliases) { - // entityAliases[aliasId] = updatedEntityAliases[aliasId]; - // } - // saveImportedDashboard(dashboard, deferred); - // }, - // function fail() { - // deferred.reject(); - // } - // ); - // } else { - // saveImportedDashboard(dashboard, deferred); - // } - // } - // ) - // } else { - // saveImportedDashboard(dashboard, deferred); - // } - // } else { - // saveImportedDashboard(dashboard, deferred); - // } - // } deferred.resolve(); }, function fail() { - deferred.reject(); + deferred.resolve(); } ); return deferred.promise; @@ -971,16 +935,23 @@ export default function ImportExport($log, $translate, $q, $mdDialog, $document, entityType: entityType }, parent: angular.element($document[0].body), + onComplete: fixedDialogSize, multiple: true, fullscreen: true, targetEvent: $event - }).then(function (importData) { - deferred.resolve(importData); + }).then(function () { + deferred.resolve(); }, function () { deferred.reject(); }); return deferred.promise; } + + function fixedDialogSize(scope, element) { + let dialogElement = element[0].getElementsByTagName('md-dialog'); + dialogElement[0].style.width = dialogElement[0].offsetWidth + 2 + "px"; + dialogElement[0].style.height = dialogElement[0].offsetHeight + "px"; + } } /* eslint-enable no-undef, angular/window-service, angular/document-service */ diff --git a/ui/src/app/import-export/table-columns-assignment.directive.js b/ui/src/app/import-export/table-columns-assignment.directive.js index 368d4d3a90..22a7a72ce2 100644 --- a/ui/src/app/import-export/table-columns-assignment.directive.js +++ b/ui/src/app/import-export/table-columns-assignment.directive.js @@ -62,8 +62,8 @@ function TableColumnsAssignmentController($scope, types, $timeout) { break; } - $scope.$watch('vm.columns', function(newVal, prevVal){ - if (newVal && !angular.equals(newVal, prevVal)) { + $scope.$watch('vm.columns', function(newVal){ + if (newVal) { var isSelectName = false; var isSelectType = false; for (var i = 0; i < newVal.length; i++) { @@ -80,12 +80,17 @@ function TableColumnsAssignmentController($scope, types, $timeout) { vm.entityField.name.disable = isSelectName; vm.entityField.type.disable = isSelectType; }); + if(isSelectName && isSelectType) { + vm.theForm.$setDirty(); + } else { + vm.theForm.$setPristine(); + } } }, true); - - $scope.$watch('vm.columns', function(newVal, prevVal) { - if (vm.isEdit && !angular.equals(newVal, prevVal)) { - vm.theForm.$setDirty(); - } - }, true); + // + // $scope.$watch('vm.columns', function(newVal, prevVal) { + // if (newVal && !angular.equals(newVal, prevVal)) { + // vm.theForm.$setDirty(); + // } + // }, true); } diff --git a/ui/src/app/import-export/table-columns-assignment.tpl.html b/ui/src/app/import-export/table-columns-assignment.tpl.html index 0cc0df5e6c..a51aebdfb3 100644 --- a/ui/src/app/import-export/table-columns-assignment.tpl.html +++ b/ui/src/app/import-export/table-columns-assignment.tpl.html @@ -15,7 +15,7 @@ limitations under the License. --> - +