From 7391959286641f34087f83fe3d17c9ba1aa0d00a Mon Sep 17 00:00:00 2001 From: wanli Date: Thu, 1 Dec 2022 11:53:46 +0800 Subject: [PATCH 01/12] =?UTF-8?q?[Frontend]=203D=E9=9B=BB=E6=A2=AF?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=9B=B4=E6=96=B0=EF=BC=8C=E6=B8=AC=E8=A9=A6?= =?UTF-8?q?=E7=A7=BB=E5=8B=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/forgetTest2.html | 349 ++++++++++----------------- Frontend/js/forge/modeltest.js | 416 +++++++++++++++++++++++++++++++++ 2 files changed, 538 insertions(+), 227 deletions(-) create mode 100644 Frontend/js/forge/modeltest.js diff --git a/Frontend/forgetTest2.html b/Frontend/forgetTest2.html index 31b822e..ffc87ea 100644 --- a/Frontend/forgetTest2.html +++ b/Frontend/forgetTest2.html @@ -1,241 +1,136 @@ - + + - - - - - - - - - Showing A360 Shared files + - - -
-
-
-
- - + + + + + + + + +
+

Robot Controls

+

Selected_ID:

+

All_ID:

+ + + + + + + + + + + + + + + 亮度 +
- +
+
+
+ + + + + + + + + + + - - - + + \ No newline at end of file diff --git a/Frontend/js/forge/modeltest.js b/Frontend/js/forge/modeltest.js new file mode 100644 index 0000000..a7edfcb --- /dev/null +++ b/Frontend/js/forge/modeltest.js @@ -0,0 +1,416 @@ +var viewer; + + + +// Initialize sensor values +//let sensorVals = []; +let fragProxy; +var targetFloorZ; +var elevatorSpeed; +// for (let i = 0; i < devices.length; i++) { +// sensorVals[i] = Math.random(); +// } + +function launchViewer(urn) { + var options = { + env: 'AutodeskProduction', + getAccessToken: getForgeToken + }; + + Autodesk.Viewing.Initializer(options, () => { + viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('forgeViewer')); + //viewer = new Autodesk.Viewing.Viewer3D(document.getElementById('forgeViewer')); + viewer.start(); + var documentId = 'urn:' + urn; + Autodesk.Viewing.Document.load(documentId, onDocumentLoadSuccess, onDocumentLoadFailure); + + + + //test + // for (let i = 0; i < urn.length; i++) { + // Autodesk.Viewing.Document.load(urn[i]["urn"], async (doc) => { + // let viewables = doc.getRoot().getDefaultGeometry(); + // let model = await viewer.loadDocumentNode(doc, viewables, { + // preserveView: false, + // keepCurrentModels: true, + // placementTransform: (new THREE.Matrix4()).setPosition(urn[i]["xform"]), + // keepCurrentModels: true, + // globalOffset: { + // x: 0, + // y: 0, + // z: 0 + // } + // }); + + // await viewer.waitForLoadDone(); //!<<< Wait for loading materials, properties and geometries for this model (URN) + // }); + // } + + //loadHeatmaps(viewer.getAllModels()[0]); //!<<< equals to viewer.model + + + + }); +} + +function getAllLeafComponents(viewer, callback) { + var cbCount = 0; + var tree; + var jsData = [] + + function getLeafComponentsRec(current, parent) { + cbCount++; + if (tree.getChildCount(current) != 0) { + tree.enumNodeChildren(current, function (children) { + getLeafComponentsRec(children, current); + }, false); + } + var nodeName = viewer.model.getInstanceTree().getNodeName(current) + jsData.push({ id: current, parent: parent, text: nodeName }) + + if (--cbCount == 0) callback(jsData); + } + viewer.getObjectTree(function (objectTree) { + tree = objectTree; + var rootId = tree.getRootId() + var nodeName = viewer.model.getInstanceTree().getNodeName(rootId) + jsData.push({ id: rootId, parent: '#', text: nodeName }) + var allLeafComponents = getLeafComponentsRec(rootId, '#'); + + }); +} + +function onDocumentLoadSuccess(doc) { + var viewables = doc.getRoot().getDefaultGeometry(); + viewer.loadDocumentNode(doc, viewables).then(i => { + // documented loaded, any action? + }); + viewer.addEventListener(Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT, (args) => { + var currSelection = viewer.getSelection(); + var domElem = document.getElementById('id_printer'); + domElem.innerText = currSelection[0]; + }); + + viewer.addEventListener(Autodesk.Viewing.GEOMETRY_LOADED_EVENT, function () { + var instanceTree = viewer.model.getData().instanceTree; + var allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex); + var domElem = document.getElementById('all_id'); + domElem.innerText = allDbIdsStr; + + + + let tree = viewer.model.getData().instanceTree; + let nodeId = 749;//10952; + let nodeId2 = 750; + let nodeId3 = 751; + + tree.enumNodeFragments(nodeId, function (frag) { + fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + fragProxy.getAnimTransform(); + let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26 + + fragProxy.position = fragPosition + + fragProxy.updateAnimTransform() + + }); + viewer.impl.sceneUpdated(true); + + //------------ add ------------- + tree.enumNodeFragments(nodeId2, function (frag) { + fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + fragProxy.getAnimTransform(); + let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26 + + fragProxy.position = fragPosition + + fragProxy.updateAnimTransform() + + }); + viewer.impl.sceneUpdated(true); + + tree.enumNodeFragments(nodeId3, function (frag) { + fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + fragProxy.getAnimTransform(); + let fragPosition = new THREE.Vector3(0, 0, 0);// 一樓0 二樓15 三樓 26 + + fragProxy.position = fragPosition + + fragProxy.updateAnimTransform() + + }); + viewer.impl.sceneUpdated(true); + + }); + + NOP_VIEWER.getProperties(NOP_VIEWER.getSelection(), data => console.log(data)); +} + +function setElevatorFloor(floor) { + if (floor == 0) + targetFloorZ = 0; + else if (floor == 1) + targetFloorZ = 14.6;// 15; + else if (floor == 2) + targetFloorZ = 24.6;// 26; + else if (floor == 3) + targetFloorZ = 34.6; + else if (floor == 4) + targetFloorZ = 44.6; + else if (floor == 5) + targetFloorZ = 54.6; + else if (floor == 6) + targetFloorZ = 64.6; + else if (floor == 7) + targetFloorZ = 74.6; + else if (floor == 8) + targetFloorZ = 84.6; + else if (floor == 9) + targetFloorZ = 94.6; + else if (floor == 10) + targetFloorZ = 104.6; + else if (floor == 11) + targetFloorZ = 114.6; + else if (floor == 12) + targetFloorZ = 124.6; + else if (floor == -1) + targetFloorZ = -13; +} + +function setElevatorSpeed(speed) { //0.01 ~ 1 + elevatorSpeed = speed; +} + +function movElevator() { + + + let tree = viewer.model.getData().instanceTree; + let nodeId = 749; //10952; + let nodeId2 = 750; + let nodeId3 = 751; + let fragProxyZ = 0; + var movStatus = 0; // 0=no 1=up 2=down + + + if (fragProxy.position.z > targetFloorZ) { + movStatus = 2 + } + else if (fragProxy.position.z < targetFloorZ) { + movStatus = 1 + } + + if (movStatus == 0) { + return; + } + + tree.enumNodeFragments(nodeId, function (frag) { + fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + fragProxy.getAnimTransform(); + //let fragPosition = new THREE.Vector3(0, 0, 15);// 一樓0 二樓15 三樓 26 + if (movStatus == 2) { + fragProxy.position.z -= elevatorSpeed; + } + else if (movStatus == 1) { + fragProxy.position.z += elevatorSpeed; + } + + fragProxyZ = fragProxy.position.z; + fragProxy.updateAnimTransform() + + }); + viewer.impl.sceneUpdated(true); + + tree.enumNodeFragments(nodeId2, function (frag) { + fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + fragProxy.getAnimTransform(); + //let fragPosition = new THREE.Vector3(0, 0, 15);// 一樓0 二樓15 三樓 26 + if (movStatus == 2) { + fragProxy.position.z -= elevatorSpeed; + } + else if (movStatus == 1) { + fragProxy.position.z += elevatorSpeed; + } + + fragProxyZ = fragProxy.position.z; + fragProxy.updateAnimTransform() + + }); + viewer.impl.sceneUpdated(true); + + tree.enumNodeFragments(nodeId3, function (frag) { + fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); + fragProxy.getAnimTransform(); + //let fragPosition = new THREE.Vector3(0, 0, 15);// 一樓0 二樓15 三樓 26 + if (movStatus == 2) { + fragProxy.position.z -= elevatorSpeed; + } + else if (movStatus == 1) { + fragProxy.position.z += elevatorSpeed; + } + + fragProxyZ = fragProxy.position.z; + fragProxy.updateAnimTransform() + + }); + viewer.impl.sceneUpdated(true); + + if (movStatus == 2) { + if (fragProxyZ >= targetFloorZ) { + requestAnimationFrame(movElevator); + } + } + else if (movStatus == 1) { + if (fragProxyZ <= targetFloorZ) { + requestAnimationFrame(movElevator); + } + } + + + //let fragPosition = new THREE.Vector3(position);// 一樓0 二樓15 三樓 26 + + //fragProxy.position = fragPosition; + + //fragProxy.updateAnimTransform(); + + //viewer.impl.sceneUpdated(true); +} + +//function movElevator() { + + +// let tree = viewer.model.getData().instanceTree; +// let nodeId = 750;// 10952; +// let fragProxyZ = 0; +// var movStatus = 0; // 0=no 1=up 2=down + + +// if (fragProxy.position.z > targetFloorZ) { +// movStatus = 2 +// } +// else if (fragProxy.position.z < targetFloorZ) { +// movStatus = 1 +// } + +// if (movStatus == 0) { +// return; +// } + +// tree.enumNodeFragments(nodeId, function (frag) { +// fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag); +// fragProxy.getAnimTransform(); +// //let fragPosition = new THREE.Vector3(0, 0, 15);// 一樓0 二樓15 三樓 26 +// if (movStatus == 2) { +// fragProxy.position.z -= elevatorSpeed; +// } +// else if (movStatus == 1) { +// fragProxy.position.z += elevatorSpeed; +// } + +// fragProxyZ = fragProxy.position.z; +// fragProxy.updateAnimTransform() + +// }); +// viewer.impl.sceneUpdated(true); + +// if (movStatus == 2) { +// if (fragProxyZ >= targetFloorZ) { +// requestAnimationFrame(movElevator); +// } +// } +// else if (movStatus == 1) { +// if (fragProxyZ <= targetFloorZ) { +// requestAnimationFrame(movElevator); +// } +// } + + +// //let fragPosition = new THREE.Vector3(position);// 一樓0 二樓15 三樓 26 + +// //fragProxy.position = fragPosition; + +// //fragProxy.updateAnimTransform(); + +// //viewer.impl.sceneUpdated(true); +//} + +function getAllDbIds(viewer) { + var instanceTree = viewer.model.getData().instanceTree; + + var allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex); + + return allDbIdsStr.map(function (id) { return parseInt(id) }); +} + +/** + * Autodesk.Viewing.Document.load() failuire callback. + */ +function onDocumentLoadFailure(viewerErrorCode) { + console.error("onDocumentLoadFailure() - errorCode:" + viewerErrorCode); +} + +function getForgeToken(callback) { + fetch(baseApiUrl + '/api/forge/oauth/token').then(res => { + res.json().then(data => { + callback(data.dictionary.access_token, data.dictionary.expires_in); + }); + }); + //callback("eyJhbGciOiJSUzI1NiIsImtpZCI6IlU3c0dGRldUTzlBekNhSzBqZURRM2dQZXBURVdWN2VhIn0.eyJzY29wZSI6WyJkYXRhOndyaXRlIiwiZGF0YTpyZWFkIiwiYnVja2V0OnJlYWQiLCJidWNrZXQ6dXBkYXRlIiwiYnVja2V0OmNyZWF0ZSJdLCJjbGllbnRfaWQiOiJUQTNocXNGZnpRYk5PVVhLcGxkS1VLU2V3NFNKMjF3NSIsImF1ZCI6Imh0dHBzOi8vYXV0b2Rlc2suY29tL2F1ZC9hand0ZXhwNjAiLCJqdGkiOiJiemxzWE5qWElvZ2R1UjUzTUJkdlhrTTNTT01qeVB1bHJrMmdTVWJudGNTeDg1b01kRG1xejg3Z05jenJkRzhpIiwiZXhwIjoxNjY4MTgzMDM2fQ.VU3qLwTJ9nlXnomKCdk4y5UcgszGEO_zlvE7w5mWWajeBMwKLo-zw7LJEqUEajRksvssppR9SbVsjLSx-vDVc3DRhCo3jYTWKPT1T3wQrlkOSqLeIrAdnKdBDNBWKgrGJt_xcmXc3dZ3XNKf9L_F6Ex808rUlo6cem1mcPpKl1jCBDqKu1mAX7aDtZ65TTQZbGGhbG4HdnET-d1i5w4LunGN11UAHhDUW3n0SWWIBL27PiiUQONZttajhD5st6IngYLcjr93BYVyJmDF7-wm4WZlHSw2OnXIfbJcFXEd83uVv_Rej4UXjzZ0e6kHwzc2nvGvKSIFu3Nt7CabdR8CkA", 3599); +} + +async function loadHeatmaps(model) { + + const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization"); + + // Given a model loaded from Forge + const structureInfo = new Autodesk.DataVisualization.Core.ModelStructureInfo(model); + + const devices = [ + { + id: "Oficina 6", + name: "Oficina-", + position: { x: 22.475382737884104, y: 7.4884431474006163, z: 3.0 }, + sensorTypes: ["temperature", "humidity"] + } + ]; + + var offset = Autodesk.viewer.model.getGlobalOffset(); + removeOffset(devices[0], offset) + + // Generates `SurfaceShadingData` after assigning each device to a room. + + const shadingData = await Autodesk.structureInfo.generateSurfaceShadingData(devices); + + // Use the resulting shading data to generate heatmap from. + await dataVizExtn.setupSurfaceShading(model, shadingData); + + // Register color stops for the heatmap. Along with the normalized sensor value + // in the range of [0.0, 1.0], `renderSurfaceShading` will interpolate the final + // heatmap color based on these specified colors. + const sensorColors = [0x0000ff, 0x00ff00, 0xffff00, 0xff0000]; + + // Set heatmap colors for temperature + const sensorType = "temperature"; + dataVizExtn.registerSurfaceShadingColors(sensorType, sensorColors); + + // Function that provides sensor value in the range of [0.0, 1.0] + + function getSensorValue(surfaceShadingPoint, sensorType) { + // The `SurfaceShadingPoint.id` property matches one of the identifiers passed + // to `generateSurfaceShadingData` function. In our case above, this will either + // be "cafeteria-entrace-01" or "cafeteria-exit-01". + const deviceId = surfaceShadingPoint.id; + + // Read the sensor data, along with its possible value range + let sensorValue = readSensorValue(deviceId, sensorType); + const maxSensorValue = getMaxSensorValue(sensorType); + const minSensorValue = getMinSensorValue(sensorType); + + // Normalize sensor value to [0, 1.0] + sensorValue = (sensorValue - minSensorValue) / (maxSensorValue - minSensorValue); + return clamp(sensorValue, 0.0, 1.0); + } + + // This value can also be a room instead of a floor + const floorName = "01 - Entry Level"; + dataVizExtn.renderSurfaceShading(floorName, sensorType, getSensorValue); +} \ No newline at end of file From 1236eaac9cf26cd5ac7d98fe7f418158581e4c47 Mon Sep 17 00:00:00 2001 From: dev01 Date: Thu, 1 Dec 2022 19:32:32 +0800 Subject: [PATCH 02/12] =?UTF-8?q?[Frontend][=E7=B3=BB=E7=B5=B1=E7=9B=A3?= =?UTF-8?q?=E6=8E=A7]=20forge=20Model=20=E9=9B=BB=E6=A2=AF=E7=89=A9?= =?UTF-8?q?=E4=BB=B6=E5=8C=96=E8=AA=BF=E6=95=B4=20|=20=E9=9B=BB=E6=A2=AF?= =?UTF-8?q?=E9=A0=86=E5=BA=8F=E8=AA=BF=E6=95=B4=20|=20[=E5=84=80=E9=8C=B6?= =?UTF-8?q?=E6=9D=BF]=20=E4=B8=8A=E6=96=B9=E5=9B=9B=E5=80=8BCard=E8=B3=87?= =?UTF-8?q?=E6=96=99=E9=A1=AF=E7=A4=BA=20|=20[=E7=B3=BB=E7=B5=B1=E7=9B=A3?= =?UTF-8?q?=E6=8E=A7]=20=E9=A0=81=E9=9D=A2=E8=B7=B3=E9=96=83=E5=95=8F?= =?UTF-8?q?=E9=A1=8C=E8=A7=A3=E6=B1=BA=20|=20bajatest=20callback=20object?= =?UTF-8?q?=20=E8=AA=BF=E6=95=B4=20|=20=E5=BB=BA=E7=BD=AE=20=E8=A8=82?= =?UTF-8?q?=E9=96=B1=E5=AE=8C=E6=88=90=20callback=20|=20[ForntendWebApi]?= =?UTF-8?q?=20GetDeviceList=20=E8=A3=9C=E4=B8=8A=20priority?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_dashboard.html | 16 +- Frontend/_sysElevator.html | 286 +++++++++++------- Frontend/_sysMonAll.html | 2 +- Frontend/css/site.css | 12 + Frontend/index.html | 11 +- Frontend/js/forge/forgemodel.js | 113 +++---- Frontend/js/n4js/bajatest.js | 177 ++++++++++- Frontend/js/yourteam/plugins/yt-tab/yt-tab.js | 11 +- .../ApiControllers/DeviceManageController.cs | 2 +- FrontendWebApi/Models/Device.cs | 1 + 10 files changed, 442 insertions(+), 189 deletions(-) diff --git a/Frontend/_dashboard.html b/Frontend/_dashboard.html index b521f52..b9f5b70 100644 --- a/Frontend/_dashboard.html +++ b/Frontend/_dashboard.html @@ -9,8 +9,8 @@

