Merge branch 'MCUT' of https://gitea.mjm-staging.developers-homelab.net/BIMS/BIMS into MCUT
This commit is contained in:
		
						commit
						9b0ad0fbd6
					
				@ -267,57 +267,7 @@
 | 
			
		||||
  };
 | 
			
		||||
  var contractCapacity = 0;
 | 
			
		||||
 | 
			
		||||
  var sysIconList = [
 | 
			
		||||
    { mainSys: "EE", subSys: "E1", iconClass: "./gif/E1_white.png" },
 | 
			
		||||
    { mainSys: "EE", subSys: "E2", iconClass: "./gif/E2_white.png" },
 | 
			
		||||
    { mainSys: "EE", subSys: "E3", iconClass: "./gif/E3_white.png" },
 | 
			
		||||
    { mainSys: "EE", subSys: "E4", iconClass: "./gif/E4-1_white.png" }, // 電表
 | 
			
		||||
    { mainSys: "LT", subSys: "L1", iconClass: "./gif/L1_white.png" },
 | 
			
		||||
    { mainSys: "LT", subSys: "L2", iconClass: "./gif/L2_white.png" }, // 景觀照明 0131目前沒有
 | 
			
		||||
    { mainSys: "ME", subSys: "M1", iconClass: "./gif/M1_white.png" }, // 儲冰 0131目前沒有
 | 
			
		||||
    { mainSys: "ME", subSys: "M5", iconClass: "./gif/M5-2_white.png" }, // 送排風
 | 
			
		||||
    { mainSys: "ME", subSys: "M8", iconClass: "./gif/M8_white.png" }, // 排油煙0131目前沒有
 | 
			
		||||
    { mainSys: "ME", subSys: "M10", iconClass: "./gif/M10_white.png" },
 | 
			
		||||
    { mainSys: "ME", subSys: "M12", iconClass: "./gif/M12_white.png" },
 | 
			
		||||
    { mainSys: "ELEV", subSys: "EL", iconClass: "./gif/EL_white.png" },
 | 
			
		||||
    { mainSys: "FE", subSys: "F1", iconClass: "./gif/F1_white.png" },
 | 
			
		||||
    { mainSys: "FE", subSys: "F2", iconClass: "./gif/lamp_white.png" }, // 排煙 0131目前沒有
 | 
			
		||||
    { mainSys: "WP", subSys: "W1", iconClass: "./gif/W1_white.png" }, // 電子水表0131目前沒有
 | 
			
		||||
    { mainSys: "WP", subSys: "W2", iconClass: "./gif/W2_white.png" },
 | 
			
		||||
    { mainSys: "WP", subSys: "P1", iconClass: "./gif/P1_white.png" },
 | 
			
		||||
    { mainSys: "S", subSys: "C", iconClass: "./gif/C_white.png" }, // CCTV
 | 
			
		||||
    { mainSys: "S", subSys: "P", iconClass: "./gif/P_white.png" }, // 緊急求救
 | 
			
		||||
    { mainSys: "S", subSys: "R", iconClass: "./gif/R_white.png" }, // 門禁
 | 
			
		||||
    { mainSys: "P", subSys: "PSC", iconClass: "./gif/PSC_white.png" }, // 停管
 | 
			
		||||
    { mainSys: "W3", subSys: "W1", iconClass: "./gif/W3_white.png" }, // 0131目前沒有
 | 
			
		||||
  ];
 | 
			
		||||
  
 | 
			
		||||
  var tempSysSubText = [
 | 
			
		||||
    { text: "水錶系統", mainSys: "WP", subSys: "W1" },
 | 
			
		||||
    { text: "空調系統", mainSys: "ME", subSys: "M10" }, // 2
 | 
			
		||||
    { text: "照明系統", mainSys: "LT", subSys: "L1" }, // 3
 | 
			
		||||
    { text: "CCTV系統", mainSys: "S", subSys: "C" }, //12
 | 
			
		||||
    { text: "太陽能管理", mainSys: "S", subSys: "C" }, //12
 | 
			
		||||
    { text: "冰水主機", mainSys: "WP", subSys: "W2" }, // 6
 | 
			
		||||
    { text: "緊急發電機", mainSys: "EE", subSys: "E3" }, //10
 | 
			
		||||
    { text: "電梯系統", mainSys: "ELEV", subSys: "EL" }, // 1
 | 
			
		||||
    { text: "環境感測設備", mainSys: "ME", subSys: "M12" }, // 4
 | 
			
		||||
    { text: "電錶系統", mainSys: "EE", subSys: "E4" }, // 5
 | 
			
		||||
    { text: "高壓配電盤", mainSys: "EE", subSys: "E1" }, // 7
 | 
			
		||||
    { text: "汙廢水設備", mainSys: "WP", subSys: "P1" }, // 8
 | 
			
		||||
    { text: "低壓配電盤", mainSys: "EE", subSys: "E2" }, //9
 | 
			
		||||
    { text: "消防設備", mainSys: "FE", subSys: "F1" }, //11
 | 
			
		||||
    { text: "門禁系統", mainSys: "S", subSys: "R" }, //13
 | 
			
		||||
    { text: "停管系統", mainSys: "P", subSys: "PSC" }, //14
 | 
			
		||||
    { text: "緊急求救系統", mainSys: "S", subSys: "P" }, //15
 | 
			
		||||
    { text: "送排風系統", mainSys: "ME", subSys: "M5" }, //16
 | 
			
		||||
    //{ text: "景觀照明系統", mainSys: "LT", subSys: "L2", },
 | 
			
		||||
    //{ text: "儲冰系統", mainSys: "ME", subSys: "M1", },
 | 
			
		||||
    // { text: "排油煙設備", mainSys: "ME", subSys: "M8", },
 | 
			
		||||
    //{ text: "排煙系統", mainSys: "FE", subSys: "F2", },
 | 
			
		||||
    //{ text: "電子水錶", mainSys: "WP", subSys: "W1", },
 | 
			
		||||
    // { text: "熱水系統", mainSys: "W3", subSys: "W1", },
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  $(document).ready(function () {
 | 
			
		||||
    $(loadEle).Loading("start");
 | 
			
		||||
 | 
			
		||||
@ -21,7 +21,7 @@
 | 
			
		||||
.yt-navbar::-webkit-scrollbar-thumb:hover {
 | 
			
		||||
  background: #555;
 | 
			
		||||
}
 | 
			
		||||
.yt-left-navbar { position: fixed; left: 0; top: 0; height: 100%; z-index: 10; background-color: rgb(25 25 25 / 95%); width: auto; max-width: 300px; margin-top: 4.125rem; }
 | 
			
		||||
.yt-left-navbar { position: absolute; left: 0; top: 0; height: calc(100% - 4.125rem); z-index: 10; background-color: rgb(25 25 25 / 95%); width: auto; max-width: 300px; margin-top: 4.125rem; }
 | 
			
		||||
.yt-navbar-content ul { padding: 1rem 0rem; list-style-type: none; }
 | 
			
		||||
.yt-navbar-content ul li { position: relative; display: flex; flex-wrap: wrap; flex-direction: column; }
 | 
			
		||||
.yt-navbar-content ul li a { font-size: 0.9rem; padding: 0.75rem 1rem 0.75rem 2rem; position: relative; width: 100%; display:flex; justify-content: space-between;}
 | 
			
		||||
@ -29,14 +29,16 @@
 | 
			
		||||
.yt-navbar-content ul li a:active, .yt-navbar-content ul li a.active { background-color: var(--theme-light); }
 | 
			
		||||
 | 
			
		||||
.yt-navbar ul li a[data-nb-node-type=parent]::after {
 | 
			
		||||
  content: "◀";
 | 
			
		||||
  margin-left:1rem;
 | 
			
		||||
  content: ">";
 | 
			
		||||
  font-family: cursive;
 | 
			
		||||
  font-weight: 700;
 | 
			
		||||
  margin-left:4rem;
 | 
			
		||||
  transform:rotate(0deg);
 | 
			
		||||
  transition:0.2s
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.yt-navbar ul li a[data-nb-node-type=parent][data-nb-node-status=open]::after {
 | 
			
		||||
  transform:rotate(-90deg);
 | 
			
		||||
  transform:rotate(90deg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.yt-navbar-content ul li a[data-nb-node-type=parent] span:hover {
 | 
			
		||||
@ -59,5 +61,5 @@
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.yt-navbar-content ul.yt-navbar-dropdown li a {
 | 
			
		||||
  padding: 0.75rem 0.5rem 0.75rem 2.5rem;
 | 
			
		||||
  padding: 0.75rem 0.5rem 0.75rem 3.5rem;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1029,6 +1029,58 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
 | 
			
		||||
      var allDevices = [];
 | 
			
		||||
      var tempSubTag = ["M10", "M12"]; // 溫度向小類
 | 
			
		||||
 | 
			
		||||
      var sysIconList = [
 | 
			
		||||
    { mainSys: "EE", subSys: "E1", iconClass: "./gif/E1_white.png" },
 | 
			
		||||
    { mainSys: "EE", subSys: "E2", iconClass: "./gif/E2_white.png" },
 | 
			
		||||
    { mainSys: "EE", subSys: "E3", iconClass: "./gif/E3_white.png" },
 | 
			
		||||
    { mainSys: "EE", subSys: "E4", iconClass: "./gif/E4-1_white.png" }, // 電表
 | 
			
		||||
    { mainSys: "LT", subSys: "L1", iconClass: "./gif/L1_white.png" },
 | 
			
		||||
    { mainSys: "LT", subSys: "L2", iconClass: "./gif/L2_white.png" }, // 景觀照明 0131目前沒有
 | 
			
		||||
    { mainSys: "ME", subSys: "M1", iconClass: "./gif/M1_white.png" }, // 儲冰 0131目前沒有
 | 
			
		||||
    { mainSys: "ME", subSys: "M5", iconClass: "./gif/M5-2_white.png" }, // 送排風
 | 
			
		||||
    { mainSys: "ME", subSys: "M8", iconClass: "./gif/M8_white.png" }, // 排油煙0131目前沒有
 | 
			
		||||
    { mainSys: "ME", subSys: "M10", iconClass: "./gif/M10_white.png" },
 | 
			
		||||
    { mainSys: "ME", subSys: "M12", iconClass: "./gif/M12_white.png" },
 | 
			
		||||
    { mainSys: "ELEV", subSys: "EL", iconClass: "./gif/EL_white.png" },
 | 
			
		||||
    { mainSys: "FE", subSys: "F1", iconClass: "./gif/F1_white.png" },
 | 
			
		||||
    { mainSys: "FE", subSys: "F2", iconClass: "./gif/lamp_white.png" }, // 排煙 0131目前沒有
 | 
			
		||||
    { mainSys: "WP", subSys: "W1", iconClass: "./gif/W1_white.png" }, // 電子水表0131目前沒有
 | 
			
		||||
    { mainSys: "WP", subSys: "W2", iconClass: "./gif/W2_white.png" },
 | 
			
		||||
    { mainSys: "WP", subSys: "P1", iconClass: "./gif/P1_white.png" },
 | 
			
		||||
    { mainSys: "S", subSys: "C", iconClass: "./gif/C_white.png" }, // CCTV
 | 
			
		||||
    { mainSys: "S", subSys: "P", iconClass: "./gif/P_white.png" }, // 緊急求救
 | 
			
		||||
    { mainSys: "S", subSys: "R", iconClass: "./gif/R_white.png" }, // 門禁
 | 
			
		||||
    { mainSys: "P", subSys: "PSC", iconClass: "./gif/PSC_white.png" }, // 停管
 | 
			
		||||
    { mainSys: "W3", subSys: "W1", iconClass: "./gif/W3_white.png" }, // 0131目前沒有
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
  var tempSysSubText = [
 | 
			
		||||
    { text: "水錶系統", mainSys: "WP", subSys: "W1" },
 | 
			
		||||
    { text: "空調系統", mainSys: "ME", subSys: "M10" }, // 2
 | 
			
		||||
    { text: "照明系統", mainSys: "LT", subSys: "L1" }, // 3
 | 
			
		||||
    { text: "CCTV系統", mainSys: "S", subSys: "C" }, //12
 | 
			
		||||
    { text: "太陽能管理", mainSys: "S", subSys: "C" }, //12
 | 
			
		||||
    { text: "冰水主機", mainSys: "WP", subSys: "W2" }, // 6
 | 
			
		||||
    { text: "緊急發電機", mainSys: "EE", subSys: "E3" }, //10
 | 
			
		||||
    { text: "電梯系統", mainSys: "ELEV", subSys: "EL" }, // 1
 | 
			
		||||
    { text: "環境感測設備", mainSys: "ME", subSys: "M12" }, // 4
 | 
			
		||||
    { text: "電錶系統", mainSys: "EE", subSys: "E4" }, // 5
 | 
			
		||||
    { text: "高壓配電盤", mainSys: "EE", subSys: "E1" }, // 7
 | 
			
		||||
    { text: "汙廢水設備", mainSys: "WP", subSys: "P1" }, // 8
 | 
			
		||||
    { text: "低壓配電盤", mainSys: "EE", subSys: "E2" }, //9
 | 
			
		||||
    { text: "消防設備", mainSys: "FE", subSys: "F1" }, //11
 | 
			
		||||
    { text: "門禁系統", mainSys: "S", subSys: "R" }, //13
 | 
			
		||||
    { text: "停管系統", mainSys: "P", subSys: "PSC" }, //14
 | 
			
		||||
    { text: "緊急求救系統", mainSys: "S", subSys: "P" }, //15
 | 
			
		||||
    { text: "送排風系統", mainSys: "ME", subSys: "M5" }, //16
 | 
			
		||||
    //{ text: "景觀照明系統", mainSys: "LT", subSys: "L2", },
 | 
			
		||||
    //{ text: "儲冰系統", mainSys: "ME", subSys: "M1", },
 | 
			
		||||
    // { text: "排油煙設備", mainSys: "ME", subSys: "M8", },
 | 
			
		||||
    //{ text: "排煙系統", mainSys: "FE", subSys: "F2", },
 | 
			
		||||
    //{ text: "電子水錶", mainSys: "WP", subSys: "W1", },
 | 
			
		||||
    // { text: "熱水系統", mainSys: "W3", subSys: "W1", },
 | 
			
		||||
  ];
 | 
			
		||||
 | 
			
		||||
      /**
 | 
			
		||||
       * 頁面 Loading 建立
 | 
			
		||||
       * */
 | 
			
		||||
@ -2095,7 +2147,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
 | 
			
		||||
                                                                              <i class="fal fa-home fa-2x"></i><br>首頁
 | 
			
		||||
                                                                          </a>
 | 
			
		||||
                                                                          <div class="dropdown-menu">
 | 
			
		||||
                                                                              <button class="dropdown-item" name="topFunBtn" data-tabname="topFunBtn" data-page="dashboard" type="button">儀錶板</button>
 | 
			
		||||
                                                                              <button class="dropdown-item d-none" name="topFunBtn" data-tabname="topFunBtn" data-page="dashboard" type="button" >儀錶板</button>
 | 
			
		||||
                                                                              <button class="dropdown-item" name="topFunBtn" data-tabname="topFunBtn" data-page="schoolView" type="button">校園總覽</button>
 | 
			
		||||
                                                                              <button class="dropdown-item" name="topFunBtn" data-tabname="topFunBtn" data-page="elecSingleLine" type="button">電表單線圖</button>
 | 
			
		||||
                                                                          </div>
 | 
			
		||||
@ -2215,11 +2267,30 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
 | 
			
		||||
                      }
 | 
			
		||||
                    );
 | 
			
		||||
                  });
 | 
			
		||||
                  const ulLen = ul.find("li").length;
 | 
			
		||||
                  for(let i = 0; i < 8 - ulLen; i++){
 | 
			
		||||
                    let li2 = creEle("li");
 | 
			
		||||
                        let a2 = creA(
 | 
			
		||||
                          tempSysSubText[i].text,
 | 
			
		||||
                          { href: "javascript:;" },
 | 
			
		||||
                          [],
 | 
			
		||||
                          `subSysBtn${tempSysSubText[i].subSys}`,
 | 
			
		||||
                          {
 | 
			
		||||
                            page: "systemMonitor",
 | 
			
		||||
                            tabname: "systemMonitor",
 | 
			
		||||
                            "building-tag": building.building_tag,
 | 
			
		||||
                          },
 | 
			
		||||
                          "topFunBtn"
 | 
			
		||||
                        );
 | 
			
		||||
                        li2.append(a2);
 | 
			
		||||
                        ul.append(li2);
 | 
			
		||||
                  }
 | 
			
		||||
                  
 | 
			
		||||
 | 
			
		||||
                  li.append(ul);
 | 
			
		||||
                  $("#sysMonBtnList").append(li);
 | 
			
		||||
                });
 | 
			
		||||
                $("#sysMonTopBtn").YTNavbar("init");
 | 
			
		||||
                $("#sysMonTopBtn").YTNavbar("init",{onlyOneOpen: true});
 | 
			
		||||
 | 
			
		||||
                $("span[id^=buildTab]").first().YTTab("setAndClick",{triggerType:"first"});
 | 
			
		||||
              }
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,4 @@
 | 
			
		||||
var viewer;
 | 
			
		||||
 | 
			
		||||
let fragProxy;
 | 
			
		||||
let fragProxy;
 | 
			
		||||
var targetFloorZ;
 | 
			
		||||
var elevatorSpeed;
 | 
			
		||||
var selector = "#forgeViewer";
 | 
			
		||||
@ -11,141 +9,6 @@ var levels; //剖面用
 | 
			
		||||
var lowerIdx = 0; //剖面的下方樓層
 | 
			
		||||
var upperIdx = 0; //剖面的上方樓層
 | 
			
		||||
 | 
			
		||||
function launchViewer(urn, callback, failCallback, _selector = "#forgeViewer") {
 | 
			
		||||
    selector = _selector;
 | 
			
		||||
    var options = {
 | 
			
		||||
        env: "AutodeskProduction",
 | 
			
		||||
        getAccessToken: getForgeToken,
 | 
			
		||||
        settings: {
 | 
			
		||||
            ambientShadows: false,
 | 
			
		||||
            groundShadows: false,
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Autodesk.Viewing.Initializer(options, () => {
 | 
			
		||||
        viewer = new Autodesk.Viewing.GuiViewer3D($(selector)[0]);
 | 
			
		||||
        //viewer = new Autodesk.Viewing.Viewer3D(document.getElementById('forgeViewer'));
 | 
			
		||||
        viewer.start();
 | 
			
		||||
        var documentId = "urn:" + urn;
 | 
			
		||||
 | 
			
		||||
        Autodesk.Viewing.Document.load(
 | 
			
		||||
            documentId,
 | 
			
		||||
            onDocumentLoadSuccess,
 | 
			
		||||
            onDocumentLoadFailure
 | 
			
		||||
        );
 | 
			
		||||
        setShadowShow();
 | 
			
		||||
 | 
			
		||||
        $(selector).on("autodesk:loaded", function (e, nodeIds) {
 | 
			
		||||
            callback ? callback(viewer, nodeIds) : "";
 | 
			
		||||
        });
 | 
			
		||||
        $(selector).on("autodesk:loaded:fail", function (e) {
 | 
			
		||||
            failCallback ? failCallback(viewer) : "";
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        //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 launchViewerForHotspot(
 | 
			
		||||
    urn,
 | 
			
		||||
    callback,
 | 
			
		||||
    failCallback,
 | 
			
		||||
    _selector = "#forgeViewer"
 | 
			
		||||
) {
 | 
			
		||||
    selector = _selector;
 | 
			
		||||
    var av = Autodesk.Viewing;
 | 
			
		||||
    var options = {
 | 
			
		||||
        env: "AutodeskProduction",
 | 
			
		||||
        getAccessToken: getForgeToken,
 | 
			
		||||
        settings: {
 | 
			
		||||
            ambientShadows: false,
 | 
			
		||||
            groundShadows: false,
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Autodesk.Viewing.Initializer(options, () => {
 | 
			
		||||
        viewer = new Autodesk.Viewing.GuiViewer3D($(selector)[0]);
 | 
			
		||||
        viewer.start();
 | 
			
		||||
        var documentId = "urn:" + urn;
 | 
			
		||||
 | 
			
		||||
        viewer.addEventListener(av.GEOMETRY_LOADED_EVENT, addHotPoint, {
 | 
			
		||||
            once: true,
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        Autodesk.Viewing.Document.load(
 | 
			
		||||
            documentId,
 | 
			
		||||
            onDocumentLoadSuccess,
 | 
			
		||||
            onDocumentLoadFailure
 | 
			
		||||
        );
 | 
			
		||||
        setShadowShow();
 | 
			
		||||
        $(selector).on("autodesk:loaded", function (e, nodeIds) {
 | 
			
		||||
            callback ? callback(viewer, nodeIds) : "";
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        $(selector).on("autodesk:loaded:fail", function (e) {
 | 
			
		||||
            failCallback ? failCallback(viewer) : "";
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function launchViewerNoTools(
 | 
			
		||||
    urn,
 | 
			
		||||
    callback,
 | 
			
		||||
    failCallback,
 | 
			
		||||
    _selector = "#forgeViewer"
 | 
			
		||||
) {
 | 
			
		||||
    selector = _selector;
 | 
			
		||||
    var options = {
 | 
			
		||||
        env: "AutodeskProduction",
 | 
			
		||||
        getAccessToken: getForgeToken,
 | 
			
		||||
        settings: {
 | 
			
		||||
            ambientShadows: false,
 | 
			
		||||
            groundShadows: false,
 | 
			
		||||
        },
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    Autodesk.Viewing.Initializer(options, () => {
 | 
			
		||||
        //viewer = new Autodesk.Viewing.GuiViewer3D(document.getElementById('forgeViewer'));
 | 
			
		||||
        viewer = new Autodesk.Viewing.Viewer3D($(selector)[0]);
 | 
			
		||||
        viewer.start();
 | 
			
		||||
        var documentId = "urn:" + urn;
 | 
			
		||||
 | 
			
		||||
        Autodesk.Viewing.Document.load(
 | 
			
		||||
            documentId,
 | 
			
		||||
            onDocumentLoadSuccess,
 | 
			
		||||
            onDocumentLoadFailure
 | 
			
		||||
        );
 | 
			
		||||
        setShadowShow();
 | 
			
		||||
        $(selector).on("autodesk:loaded", function (e, nodeIds) {
 | 
			
		||||
            callback ? callback(viewer, nodeIds) : "";
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        $(selector).on("autodesk:loaded:fail", function (e) {
 | 
			
		||||
            failCallback ? failCallback(viewer) : "";
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getAllLeafComponents(viewer, callback) {
 | 
			
		||||
  var cbCount = 0;
 | 
			
		||||
  var tree;
 | 
			
		||||
@ -179,9 +42,9 @@ function getAllLeafComponents(viewer, callback) {
 | 
			
		||||
class elevator3D {
 | 
			
		||||
  constructor(option = {}) {
 | 
			
		||||
    this.ele = option.element;
 | 
			
		||||
        this.viewer = option.viewer;
 | 
			
		||||
    viewer = option.viewer;
 | 
			
		||||
    this.nodeId = option.nodeId;
 | 
			
		||||
        this.speed = option.speed ?? 0.18;
 | 
			
		||||
    this.speed = option.speed ?? 0.07;
 | 
			
		||||
    this.tagValue = option.tagValue ?? "";
 | 
			
		||||
    this.fragProxys = [];
 | 
			
		||||
    this.fragProxy = null;
 | 
			
		||||
@ -199,7 +62,7 @@ class elevator3D {
 | 
			
		||||
      // 定義結果陣列
 | 
			
		||||
      let result = [];
 | 
			
		||||
      // 使用 InstanceTree.enumNodeFragments 遍歷模型中的所有片段
 | 
			
		||||
            this.viewer?.model?.getData().instanceTree.enumNodeFragments(
 | 
			
		||||
      viewer?.model?.getData().instanceTree.enumNodeFragments(
 | 
			
		||||
        nodeId,
 | 
			
		||||
        (fragId) => {
 | 
			
		||||
          // 將遍歷到的片段 ID 添加到結果陣列中
 | 
			
		||||
@ -217,7 +80,7 @@ class elevator3D {
 | 
			
		||||
 | 
			
		||||
  // 設置樹狀結構中片段
 | 
			
		||||
  setTreeFrag = async function (callback) {
 | 
			
		||||
        let tree = this.viewer?.model?.getData().instanceTree;
 | 
			
		||||
    let tree = viewer?.model?.getData().instanceTree;
 | 
			
		||||
    if (!tree) {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
@ -238,10 +101,7 @@ class elevator3D {
 | 
			
		||||
 | 
			
		||||
      fragments.forEach((frag) => {
 | 
			
		||||
        // 取得當前片段的 FragmentProxy 物件
 | 
			
		||||
                let fragProxy = this.viewer.impl.getFragmentProxy(
 | 
			
		||||
                    this.viewer.model,
 | 
			
		||||
                    frag
 | 
			
		||||
                );
 | 
			
		||||
        let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
 | 
			
		||||
        // 將當前片段的信息添加到 fragProxys 陣列中
 | 
			
		||||
        this.fragProxys.push({ nodeId: nodeId, fragId: frag, frag: fragProxy });
 | 
			
		||||
        // 取得當前片段的動畫變換矩陣
 | 
			
		||||
@ -256,7 +116,7 @@ class elevator3D {
 | 
			
		||||
      });
 | 
			
		||||
    }
 | 
			
		||||
    // 通知檢視器更新場景
 | 
			
		||||
        this.viewer.impl.sceneUpdated(true);
 | 
			
		||||
    viewer.impl.sceneUpdated(true);
 | 
			
		||||
 | 
			
		||||
    if (!$(this.ele)[0]) {
 | 
			
		||||
      callback ? callback() : "";
 | 
			
		||||
@ -326,10 +186,7 @@ class elevator3D {
 | 
			
		||||
    let fragments = await this.enumFragments(nodeId);
 | 
			
		||||
 | 
			
		||||
    fragments.forEach((frag) => {
 | 
			
		||||
            let fragProxy = this.viewer.impl.getFragmentProxy(
 | 
			
		||||
                this.viewer.model,
 | 
			
		||||
                frag
 | 
			
		||||
            );
 | 
			
		||||
      let fragProxy = viewer.impl.getFragmentProxy(viewer.model, frag);
 | 
			
		||||
      fragProxy.getAnimTransform();
 | 
			
		||||
 | 
			
		||||
      if (this.movStatus == 2) {
 | 
			
		||||
@ -352,7 +209,7 @@ class elevator3D {
 | 
			
		||||
      fragProxy.updateAnimTransform();
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
        this.viewer.impl.sceneUpdated(true);
 | 
			
		||||
    viewer.impl.sceneUpdated(true);
 | 
			
		||||
 | 
			
		||||
    let movElevator = $(this.ele)[0]
 | 
			
		||||
      ._elevator3D.filter((x) => x.nodeId == this.nodeId)[0]
 | 
			
		||||
@ -386,27 +243,6 @@ class elevator3D {
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function onDocumentLoadSuccess(doc, eleOption) {
 | 
			
		||||
    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 () {
 | 
			
		||||
        let instanceTree = viewer.model?.getData().instanceTree;
 | 
			
		||||
        // console.log(instanceTree.nodeAccess)
 | 
			
		||||
        allDbIdsStr = Object.keys(instanceTree.nodeAccess.dbIdToIndex);
 | 
			
		||||
        /*getNodeIdByDbIds("【電梯】", (nodeIds) => {*/
 | 
			
		||||
        $(selector).trigger("autodesk:loaded");
 | 
			
		||||
        /*});*/
 | 
			
		||||
    });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 輔助函數,使用 Promise 封裝 viewer.getProperties 函數
 | 
			
		||||
function viewerGetProperties(dbIds, attributeName = null) {
 | 
			
		||||
  // 在這裡,我們使用 viewer.getProperties 函數的成功回調函數作為 resolve 函數,
 | 
			
		||||
@ -565,42 +401,6 @@ function getAllDbIds(viewer) {
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Autodesk.Viewing.Document.load() failuire callback.
 | 
			
		||||
 */
 | 
			
		||||
function onDocumentLoadFailure(viewerErrorCode) {
 | 
			
		||||
    $(selector).trigger("autodesk:loaded:fail");
 | 
			
		||||
    console.error("onDocumentLoadFailure() - errorCode:" + viewerErrorCode);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function getForgeToken(callback) {
 | 
			
		||||
    fetch(forgeTokenBase.url).then((res) => {
 | 
			
		||||
        res.json().then((data) => {
 | 
			
		||||
            let limitResType = ["object", "undefined"];
 | 
			
		||||
            let access_token = data;
 | 
			
		||||
            $.each(forgeTokenBase.res_access_token, (idx, dict) => {
 | 
			
		||||
                access_token = access_token[dict];
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            let expires_in = data;
 | 
			
		||||
            $.each(forgeTokenBase.res_expires_in, (idx, dict) => {
 | 
			
		||||
                expires_in = expires_in[dict];
 | 
			
		||||
            });
 | 
			
		||||
 | 
			
		||||
            if (
 | 
			
		||||
                limitResType.includes(typeof access_token) ||
 | 
			
		||||
                limitResType.includes(typeof expires_in)
 | 
			
		||||
            ) {
 | 
			
		||||
                (access_token = ""), (expires_in = "");
 | 
			
		||||
                throw "access_token or expires_in on the ForgeTokenBase object for getting forge token by URL is not the correct path.";
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            callback(access_token, expires_in);
 | 
			
		||||
        });
 | 
			
		||||
    });
 | 
			
		||||
    //callback("eyJhbGciOiJSUzI1NiIsImtpZCI6IlU3c0dGRldUTzlBekNhSzBqZURRM2dQZXBURVdWN2VhIn0.eyJzY29wZSI6WyJkYXRhOndyaXRlIiwiZGF0YTpyZWFkIiwiYnVja2V0OnJlYWQiLCJidWNrZXQ6dXBkYXRlIiwiYnVja2V0OmNyZWF0ZSJdLCJjbGllbnRfaWQiOiJUQTNocXNGZnpRYk5PVVhLcGxkS1VLU2V3NFNKMjF3NSIsImF1ZCI6Imh0dHBzOi8vYXV0b2Rlc2suY29tL2F1ZC9hand0ZXhwNjAiLCJqdGkiOiJiemxzWE5qWElvZ2R1UjUzTUJkdlhrTTNTT01qeVB1bHJrMmdTVWJudGNTeDg1b01kRG1xejg3Z05jenJkRzhpIiwiZXhwIjoxNjY4MTgzMDM2fQ.VU3qLwTJ9nlXnomKCdk4y5UcgszGEO_zlvE7w5mWWajeBMwKLo-zw7LJEqUEajRksvssppR9SbVsjLSx-vDVc3DRhCo3jYTWKPT1T3wQrlkOSqLeIrAdnKdBDNBWKgrGJt_xcmXc3dZ3XNKf9L_F6Ex808rUlo6cem1mcPpKl1jCBDqKu1mAX7aDtZ65TTQZbGGhbG4HdnET-d1i5w4LunGN11UAHhDUW3n0SWWIBL27PiiUQONZttajhD5st6IngYLcjr93BYVyJmDF7-wm4WZlHSw2OnXIfbJcFXEd83uVv_Rej4UXjzZ0e6kHwzc2nvGvKSIFu3Nt7CabdR8CkA", 3599);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//------------------ 熱圖 -------------------------------
 | 
			
		||||
class ADHeatMaps {
 | 
			
		||||
  constructor(option = {}) {
 | 
			
		||||
@ -616,17 +416,16 @@ class ADHeatMaps {
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  init = async function () {
 | 
			
		||||
        // 載入 Autodesk Viewer 的資料視覺化擴充功能
 | 
			
		||||
        const dataVizExtn = await viewer.loadExtension(
 | 
			
		||||
            "Autodesk.DataVisualization"
 | 
			
		||||
        );
 | 
			
		||||
        this.dataVizExtn = dataVizExtn;
 | 
			
		||||
    // 儲存 Viewer 的模型
 | 
			
		||||
    this.model = viewer.model;
 | 
			
		||||
    this.addHeatMaps();
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  async addHeatMaps() {
 | 
			
		||||
    // 載入 Autodesk Viewer 的資料視覺化擴充功能
 | 
			
		||||
    const dataVizExtn = await viewer.loadExtension(
 | 
			
		||||
      "Autodesk.DataVisualization"
 | 
			
		||||
    );
 | 
			
		||||
    const {
 | 
			
		||||
      SurfaceShadingData,
 | 
			
		||||
      SurfaceShadingPoint,
 | 
			
		||||
@ -637,8 +436,8 @@ class ADHeatMaps {
 | 
			
		||||
    const shadingGroup = new SurfaceShadingGroup("iot-heatmap");
 | 
			
		||||
    const rooms = new Map();
 | 
			
		||||
 | 
			
		||||
        console.log(this.devices);
 | 
			
		||||
        for (const { id, roomDbId, position, sensorTypes } of this.devices) {
 | 
			
		||||
    for (const { id, roomDbId, forge_dbid, position, sensorTypes } of this
 | 
			
		||||
      .devices) {
 | 
			
		||||
      if (!id || roomDbId == -1) {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
@ -648,106 +447,71 @@ class ADHeatMaps {
 | 
			
		||||
        shadingGroup.addChild(room);
 | 
			
		||||
        rooms.set(roomDbId, room);
 | 
			
		||||
      }
 | 
			
		||||
            const room = rooms.get(roomDbId);
 | 
			
		||||
      let room = rooms.get(roomDbId);
 | 
			
		||||
      room.addPoint(new SurfaceShadingPoint(id, position, sensorTypes));
 | 
			
		||||
    }
 | 
			
		||||
        this.shadingData = new SurfaceShadingData();
 | 
			
		||||
        this.shadingData.addChild(shadingGroup);
 | 
			
		||||
        this.shadingData.initialize(this.model);
 | 
			
		||||
 | 
			
		||||
    const shadingData = new SurfaceShadingData();
 | 
			
		||||
    shadingData.addChild(shadingGroup);
 | 
			
		||||
 | 
			
		||||
    shadingData.initialize(this.model);
 | 
			
		||||
    this.shadingData = shadingData;
 | 
			
		||||
 | 
			
		||||
    if (pageAct.sysSubTag == "L1") {
 | 
			
		||||
            await this.dataVizExtn.setupSurfaceShading(this.model, this.shadingData, {
 | 
			
		||||
      await dataVizExtn.setupSurfaceShading(this.model, shadingData, {
 | 
			
		||||
        type: "PlanarHeatmap",
 | 
			
		||||
        placementPosition: 0.7,
 | 
			
		||||
        confidence: 240.0,
 | 
			
		||||
      });
 | 
			
		||||
            this.dataVizExtn.registerSurfaceShadingColors(
 | 
			
		||||
      dataVizExtn.registerSurfaceShadingColors(
 | 
			
		||||
        "temperature",
 | 
			
		||||
                [0x000000, 0xffd524]
 | 
			
		||||
        // [0x000000, 0xffd524]
 | 
			
		||||
        [0xff0000, 0x0000ff]
 | 
			
		||||
      );
 | 
			
		||||
    } else {
 | 
			
		||||
            await this.dataVizExtn.setupSurfaceShading(this.model, this.shadingData);
 | 
			
		||||
            this.dataVizExtn.registerSurfaceShadingColors(
 | 
			
		||||
      await dataVizExtn.setupSurfaceShading(this.model, shadingData);
 | 
			
		||||
      dataVizExtn.registerSurfaceShadingColors(
 | 
			
		||||
        "temperature",
 | 
			
		||||
        [0x0000ff, 0x00ff00, 0xffff00, 0xff0000]
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
        this.dataVizExtn.renderSurfaceShading(
 | 
			
		||||
    dataVizExtn.renderSurfaceShading(
 | 
			
		||||
      "iot-heatmap",
 | 
			
		||||
      "temperature",
 | 
			
		||||
      this.getSensorValue.bind(this)
 | 
			
		||||
    );
 | 
			
		||||
 | 
			
		||||
        //let nodeIds = await getNodeIdByDbIds(this.checkNodeString);
 | 
			
		||||
        //nodeIds = Array.from(nodeIds);
 | 
			
		||||
        //nodeIds = nodeIds.map(x => { return { room: x[0] , nodeId: x[1]} });
 | 
			
		||||
        // this.roomDbIds = this.devices.filter(x => x.roomDbId != -1).map(x => x.roomDbId).Distinct();
 | 
			
		||||
 | 
			
		||||
        // // 建立一個 SurfaceShadingData 物件,並將 SurfaceShadingNode 加入到該物件中
 | 
			
		||||
        // const heatmapData = new SurfaceShadingData();
 | 
			
		||||
 | 
			
		||||
        // $.each(this.roomDbIds, (idx, rDbid) => {
 | 
			
		||||
        //     // 建立一個名為 "Room Panel" 的 SurfaceShadingNode 物件,並將房間的模型給傳入,只在該房間呈現溫度
 | 
			
		||||
        //     const shadingNode = new SurfaceShadingNode("RoomPanel" + rDbid, rDbid);
 | 
			
		||||
 | 
			
		||||
        //     // 遍歷每個設備,建立一個 SurfaceShadingPoint 物件並加入到 SurfaceShadingNode 中,透過這些設備渲染溫度
 | 
			
		||||
        //     this.devices.filter(x => x.roomDbId == rDbid).forEach((device) => {
 | 
			
		||||
        //         const shadingPoint = new SurfaceShadingPoint(
 | 
			
		||||
        //             device.id,
 | 
			
		||||
        //             undefined,
 | 
			
		||||
        //             device.sensorTypes
 | 
			
		||||
        //         );
 | 
			
		||||
        //         shadingPoint.positionFromDBId(this.model, device.roomDbId)
 | 
			
		||||
        //         shadingNode.addPoint(shadingPoint);
 | 
			
		||||
        //         // device.temp = 0;
 | 
			
		||||
        //     });
 | 
			
		||||
 | 
			
		||||
        //     heatmapData.addChild(shadingNode);
 | 
			
		||||
        // })
 | 
			
		||||
 | 
			
		||||
        // // 將資料初始化並顯示在模型上
 | 
			
		||||
        // heatmapData.initialize(this.model);
 | 
			
		||||
 | 
			
		||||
        // // 對模型做表面顏色的渲染
 | 
			
		||||
        // await this.dataVizExtn.setupSurfaceShading(this.model, heatmapData);
 | 
			
		||||
 | 
			
		||||
        // // 對 "temperature" 的溫度設定兩種顏色:紅色和藍色
 | 
			
		||||
        // this.dataVizExtn.registerSurfaceShadingColors("temperature", [0x0000ff, 0x00ff00, 0xffff00, 0xff0000]);
 | 
			
		||||
 | 
			
		||||
        // $.each(this.roomDbIds, (idx, rDbid) => {
 | 
			
		||||
        //     this.dataVizExtn.renderSurfaceShading("RoomPanel" + rDbid, "temperature", this.getSensorValue.bind(this));
 | 
			
		||||
        // })
 | 
			
		||||
 | 
			
		||||
        //   /*this.changeTemp(this.tempVal);*/
 | 
			
		||||
    this.onComplete ? this.onComplete() : "";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getSensorValue = function (device, sensorType) {
 | 
			
		||||
    let dev = this.devices.filter((x) => x.id == device.id)[0];
 | 
			
		||||
        // shadingPoint.positionFromDBId(this.model, device.roomDbId)
 | 
			
		||||
        return dev.temp / 40;
 | 
			
		||||
    return dev._temp / 40;
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  // 改變溫度
 | 
			
		||||
  changeTemp = async function (devId, temp) {
 | 
			
		||||
    const dataVizExtn = await viewer.loadExtension(
 | 
			
		||||
      "Autodesk.DataVisualization"
 | 
			
		||||
    );
 | 
			
		||||
    //   console.log("changeTemp",devId, temp)
 | 
			
		||||
    this.tempVal = temp;
 | 
			
		||||
    // 透過 device id 取得 roomDbId
 | 
			
		||||
    this.devices.forEach((dev) => {
 | 
			
		||||
      if (devId == dev.id) {
 | 
			
		||||
                dev.temp = temp;
 | 
			
		||||
        dev._temp = temp;
 | 
			
		||||
      }
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    if (!this.shadingData) {
 | 
			
		||||
      await this.addHeatMaps();
 | 
			
		||||
            this.dataVizExtn.renderSurfaceShading(
 | 
			
		||||
      dataVizExtn.renderSurfaceShading(
 | 
			
		||||
        "iot-heatmap",
 | 
			
		||||
        "temperature",
 | 
			
		||||
        this.getSensorValue.bind(this)
 | 
			
		||||
      );
 | 
			
		||||
    } else {
 | 
			
		||||
            this.dataVizExtn.updateSurfaceShading(this.getSensorValue.bind(this));
 | 
			
		||||
      dataVizExtn.updateSurfaceShading(this.getSensorValue.bind(this));
 | 
			
		||||
    }
 | 
			
		||||
    // $.each(this.roomDbIds, async (idx, rDbid) => {
 | 
			
		||||
    //     this.dataVizExtn.renderSurfaceShading("RoomPanel" + rDbid, "temperature", this.getSensorValue.bind(this));
 | 
			
		||||
@ -762,6 +526,22 @@ class ADHeatMaps {
 | 
			
		||||
    //    this.dataVizExtn.renderSurfaceShading("RoomPanel" + rDbid, "temperature", getSensorValue);
 | 
			
		||||
    //}
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  // 改變設備顏色
 | 
			
		||||
  changeErrorDevice() {
 | 
			
		||||
    const ErrorDeviceList = new ErrorDevice({
 | 
			
		||||
      errorDevices: alarmDbIdList.map((d) => ({
 | 
			
		||||
        ...d,
 | 
			
		||||
        roomDbId: !isNaN(parseInt(x.room_dbid)) ? parseInt(x.room_dbid) : -1,
 | 
			
		||||
        id: d.device_number,
 | 
			
		||||
        position: isJSON(d.device_coordinate_3d)
 | 
			
		||||
          ? JSON.parse(d.device_coordinate_3d)
 | 
			
		||||
          : {}, // x: 0, y: 25, z: -2.5      (3.35, -4.81, 12.88
 | 
			
		||||
        sensorTypes: ["error", "temperature", "humidity", "CO2"],
 | 
			
		||||
        forge_dbid: parseInt(d.forge_dbid),
 | 
			
		||||
      })),
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//全部物件 透明度: 輸入0:透明;輸入1:不透明
 | 
			
		||||
@ -868,71 +648,30 @@ async function getLightData(data) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
async function testNewLight(dataList) {
 | 
			
		||||
    dataList.forEach((myData, index) => {
 | 
			
		||||
        const position = myData.position;
 | 
			
		||||
        if (lightList.findIndex((x) => x.device_guid == myData.device_guid) == -1) {
 | 
			
		||||
            lightList.push({
 | 
			
		||||
                dbid: myData.forge_dbid,
 | 
			
		||||
                device_guid: myData.device_guid,
 | 
			
		||||
                lightObject: new THREE.SpotLight(0xe1cf18, 10, 200, 1, 1, 2),
 | 
			
		||||
            });
 | 
			
		||||
        } else if (
 | 
			
		||||
            lightList.findIndex((x) => x.device_guid == myData.device_node_guid) == -1
 | 
			
		||||
        ) {
 | 
			
		||||
            lightList.push({
 | 
			
		||||
                dbid: myData.forge_dbid,
 | 
			
		||||
                device_guid: myData.device_node_guid,
 | 
			
		||||
                lightObject: new THREE.SpotLight(0xe1cf18, 10, 200, 1, 1, 2),
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
        if (position && position.x && position.y && position.z) {
 | 
			
		||||
            lightList[index].lightObject.position.set(
 | 
			
		||||
                position.x,
 | 
			
		||||
                position.y,
 | 
			
		||||
                position.z
 | 
			
		||||
            );
 | 
			
		||||
            lightList[index].lightObject.castShadow = true;
 | 
			
		||||
            lightList[index].lightObject.visible = true;
 | 
			
		||||
            lightList[index].lightObject.target.position.set(
 | 
			
		||||
                position.x,
 | 
			
		||||
                position.y,
 | 
			
		||||
                position.z - 100
 | 
			
		||||
            );
 | 
			
		||||
            viewer.scene.add(lightList[index].lightObject.target);
 | 
			
		||||
            viewer.scene.add(lightList[index].lightObject);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //let spotLightHelper = new THREE.SpotLightHelper(lightList[index].lightObject);
 | 
			
		||||
        //viewer.scene.add(spotLightHelper);
 | 
			
		||||
    });
 | 
			
		||||
    viewer.impl.sceneUpdated(true);
 | 
			
		||||
  // changeColorForHotspot;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//------------------- 加入熱點 -----------------
 | 
			
		||||
async function addHotPoint(data) {
 | 
			
		||||
  // console.log("addHotPoint", data)
 | 
			
		||||
  if (!pageAct.sysSubTag && !pageAct.sysMainTag) {
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
  var viewer = data.target ? data.target : data;
 | 
			
		||||
  const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
 | 
			
		||||
  const DataVizCore = Autodesk.DataVisualization.Core;
 | 
			
		||||
  const viewableType = Autodesk.DataVisualization.Core.ViewableType.SPRITE; //DataVizCore.ViewableType.SPRITE;
 | 
			
		||||
  let spriteColor = null;
 | 
			
		||||
    let spriteIcon = "";
 | 
			
		||||
  let url = "";
 | 
			
		||||
  const dbIdStart = 10;
 | 
			
		||||
  const dbIdEnd = 19;
 | 
			
		||||
    if (pageAct.sysSubTag === "M12") {
 | 
			
		||||
        return;
 | 
			
		||||
    } else {
 | 
			
		||||
  spriteColor = new THREE.Color(0xffffff);
 | 
			
		||||
        spriteIcon = "/file/img/forge/hotspot.svg";
 | 
			
		||||
  url = "/file/img/forge/sensor_circle.svg";
 | 
			
		||||
  if (location.href.indexOf("localhost:5966") != -1) {
 | 
			
		||||
            spriteIcon = "/img/forge/hotspot.svg";
 | 
			
		||||
        }
 | 
			
		||||
    url = "/img/forge/sensor_circle.svg";
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
    const style = new DataVizCore.ViewableStyle(
 | 
			
		||||
        viewableType,
 | 
			
		||||
        spriteColor,
 | 
			
		||||
        spriteIcon
 | 
			
		||||
    );
 | 
			
		||||
  const style = new DataVizCore.ViewableStyle(viewableType, spriteColor, url);
 | 
			
		||||
 | 
			
		||||
  if (
 | 
			
		||||
    lightDataList != undefined &&
 | 
			
		||||
@ -972,13 +711,18 @@ async function addHotPoint(data) {
 | 
			
		||||
        //event.dbId > 0 && event.dbId < 19
 | 
			
		||||
        // console.log(`Sprite clicked: ${event.dbId}`);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
        for (let i = dbIdStart; i <= myDataList.length + 10; i++) {
 | 
			
		||||
                    !alarmDbIdList.some((dbId) => dbId == i) &&
 | 
			
		||||
          !alarmDbIdList.some(({ spriteDbid }) => spriteDbid == i) &&
 | 
			
		||||
            pageAct.sysSubTag !== "L1" &&
 | 
			
		||||
            changeColorForHotspot(i);
 | 
			
		||||
          changeScaleForHotspot(i, true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        let myData = myDataList.filter((x) => x._dbId == event.dbId)[0];
 | 
			
		||||
        if (myData && pageAct.sysSubTag == "L1" && pageAct.floTag == null) {
 | 
			
		||||
          getLTNode(myData);
 | 
			
		||||
        }
 | 
			
		||||
        if (
 | 
			
		||||
          lightList != undefined &&
 | 
			
		||||
          lightList != null &&
 | 
			
		||||
@ -990,7 +734,7 @@ async function addHotPoint(data) {
 | 
			
		||||
        }
 | 
			
		||||
        $(selector).trigger("autodesk:click:sprite", { event, myData });
 | 
			
		||||
      } else {
 | 
			
		||||
                !alarmDbIdList.some((dbId) => dbId == i) &&
 | 
			
		||||
        !alarmDbIdList.some(({ spriteDbid }) => spriteDbid == event.dbId) &&
 | 
			
		||||
          pageAct.sysSubTag !== "L1" &&
 | 
			
		||||
          changeColorForHotspot(event.dbId, null);
 | 
			
		||||
        changeScaleForHotspot(event.dbId, false);
 | 
			
		||||
@ -1038,36 +782,73 @@ async function addHotPoint(data) {
 | 
			
		||||
  //}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//hex -> rgb
 | 
			
		||||
function hexToRgb(hex) {
 | 
			
		||||
  return (
 | 
			
		||||
    "rgb(" +
 | 
			
		||||
    parseInt("0x" + hex.slice(1, 3)) +
 | 
			
		||||
    "," +
 | 
			
		||||
    parseInt("0x" + hex.slice(3, 5)) +
 | 
			
		||||
    "," +
 | 
			
		||||
    parseInt("0x" + hex.slice(5, 7)) +
 | 
			
		||||
    ")"
 | 
			
		||||
  );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 熱點 更換顏色
 | 
			
		||||
async function changeColorForHotspot(dbId, type = null, lightOn = false) {
 | 
			
		||||
async function changeColorForHotspot(dbId, type = null, OnOff = false) {
 | 
			
		||||
  const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
 | 
			
		||||
  let spriteColorFocus = new THREE.Color(0xffffff);
 | 
			
		||||
    if (pageAct.sysSubTag == "L1") {
 | 
			
		||||
        spriteColorFocus = lightOn
 | 
			
		||||
            ? new THREE.Color(0xffd524)
 | 
			
		||||
            : new THREE.Color(0x40525e);
 | 
			
		||||
        if (lightOn) {
 | 
			
		||||
            console.log(dbId);
 | 
			
		||||
        }
 | 
			
		||||
    } else if (type == "focus" && pageAct.sysSubTag !== "M12") {
 | 
			
		||||
 | 
			
		||||
  spriteColorFocus = OnOff
 | 
			
		||||
    ? pageAct.sysSubObj.device_normal_color
 | 
			
		||||
      ? new THREE.Color(hexToRgb(pageAct.sysSubObj.device_normal_color))
 | 
			
		||||
      : new THREE.Color(0xffffff)
 | 
			
		||||
    : pageAct.sysSubObj.device_close_color
 | 
			
		||||
      ? new THREE.Color(hexToRgb(pageAct.sysSubObj.device_close_color))
 | 
			
		||||
      : new THREE.Color(0xffffff);
 | 
			
		||||
 | 
			
		||||
  if (type == "focus") {
 | 
			
		||||
    spriteColorFocus = new THREE.Color(0x00ffe1);
 | 
			
		||||
  } else if (type == "error") {
 | 
			
		||||
        spriteColorFocus = new THREE.Color(0xff0000);
 | 
			
		||||
    spriteColorFocus = new THREE.Color(
 | 
			
		||||
      hexToRgb(pageAct.sysSubObj.device_error_color)
 | 
			
		||||
    );
 | 
			
		||||
    spriteErrIcon = baseForgeApiUrl + "/file/img/forge/sensor_circle.svg";
 | 
			
		||||
    if (location.href.indexOf("localhost:5966") != -1) {
 | 
			
		||||
      spriteErrIcon = baseForgeApiUrl + "/img/forge/sensor_circle.svg";
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  const viewablesToUpdate = dbId;
 | 
			
		||||
  dataVizExtn.invalidateViewables(viewablesToUpdate, (viewable) => {
 | 
			
		||||
    return {
 | 
			
		||||
      url: "/file/img/forge/sensor_circle.svg",
 | 
			
		||||
      color: spriteColorFocus,
 | 
			
		||||
    };
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 更換 icon
 | 
			
		||||
async function changeScaleForHotspot(dbId, type = true) {
 | 
			
		||||
  const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
 | 
			
		||||
  let spriteErrIcon = baseForgeApiUrl + "/file/img/forge/sensor_circle.svg";
 | 
			
		||||
  if (location.href.indexOf("localhost:5966") != -1) {
 | 
			
		||||
    spriteErrIcon = baseForgeApiUrl + "/img/forge/hotspot.svg";
 | 
			
		||||
  }
 | 
			
		||||
  const viewablesToUpdate = dbId;
 | 
			
		||||
  dataVizExtn.invalidateViewables(viewablesToUpdate, (viewable) => {
 | 
			
		||||
    return {
 | 
			
		||||
      url: spriteErrIcon,
 | 
			
		||||
    };
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 熱點 更換大小
 | 
			
		||||
async function changeScaleForHotspot(dbId, type = true) {
 | 
			
		||||
  const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
 | 
			
		||||
  let scale = 1;
 | 
			
		||||
  if (type) {
 | 
			
		||||
        scale = 1.2;
 | 
			
		||||
    scale = 1.5;
 | 
			
		||||
  }
 | 
			
		||||
  const viewablesToUpdate = dbId;
 | 
			
		||||
  dataVizExtn.invalidateViewables(viewablesToUpdate, (viewable) => {
 | 
			
		||||
@ -1277,7 +1058,7 @@ function findLevels(model) {
 | 
			
		||||
 | 
			
		||||
async function getRemoteLevels() {
 | 
			
		||||
  let aecData = await Autodesk.Viewing.Document.getAecModelData(
 | 
			
		||||
        this.viewer.model.getDocumentNode()
 | 
			
		||||
    viewer.model.getDocumentNode()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  let levels;
 | 
			
		||||
@ -1297,7 +1078,7 @@ async function getLevelsData(lowerFloor, upperFloor, callback = null) {
 | 
			
		||||
  // 樓層正規化 取得樓層
 | 
			
		||||
  const floorRegex = /[\d|\w]+F/gim;
 | 
			
		||||
  const floorRegex2 = /^FL[\d|\w]+/gim;
 | 
			
		||||
    const data = await this.getRemoteLevels();
 | 
			
		||||
  const data = await getRemoteLevels();
 | 
			
		||||
  for (var i = 0; i < data.length; i++) {
 | 
			
		||||
    let name =
 | 
			
		||||
      data[i].name?.match(floorRegex) || data[i].name?.match(floorRegex2);
 | 
			
		||||
@ -1328,7 +1109,7 @@ function getCutPlaneParam(idx, n) {
 | 
			
		||||
  const level = this.levels[idx];
 | 
			
		||||
  if (!level) return;
 | 
			
		||||
 | 
			
		||||
    const model = this.viewer.model;
 | 
			
		||||
  const model = viewer.model;
 | 
			
		||||
  const globalOffset = model.getData().globalOffset;
 | 
			
		||||
  const units = model.getUnitString();
 | 
			
		||||
  const elevRaw = Autodesk.Viewing.Private.convertUnits(
 | 
			
		||||
@ -1348,7 +1129,7 @@ function profile(callback = null) {
 | 
			
		||||
  const upperCutPlaneParam = this.getCutPlaneParam(upperIdx, 1);
 | 
			
		||||
  //const lowerIdx = 7;
 | 
			
		||||
  const lowerCutPlaneParam = this.getCutPlaneParam(lowerIdx, -1);
 | 
			
		||||
    this.viewer.setCutPlanes([upperCutPlaneParam, lowerCutPlaneParam]);
 | 
			
		||||
  viewer.setCutPlanes([upperCutPlaneParam, lowerCutPlaneParam]);
 | 
			
		||||
  callback ? callback() : "";
 | 
			
		||||
}
 | 
			
		||||
//----------------- end -----------------------------------------------
 | 
			
		||||
@ -1375,8 +1156,8 @@ async function newLight(lightPosition) {
 | 
			
		||||
//調整燈光 強度、顏色
 | 
			
		||||
async function setLightValues(deviceGuid, intensity, color) {
 | 
			
		||||
  const light = lightList.find(({ device_guid }) => device_guid === deviceGuid);
 | 
			
		||||
 | 
			
		||||
  if (light) {
 | 
			
		||||
        console.log(light, intensity, color);
 | 
			
		||||
    light.lightObject.intensity = intensity;
 | 
			
		||||
    var tempcolor = new THREE.Color().setHex(color);
 | 
			
		||||
    light.lightObject.color = tempcolor;
 | 
			
		||||
@ -1439,6 +1220,16 @@ function showHeat(selector) {
 | 
			
		||||
  createHeatmapRect(labels, colorStops, selector);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function showHeatCO2(selector) {
 | 
			
		||||
  const labels = [
 | 
			
		||||
    `${(400).toFixed(2)}`,
 | 
			
		||||
    `${(1600 / 2 + 400).toFixed(2)}`,
 | 
			
		||||
    `${(2000).toFixed(2)}`,
 | 
			
		||||
  ];
 | 
			
		||||
  const colorStops = ["blue", "green", "yellow", "red"];
 | 
			
		||||
  createHeatmapRect(labels, colorStops, selector);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function createHeatmapRect(labels, colorStops, selector) {
 | 
			
		||||
  if (!$(selector)[0]) {
 | 
			
		||||
    return;
 | 
			
		||||
@ -1491,3 +1282,128 @@ function moveViewToDevice(letter) {
 | 
			
		||||
    viewer.clearSelection();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class ErrorDevice {
 | 
			
		||||
  constructor(options) {
 | 
			
		||||
    this.errorDevices = options.errorDevices ?? [];
 | 
			
		||||
    this.model = null;
 | 
			
		||||
    this.#init();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  #init = async function () {
 | 
			
		||||
    this.model = viewer.model;
 | 
			
		||||
    // 載入 Autodesk Viewer 的資料視覺化擴充功能
 | 
			
		||||
    const dataVizExtn = await viewer.loadExtension(
 | 
			
		||||
      "Autodesk.DataVisualization"
 | 
			
		||||
    );
 | 
			
		||||
    // dataVizExtn.removeSurfaceShading(this.model);
 | 
			
		||||
    // 儲存 Viewer 的模型
 | 
			
		||||
    this.addHeatMaps();
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  async addHeatMaps() {
 | 
			
		||||
    const dataVizExtn = await viewer.loadExtension(
 | 
			
		||||
      "Autodesk.DataVisualization"
 | 
			
		||||
    );
 | 
			
		||||
    const {
 | 
			
		||||
      SurfaceShadingData,
 | 
			
		||||
      SurfaceShadingPoint,
 | 
			
		||||
      SurfaceShadingNode,
 | 
			
		||||
      SurfaceShadingGroup,
 | 
			
		||||
    } = Autodesk.DataVisualization.Core;
 | 
			
		||||
    // test
 | 
			
		||||
    const shadingGroup = new SurfaceShadingGroup("device-error-heatmap");
 | 
			
		||||
    const rooms = new Map();
 | 
			
		||||
    for (const { id, forge_dbid, roomDbId, position, sensorTypes } of this
 | 
			
		||||
      .errorDevices) {
 | 
			
		||||
      if (!id || forge_dbid == -1 || roomDbId == -1) {
 | 
			
		||||
        continue;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      if (!rooms.has(forge_dbid) || !rooms.has(roomDbId)) {
 | 
			
		||||
        const room = new SurfaceShadingNode(`error_${id}`, forge_dbid);
 | 
			
		||||
        shadingGroup.addChild(room);
 | 
			
		||||
        rooms.set(forge_dbid, room);
 | 
			
		||||
      }
 | 
			
		||||
      const room = rooms.get(forge_dbid);
 | 
			
		||||
      room.addPoint(
 | 
			
		||||
        new SurfaceShadingPoint(`error_${id}`, position, sensorTypes)
 | 
			
		||||
      );
 | 
			
		||||
    }
 | 
			
		||||
    const shadingData = new SurfaceShadingData();
 | 
			
		||||
    shadingData.addChild(shadingGroup);
 | 
			
		||||
 | 
			
		||||
    shadingData.initialize(this.model);
 | 
			
		||||
 | 
			
		||||
    await dataVizExtn.setupSurfaceShading(this.model, shadingData);
 | 
			
		||||
    dataVizExtn.registerSurfaceShadingColors("error", [0xff0000, 0xff0000]);
 | 
			
		||||
 | 
			
		||||
    dataVizExtn.renderSurfaceShading(
 | 
			
		||||
      "device-error-heatmap",
 | 
			
		||||
      "error",
 | 
			
		||||
      this.getSensorValue.bind(this)
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  getSensorValue = function (device, sensorType) {
 | 
			
		||||
    let dev = this.errorDevices.filter((x) => `error_${x.id}` == device.id)[0];
 | 
			
		||||
    if (sensorType === "error") {
 | 
			
		||||
      return 0;
 | 
			
		||||
    }
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
// =================================燈光用===============================================
 | 
			
		||||
async function getLTNode(device) {
 | 
			
		||||
  // 處理 node 的資料
 | 
			
		||||
  const nodes = device.device_nodes?.map((n) => ({
 | 
			
		||||
    ...n,
 | 
			
		||||
    position: isJSON(n.device_node_coordinate_3D)
 | 
			
		||||
      ? JSON.parse(n.device_node_coordinate_3D)
 | 
			
		||||
      : {}, // x: 0, y: 25, z: -2.5      (3.35, -4.81, 12.88
 | 
			
		||||
    sensorTypes: ["TrafficDensity"],
 | 
			
		||||
    forgeDbId: parseInt(n.forge_dbid),
 | 
			
		||||
    dbId: parseInt(n.forge_dbid),
 | 
			
		||||
  }));
 | 
			
		||||
 | 
			
		||||
  // 載入 Autodesk Viewer 的資料視覺化擴充功能
 | 
			
		||||
  const dataVizExtn = await viewer.loadExtension("Autodesk.DataVisualization");
 | 
			
		||||
 | 
			
		||||
  const {
 | 
			
		||||
    SurfaceShadingGroup,
 | 
			
		||||
    SurfaceShadingData,
 | 
			
		||||
    SurfaceShadingPoint,
 | 
			
		||||
    SurfaceShadingNode,
 | 
			
		||||
  } = Autodesk.DataVisualization.Core;
 | 
			
		||||
 | 
			
		||||
  dataVizExtn.removeSurfaceShading(viewer.model);
 | 
			
		||||
 | 
			
		||||
  // Group to select both north and southbound
 | 
			
		||||
  const shadingGroup = new SurfaceShadingGroup("LT");
 | 
			
		||||
 | 
			
		||||
  nodes.forEach(({ position, forgeDbId, sensorTypes, device_number }) => {
 | 
			
		||||
    const LTGroup = new SurfaceShadingNode("LTGroup" + forgeDbId, forgeDbId);
 | 
			
		||||
    LTGroup.addPoint(
 | 
			
		||||
      new SurfaceShadingPoint(device_number, position, sensorTypes)
 | 
			
		||||
    );
 | 
			
		||||
    shadingGroup.addChild(LTGroup);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  const heatmapData = new SurfaceShadingData();
 | 
			
		||||
  heatmapData.addChild(shadingGroup);
 | 
			
		||||
 | 
			
		||||
  // Initialize with model loaded from APS
 | 
			
		||||
  heatmapData.initialize(viewer.model);
 | 
			
		||||
  await dataVizExtn.setupSurfaceShading(viewer.model, heatmapData);
 | 
			
		||||
  const sensorColors = [0x0080FF, 0x0080FF];
 | 
			
		||||
 | 
			
		||||
  // Set heatmap colors for temperature
 | 
			
		||||
  const sensorType = "TrafficDensity";
 | 
			
		||||
  dataVizExtn.registerSurfaceShadingColors(sensorType, sensorColors);
 | 
			
		||||
  dataVizExtn.renderSurfaceShading("LT", "TrafficDensity", getLTSensorValue);
 | 
			
		||||
  console.log("dataVizExtn", dataVizExtn);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Function that provides a [0,1] value for the Heatmap
 | 
			
		||||
function getLTSensorValue(surfaceShadingPoint, sensorType) {
 | 
			
		||||
  return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -3,14 +3,14 @@
 | 
			
		||||
// var baseImgUrl = "https://localhost:44376"; // 本地開發用
 | 
			
		||||
 | 
			
		||||
// Mitsubishi
 | 
			
		||||
var baseApiUrl = "http://220.132.206.5:8005"; // production 用
 | 
			
		||||
// var baseApiUrl = "http://220.132.206.5:8005"; // production 用
 | 
			
		||||
var baseImgUrl = "http://220.132.206.5:8053"; // production 用
 | 
			
		||||
 | 
			
		||||
// WSP
 | 
			
		||||
// var baseApiUrl = "http://192.168.0.136:8005"; // production 用
 | 
			
		||||
// var baseImgUrl = "http://192.168.0.136:8053"; // production 用
 | 
			
		||||
 | 
			
		||||
// var baseApiUrl = "http://localhost:3604";
 | 
			
		||||
var baseApiUrl = "http://localhost:3604";
 | 
			
		||||
//var baseImgUrl = "http://localhost:8848";
 | 
			
		||||
 | 
			
		||||
var varRegApiUrl = "/reg/api/";  //註冊API路徑
 | 
			
		||||
 | 
			
		||||
@ -876,7 +876,9 @@ function getAllDeviceAlarmByBaja(
 | 
			
		||||
      .then(function (table) {
 | 
			
		||||
        return table.cursor({
 | 
			
		||||
          each: function (record) {
 | 
			
		||||
            if (record.get("alarmData").get("sourceName")) {
 | 
			
		||||
              let main = {};
 | 
			
		||||
              // console.log("告警", record.get("alarmData").get("sourceName"));
 | 
			
		||||
              //   const alarmDisplayName = record.get('alarmData').get('sourceName').split(":")[1] ?? record.get('alarmData').get('sourceName').split(":")[0]
 | 
			
		||||
              const alarmDisplayName =
 | 
			
		||||
                record.get("alarmData").get("sourceName").split(":")[1] ??
 | 
			
		||||
@ -908,6 +910,7 @@ function getAllDeviceAlarmByBaja(
 | 
			
		||||
              }
 | 
			
		||||
              _result.data.push(main);
 | 
			
		||||
              _index++;
 | 
			
		||||
            }
 | 
			
		||||
          },
 | 
			
		||||
          after: function () {
 | 
			
		||||
            _result.count = _index;
 | 
			
		||||
 | 
			
		||||
@ -43,6 +43,7 @@ function getHistoryDataByBaja(devicePath, startDate_millisecond, endDate_millise
 | 
			
		||||
        console.log('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond);
 | 
			
		||||
        baja.Ord.make('local:|foxs:|history:/' + company + '/' + devicePath + '|bql:select * from control:ControlPoint where timestamp.millis > ' + startDate_millisecond + ' and timestamp.millis < ' + endDate_millisecond).get()
 | 
			
		||||
        .then(function (table) {
 | 
			
		||||
            $(loadEle).Loading("start");
 | 
			
		||||
            return table.cursor({
 | 
			
		||||
                each: function (record) {
 | 
			
		||||
                    console.log(record.get('timestamp'))
 | 
			
		||||
@ -57,6 +58,7 @@ function getHistoryDataByBaja(devicePath, startDate_millisecond, endDate_millise
 | 
			
		||||
                    _index++;
 | 
			
		||||
                },
 | 
			
		||||
                after: function () {
 | 
			
		||||
                    $(loadEle).Loading("close");
 | 
			
		||||
                    _result={count: _index, data: _ss}
 | 
			
		||||
                    // _result += '{' + '"count": ' + _index + ', "data":[';
 | 
			
		||||
                    // _result += _ss;
 | 
			
		||||
 | 
			
		||||
@ -35,10 +35,15 @@ class YourTeamNavbar {
 | 
			
		||||
        this.element = option.element;
 | 
			
		||||
        this.type = option.type ?? "left";
 | 
			
		||||
        this.isOpen = false;
 | 
			
		||||
        this.onlyOneOpen = false;
 | 
			
		||||
        this.init();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    init = function () {
 | 
			
		||||
    init = function (option = {}) {
 | 
			
		||||
        // this = Object.assign(option ?? {});
 | 
			
		||||
        Object.keys(option).forEach(k => {
 | 
			
		||||
            this[k] = option[k];
 | 
			
		||||
        });
 | 
			
		||||
        this.initClose();
 | 
			
		||||
        this.checkIsOpen();
 | 
			
		||||
        $(this.element)[0]._ytNavbar = this;
 | 
			
		||||
@ -115,24 +120,43 @@ class YourTeamNavbar {
 | 
			
		||||
        $(this.element).find("[data-nb-node-type=parent]").on("click",this.nbNodeParentOnClick.bind(this))
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    nbNodeParentOnClick(e){
 | 
			
		||||
        if(this.chkNbNodeParentIsOpen(e.target)){
 | 
			
		||||
            $(e.target).data("nb-node-status","close").attr("data-nb-node-status","close");
 | 
			
		||||
            $(e.target).next("ul").css({transform:"translateY(-5%)"});
 | 
			
		||||
            $(e.target).next("ul").animate({
 | 
			
		||||
    closeParentCollapse(ele,isAnimation = true){
 | 
			
		||||
        $(ele).data("nb-node-status","close").attr("data-nb-node-status","close");
 | 
			
		||||
        $(ele).next("ul").css({transform:"translateY(-5%)"});
 | 
			
		||||
        if(isAnimation){
 | 
			
		||||
        $(ele).next("ul").animate({
 | 
			
		||||
            opacity:0,
 | 
			
		||||
            },200, () => {
 | 
			
		||||
                $(e.target).next("ul").hide();
 | 
			
		||||
                $(ele).next("ul").hide();
 | 
			
		||||
            })
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        } else {
 | 
			
		||||
            $(e.target).data("nb-node-status","open").attr("data-nb-node-status","open");
 | 
			
		||||
            $(e.target).next("ul").show();
 | 
			
		||||
            $(e.target).next("ul").animate({
 | 
			
		||||
            $(ele).next("ul").css({opacity:0}).hide();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    openParentCollapse(ele){
 | 
			
		||||
        $(ele).data("nb-node-status","open").attr("data-nb-node-status","open");
 | 
			
		||||
            $(ele).next("ul").show();
 | 
			
		||||
            $(ele).next("ul").animate({
 | 
			
		||||
                opacity:1,
 | 
			
		||||
            },200)
 | 
			
		||||
            $(e.target).next("ul").css({transform:"translateY(0%)"});
 | 
			
		||||
            $(ele).next("ul").css({transform:"translateY(0%)"});
 | 
			
		||||
       
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    nbNodeParentOnClick(e){
 | 
			
		||||
        if(this.chkNbNodeParentIsOpen(e.target)){
 | 
			
		||||
            
 | 
			
		||||
            this.closeParentCollapse(e.target);
 | 
			
		||||
            
 | 
			
		||||
        } else {
 | 
			
		||||
            
 | 
			
		||||
            if(this.onlyOneOpen === true){
 | 
			
		||||
                this.closeParentCollapse($(this.element).find("[data-nb-node-type=parent]").filter((i,ele) => ele != e.target),false);
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            this.openParentCollapse(e.target)
 | 
			
		||||
            
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -140,9 +164,16 @@ class YourTeamNavbar {
 | 
			
		||||
        return $(ele).is("[data-nb-node-status=open]");
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    openAllCollapse(){
 | 
			
		||||
        $(this.element).find("[data-nb-node-type=parent]").each((i,ele) => {
 | 
			
		||||
            if(!this.chkNbNodeParentIsOpen(ele)){
 | 
			
		||||
                $(this.element).find("[data-nb-node-type=parent]").click();
 | 
			
		||||
            }
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$.fn.YTNavbar = function (method) {
 | 
			
		||||
$.fn.YTNavbar = function (method,...arg) {
 | 
			
		||||
    let nbObj = $(this)[0]._ytNavbar;
 | 
			
		||||
    let target = $(this).data("target");
 | 
			
		||||
    if (!nbObj && $(target).length != 0) { 
 | 
			
		||||
@ -156,7 +187,9 @@ $.fn.YTNavbar = function (method) {
 | 
			
		||||
    } else if (method == "hide") {
 | 
			
		||||
        nbObj.close();
 | 
			
		||||
    } else if (method == "init") {
 | 
			
		||||
        nbObj.init();
 | 
			
		||||
        nbObj.init(arg[0]);
 | 
			
		||||
    } else if(method == "openAllCollapse") {
 | 
			
		||||
        nbObj.openAllCollapse();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return nbObj;
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user