diff --git a/projects/IoTCenter/Views/Home/Index.cshtml b/projects/IoTCenter/Views/Home/Index.cshtml
index 230e0296..96550b38 100644
--- a/projects/IoTCenter/Views/Home/Index.cshtml
+++ b/projects/IoTCenter/Views/Home/Index.cshtml
@@ -7,17 +7,6 @@
-
@section styles{
diff --git a/projects/IoTCenter/appsettings.json b/projects/IoTCenter/appsettings.json
index 45c25979..fd5a29d2 100644
--- a/projects/IoTCenter/appsettings.json
+++ b/projects/IoTCenter/appsettings.json
@@ -1,5 +1,5 @@
{
- "version": "1.0.0-rc.31",
+ "version": "1.0.0-rc.40",
"Logging": {
"LogLevel": {
"Default": "Warning",
diff --git a/projects/IoTClient/Assets/StreamingAssets/IoT.Resources.csproj b/projects/IoTClient/Assets/StreamingAssets/IoT.Resources.csproj
index 9c6907bf..78147af7 100644
--- a/projects/IoTClient/Assets/StreamingAssets/IoT.Resources.csproj
+++ b/projects/IoTClient/Assets/StreamingAssets/IoT.Resources.csproj
@@ -15,6 +15,7 @@
+
\ No newline at end of file
diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/index.js b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/index.js
index ae0dc9b6..5b3840f9 100644
--- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/index.js
+++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/index.js
@@ -11,16 +11,6 @@ data = function data() {
}
};
}
-function mounted() {
- if (isApp) {
- if (!this.server) {
- location.href = "config.html";
- }
- if (!this.token) {
- location.href = "login.html";
- }
- }
-};
methods = {
GetProducts() {
return Enumerable.from(this.model.Products).orderBy('o=>o.DisplayOrder').toArray();
diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/nodes.js b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/nodes.js
new file mode 100644
index 00000000..90185c55
--- /dev/null
+++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/nodes.js
@@ -0,0 +1,56 @@
+isDebug = true;
+useSingalR = false; dataUrl = iotCenter + '/App/GetNodes';
+data = function data() {
+ return {
+ f7params: f7params,
+ server: localStorage.getItem('server'),
+ token: localStorage.getItem('token'),
+ model: {
+ Products: [],
+ Scenes: []
+ }
+ };
+}
+function mounted() {
+ if (isApp) {
+ if (!this.server) {
+ location.href = "config.html";
+ }
+ if (!this.token) {
+ location.href = "login.html";
+ }
+ }
+};
+methods = {
+ GetProducts() {
+ return Enumerable.from(this.model.Products).orderBy('o=>o.DisplayOrder').toArray();
+ },
+ GetScenes() {
+ return Enumerable.from(this.model.Scenes).orderBy('o=>o.DisplayOrder').toArray();
+ },
+ CallScene(id) {
+ ajax('/App/ExecGlobalScene', { token: token, connectionId: connectionId, id: id }, 'post');
+ }
+};
+function onMessage(method, json, to, from) {
+ debug(method + ':' + json);
+ var item = JSON.parse(json);
+ console.log(method + ':' + json);
+ var item = JSON.parse(json);
+ if (method == 'ProductEntityInserted' ||
+ method == 'ProductEntityUpdated' ||
+ method == 'ProductEntityDeleted' ||
+ method == 'DeviceEntityInserted' ||
+ method == 'DeviceEntityDeleted' ||
+ method == 'DeviceEntityDeleted') {
+ loadData();
+ }
+ else if (method == 'SceneEntityInserted' ||
+ method == 'SceneEntityUpdated' ||
+ method == 'SceneEntityDeleted') {
+ if (item.NodeId == null) {
+ loadData();
+ }
+ }
+}
+start();
\ No newline at end of file
diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/nodes.js.meta b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/nodes.js.meta
new file mode 100644
index 00000000..3171df42
--- /dev/null
+++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/nodes.js.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 338522422683d67479a6658c9958b319
+DefaultImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/page.js b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/page.js
index 89de8ad2..c32a77bb 100644
--- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/page.js
+++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/page.js
@@ -10,7 +10,8 @@ var templateUrl = templateUrl || null;
var dataUrl = dataUrl||null;
var token = isApp ? localStorage.getItem('token') : null;
//
-var connection = useSignalR? new signalR.HubConnectionBuilder().withUrl(wsUrl).build():null;
+var connection = useSignalR ? new signalR.HubConnectionBuilder().withUrl(wsUrl).build():null;
+var connectionId;
var vm;
var app;
//
@@ -122,8 +123,15 @@ function init() {
el: '#app',
data: data,
mounted: function () {
- mounted();
if (isApp) {
+ if (!this.server) {
+ location.href = "config.html";
+ }
+ if (!this.token) {
+ if (location.href.indexOf('config.html')===-1&& location.href.indexOf('login.html') === -1)
+ location.href = "login.html";
+ }
+ mounted();
this.$f7ready((f7) => {
app = this.$f7;
$.validator.unobtrusive.parse('form');
@@ -135,4 +143,163 @@ function init() {
},
methods: methods
});
+}
+//tools
+//
+function getCode1(code) {
+ var pattern = 0;
+ var direction = 0;
+ var wind = 0;
+ var power = 2;
+ var temperature = 1;
+ if (code > 480 + 2) {
+ pattern = 480;
+ }
+ else if (code > 360 + 2) {
+ pattern = 360;
+ }
+ else if (code > 240 + 2) {
+ pattern = 240;
+ }
+ else if (code > 120 + 2) {
+ pattern = 120;
+ }
+ else {
+ pattern = 0;
+ }
+ code -= pattern;
+ if (code > 75 + 2) {
+ direction = 75;
+ }
+ else if (code > 60 + 2) {
+ direction = 60;
+ }
+ else {
+ direction = 0;
+ }
+ code -= direction;
+ if (code > 45 + 2) {
+ wind = 45;
+ }
+ else if (code > 30 + 2) {
+ wind = 30;
+ }
+ else if (code > 15 + 2) {
+ wind = 15;
+ }
+ else {
+ wind = 0;
+ }
+ code -= wind;
+ if (code === 1) {
+ power = 1;
+ }
+ else {
+ power = 2;
+ temperature = code - power;
+ }
+ return {
+ pattern: pattern,
+ direction: direction,
+ wind: wind,
+ power: power,
+ temperature: temperature
+ };
+}
+//
+function hsvToRgb(h, s, v) {
+ if (h == "") h = 0;
+ if (s == "") s = 0;
+ if (v == "") v = 0;
+ h = parseFloat(h);
+ s = parseFloat(s);
+ v = parseFloat(v);
+ if (h < 0) h = 0;
+ if (s < 0) s = 0;
+ if (v < 0) v = 0;
+ if (h >= 360) h = 359;
+ if (s > 100) s = 100;
+ if (v > 100) v = 100;
+ s /= 100.0;
+ v /= 100.0;
+ C = v * s;
+ hh = h / 60.0;
+ X = C * (1.0 - Math.abs((hh % 2) - 1.0));
+ r = g = b = 0;
+ if (hh >= 0 && hh < 1) {
+ r = C;
+ g = X;
+ }
+ else if (hh >= 1 && hh < 2) {
+ r = X;
+ g = C;
+ }
+ else if (hh >= 2 && hh < 3) {
+ g = C;
+ b = X;
+ }
+ else if (hh >= 3 && hh < 4) {
+ g = X;
+ b = C;
+ }
+ else if (hh >= 4 && hh < 5) {
+ r = X;
+ b = C;
+ }
+ else {
+ r = C;
+ b = X;
+ }
+ m = v - C;
+ r += m;
+ g += m;
+ b += m;
+ r *= 255.0;
+ g *= 255.0;
+ b *= 255.0;
+ r = Math.round(r);
+ g = Math.round(g);
+ b = Math.round(b);
+ hex = r * 65536 + g * 256 + b;
+ hex = hex.toString(16, 6);
+ len = hex.length;
+ if (len < 6)
+ for (i = 0; i < 6 - len; i++)
+ hex = '0' + hex;
+ return '#' + hex;
+}
+//
+function ajax(url, data, type) {
+ url = iotCenter + url
+ console.log(url);
+ type = type || 'get';
+ $('.overlay').show();
+ $.ajax({
+ type: type,
+ url: url,
+ data: data,
+ success: AjaxCallBack
+ }).fail(function (result) {
+ toastr.error('请求发送失败!');
+ console.log(result);
+ }).always(function () {
+ $('.overlay').hide();
+ });
+}
+//
+function AjaxCallBack(response) {
+ var result = response;
+ if (result.code === 0) {
+ if (result.type === 0) {
+ if (result.format === 1) {
+ console.log('format/1/base64 jpeg image');
+ $('#callback .page-content').html('
');
+ }
+ else {
+ console.log('format/0/json object');
+ $('#callback .page-content').html(result.data);
+ }
+ app.popup.open('#callback');
+ }
+ }
}
\ No newline at end of file
diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/login.html b/projects/IoTClient/Assets/StreamingAssets/wwwroot/login.html
index 715da5f0..b8e781ac 100644
--- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/login.html
+++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/login.html
@@ -78,11 +78,6 @@
username: localStorage.getItem('username')
};
}
- function mounted() {
- if (isApp && !this.server) {
- location.href = "config.html";
- }
- }
var methods = {
submit: function (e) {
if (!$(e.target).valid()) {
diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/nodes.html b/projects/IoTClient/Assets/StreamingAssets/wwwroot/nodes.html
index aaada1d4..4e6871d6 100644
--- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/nodes.html
+++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/nodes.html
@@ -62,12 +62,18 @@
+
+
+
+
+
+