diff --git a/projects/IoTCenter/Controllers/AppController.cs b/projects/IoTCenter/Controllers/AppController.cs
index e0762fdd..9fe53649 100644
--- a/projects/IoTCenter/Controllers/AppController.cs
+++ b/projects/IoTCenter/Controllers/AppController.cs
@@ -417,15 +417,14 @@ namespace IoTCenter.Controllers
/************************************************************/
- public IActionResult AllPowerOn(string connectionId, string[] nodes)
+ public IActionResult Power(string token,string connectionId, string method,string[] numbers)
{
- this.Power(connectionId, nodes, "On", o => o.Name.Contains("开关") || o.Name.Contains("插座"));
- return Json(ApiResponse.AsyncSuccess());
- }
-
- public IActionResult AllPowerOff(string connectionId, string[] nodes)
- {
- this.Power(connectionId, nodes, "Off", o => o.Name.Contains("开关") || o.Name.Contains("插座"));
+ var userName = this.GetUserName(token);
+ if (string.IsNullOrEmpty(userName))
+ {
+ return Forbid();
+ }
+ this.Power(connectionId, numbers, method, o => o.Name.Contains("开关") || o.Name.Contains("插座") || o.Name.Contains("灯"));
return Json(ApiResponse.AsyncSuccess());
}
diff --git a/projects/IoTCenter/Views/Home/Nodes.cshtml b/projects/IoTCenter/Views/Home/Nodes.cshtml
index e782d5b3..c0a2a31a 100644
--- a/projects/IoTCenter/Views/Home/Nodes.cshtml
+++ b/projects/IoTCenter/Views/Home/Nodes.cshtml
@@ -3,10 +3,27 @@
}
+
diff --git a/projects/IoTCenter/appsettings.json b/projects/IoTCenter/appsettings.json
index 78d1fcf9..f74900b6 100644
--- a/projects/IoTCenter/appsettings.json
+++ b/projects/IoTCenter/appsettings.json
@@ -1,5 +1,5 @@
{
- "version": "1.0.0-rc.102",
+ "version": "1.0.0-rc.103",
"Logging": {
"LogLevel": {
"Default": "Warning",
diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/nodes.js b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/nodes.js
index 544e7d58..c3f61ffa 100644
--- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/nodes.js
+++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/nodes.js
@@ -15,6 +15,19 @@ data = function data() {
methods = {
GetNodes() {
return Enumerable.from(this.model).orderBy('o=>o.DisplayOrder').toArray();
+ },
+ SelectNode: Select,
+ Power(method) {
+ var numbers = [];
+ $('.item:checked').each(function () {
+ numbers.push($(this).val());
+ });
+ if (numbers.length) {
+ ajax('/App/Power', { token: token, connectionId: connectionId, method: method, numbers: numbers }, 'post');
+ }
+ else {
+ toastr.error('没有选中任何项');
+ }
}
};
function onMessage(method, json, to, from) {
diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/page.js b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/page.js
index 58129c54..07c6b656 100644
--- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/page.js
+++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/page.js
@@ -604,4 +604,32 @@ $(document).on('click', '.segmented .button', function (e) {
current.parent().find('.button-active').removeClass('button-active');
current.addClass('button-active');
}
-});
\ No newline at end of file
+});
+function Select(e) {
+ var checkbox = $(e.target);
+ if (checkbox.hasClass('checkall')) {
+ if (e.target.checked) {
+ $('input.item:visible').not(':checked').prop("checked", true);
+ }
+ else {
+ $('input.item:visible').filter(':checked').prop("checked", false);
+ }
+ }
+ else if (checkbox.hasClass('uncheck')) {
+ $('input.item:visible').each(function () {
+ $(this).prop("checked", !$(this).prop("checked")).change();
+ });
+ }
+ var parent = $('input.checkall');
+ if ($('input.item').not(':checked').length === 0) {
+ parent.prop("indeterminate", false);
+ parent.prop("checked", true);
+ }
+ else if ($('input.item').filter(':checked').length === 0) {
+ parent.prop("indeterminate", false);
+ parent.prop("checked", false);
+ }
+ else {
+ parent.prop("indeterminate", true);
+ }
+}
diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/product.js b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/product.js
index d8092966..c415bc9b 100644
--- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/product.js
+++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/product.js
@@ -33,40 +33,18 @@ methods = {
}
return null;
},
- SelectDevice(e) {
- var checkbox = $(e.target);
- if (checkbox.hasClass('checkall')) {
- if (e.target.checked) {
- $('input.item').not(':checked').prop("checked", true);
- }
- else {
- $('input.item').filter(':checked').prop("checked", false);
- }
- }
- else if (checkbox.hasClass('uncheck')) {
- $('input.item').each(function () {
- $(this).prop("checked", !$(this).prop("checked")).change();
- });
- }
- var parent = $('input.checkall');
- if ($('input.item').not(':checked').length === 0) {
- parent.prop("indeterminate", false);
- parent.prop("checked", true);
- }
- else if ($('input.item').filter(':checked').length === 0) {
- parent.prop("indeterminate", false);
- parent.prop("checked", false);
- }
- else {
- parent.prop("indeterminate", true);
- }
- },
+ SelectDevice:Select,
CallApiAll(method) {
var numbers = [];
$('.item:checked').each(function () {
numbers.push($(this).val());
});
- ajax('/App/ExecApiAll', { token: token, connectionId: connectionId, method: vm.model.Path + method, numbers: numbers }, 'post');
+ if (numbers.length) {
+ ajax('/App/ExecApiAll', { token: token, connectionId: connectionId, method: vm.model.Path + method, numbers: numbers }, 'post');
+ }
+ else {
+ toastr.error('没有选中任何项');
+ }
}
};
function onMessage(method, json, to, from) {
diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/nodes.html b/projects/IoTClient/Assets/StreamingAssets/wwwroot/nodes.html
index 4b4a497f..ecc8c7cf 100644
--- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/nodes.html
+++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/nodes.html
@@ -28,18 +28,37 @@
search-container=".search-list"
search-in=".item-title">
+
-
-
+
+
diff --git a/projects/IoTNode/appsettings.json b/projects/IoTNode/appsettings.json
index 61004dd4..6930198b 100644
--- a/projects/IoTNode/appsettings.json
+++ b/projects/IoTNode/appsettings.json
@@ -1,5 +1,5 @@
{
- "version": "1.0.0-rc.102",
+ "version": "1.0.0-rc.103",
"Logging": {
"LogLevel": {
"Default": "Warning",