- 21.5k - users signed up + 560 + 今日用電量 kWH

@@ -20,8 +20,8 @@

- $10,203 - Visual Index Figure + 6560 + 昨日用電量

@@ -69,8 +69,8 @@

- - 103.72 - Offset Balance Ratio + 9,218 + 即時功率

@@ -80,8 +80,8 @@

- +40% - Product level increase + 8,846 + 即時契約容量占比 kWH

diff --git a/Frontend/_sysElevator.html b/Frontend/_sysElevator.html index 18b42c0..6a0ed67 100644 --- a/Frontend/_sysElevator.html +++ b/Frontend/_sysElevator.html @@ -3,9 +3,11 @@ background-color: #fff; min-height: 520px; } + .elevator-table-wrapper { - padding:0.8rem; + padding: 0.8rem; } + table.elevator-build { /*border: 1px double #000;*/ } @@ -51,10 +53,10 @@
- -
@@ -88,47 +90,7 @@
-
-
- -
號機別 : 1
- -
-

10F

- -

狀態 : 運行中

- -
-
-
-
-
- -
號機別 : 2
- -
-

5F

- -

- 狀態 : 維修 -

- -
-
-
-
-
- -
號機別 : 3
- -
-

3F

- -

狀態 : 運行中

- -
-
-
+
@@ -520,7 +482,7 @@
- +
@@ -893,6 +855,7 @@
- + @@ -2537,6 +2539,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li + - + diff --git a/Frontend/js/site.js b/Frontend/js/site.js index 63dfd10..55248fa 100644 --- a/Frontend/js/site.js +++ b/Frontend/js/site.js @@ -19,9 +19,66 @@ $.fn.outerHtml = function () { return $(this).prop("outerHTML"); } +/** + * fn 定義 | Loading 操作 + * @param {any} type - close / start / exceed , exceed => 繼續執行並可切換文字 + * @param {any} text - 右下角 Alert 文字 + */ +$.fn.Loading = function (type = "close",text) { + let ele = this; + let aleObj = $(this)[0]._aleObj; + + function closeLoading() { + $("body").css("overflow", "auto"); + $(aleObj.ele).YTAlert().hide(); + $(ele).animate({ opacity: 0 }, 300, () => { + $(ele).hide(); + }) + } + function showLoading() { + $("body").css("overflow", "hidden"); + let aleObj = YT.Alert.Tip(text || "讀取中,請稍後", "show"); + $(ele)[0]._aleObj = aleObj; + $(ele).show(); + $(ele).animate({ opacity: 1 }, 300); + + $(aleObj.ele).YTAlert().text(text); + } + if (type == "close") { + closeLoading(); + } else if (type == "exceed") { + $(aleObj.ele).YTAlert().text(text); + } else if (type == "start") { + showLoading(); + } + + return $(this); +} + +$.fn.YTAlert = function () { + let th = { element: this }; + th.hide = function (delay = 0) { + let obj = this; + setTimeout(function () { + $(obj.element).fadeOut(300); + alertIdArray.splice($.inArray($(obj.element).prop("id"), alertIdArray), 1); + setTimeout(function () { + $(obj.element).remove(); + }, 1000); + }, delay); + } + + th.text = function (text) { + let obj = this; + let id = $(obj.element).prop("id").split("tip-alert-")[1]; + $(`#alert-text-${id}`).text(text); + } + return th; +} + /** * 設置 bootstrap dropdown 為下拉選單 - * @param {any} menuEle .dropdown-menu element + * @param {any} menuEle - .dropdown-menu element */ function setDropdownItem(menuEle) { if ($(menuEle).find(".dropdown-item.active").length == 0) { @@ -52,6 +109,11 @@ function defDev(obj) { obj.src = defSrc; } +/** + * jquery datatable - ajax send data reset + * @param {any} table + * @param {any} sendData + */ function dtAjaxResetSendData(table,sendData) { table.context[0].ajax.data = function (d) { d = sendData; @@ -59,6 +121,7 @@ function dtAjaxResetSendData(table,sendData) { } } + /** * element 建造 * @param {any} text @@ -108,6 +171,9 @@ function creOption(text = null, value = null, data = {}, attr = {}, cls = [], na return creEle("option", text, id, name, cls, data, attr); } +/** + * 根據該棟建築底下的'所有'電梯執行緒物件 + * */ class ElevatorHandler { constructor(ele, option = {}) { this.ele = ele; @@ -124,9 +190,11 @@ class ElevatorHandler { this.init(); } + // 所有電梯初始化 init = function () { this.setTabWra(); this.setTabFloor(); + // 若已有每個設備的所在樓層,則預設到該樓層位置 if (Object.keys(this.curElevFloor).length != 0) { $.each(Object.keys(this.curElevFloor), (idx, elevKey) => { this.setElevFloor(elevKey,this.curElevFloor[elevKey]); @@ -158,16 +226,16 @@ class ElevatorHandler { for (let e = 1; e <= _elevators.length + 2; e++) { let th = creEle("th"); - th.css({ "width": `${_w}px`, "height": `${_h}px` }); + th.css({ "width": `${_w}px`, "height": `${_h}px` ,"position":"relative"}); if (e != 1 && e != _elevators.length + 2) { let elevId = _elevators[e - 2]?.id; // 電梯方框 let span = creEle("span", null, "elevator-item-" + (elevId), null, ["elevator-item"]); let spanUp = creEle("span", null, null, null, ["elevator-item-toup"]); let spanDown = creEle("span", null, null, null, ["elevator-item-todown"]); - span.css({ "width": `${_w - 3}px`, "height": `${_h - 3}px`, "top": `1.5px`, "transition":`transform ${1 / this.speed}s cubic-bezier(0.43, 0.05, 0.62, 1) 0s`}) - spanUp.css({ "width": `${_w - 3}px`, "height": `${(_h - 3) / 2}px`, "top": `1.5px`, "transition":`transform ${1 / this.speed}s cubic-bezier(0.43, 0.05, 0.62, 1) 0s`}) - spanDown.css({ "width": `${_w - 3}px`, "height": `${(_h - 3) / 2}px`, "top": `1.5px`, "transition":`transform ${1 / this.speed}s cubic-bezier(0.43, 0.05, 0.62, 1) 0s`,"top":`${1.5 + (_h-3) / 2}px`}) + span.css({ "width": `${_w - 3}px`, "height": `${_h - 3}px`, "top": `1.5px`,"left":"1.5px", "transition":`transform ${1 / this.speed}s cubic-bezier(0.43, 0.05, 0.62, 1) 0s`}) + spanUp.css({ "width": `${_w - 3}px`, "height": `${(_h - 3) / 2}px`, "top": `1.5px`, "left": "1.5px", "transition":`transform ${1 / this.speed}s cubic-bezier(0.43, 0.05, 0.62, 1) 0s`}) + spanDown.css({ "width": `${_w - 3}px`, "height": `${(_h - 3) / 2}px`, "top": `1.5px`, "left": "1.5px", "transition":`transform ${1 / this.speed}s cubic-bezier(0.43, 0.05, 0.62, 1) 0s`,"top":`${1.5 + (_h-3) / 2}px`}) th.append(spanUp); th.append(span); th.append(spanDown); @@ -221,26 +289,18 @@ class ElevatorHandler { } + // 設置某個電梯到某個樓層 setElevFloor = function (elevId, floId) { let curFloId = this.curElevFloor[elevId]; let curSort = this.floors.filter(x => x.id == curFloId).map(x => x.sort)[0]; let tarSort = this.floors.filter(x => x.id == floId).map(x => x.sort)[0]; let gapFloor = tarSort - curSort; let cssEle = [$(`#elevator-item-${elevId}`)[0], $(`#elevator-item-${elevId}`).prev("span.elevator-item-toup")[0], $(`#elevator-item-${elevId}`).next("span.elevator-item-todown")[0]] - clearTimeout(this.setTimeout); - console.log("123",this.movStatus) if (this.movStatus[elevId] != 0) { $(cssEle).css("transition", `transform ${1 / this.speed * Math.abs(gapFloor)}s cubic-bezier(0, 0, 0.62, 1) 0s`); } - //if (gapFloor < 0) { - // this.movStatus[elevId] = 2; - //} else if (gapFloor > 0) { - // this.movStatus[elevId] = 1; - //} else { - // this.movStatus[elevId] = 0; - //} + clearTimeout(this.setTimeout); this.setTimeout = setTimeout(() => { - /*this.movStatus[elevId] = 0;*/ $(cssEle).css("transition", `transform ${1 / this.speed * Math.abs(gapFloor)}s cubic-bezier(0.43, 0.05, 0.62, 1) 0s`); this.setEleUpDownStyle(elevId); }, (1 / this.speed * Math.abs(gapFloor)) * 1000) @@ -250,10 +310,12 @@ class ElevatorHandler { $(cssEle).css("transform", `translateY(${this.floorHeight * (this.floors.length - tarSort)}px)`); } + // 設定現在電梯狀態 (往上/往下/停止) setEleMovStatus = function (elevId,status) { this.movStatus[elevId] = status; } + // 電梯方框 往上或往下閃爍 setEleUpDownStyle = function (elevId) { if (this.movStatus[elevId] == 1) { $(`#elevator-item-${elevId}`).next("span.elevator-item-todown").removeClass("light-flash-c-bd") @@ -269,10 +331,12 @@ class ElevatorHandler { } } + // 設定現在某個電梯所在樓層 setCurElevFloor = function (elevId,floId) { this.curElevFloor[elevId] = floId; } + // 重新繪製 redraw = function () { $(this.ele).empty(); this.setTabFloor(); diff --git a/Frontend/js/yourteam/plugins/yt-alert/ytpop-alert.js b/Frontend/js/yourteam/plugins/yt-alert/ytpop-alert.js new file mode 100644 index 0000000..6a99500 --- /dev/null +++ b/Frontend/js/yourteam/plugins/yt-alert/ytpop-alert.js @@ -0,0 +1,120 @@ + +alertIdArray = []; +window.YT = typeof YT == "undefined" ? {} : YT; +window.YT.Alert = { Success: null, Error: null, Tip: null }; + + +YT.Alert.Success = function (text) { + let ranId = Math.floor(Math.random() * 100000); + $("body").append(``) + + //紀錄上一筆出現的alert + alertIdArray.push("success-alert-" + ranId) + alertIdArray.length > 2 ? alertIdArray.shift() : "" + $("#success-alert-" + ranId).fadeIn(300); + //判斷上一筆是否還存在頁面中 + if (typeof ($("#" + alertIdArray[0]).css("bottom")) != "undefined" && $("#" + alertIdArray[0]).css("display") != "none" && (alertIdArray[1] != "" || alertIdArray[1] != null)) { + //存在的話下一個alert出現在前一個alert上面 + let newAlertWidth = parseInt($("#" + alertIdArray[0]).css("bottom").split('px')[0]) + parseInt($("#" + alertIdArray[0]).css("height")) + 10 + "px" + $("#" + alertIdArray[1]).css("bottom", newAlertWidth); + } + $("#success-alert-" + ranId).click(function () { + $("#success-alert-" + ranId).fadeOut(300); + }) + + setTimeout(function () { $("#success-alert-" + ranId).fadeOut(300); }, 6000); + setTimeout(function () { + $("#success-alert-" + ranId).remove(); + alertIdArray.splice($.inArray("#success-alert-" + ranId, alertIdArray), 1); + }, 7000); + +} + +YT.Alert.Error = function (text) { + let ranId = Math.floor(Math.random() * 100000); + $("body").append(``) + + alertIdArray.push("danger-alert-" + ranId); + alertIdArray.length > 2 ? alertIdArray.shift() : "" + $("#danger-alert-" + ranId).fadeIn(300); + if (typeof ($("#" + alertIdArray[0]).css("bottom")) != "undefined" && $("#" + alertIdArray[0]).css("display") != "none" && (alertIdArray[1] != "" || alertIdArray[1] != null)) { + let newAlertWidth = parseInt($("#" + alertIdArray[0]).css("bottom").split('px')[0]) + parseInt($("#" + alertIdArray[0]).css("height")) + 10 + "px" + $("#" + alertIdArray[1]).css("bottom", newAlertWidth); + } + $("#danger-alert-" + ranId).click(function () { + $("#danger-alert-" + ranId).fadeOut(300); + }) + + setTimeout(function () { + $("#danger-alert-" + ranId).fadeOut(300); + alertIdArray.splice($.inArray("#danger-alert-" + ranId, alertIdArray), 1); + }, 6000); + setTimeout(function () { $("#danger-alert-" + ranId).remove(); }, 7000); + +} + +YT.Alert.Tip = function (text, type = null, color = null) { + let ranId = Math.floor(Math.random() * 100000); + $("body").append(``) + + alertIdArray.push("tip-alert-" + ranId); + alertIdArray.length > 2 ? alertIdArray.shift() : "" + if (color != null) { + $("#tip-alert-" + ranId).css("background-color", color); + } + + if (type == null) { + $("#tip-alert-" + ranId).fadeIn(300); + if (typeof ($("#" + alertIdArray[0]).css("bottom")) != "undefined" && $("#" + alertIdArray[0]).css("display") != "none" && (alertIdArray[1] != "" || alertIdArray[1] != null)) { + let newAlertWidth = parseInt($("#" + alertIdArray[0]).css("bottom").split('px')[0]) + parseInt($("#" + alertIdArray[0]).css("height")) + 10 + "px" + $("#" + alertIdArray[1]).css("bottom", newAlertWidth); + } + $("#tip-alert-" + ranId).click(function () { + $("#tip-alert-" + ranId).fadeOut(300); + }) + setTimeout(function () { + $("#tip-alert-" + ranId).fadeOut(300); + alertIdArray.splice($.inArray("#tip-alert-" + ranId, alertIdArray), 1); + }, 6000); + + setTimeout(function () { $("#tip-alert-" + ranId).remove(); }, 7000); + } else if (type == "show") { + $("#tip-alert-" + ranId).fadeIn(300); + } else if (type == "hide") { + $("#tip-alert-" + ranId).fadeOut(300); + alertIdArray.splice($.inArray("#tip-alert-" + ranId, alertIdArray), 1); + setTimeout(function () { + $("#tip-alert-" + ranId).remove(); + }, 1000); + } + return { id: "#tip-alert-" + ranId, ele: $("#tip-alert-" + ranId) }; + +} + + +//因非使用 Require 引用,$.fn 被二次引用 jquery.js 吃掉,則移至 site.js + +//$.fn.YTAlert = function () { +// let th = { element: this }; +// th.hide = function (delay = 0) { +// let obj = this; +// setTimeout(function () { +// $(obj.element).fadeOut(300); +// alertIdArray.splice($.inArray($(obj.element).prop("id"), alertIdArray), 1); +// setTimeout(function () { +// $(obj.element).remove(); +// }, 1000); +// }, delay); +// } + +// th.text = function (text) { +// let obj = this; +// let id = $(obj.element).prop("id").split("tip-alert-")[1]; +// $(`#alert-text-${id}`).text(text); +// } +// return th; +//} + diff --git a/Frontend/js/yourteam/yourteam.ajax.class.js b/Frontend/js/yourteam/yourteam.ajax.class.js index 215fef6..9f17d06 100644 --- a/Frontend/js/yourteam/yourteam.ajax.class.js +++ b/Frontend/js/yourteam/yourteam.ajax.class.js @@ -58,7 +58,8 @@ class Ajax { */ successFunction = function (data,callback) { if (data && data.unauthorized == 401) { - location.href = "login.html"; + localStorage.removeItem("JWT-Authorization"); + location.href = "/login"; } if (callback) { callback(data); @@ -79,6 +80,7 @@ class Ajax { window.alert("執行失敗,請聯絡客服人員。"); } else if (xhr.status == "401") { window.alert("登入時間超時,請重新登入!"); + localStorage.removeItem("JWT-Authorization"); location.href = "~/Login/Login"; } } From eba516ca9885843a34d2ea87013489886621be24 Mon Sep 17 00:00:00 2001 From: dev01 Date: Fri, 2 Dec 2022 16:25:57 +0800 Subject: [PATCH 10/12] =?UTF-8?q?[Frontend][=E6=AD=B7=E5=8F=B2=E8=B3=87?= =?UTF-8?q?=E6=96=99]=20=E8=A8=82=E9=96=B1=20Loading=20=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E8=A3=9C=E4=B8=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_historyData.html | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Frontend/_historyData.html b/Frontend/_historyData.html index a2543c1..f89f042 100644 --- a/Frontend/_historyData.html +++ b/Frontend/_historyData.html @@ -198,6 +198,7 @@ if (index == 0) { strHtml += ``; pageAct.deviceItem = val.points; + pageAct.devicePoiName = val.full_name + ' ' + val.points; getData(); } else { strHtml += ``; @@ -231,7 +232,8 @@ t.fnClearTable(); if (res.data.length > 0) t.fnAddData(res.data); - } + } + $(loadEle).Loading("close"); } function setValue(deviceNumber, deviceName, deviceItem, elem) { @@ -242,7 +244,8 @@ pageAct.deviceName = deviceName; devPointsList(); } - else if (deviceItem != null && deviceItem != undefined) { + else if (deviceItem != null && deviceItem != undefined) { + pageAct.devicePoiName = $(elem).text(); pageAct.deviceItem = deviceItem; getData(); } @@ -330,7 +333,7 @@ function loadTable(data) { if (data) { $.each(data, function (i, v) { - v.type = deviceName; + v.type = pageAct.devicePoiName; }); } From 6a9ea02e234fd891e4bea6084706d27e70e2ce79 Mon Sep 17 00:00:00 2001 From: dev01 Date: Fri, 2 Dec 2022 18:53:00 +0800 Subject: [PATCH 11/12] =?UTF-8?q?[Frontend]=20=E9=96=8B=E7=99=BC=E6=A9=9F?= =?UTF-8?q?=20=E7=99=BB=E5=85=A5=20401=20=E8=BD=89=20login.html=20|=20[?= =?UTF-8?q?=E5=84=80=E9=8C=B6=E6=9D=BF]=20=E5=8B=95=E6=85=8B=E7=B3=BB?= =?UTF-8?q?=E7=B5=B1=E5=B0=8F=E9=A1=9E=E6=8C=89=E9=88=95=E5=BB=BA=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_dashboard.html | 95 +++++++++------------ Frontend/index.html | 5 +- Frontend/js/yourteam/yourteam.ajax.class.js | 7 +- 3 files changed, 50 insertions(+), 57 deletions(-) diff --git a/Frontend/_dashboard.html b/Frontend/_dashboard.html index 6ef899b..d0b67d7 100644 --- a/Frontend/_dashboard.html +++ b/Frontend/_dashboard.html @@ -146,62 +146,12 @@
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
+
+
+
+
@@ -340,7 +290,8 @@ ]; $(document).ready(function () { - + getSubList(); + /* init datatables */ $('#dt-basic-example').dataTable( { @@ -725,4 +676,38 @@ $("#js-page-content").load("_sysMonAll.html", loadCallback); } + function getSubList() { + let url = baseApiUrl + "/api/Device/GetMainSub"; + let sendData = { + building_tag: pageAct.buiTag, + }; + objSendData.Data = sendData; + ytAjax = new YourTeam.Ajax(url, objSendData, function (res) { + if (!res || res.code != "0000" || !res.data) { + + } else { + let strHtml = ``; + $.each(res.data.history_Main_Systems, (index, mainSysObj) => { + $.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => { + strHtml += `
+ + +
`; + }) + }) + $("#sysSubBtnList").html(strHtml); + getAlarmSub(); + } + }, null, "POST").send(); + } + + function getAlarmSub() { + $(".dev-group").each((idx, ele) => { + let path = $(ele).data("id"); + getOneSystemStateByBaja(path, (data) => { + console.log(data) + }) + }) + + } \ No newline at end of file diff --git a/Frontend/index.html b/Frontend/index.html index ebed679..d8da4e7 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -2559,7 +2559,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li /*$('#js-page-content').smartPanel();*/ var jwt = localStorage.getItem("JWT-Authorization"); var pageAct = {}; //記錄全頁面已選擇項目 - + pageAct.AreaTag = "TPE"; if (location.href.indexOf("ord") != -1) { location.href = "/file/index.html" } @@ -2615,6 +2615,9 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li function loadedJsPack() { loadEvent(); if (!jwt) { + if (location.href.indexOf("localhost:5966") != -1) { + location.href = "login.html"; + } myBaja = new MyBaja(); myBaja.setMyUserAccount(Login); } else { diff --git a/Frontend/js/yourteam/yourteam.ajax.class.js b/Frontend/js/yourteam/yourteam.ajax.class.js index 9f17d06..5c115bf 100644 --- a/Frontend/js/yourteam/yourteam.ajax.class.js +++ b/Frontend/js/yourteam/yourteam.ajax.class.js @@ -58,8 +58,13 @@ class Ajax { */ successFunction = function (data,callback) { if (data && data.unauthorized == 401) { + let href = location.href; localStorage.removeItem("JWT-Authorization"); - location.href = "/login"; + if (href.indexOf("localhost:5966") == -1) { + location.href = "/login"; + } else { + location.href = "login.html"; + } } if (callback) { callback(data); From ae17655e86df81c8974f8b8d7b2fec4eab181c4d Mon Sep 17 00:00:00 2001 From: dev01 Date: Fri, 2 Dec 2022 18:59:00 +0800 Subject: [PATCH 12/12] =?UTF-8?q?[Frontend]=20=E5=84=80=E9=8C=B6=E6=9D=BF?= =?UTF-8?q?=20baja=20=E5=8F=96=E5=80=BC=20=E7=A8=8B=E5=BA=8F=E4=B8=B2?= =?UTF-8?q?=E6=8E=A5=20|=20Layout=20=E7=99=BB=E5=87=BA=20=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E5=BB=BA=E7=BD=AE=20|=20=E9=9B=BB=E6=A2=AF=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E6=9B=B4=E6=8F=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/_dashboard.html | 78 +++++- Frontend/_sysElevator.html | 4 +- Frontend/index.html | 527 ++----------------------------------- 3 files changed, 94 insertions(+), 515 deletions(-) diff --git a/Frontend/_dashboard.html b/Frontend/_dashboard.html index d0b67d7..6f97a67 100644 --- a/Frontend/_dashboard.html +++ b/Frontend/_dashboard.html @@ -174,11 +174,15 @@
--> -
+
+ 異常數量
18
+ 賦歸數量
28
-
+
+ 已確認異常
8
+ 未確認異常
6
@@ -204,11 +208,15 @@
--> -
- +
+ 已完成
6
+ + 未完成
8
-
+
+ 未派工
5
+ 派工中
9
@@ -289,9 +297,11 @@ [700, 1] ]; + var tarElePath = ''; + $(document).ready(function () { getSubList(); - + getFirstEletric(); /* init datatables */ $('#dt-basic-example').dataTable( { @@ -689,7 +699,7 @@ let strHtml = ``; $.each(res.data.history_Main_Systems, (index, mainSysObj) => { $.each(mainSysObj.history_Sub_systems, (index2, subSysObj) => { - strHtml += `
+ strHtml += `
`; @@ -697,17 +707,59 @@ }) $("#sysSubBtnList").html(strHtml); getAlarmSub(); + } }, null, "POST").send(); } - function getAlarmSub() { - $(".dev-group").each((idx, ele) => { - let path = $(ele).data("id"); - getOneSystemStateByBaja(path, (data) => { - console.log(data) - }) + function getFirstEletric() { + let url = baseApiUrl + "/api/Device/GetDeviceList"; + let sendData = { + sub_system_tag: "E4", + building_tag: pageAct.buiTag, + }; + objSendData.Data = sendData; + ytAjax = new YourTeam.Ajax(url, objSendData, function (res) { + if (!res || res.code != "0000" || !res.data) { + + } else { + + $.each(res.data, (index, floObj) => { + $.each(floObj.device_list, (index2, devObj) => { + tarElePath = devObj.device_number; + }) + }) + + getElectricBaja(); + } + }, null, "POST").send(); + } + + function getElectricBaja() { + let devPath = tarElePath.split("_").slice(0, 8).join("_"); + + let today = displayDate(new Date, "date").replaceAll("/", "-") + "T00:00:00"; + let tomorrow = displayDate(new Date(new Date(today).getTime() + (24 * 60 * 60 * 1000)), "date").replaceAll("/", "-") + "T00:00:00"; + + getElectricMeterDayDataByBaja(devPath + "_KWH", "Mitsubishi_Sup", today, tomorrow, (data) => { + console.log(data) }) + } + + function getAlarmSub() { + + + //$(".dev-group").each((idx, ele) => { + // let path = $(ele).data("id"); + // let start = (new Date()).getTime(); + // console.log("path enter baja:", path); + // getOneSystemStateByBaja(path, (data) => { + // let end = (new Date()).getTime(); + // console.log("執行時間 :" + (end - start) / 1000 + " 秒","path : " + path, "輸出結果 :"+ data) + + + // }) + //}) } \ No newline at end of file diff --git a/Frontend/_sysElevator.html b/Frontend/_sysElevator.html index 5d206ab..47c96d5 100644 --- a/Frontend/_sysElevator.html +++ b/Frontend/_sysElevator.html @@ -861,7 +861,7 @@ var subSeviceData = []; //每個設備訂閱點位值 var floList = []; //每個樓層 var elevObj = null; //左側 2D 電梯物件 - var viewer3DNodeIds = [233, 228, 223]; + var viewer3DNodeIds = [758, 753, 748]; var elev3DBind = {}; var elev3DOption = {}; var elev3DObj = []; @@ -2395,7 +2395,7 @@ function load3DModel() { - launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDLm53ZA==', (viewer) => { + launchViewer('dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6dGEzaHFzZmZ6cWJub3V4a3BsZGt1a3NldzRzajIxdzUtYmltc19tb2RlbHMvJUUzJTgwJTkwJUU1JThGJUIwJUU1JThDJTk3JUU0JUI4JUFEJUU4JThGJUIxJUU1JUE0JUE3JUU2JUE4JTkzJUUzJTgwJTkxQVJDMjAyMjEyMDEubndk', (viewer) => { $.each(viewer3DNodeIds, function (idx, node) { let options = { element: $("#forgeViewer"), diff --git a/Frontend/index.html b/Frontend/index.html index d8da4e7..7f6ab0b 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -1417,8 +1417,8 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li SmartAdmin WebApp + + -->
@@ -1467,10 +1467,10 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
首頁 + + + +
-->
@@ -1518,11 +1518,6 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
+
+
+ +
@@ -2080,433 +2031,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
- +