Browse Source

CheckPoint Node ui, Queue Controller, queue-type-list directive (#2612)

* init commit

* ui: service for queue

* merge with develop/2.5 & fix license

* queue directive

* queue directive

* queue-type-list directive & TbCheckPointNode

* added rulenode-core-config.js file

* added new rulenode-core-config.js

* Develop/2.5 check point node (#3)

* fixed mistakes to pull https://github.com/thingsboard/thingsboard/pull/2612

* fixed mistakes to pull https://github.com/thingsboard/thingsboard/pull/2612

* fixed mistakes to pull https://github.com/thingsboard/thingsboard/pull/2612

* fixed mistakes to pull https://github.com/thingsboard/thingsboard/pull/2612

* Develop/2.5 check point node (#4)

* fixed mistakes to pull https://github.com/thingsboard/thingsboard/pull/2612

* fixed mistakes to pull https://github.com/thingsboard/thingsboard/pull/2612

* fixed mistakes to pull https://github.com/thingsboard/thingsboard/pull/2612

* fixed mistakes to pull https://github.com/thingsboard/thingsboard/pull/2612

* fixed mistakes to pull https://github.com/thingsboard/thingsboard/pull/2612

* fixed mistakes to pull https://github.com/thingsboard/thingsboard/pull/2612

* fixed mistakes to pull https://github.com/thingsboard/thingsboard/pull/2612

Co-authored-by: Dmitriymush <powder322@gmail.com>
Co-authored-by: Dmitriy Mushat <54553744+Dmitriymush@users.noreply.github.com>
pull/2634/head
ShvaykaD 7 years ago
committed by GitHub
parent
commit
0a136588eb
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 54
      application/src/main/java/org/thingsboard/server/controller/QueueController.java
  2. 10
      rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/flow/TbAckNode.java
  3. 6
      rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/flow/TbCheckpointNode.java
  4. 8
      rule-engine/rule-engine-components/src/main/resources/public/static/rulenode/rulenode-core-config.js
  5. 40
      ui/src/app/api/queue.service.js
  6. 23
      ui/src/app/components/queue/index.js
  7. 111
      ui/src/app/components/queue/queue-type-list.directive.js
  8. 15
      ui/src/app/components/queue/queue-type-list.scss
  9. 43
      ui/src/app/components/queue/queue-type-list.tpl.html
  10. 2
      ui/src/app/layout/index.js
  11. 6
      ui/src/app/locale/locale.constant-en_US.json
  12. 6
      ui/src/app/locale/locale.constant-ru_RU.json
  13. 6
      ui/src/app/locale/locale.constant-uk_UA.json

54
application/src/main/java/org/thingsboard/server/controller/QueueController.java

@ -0,0 +1,54 @@
/**
* Copyright © 2016-2020 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.
*/
package org.thingsboard.server.controller;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.thingsboard.server.common.data.exception.ThingsboardException;
import org.thingsboard.server.common.msg.queue.ServiceType;
import org.thingsboard.server.queue.util.TbCoreComponent;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@RestController
@TbCoreComponent
@RequestMapping("/api")
public class QueueController extends BaseController {
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
@RequestMapping(value = "/tenant/queues", params = {"serviceType"}, method = RequestMethod.GET)
@ResponseBody
public List<String> getTenantQueuesByServiceType(@RequestParam String serviceType) throws ThingsboardException {
checkParameter("serviceType", serviceType);
try {
ServiceType type = ServiceType.valueOf(serviceType);
switch (type) {
case TB_RULE_ENGINE:
return Arrays.asList("HighPriority", "Main");
default:
return Collections.emptyList();
}
} catch (Exception e) {
throw handleException(e);
}
}
}

10
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/flow/TbAckNode.java

@ -22,7 +22,6 @@ import org.thingsboard.rule.engine.api.TbContext;
import org.thingsboard.rule.engine.api.TbNode; import org.thingsboard.rule.engine.api.TbNode;
import org.thingsboard.rule.engine.api.TbNodeConfiguration; import org.thingsboard.rule.engine.api.TbNodeConfiguration;
import org.thingsboard.rule.engine.api.TbNodeException; import org.thingsboard.rule.engine.api.TbNodeException;
import org.thingsboard.rule.engine.api.TbRelationTypes;
import org.thingsboard.rule.engine.api.util.TbNodeUtils; import org.thingsboard.rule.engine.api.util.TbNodeUtils;
import org.thingsboard.server.common.data.plugin.ComponentType; import org.thingsboard.server.common.data.plugin.ComponentType;
import org.thingsboard.server.common.msg.TbMsg; import org.thingsboard.server.common.msg.TbMsg;
@ -33,12 +32,17 @@ import org.thingsboard.server.common.msg.TbMsg;
name = "acknowledge", name = "acknowledge",
configClazz = EmptyNodeConfiguration.class, configClazz = EmptyNodeConfiguration.class,
nodeDescription = "Acknowledges the incoming message", nodeDescription = "Acknowledges the incoming message",
nodeDetails = "After acknowledgement, the message is pushed to related rule nodes. Useful if you don't care what happens to this message next.") nodeDetails = "After acknowledgement, the message is pushed to related rule nodes. Useful if you don't care what happens to this message next.",
uiResources = {"static/rulenode/rulenode-core-config.js"},
configDirective = "tbNodeEmptyConfig"
)
public class TbAckNode implements TbNode { public class TbAckNode implements TbNode {
EmptyNodeConfiguration config;
@Override @Override
public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException { public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
this.config = TbNodeUtils.convert(configuration, EmptyNodeConfiguration.class);
} }
@Override @Override

6
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/flow/TbCheckpointNode.java

@ -35,8 +35,10 @@ import static org.thingsboard.common.util.DonAsynchron.withCallback;
name = "checkpoint", name = "checkpoint",
configClazz = TbCheckpointNodeConfiguration.class, configClazz = TbCheckpointNodeConfiguration.class,
nodeDescription = "transfers the message to another queue", nodeDescription = "transfers the message to another queue",
nodeDetails = "After successful transfer incoming message is automatically acknowledged. Queue name is configurable.") nodeDetails = "After successful transfer incoming message is automatically acknowledged. Queue name is configurable.",
uiResources = {"static/rulenode/rulenode-core-config.js"},
configDirective = "tbActionNodeCheckPointConfig"
)
public class TbCheckpointNode implements TbNode { public class TbCheckpointNode implements TbNode {
private TbCheckpointNodeConfiguration config; private TbCheckpointNodeConfiguration config;

8
rule-engine/rule-engine-components/src/main/resources/public/static/rulenode/rulenode-core-config.js

File diff suppressed because one or more lines are too long

40
ui/src/app/api/queue.service.js

@ -0,0 +1,40 @@
/*
* Copyright © 2016-2020 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.
*/
export default angular.module('thingsboard.api.queue', [])
.factory('queueService', queueService)
.name;
/*@ngInject*/
function queueService($http, $q) {
var service = {
getTenantQueuesByServiceType: getTenantQueuesByServiceType
};
return service;
function getTenantQueuesByServiceType(serviceType, config) {
let deferred = $q.defer();
let url = '/api/tenant/queues?serviceType=' + serviceType;
$http.get(url, config).then(function success(data) {
deferred.resolve(data);
}, function fail() {
deferred.reject();
});
return deferred.promise;
}
}

23
ui/src/app/components/queue/index.js

@ -0,0 +1,23 @@
/*
* Copyright © 2016-2020 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.
*/
import thingsboardApiQueue from '../../api/queue.service';
import queueTypeList from "./queue-type-list.directive";
export default angular.module('thingsboard.queue', [
thingsboardApiQueue
])
.directive('tbQueueTypeList', queueTypeList)
.name;

111
ui/src/app/components/queue/queue-type-list.directive.js

@ -0,0 +1,111 @@
/*
* Copyright © 2016-2020 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.
*/
import './queue-type-list.scss';
/* eslint-disable import/no-unresolved, import/default */
import queueTypeListTemplate from './queue-type-list.tpl.html';
/* eslint-enable import/no-unresolved, import/default */
/*@ngInject*/
export default function QueueTypeList($compile, $templateCache, $q, $filter, queueService) {
var linker = function (scope, element, attrs, ngModelCtrl) {
var template = $templateCache.get(queueTypeListTemplate);
element.html(template);
scope.queues = null;
scope.queue = null;
scope.tbRequired = angular.isDefined(scope.tbRequired) ? scope.tbRequired : false;
scope.queueSearchText = '';
scope.fetchQueues = function(searchText) {
var deferred = $q.defer();
loadQueues().then(
function success(queueArr) {
let result = $filter('filter')(queueArr, {'$': searchText});
if (result && result.length) {
if (searchText && searchText.length && result.indexOf(searchText) === -1) {
result.push(searchText);
}
result.sort();
deferred.resolve(result);
} else {
deferred.resolve([searchText]);
}
},
function fail() {
deferred.reject();
}
);
return deferred.promise;
};
scope.updateView = function () {
if (!scope.disabled) {
ngModelCtrl.$setViewValue(scope.queue);
}
};
function loadQueues() {
var deferred = $q.defer();
if (!scope.queues) {
queueService.getTenantQueuesByServiceType(scope.queueType).then(
function success(queueArr) {
scope.queues = queueArr.data;
deferred.resolve(scope.queues);
},
function fail() {
deferred.reject();
}
);
} else {
deferred.resolve(scope.queues);
}
return deferred.promise;
}
ngModelCtrl.$render = function () {
scope.queue = ngModelCtrl.$viewValue;
};
scope.$watch('queue', function (newValue, prevValue) {
if (!angular.equals(newValue, prevValue)) {
scope.updateView();
}
});
scope.$watch('disabled', function () {
scope.updateView();
});
$compile(element.contents())(scope);
};
return {
restrict: "E",
require: "^ngModel",
link: linker,
scope: {
theForm: '=?',
tbRequired: '=?',
disabled:'=ngDisabled',
queueType: '=?'
}
};
}

15
ui/src/app/components/queue/queue-type-list.scss

@ -0,0 +1,15 @@
/**
* Copyright © 2016-2020 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.
*/

43
ui/src/app/components/queue/queue-type-list.tpl.html

@ -0,0 +1,43 @@
<!--
Copyright © 2016-2020 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.
-->
<md-autocomplete ng-required="tbRequired"
ng-disabled="disabled"
md-no-cache="true"
md-input-name="queue"
ng-model="queue"
md-selected-item="queue"
md-search-text="queueSearchText"
md-items="item in fetchQueues(queueSearchText)"
md-item-text="item"
md-min-length="0"
md-select-on-match="false"
md-autoselect="true"
ng-blur="queue = queueSearchText"
md-menu-class="tb-queue-autocomplete"
md-clear-button="true"
placeholder="{{'queue.select_name' | translate}}"
md-floating-label="{{'queue.name' | translate}}">
<md-item-template>
<div class="tb-queue-item">
<span md-highlight-text="queueSearchText" md-highlight-flags="^i">{{item}}</span>
</div>
</md-item-template>
<div ng-messages="theForm.queue.$error">
<div translate ng-message="required">{{'queue.name_required' | translate}}</div>
</div>
</md-autocomplete>

2
ui/src/app/layout/index.js

@ -55,6 +55,7 @@ import thingsboardEntityView from '../entity-view';
import thingsboardWidgetLibrary from '../widget'; import thingsboardWidgetLibrary from '../widget';
import thingsboardDashboard from '../dashboard'; import thingsboardDashboard from '../dashboard';
import thingsboardRuleChain from '../rulechain'; import thingsboardRuleChain from '../rulechain';
import thingsboardQueue from '../components/queue';
import thingsboardJsonForm from '../jsonform'; import thingsboardJsonForm from '../jsonform';
@ -86,6 +87,7 @@ export default angular.module('thingsboard.home', [
thingsboardWidgetLibrary, thingsboardWidgetLibrary,
thingsboardDashboard, thingsboardDashboard,
thingsboardRuleChain, thingsboardRuleChain,
thingsboardQueue,
thingsboardJsonForm, thingsboardJsonForm,
thingsboardApiDevice, thingsboardApiDevice,
thingsboardApiLogin, thingsboardApiLogin,

6
ui/src/app/locale/locale.constant-en_US.json

@ -1484,6 +1484,12 @@
"help": "Help", "help": "Help",
"reset-debug-mode": "Reset debug mode in all nodes" "reset-debug-mode": "Reset debug mode in all nodes"
}, },
"queue": {
"select_name": "Select queue name",
"name": "Queue Name",
"name_required": "Queue name is required!"
},
"tenant": { "tenant": {
"tenant": "Tenant", "tenant": "Tenant",
"tenants": "Tenants", "tenants": "Tenants",

6
ui/src/app/locale/locale.constant-ru_RU.json

@ -1403,6 +1403,12 @@
"help": "Помощь", "help": "Помощь",
"reset-debug-mode": "Сбросить режим отладки во всех правилах" "reset-debug-mode": "Сбросить режим отладки во всех правилах"
}, },
"queue": {
"select_name": "Выберите имя для Queue",
"name": "Имя для Queue",
"name_required": "Поле 'Имя для Queue' обязательно к заполнению!"
},
"tenant": { "tenant": {
"tenant": "Владелец", "tenant": "Владелец",
"tenants": "Владельцы", "tenants": "Владельцы",

6
ui/src/app/locale/locale.constant-uk_UA.json

@ -1820,6 +1820,12 @@
"help": "Допомога", "help": "Допомога",
"reset-debug-mode": "Вимкнути режим налогодження у всіх правилах" "reset-debug-mode": "Вимкнути режим налогодження у всіх правилах"
}, },
"queue": {
"select_name": "Виберіть ім'я для Queue",
"name": "Iм'я для Queue",
"name_required": "Поле 'Имя для Queue' обязательно к заполнению!"
},
"scheduler": { "scheduler": {
"scheduler": "Планувальник", "scheduler": "Планувальник",
"scheduler-event": "Подія планувальника", "scheduler-event": "Подія планувальника",

Loading…
Cancel
Save