Browse Source
* 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
committed by
GitHub
13 changed files with 321 additions and 9 deletions
@ -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); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
File diff suppressed because one or more lines are too long
@ -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; |
||||
|
} |
||||
|
} |
||||
@ -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; |
||||
@ -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: '=?' |
||||
|
} |
||||
|
}; |
||||
|
} |
||||
@ -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. |
||||
|
*/ |
||||
@ -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> |
||||
Loading…
Reference in new issue