thingsboard-aplcache
Changes
ui/src/app/locale/locale.constant.js 5(+4 -1)
Details
diff --git a/ui/src/app/entity/relation/relation-dialog.scss b/ui/src/app/entity/relation/relation-dialog.scss
new file mode 100644
index 0000000..55064df
--- /dev/null
+++ b/ui/src/app/entity/relation/relation-dialog.scss
@@ -0,0 +1,27 @@
+/**
+ * Copyright © 2016-2017 The Thingsboard Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+.tb-relation-additional-info-panel {
+ margin-left: 15px;
+ border: 1px solid #C0C0C0;
+ height: 100%;
+ #tb-relation-additional-info {
+ min-width: 600px;
+ min-height: 200px;
+ width: 100%;
+ height: 100%;
+ }
+}
diff --git a/ui/src/app/entity/relation/relation-table.directive.js b/ui/src/app/entity/relation/relation-table.directive.js
index f0c192b..17436a6 100644
--- a/ui/src/app/entity/relation/relation-table.directive.js
+++ b/ui/src/app/entity/relation/relation-table.directive.js
@@ -19,11 +19,11 @@ import './relation-table.scss';
/* eslint-disable import/no-unresolved, import/default */
import relationTableTemplate from './relation-table.tpl.html';
-import addRelationTemplate from './add-relation-dialog.tpl.html';
+import relationTemplate from './relation-dialog.tpl.html';
/* eslint-enable import/no-unresolved, import/default */
-import AddRelationController from './add-relation-dialog.controller';
+import RelationController from './relation-dialog.controller';
/*@ngInject*/
export default function RelationTable() {
@@ -66,6 +66,7 @@ function RelationTableController($scope, $q, $mdDialog, $document, $translate, $
vm.onReorder = onReorder;
vm.onPaginate = onPaginate;
vm.addRelation = addRelation;
+ vm.editRelation = editRelation;
vm.deleteRelation = deleteRelation;
vm.deleteRelations = deleteRelations;
vm.reloadRelations = reloadRelations;
@@ -110,18 +111,52 @@ function RelationTableController($scope, $q, $mdDialog, $document, $translate, $
if ($event) {
$event.stopPropagation();
}
- var entityId = {
- id: vm.entityId,
- entityType: vm.entityType
- };
+ openRelationDialog($event);
+ }
+
+ function editRelation($event, relation) {
+ if ($event) {
+ $event.stopPropagation();
+ }
+ openRelationDialog($event, relation);
+ }
+
+ function openRelationDialog($event, relation) {
+ if ($event) {
+ $event.stopPropagation();
+ }
+ var isAdd = false;
+ if (!relation) {
+ isAdd = true;
+ var entityId = {
+ id: vm.entityId,
+ entityType: vm.entityType
+ };
+ relation = {};
+ if (vm.direction == vm.types.entitySearchDirection.from) {
+ relation.from = entityId;
+ } else {
+ relation.to = entityId;
+ }
+ }
+ var onShowingCallback = {
+ onShowing: function(){}
+ }
$mdDialog.show({
- controller: AddRelationController,
+ controller: RelationController,
controllerAs: 'vm',
- templateUrl: addRelationTemplate,
+ templateUrl: relationTemplate,
parent: angular.element($document[0].body),
- locals: { direction: vm.direction, entityId: entityId },
+ locals: { isAdd: isAdd,
+ direction: vm.direction,
+ relation: relation,
+ showingCallback: onShowingCallback},
+ targetEvent: $event,
fullscreen: true,
- targetEvent: $event
+ skipHide: true,
+ onShowing: function(scope, element) {
+ onShowingCallback.onShowing(scope, element);
+ }
}).then(function () {
reloadRelations();
}, function () {
diff --git a/ui/src/app/entity/relation/relation-table.tpl.html b/ui/src/app/entity/relation/relation-table.tpl.html
index 56970f9..8599397 100644
--- a/ui/src/app/entity/relation/relation-table.tpl.html
+++ b/ui/src/app/entity/relation/relation-table.tpl.html
@@ -112,6 +112,12 @@
<td md-cell ng-if="vm.direction == vm.types.entitySearchDirection.from">{{ relation.toName }}</td>
<td md-cell ng-if="vm.direction == vm.types.entitySearchDirection.to">{{ relation.fromName }}</td>
<td md-cell class="tb-action-cell">
+ <md-button class="md-icon-button" aria-label="{{ 'action.edit' | translate }}" ng-click="vm.editRelation($event, relation)">
+ <md-icon aria-label="{{ 'action.edit' | translate }}" class="material-icons">edit</md-icon>
+ <md-tooltip md-direction="top">
+ {{ 'relation.edit' | translate }}
+ </md-tooltip>
+ </md-button>
<md-button class="md-icon-button" aria-label="{{ 'action.delete' | translate }}" ng-click="vm.deleteRelation($event, relation)">
<md-icon aria-label="{{ 'action.delete' | translate }}" class="material-icons">delete</md-icon>
<md-tooltip md-direction="top">
ui/src/app/locale/locale.constant.js 5(+4 -1)
diff --git a/ui/src/app/locale/locale.constant.js b/ui/src/app/locale/locale.constant.js
index d5f8dd2..6513ce8 100644
--- a/ui/src/app/locale/locale.constant.js
+++ b/ui/src/app/locale/locale.constant.js
@@ -888,6 +888,7 @@ export default angular.module('thingsboard.locale', [])
"relation-type-required": "Relation type is required.",
"any-relation-type": "Any type",
"add": "Add relation",
+ "edit": "Edit relation",
"delete-to-relation-title": "Are you sure you want to delete relation to the entity '{{entityName}}'?",
"delete-to-relation-text": "Be careful, after the confirmation the entity '{{entityName}}' will be unrelated from the current entity.",
"delete-to-relations-title": "Are you sure you want to delete { count, select, 1 {1 relation} other {# relations} }?",
@@ -899,7 +900,9 @@ export default angular.module('thingsboard.locale', [])
"remove-relation-filter": "Remove relation filter",
"add-relation-filter": "Add relation filter",
"any-relation": "Any relation",
- "relation-filters": "Relation filters"
+ "relation-filters": "Relation filters",
+ "additional-info": "Additional info (JSON)",
+ "invalid-additional-info": "Unable to parse additional info json."
},
"rule": {
"rule": "Rule",