Browse Source

Clear code and style

pull/1776/head
Vladyslav_Prykhodko 7 years ago
parent
commit
27ac1918fc
  1. 2
      ui/package.json
  2. 8
      ui/src/app/api/device.service.js
  3. 2
      ui/src/app/import-export/import-dialog-csv.controller.js
  4. 68
      ui/src/app/import-export/import-dialog-csv.tpl.html
  5. 11
      ui/src/app/import-export/import-dialog.scss
  6. 49
      ui/src/app/import-export/import-export.service.js
  7. 21
      ui/src/app/import-export/table-columns-assignment.directive.js
  8. 2
      ui/src/app/import-export/table-columns-assignment.tpl.html

2
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",

8
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);
}
});

2
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;
}

68
ui/src/app/import-export/import-dialog-csv.tpl.html

@ -15,7 +15,7 @@
limitations under the License.
-->
<md-dialog aria-label="{{ vm.importTitle | translate }}">
<md-dialog aria-label="{{ vm.importTitle | translate }}" class="tb-import-stepper">
<md-toolbar>
<div class="md-toolbar-tools">
<h2 translate>{{ vm.importTitle }}</h2>
@ -27,7 +27,7 @@
</md-toolbar>
<md-progress-linear class="md-warn" md-mode="indeterminate" ng-disabled="!$root.loading"
ng-show="$root.loading"></md-progress-linear>
<span style="min-height: 5px;" flex="" ng-show="!$root.loading"></span>
<span style="max-height: 5px; height: 5px;" flex ng-show="!$root.loading"></span>
<md-dialog-content>
<md-stepper id="import-stepper" md-mobile-step-text="vm.isMobileStepText" md-vertical="vm.isVertical"
md-linear="vm.isLinear" md-alternative="vm.isAlternative">
@ -83,7 +83,7 @@
</md-step-actions>
</md-step>
<md-step md-label="Select config import">
<md-step md-label="Import configuration">
<md-step-body>
<div flex layout="row" layout-xs="column">
<md-input-container class="md-block" style="min-width: 120px">
@ -95,13 +95,13 @@
</md-select>
</md-input-container>
<md-input-container class="md-block">
<md-checkbox ng-model="vm.importParams.isHeader" aria-label="Checkbox 1">
<md-checkbox ng-model="vm.importParams.isHeader" aria-label="First line is header">
First line is header
</md-checkbox>
</md-input-container>
<md-input-container class="md-block">
<md-checkbox ng-model="vm.importParams.isUpdate" aria-label="Checkbox 1">
Update parameters
<md-checkbox ng-model="vm.importParams.isUpdate" aria-label="Update attributes/telemetry">
Update attributes/telemetry
</md-checkbox>
</md-input-container>
</div>
@ -122,8 +122,10 @@
<md-step md-label="Select columns type">
<md-step-body>
<tb-table-columns-assignment columns="vm.columnsParam"
entity-type="vm.entityType"></tb-table-columns-assignment>
<form name="vm.theFormStep3">
<tb-table-columns-assignment columns="vm.columnsParam" the-form="vm.theFormStep3"
entity-type="vm.entityType"></tb-table-columns-assignment>
</form>
</md-step-body>
<md-step-actions layout="row">
@ -133,35 +135,35 @@
<md-button ng-disabled="$root.loading" ng-click="vm.cancel()">
{{ 'action.cancel' | translate }}
</md-button>
<md-button class="md-primary md-raised" ng-disabled="$root.loading" ng-click="vm.nextStep(4);">
<md-button class="md-primary md-raised"
ng-disabled="$root.loading || !vm.theFormStep3.$dirty || !vm.theFormStep3.$valid"
ng-click="vm.nextStep(4);">
Continue
</md-button>
</md-step-actions>
</md-step>
<md-step md-label="Creat new device">
<md-step md-label="Creating new entities">
<md-step-body>
<md-progress-linear md-mode="determinate" value="{{vm.determinateValue}}"></md-progress-linear>
</md-step-body>
</md-step>
<md-step md-label="Creat new Entitys">
<md-step-body>
<div flex layout="row" ng-repeat="(key, value) in vm.statistical">
<md-list flex layout="column">
<md-subheader class="md-no-sticky">{{key}}</md-subheader>
<md-list-item class="md-2-line" ng-repeat="(info, infoValue) in vm.statistical[key]" ng-click="null">
<div class="md-list-item-text">
<p>{{ info }}: {{ infoValue }}</p>
</div>
</md-list-item>
</md-list>
<md-step md-label="Done">
<md-step-body layout="row">
<div flex ng-repeat="(key, value) in vm.statistical">
<div flex layout="column">
<div class="md-subhead" style="font-weight: 500; margin: 0.4em 0 0.6em;">{{key}}</div>
<div class="md-body-1" ng-repeat="(info, infoValue) in vm.statistical[key]">
{{ info }}: {{ infoValue }}
</div>
</div>
</div>
</md-step-body>
<md-step-actions>
<md-step-actions layout="row">
<span flex></span>
<md-button ng-disabled="$root.loading" ng-click="vm.cancel()">
{{ 'action.cancel' | translate }}
</md-button>
<!--<md-button ng-disabled="$root.loading" ng-click="vm.cancel()">-->
<!--{{ 'action.cancel' | translate }}-->
<!--</md-button>-->
<md-button class="md-primary md-raised" ng-disabled="$root.loading" ng-click="vm.finishExport();">
Ok
</md-button>
@ -171,13 +173,13 @@
</md-stepper>
</md-dialog-content>
<!--<md-dialog-actions layout="row">-->
<!--<span flex></span>-->
<!--<md-button ng-disabled="$root.loading || !theForm.$dirty || !theForm.$valid || !vm.importData" type="submit"-->
<!--class="md-raised md-primary">-->
<!--{{ 'action.import' | translate }}-->
<!--</md-button>-->
<!--<md-button ng-disabled="$root.loading" ng-click="vm.cancel()" style="margin-right:20px;">{{ 'action.cancel'-->
<!--| translate }}-->
<!--</md-button>-->
<!--<span flex></span>-->
<!--<md-button ng-disabled="$root.loading || !theForm.$dirty || !theForm.$valid || !vm.importData" type="submit"-->
<!--class="md-raised md-primary">-->
<!--{{ 'action.import' | translate }}-->
<!--</md-button>-->
<!--<md-button ng-disabled="$root.loading" ng-click="vm.cancel()" style="margin-right:20px;">{{ 'action.cancel'-->
<!--| translate }}-->
<!--</md-button>-->
<!--</md-dialog-actions>-->
</md-dialog>

11
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}}';
//}

49
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 */

21
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);
}

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

@ -15,7 +15,7 @@
limitations under the License.
-->
<md-table-container flex class="tb-table-select">
<md-table-container layout="column" class="tb-table-select">
<table md-table>
<thead md-head>
<tr md-row>

Loading…
Cancel
Save