From 9c616bd3a3feaf7898c13bfe1fc6b2844153b554 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Fri, 6 Jan 2017 19:49:00 +0200 Subject: [PATCH] Import/Export. Bug fixes. --- ui/package.json | 1 + ui/src/app/api/device.service.js | 4 +- ui/src/app/components/dashboard.directive.js | 13 + ui/src/app/components/dashboard.tpl.html | 12 + ui/src/app/components/grid.directive.js | 4 + ui/src/app/components/grid.tpl.html | 23 +- .../app/components/react/json-form-number.jsx | 10 +- ui/src/app/dashboard/add-widget.controller.js | 10 +- .../app/dashboard/dashboard-fieldset.tpl.html | 1 + ui/src/app/dashboard/dashboard.controller.js | 96 +---- ui/src/app/dashboard/dashboard.directive.js | 1 + ui/src/app/dashboard/dashboard.tpl.html | 43 +- ui/src/app/dashboard/dashboards.controller.js | 38 +- ui/src/app/dashboard/dashboards.tpl.html | 1 + .../dashboard/device-aliases.controller.js | 55 ++- ui/src/app/dashboard/device-aliases.tpl.html | 6 +- ui/src/app/dashboard/edit-widget.directive.js | 10 +- ui/src/app/dashboard/index.js | 2 + ui/src/app/global-interceptor.service.js | 11 +- .../import-export/import-dialog.controller.js | 71 ++++ ui/src/app/import-export/import-dialog.scss | 70 ++++ .../app/import-export/import-dialog.tpl.html | 72 ++++ .../import-export/import-export.service.js | 373 ++++++++++++++++++ ui/src/app/import-export/index.js | 24 ++ ui/src/app/services/item-buffer.service.js | 56 ++- .../app/widget/lib/analogue-linear-gauge.js | 15 +- .../app/widget/lib/analogue-radial-gauge.js | 15 +- ui/src/locale/en_US.json | 25 +- 28 files changed, 928 insertions(+), 134 deletions(-) create mode 100644 ui/src/app/import-export/import-dialog.controller.js create mode 100644 ui/src/app/import-export/import-dialog.scss create mode 100644 ui/src/app/import-export/import-dialog.tpl.html create mode 100644 ui/src/app/import-export/import-export.service.js create mode 100644 ui/src/app/import-export/index.js diff --git a/ui/package.json b/ui/package.json index c1101d2dcc..b39ae99198 100644 --- a/ui/package.json +++ b/ui/package.json @@ -54,6 +54,7 @@ "json-schema-defaults": "^0.2.0", "justgage": "^1.2.2", "material-ui": "^0.16.1", + "material-ui-number-input": "^5.0.16", "md-color-picker": "^0.2.6", "mdPickers": "git://github.com/alenaksu/mdPickers.git#0.7.5", "moment": "^2.15.0", diff --git a/ui/src/app/api/device.service.js b/ui/src/app/api/device.service.js index 27cf605c6b..1a1d714a3e 100644 --- a/ui/src/app/api/device.service.js +++ b/ui/src/app/api/device.service.js @@ -88,10 +88,10 @@ function DeviceService($http, $q, $filter, telemetryWebsocketService, types) { return deferred.promise; } - function getDevice(deviceId) { + function getDevice(deviceId, ignoreErrors) { var deferred = $q.defer(); var url = '/api/device/' + deviceId; - $http.get(url, null).then(function success(response) { + $http.get(url, { ignoreErrors: ignoreErrors }).then(function success(response) { deferred.resolve(response.data); }, function fail(response) { deferred.reject(response.data); diff --git a/ui/src/app/components/dashboard.directive.js b/ui/src/app/components/dashboard.directive.js index 7c5094a6ff..c55995eeb3 100644 --- a/ui/src/app/components/dashboard.directive.js +++ b/ui/src/app/components/dashboard.directive.js @@ -58,8 +58,10 @@ function Dashboard() { isMobile: '=', isMobileDisabled: '=?', isEditActionEnabled: '=', + isExportActionEnabled: '=', isRemoveActionEnabled: '=', onEditWidget: '&?', + onExportWidget: '&?', onRemoveWidget: '&?', onWidgetMouseDown: '&?', onWidgetClicked: '&?', @@ -139,6 +141,7 @@ function DashboardController($scope, $rootScope, $element, $timeout, $log, toast vm.showWidgetTitle = showWidgetTitle; vm.hasTimewindow = hasTimewindow; vm.editWidget = editWidget; + vm.exportWidget = exportWidget; vm.removeWidget = removeWidget; vm.loading = loading; @@ -413,6 +416,16 @@ function DashboardController($scope, $rootScope, $element, $timeout, $log, toast } } + function exportWidget ($event, widget) { + resetWidgetClick(); + if ($event) { + $event.stopPropagation(); + } + if (vm.isExportActionEnabled && vm.onExportWidget) { + vm.onExportWidget({event: $event, widget: widget}); + } + } + function removeWidget($event, widget) { resetWidgetClick(); if ($event) { diff --git a/ui/src/app/components/dashboard.tpl.html b/ui/src/app/components/dashboard.tpl.html index c43caac54f..0ad43eb8eb 100644 --- a/ui/src/app/components/dashboard.tpl.html +++ b/ui/src/app/components/dashboard.tpl.html @@ -62,6 +62,18 @@ edit + + + {{ 'widget.export' | translate }} + + + file_download + + -