[Frontend] 開發機 登入 401 轉 login.html | [儀錶板] 動態系統小類按鈕建置

This commit is contained in:
dev01 2022-12-02 18:53:00 +08:00
parent eba516ca98
commit 6a9ea02e23
3 changed files with 50 additions and 57 deletions

View File

@ -146,62 +146,12 @@
</div>
<div class="row">
<div class="col-sm-12 col-lg-4">
<div class="row">
<div class="btn-group btn-group-lg col-lg-6 mb-4">
<button type="button" class="btn btn-secondary"><i class="fal fa-lightbulb-on fa-2x blink"></i></button>
<button type="button" class="btn btn-secondary">照明系統  </button>
</div>
<div class="btn-group btn-group-lg col-lg-6 mb-4">
<button type="button" class="btn btn-secondary"><i class="fal fa-thermometer-full fa-2x"></i></button>
<button type="button" class="btn btn-secondary">環境感測系統</button>
</div>
<div class="btn-group btn-group-lg col-lg-6 mb-4">
<button type="button" class="btn btn-secondary"><i class="fal fa-car-battery fa-2x"></i></button>
<button type="button" class="btn btn-secondary" onclick="goElectricMeter()">電錶系統  </button>
</div>
<div class="btn-group btn-group-lg col-lg-6 mb-4">
<button type="button" class="btn btn-secondary"><i class="fal fa-wind fa-2x"></i></button>
<button type="button" class="btn btn-secondary">空調系統  </button>
</div>
<div class="btn-group btn-group-lg col-lg-6 mb-4">
<button type="button" class="btn btn-secondary"><i class="fal fa-window-restore fa-2x"></i></button>
<button type="button" class="btn btn-secondary">電梯系統  </button>
</div>
<div class="btn-group btn-group-lg col-lg-6 mb-4">
<button type="button" class="btn btn-secondary"><i class="fal fa-door-closed fa-2x"></i></button>
<button type="button" class="btn btn-secondary">門禁系統  </button>
</div>
</div>
</div>
<div class="col-sm-12 col-lg-4">
<div class="row">
<div class="btn-group btn-group-lg col-lg-6 mb-4">
<button type="button" class="btn btn-secondary"><i class="fal fa-lightbulb-on fa-2x"></i></button>
<button type="button" class="btn btn-secondary">照明系統  </button>
</div>
<div class="btn-group btn-group-lg col-lg-6 mb-4">
<button type="button" class="btn btn-secondary"><i class="fal fa-thermometer-full fa-2x"></i></button>
<button type="button" class="btn btn-secondary">環境感測系統</button>
</div>
<div class="btn-group btn-group-lg col-lg-6 mb-4">
<button type="button" class="btn btn-secondary"><i class="fal fa-car-battery fa-2x"></i></button>
<button type="button" class="btn btn-secondary">電錶系統  </button>
</div>
<div class="btn-group btn-group-lg col-lg-6 mb-4">
<button type="button" class="btn btn-secondary"><i class="fal fa-wind fa-2x"></i></button>
<button type="button" class="btn btn-secondary">空調系統  </button>
</div>
<div class="btn-group btn-group-lg col-lg-6 mb-4">
<button type="button" class="btn btn-secondary"><i class="fal fa-window-restore fa-2x"></i></button>
<button type="button" class="btn btn-secondary">電梯系統  </button>
</div>
<div class="btn-group btn-group-lg col-lg-6 mb-4">
<button type="button" class="btn btn-secondary"><i class="fal fa-door-closed fa-2x"></i></button>
<button type="button" class="btn btn-secondary">門禁系統  </button>
</div>
<div class="col-sm-12 col-lg-8">
<div class="row" id="sysSubBtnList">
</div>
</div>
<div class="col-sm-12 col-lg-4">
<div class="row">
<div class="col-lg-6">
@ -340,6 +290,7 @@
];
$(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 += `<div class="btn-group btn-group-lg col-lg-4 mb-4 dev-group" data-id="${pageAct.AreaTag}/${pageAct.buiTag}/${mainSysObj.main_system_tag}/${subSysObj.sub_system_tag}">
<button type="button" class="btn btn-secondary col-4"><i class="fal fa-lightbulb-on fa-2x"></i></button>
<button type="button" class="btn btn-secondary">${subSysObj.full_name}</button>
</div>`;
})
})
$("#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)
})
})
}
</script>

View File

@ -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 {

View File

@ -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);