[Forntend] Require 套件整理 | 套件引用順序調整及整理並加上備註 | datatable.bundle.js 換成 datatable.min.js

This commit is contained in:
dev01 2022-11-22 13:33:49 +08:00
parent dfb36f08f3
commit 3af363566c
11 changed files with 11517 additions and 156 deletions

View File

@ -32,7 +32,8 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
<link rel="mask-icon" href="img/favicon/safari-pinned-tab.svg" color="#5bbad5"> <link rel="mask-icon" href="img/favicon/safari-pinned-tab.svg" color="#5bbad5">
<!-- Font Awesome --> <!-- Font Awesome -->
<link href="lib/fontawesome-free/css/all.min.css" rel="stylesheet" /> <link href="lib/fontawesome-free/css/all.min.css" rel="stylesheet" />
<link rel="stylesheet" media="screen, print" href="lib/datagrid/datatables/datatables.bundle.css"> <link rel="stylesheet" media="screen, print" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap.min.css">
<link rel="stylesheet" media="screen, print" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="css/site.css" /> <link rel="stylesheet" href="css/site.css" />
<link rel="stylesheet" href="css/yourteam/plugins/yt-tooltip/yt-tooltip.css" /> <link rel="stylesheet" href="css/yourteam/plugins/yt-tooltip/yt-tooltip.css" />
</head> </head>
@ -2042,79 +2043,90 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
+ waves.js (extension) + waves.js (extension)
+ smartpanels.js (extension) + smartpanels.js (extension)
+ src/../jquery-snippets.js (core) --> + src/../jquery-snippets.js (core) -->
<!-- verdors.bundle.js 已含有 jquery Library v3.5.1-->
<script src="lib/vendors.bundle.js"></script> <script src="lib/vendors.bundle.js"></script>
<script src="lib/app.bundle.js"></script> <script src="lib/app.bundle.js"></script>
<script type="text/javascript"> <!-- toast 第三方套件 若 require 此套件只能用 define 使用,先暫時 html 引用-->
/* Activate smart panels */
$('#js-page-content').smartPanel();
</script>
<!-- The order of scripts is irrelevant. Please check out the plugin pages for more details about these plugins below: -->
<script src="lib/statistics/peity/peity.bundle.js"></script>
<script src="lib/statistics/flot/flot.bundle.js"></script>
<script src="lib/statistics/easypiechart/easypiechart.bundle.js"></script>
<script src="lib/datagrid/datatables/datatables.bundle.js"></script>
<script src="lib/notifications/toastr/toastr.min.js"></script> <script src="lib/notifications/toastr/toastr.min.js"></script>
<script src="lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="lib/jquery-validation/dist/localization/messages_zh_TW.js"></script>
<script src="js/yourteam/yourteam.ajax.class.js"></script>
<script src="js/yourteam/yourteam.jquery.datatables.js"></script>
<script src="js/yourteam/yourteam.utility.class.js"></script>
<script src="js/yourteam/plugins/yt-tooltip/yt-tooltip.js"></script>
<script src="js/yourteam/plugins/yt-tab/yt-tab.js"></script>
<script src="js/toast.js"></script> <script src="js/toast.js"></script>
<script src="js/style.js"></script> <script src="lib/echarts.min.js"></script>
<script src="js/site.js"></script> <!--The order of scripts is irrelevant. Please check out the plugin pages for more details about these plugins below:-->
<script src="js/init.js"></script> <script src="lib/statistics/easypiechart/easypiechart.bundle.js"></script>
<script src="js/n4js/alarmbaja.js"></script>
<script>
<!--Bajascript-->
<script src="js/bajascript/bscriptReq.js"></script>
<!--<script type='text/javascript' src='/module/js/com/tridium/js/ext/require/require.min.js?version=1496767636459'></script>-->
<script src='js/bajascript/require.js'></script>
<script src='js/require.js'></script>
<script type='text/javascript'>
define('niagaraSystemProperties', function () {
return {
};
});
</script>
<script src="js/bajascript/require.config.js"></script>
<script src="js/FileSaver.js"></script>
<script>
/*$('#js-page-content').smartPanel();*/
var jwt = localStorage.getItem("JWT-Authorization"); var jwt = localStorage.getItem("JWT-Authorization");
var pageAct = {}; //記錄全頁面已選擇項目 var pageAct = {}; //記錄全頁面已選擇項目
if (jwt) { if (!jwt) {
$("#app").load("_dashboard.html", loadCallback);
} else {
location.href = "login.html"; location.href = "login.html";
} }
$(function () { $(function () {
// 二次引用 jquery.js
// - 在 require 內部程序需要引用 jquery由於 require 的套件需要依賴 jquery ,就算 HTML 已經引用 jquery require 也無法參考
// - 上方 HTML 引用套件若有使用 jquery 內存數據程序 (ex: $(x).data() , $(x).trigger("custom event") , $.fn.custom ...)
// - 會被清洗,有類似程序需放入 loadPack1 Function rquired 引用
// (原 datatable.bundle.js require 會出問題,先以 cdn datatable.min.js引用)
require(["jquery"], loadedBasePack);
})
/**
* jquery.js 二次引用後 Callback載入第三方套件
* */
function loadedBasePack() {
require(
[
"datatables.net.b4",
"n4js/alarmbaja",
"lib/statistics/flot/flot.bundle",
"lib/statistics/peity/peity.bundle",
], loadedMasterPack);
}
/**
* 第三方套件引用後 Callback載入額外套件
* */
function loadedMasterPack() {
require(
[
"yourteam/yourteam.ajax.class",
"yourteam/yourteam.utility.class",
"yourteam/yourteam.jquery.datatables",
"yourteam/plugins/yt-tooltip/yt-tooltip",
"yourteam/plugins/yt-tab/yt-tab",
"style",
"init",
], function () {
require(["site"], loadedJsPack)
});
}
/**
* 全數套件讀取完成 Callback
* */
function loadedJsPack() {
loadEvent();
$("#app").load("_dashboard.html", loadCallback);
getBuiList(); getBuiList();
getSysMonBtnList(); getSysMonBtnList();
}) checkDevState();
onEvent("click", "[name=topFunBtn]", function () {
let page = $(this).data("page");
if (page != "systemMonitor") {
$("#sysMonBtnList .dropdown-item").removeClass("active");
pageAct.sysMainTag = null;
}
$("#app").load(`_${page}.html`, loadCallback);
})
onEvent("active:change", "#sysMonBtnList", function (e, actEle) {
if (actEle) {
pageAct.sysMainTag = $(actEle).data("subSysObj").main_system_tag;
pageAct.sysSubTag = $(actEle).data("subSysObj").sub_system_tag;
pageAct.sysSubName = $(actEle).data("subSysObj").full_name;
pageAct.sysSubObj = $(actEle).data("subSysObj");
}
$(this).trigger("change");
})
onEvent("active:change", "#buiList", function (e, actEle) {
if (actEle) {
pageAct.buiTag = $(actEle).prop("id").split("buiBtn")[1];
}
$(this).trigger("change");
})
function loadCallback() {
initTabsByEle();
resetYTTooltip();
}
function getSysMonBtnList() { function getSysMonBtnList() {
let url = baseApiUrl + "/api/Device/GetMainSub"; let url = baseApiUrl + "/api/Device/GetMainSub";
@ -2154,7 +2166,80 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li
}, null, "POST").send(); }, null, "POST").send();
} }
//lily test
function checkDevState() {
//TPE_B1_LT_L1
//main_system_tag: pageAct.sysMainTag,
//building_tag: pageAct.buiTag,
//floor_tag: pageAct.floTag,
let systemPath = "TPE_B1";
// if (pageAct != undefined && pageAct != null && pageAct.sysMainTag != null && pageAct.buiTag != null) {
// systemPath = "TPE_" + pageAct.buiTag + "_" + pageAct.sysMainTag + "_" + "EL";
// }
getOneSystemAlarmStateByBaja(systemPath, callbackForCheckDevState);
// console.log("systemP: " + systemPath);
// console.log("devList: " + deviceList[0].device_guid + ", " + deviceList[3].device_guid + ", " + deviceList[8].device_guid);
//callbackForCheckDevState("test");
}
function callbackForCheckDevState(result) {
console.log("------ " + result);
// $.each(deviceList, (index, devObj) => {
// if ((`${devObj.device_guid}`) == '4ed28a93-5025-11ed-b23e-0242ac110002'
// || (`${devObj.device_guid}`) == '5d9fdff0-5343-43fe-86f4-bd73cdb15111') {
// var str = "";
// $(`#${devObj.device_guid}`).empty();
// str = `<span class="status status-danger d-inline-block"><img src="${baseImgUrl + varPathImg + devObj.device_master_icon}" class="profile-image rounded-circle" onerror="defDev(this)" alt="..."></span> ${devObj.full_name}`;
// $(`#${devObj.device_guid}`).append(str);
// }
// })
console.log(result);
}
/*})*/
//})
}
// page loaded callback
function loadCallback() {
initTabsByEle();
resetYTTooltip();
}
//事件先行讀取
function loadEvent() {
onEvent("click", "[name=topFunBtn]", function () {
let page = $(this).data("page");
if (page != "systemMonitor") {
$("#sysMonBtnList .dropdown-item").removeClass("active");
pageAct.sysMainTag = null;
}
$("#app").load(`_${page}.html`, loadCallback);
})
onEvent("active:change", "#sysMonBtnList", function (e, actEle) {
if (actEle) {
pageAct.sysMainTag = $(actEle).data("subSysObj").main_system_tag;
pageAct.sysSubTag = $(actEle).data("subSysObj").sub_system_tag;
pageAct.sysSubName = $(actEle).data("subSysObj").full_name;
pageAct.sysSubObj = $(actEle).data("subSysObj");
}
})
onEvent("active:change", "#buiList", function (e, actEle) {
if (actEle) {
pageAct.buiTag = $(actEle).prop("id").split("buiBtn")[1];
}
})
}
</script> </script>
</body> </body>
<!-- END Body --> <!-- END Body -->
</html> </html>

View File

@ -25,7 +25,7 @@ require.hbs.fetchText = function (uri, callback) {
return href; return href;
} }
require(['baja!', 'jquery'], function (baja, $) { require(['baja!'], function (baja) {
if (baja.isOffline()) { if (baja.isOffline()) {
uri = /([^?]*)\??.*/.exec(uri)[1]; uri = /([^?]*)\??.*/.exec(uri)[1];
uri = uri.replace('https://workbench/module/', 'module://'); uri = uri.replace('https://workbench/module/', 'module://');
@ -35,9 +35,9 @@ require.hbs.fetchText = function (uri, callback) {
}); });
} }
else { else {
$.ajax(unmodularize(uri)).then(function (text) { //$.ajax(unmodularize(uri)).then(function (text) {
callback(text, uri); // callback(text, uri);
}); //});
} }
}); });
}; };
@ -62,7 +62,7 @@ require.paths.hbs=require.paths.hbs || '/module/js/rc/require-handlebars-plugin/
require.paths.moment=require.paths.moment || '/module/js/rc/moment/moment.min'; require.paths.moment=require.paths.moment || '/module/js/rc/moment/moment.min';
require.paths.d3=require.paths.d3 || '/module/js/rc/d3/d3.min'; require.paths.d3=require.paths.d3 || '/module/js/rc/d3/d3.min';
require.paths.hx=require.paths.hx || '/module/hx/javax/baja/hx/hx'; require.paths.hx=require.paths.hx || '/module/hx/javax/baja/hx/hx';
require.paths.jqueryContextMenu=require.paths.jqueryContextMenu || '/module/js/rc/jquery/contextMenu/jquery.contextMenu'; /*require.paths.jqueryContextMenu=require.paths.jqueryContextMenu || '/module/js/rc/jquery/contextMenu/jquery.contextMenu';*/
require.paths.ace=require.paths.ace || '/module/js/rc/ace'; require.paths.ace=require.paths.ace || '/module/js/rc/ace';
require.shim=require.shim || {}; require.shim=require.shim || {};
require.shim.d3=require.shim.d3 || {}; require.shim.d3=require.shim.d3 || {};

View File

@ -2,11 +2,14 @@ require.config({
baseUrl: 'js', baseUrl: 'js',
"paths": { "paths": {
"lib": "../lib",
"jquery-ui": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui", "jquery-ui": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui",
"jquery-ui-min": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min", "jquery-ui-min": "//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min",
"d3" : "https://d3js.org/d3.v4.min" "d3": "https://d3js.org/d3.v4.min",
"datatables.net": "https://cdn.datatables.net/1.10.21/js/jquery.dataTables.min",
"datatables.net.b4": "https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap4.min"
}, },
urlArgs: "ts=" + new Date().getTime(),
shim: { shim: {
"d3": { "d3": {
exports: "d3" exports: "d3"

View File

@ -1,4 +1,8 @@
 
function addzero(num) {
return num < 10 ? '0' + num : num;
}
/** /**
* 取得異常資料 by baja * 取得異常資料 by baja
* @param {any} startDate_millisecond * @param {any} startDate_millisecond
@ -8,6 +12,39 @@
* @param {any} alarmClass * @param {any} alarmClass
* @param {any} callback * @param {any} callback
*/ */
// function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, alarmClass, callback) {
// let _sourceTmp;
// var _result = "";
// var _ss = "";
// var _bfName = "";
// var _sourceName = "";
// var _index = 0;
// var _recoverState = isRecover ? "!= null" : "= null";
// var _ackState = isAck ? "= 1" : "!= 1";
// require(['baja!'], function (baja) {
// baja.Ord.make("local:|foxs:|alarm:|bql:select timestamp, ackState, alarmClass, alarmClassDisplayName, alarmValue, alarmData, alarmData.sourceName, uuid, alarmData.msgText, alarmData.numericValue, alarmData.presentValue, alarmData.status, alarmData.toState, normalTime from openAlarms where alarmClass = '" + alarmClass + "' and timestamp.millis > " + startDate_millisecond + " and timestamp.millis < " + endDate_millisecond + " and normalTime " + _recoverState + " order by timestamp asc").get()
// .then(function (table) {
// return table.cursor({
// each: function (record) {
// _sourceTmp = (record.get('alarmData').get('sourceName')).toString().split('_');
// _bfName = _sourceTmp[1] + "-" + _sourceTmp[4];
// _sourceName = _sourceTmp[7] + "-" + _sourceTmp[8];
// _ss += ', "' + _index + '": {"buildingFloorName_zh":"' + _bfName + '", "uuid":"' + record.get('uuid') + '", "timestamp":"' + record.get('timestamp') + '", "alarmClass":"' + record.get('alarmClass') + '", "sourceName_zh":"' + _sourceName + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "normalTime":"' + record.get('normalTime') + '"}';
// _index++;
// },
// after: function () {
// _result += '{' + '"count": ' + _index;
// _result += _ss;
// _result += '}';
// if (typeof callback === 'function') {
// callback(_result);
// }
// }
// });
// });
// });
// }
function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, alarmClass, callback) { function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, isAck, alarmClass, callback) {
let _sourceTmp; let _sourceTmp;
var _result = ""; var _result = "";
@ -15,7 +52,7 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
var _bfName = ""; var _bfName = "";
var _sourceName = ""; var _sourceName = "";
var _index = 0; var _index = 0;
var _recoverState = isRecover ? "!= null" : "= null"; var _recoverState = isRecover ? "!= null" : "= null"
var _ackState = isAck ? "= 1" : "!= 1"; var _ackState = isAck ? "= 1" : "!= 1";
require(['baja!'], function (baja) { require(['baja!'], function (baja) {
@ -51,9 +88,40 @@ function getAlarmByBaja(startDate_millisecond, endDate_millisecond, isRecover, i
* @param {any} devicePath * @param {any} devicePath
* @param {any} callback * @param {any} callback
*/ */
// function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
// var _result = "";
// var _ss = "";
// var _index = 0;
// //{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]}
// require(['baja!'], function (baja) {
// baja.Ord.make("local:|foxs:|alarm:|bql:select top 10 timestamp, ackState, alarmData, alarmData.sourceName, sourceState, uuid, alarmData.msgText, normalTime where alarmData.sourceName like '%" + devicePath + "%' order by timestamp desc").get()
// .then(function (table) {
// return table.cursor({
// each: function (record) {
// if (_index == 0)
// _ss += '{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}';
// else
// _ss += ',{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}';
// _index++;
// },
// after: function () {
// _result += '{' + '"count": ' + _index +', "data":[';
// _result += _ss+']';
// _result += '}';
// if (typeof callback === 'function') {
// callback(_result);
// }
// }
// });
// });
// });
// }
function getOneDeviceAlarmTop10ByBaja(devicePath, callback) { function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
var _result = ""; var _result = "";
var _ss = ""; var _ss = "";
var _occurrenceTime = "";
var _normalTime = "";
var _index = 0; var _index = 0;
//{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]} //{ "count":2,"data": [{ "time": "2022/11/14 15:00:00", "errId": "0001", "ackCheck": "未確認", "errReason": "燈泡故障" }, { "time": "2022/11/14 15:00:00", "errId": "0002", "ackCheck": "未確認", "errReason": "燈泡故障" }]}
require(['baja!'], function (baja) { require(['baja!'], function (baja) {
@ -61,10 +129,23 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
.then(function (table) { .then(function (table) {
return table.cursor({ return table.cursor({
each: function (record) { each: function (record) {
_occurrenceTime = "";
_normalTime = "";
var _resultUuid = record.get('uuid').toString().split("-");//43dc7846-bd96-4be2-ab35-f11aec729c60
var _timestampTemp = new Date(record.get('timestamp').toString());
_occurrenceTime += _timestampTemp.getFullYear().toString() + "-" + addzero(_timestampTemp.getMonth() + 1).toString() + "-" + addzero(_timestampTemp.getDate()).toString() + " " + addzero(_timestampTemp.getHours()).toString() + ":" + addzero(_timestampTemp.getMinutes()).toString() + ":" + addzero(_timestampTemp.getSeconds()).toString();
//var _occurrenceTime = _timestamp.format("yyyy-MM-dd hh:mm:ss");//.toLocaleString();
var _normaltime = new Date(record.get('normalTime').toString());
_normalTime += _normaltime.getFullYear().toString() + "-" + addzero(_normaltime.getMonth() + 1).toString() + "-" + addzero(_normaltime.getDate()).toString() + " " + addzero(_normaltime.getHours()).toString() + ":" + addzero(_normaltime.getMinutes()).toString() + ":" + addzero(_normaltime.getSeconds()).toString();
var _msgText = record.get('alarmData').get('msgText') == 1 ? _occurrenceTime : "未確認";
if (_index == 0) if (_index == 0)
_ss += '{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}'; _ss += '{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
else else
_ss += ',{"uuid":"' + record.get('uuid') + '", "msgText":"' + record.get('alarmData').get('msgText') + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + record.get('timestamp') + '"}'; _ss += ',{"uuid":"' + _resultUuid[0] + '", "msgText":"' + _msgText + '", "ackState":"' + record.get('ackState') + '", "timestamp":"' + _occurrenceTime + '", "normalTime":"' + _normalTime + '"}';
_index++; _index++;
}, },
after: function () { after: function () {
@ -85,6 +166,31 @@ function getOneDeviceAlarmTop10ByBaja(devicePath, callback) {
* @param {any} systemPath * @param {any} systemPath
* @param {any} callback * @param {any} callback
*/ */
// function getOneSystemAlarmStateByBaja(systemPath, callback) {
// var _result = "";
// var _ss = "";
// var _index = 0;
// require(['baja!'], function (baja) {
// baja.Ord.make("local:|foxs:|alarm:|bql:select alarmData, alarmData.sourceName, sourceState, uuid where alarmData.sourceName like '%" + systemPath + "%' order by timestamp desc").get()
// .then(function (table) {
// return table.cursor({
// each: function (record) {
// _ss += ', "' + _index + '": {"uuid":"' + record.get('uuid') + '", "sourceName":"' + record.get('alarmData').get('sourceName') + '", "sourceState":"' + record.get('sourceState') + '"}';
// _index++;
// },
// after: function () {
// _result += '{' + '"count": ' + _index;
// _result += _ss;
// _result += '}';
// if (typeof callback === 'function') {
// callback(_result);
// }
// }
// });
// });
// });
// }
function getOneSystemAlarmStateByBaja(systemPath, callback) { function getOneSystemAlarmStateByBaja(systemPath, callback) {
var _result = ""; var _result = "";
var _ss = ""; var _ss = "";
@ -113,4 +219,3 @@ function getOneSystemAlarmStateByBaja(systemPath, callback) {
}); });
}); });
} }

View File

@ -1,3 +1,268 @@
 let baja_subscribe_device_callback_func; //設定BQL訂閱之後要回傳的Function
var ordPath; //當前點選選單的tag用來抓出設備路徑例如:旅館棟->H消防偵煙器->F3
function subscriptionDevices() {
// 用BQL的方式去訂閱
this.setSubscribeDevicesByBql = function (tempOrdPath) {
ordPath = tempOrdPath;
BajaSubscribeDevicesByBql();
};
// BQL去訂閱回傳的Function
this.setSubscribeDevicesCallBack = function (callBackFunc) {
if (callBackFunc != undefined && callBackFunc != null) {
baja_subscribe_device_callback_func = callBackFunc;
}
}
}
/**
* 使用者透過BQL指定路徑去訂閱設備點位
*/
function BajaSubscribeDevicesByBql() {
require(['baja!'], function (baja) {
console.log("進入Function 準備執行BQL訂閱");
var init_start = new Date(Date.now());
var sub = new baja.Subscriber();
sub.attach('changed', function (prop) {
if (prop.getName() === 'out') {
var out_value = this.getOutDisplay();
var target_device_number = this.$parent.getDisplayName().split('_').slice(0, 5).join('_');
var point_name = this.getDisplayName();
//依據Facets判斷回傳的內容值為何
var facets_split = this.getFacets1().$cEncStr.split('|');
var facets_arr = [];
facets_split.forEach(function (item, index) {
facets_arr.push(item.split('=s:'));
});
var facets = facets_arr.reduce((obj, cur) => ({ ...obj, [cur[0]]: cur[1] }), {})
var point_out_split = this.getOutDisplay().split(' ');
let key = Object.keys(facets).find(k => facets[k] === point_out_split[0]);
if (key == undefined) {
key = point_out_split[0];
}
var modify_target_device = {
"device_number": target_device_number ? target_device_number : null,
"point_name": point_name ? point_name : null,
"value": key
}
if (baja_subscribe_device_callback_func != undefined && baja_subscribe_device_callback_func != null) {
baja_subscribe_device_callback_func(modify_target_device, true); //第2參數用在平面圖刷新畫面
}
}
});
//使用bql語法
// var building_tag = "H";
// var system_tag = "M10";
// baja.Ord.make(`ip:greencloud.fic.com.tw|foxs:|station:|slot:/Arena/${building_tag}/${system_tag}|bql:select name, displayname, slotPath, out.value, out from control:ControlPoint`)
console.log(`local:|foxs:|station:|slot:/TPE/${ordPath.building_tag}/${ordPath.system_tag}/${ordPath.name_tag}|bql:select name, displayname, slotPath, out.value, out, facets from control:ControlPoint`);
baja.Ord.make(`local:|foxs:|station:|slot:/TPE/${ordPath.building_tag}/${ordPath.system_tag}/${ordPath.name_tag}|bql:select name, displayname, slotPath, out.value, out, facets from control:ControlPoint`)
.get(
function (table) {
var tableStart, tableFinish;
var subStart, subFinish;
var component_index = 0;
var total_component_index = 0;
var readBqlFinish = new Date(Date.now());
// $("#readPath-finish-timestamp").html(readBqlFinish.toISOString());
// $("#readPath-finish-time").html((readBqlFinish.getTime() - init_start.getTime()) / 1000 + "sec");
console.log("讀取路徑完成-花費時間", (readBqlFinish.getTime() - init_start.getTime()) / 1000 + "sec");
table.cursor({
before: function () {
tableStart = new Date(Date.now());
$("#table-start-timestamp").html(tableStart.toISOString());
render_start = new Date(Date.now());
},
each: function (item, index) {
if (index < 1) {
subStart = new Date(Date.now());
$("#sub-start").html(subStart.toISOString());
}
$("#sub-number").html(index + 1);
total_component_index = index;
var target_device_number_split = this.getDisplay("slotPath").split('/');
var target_device_number = target_device_number_split[target_device_number_split.length - 2];
//console.log(target_device_number);
var point_name = this.getDisplay("name");
var facets = this.getDisplay("facets");
//依據Facets判斷回傳的內容值為何
var facets_split = facets.split(',');
var facets_arr = [];
facets_split.forEach(function (item, index) {
facets_arr.push(item.split('='));
});
facets = facets_arr.reduce((obj, cur) => ({ ...obj, [cur[0]]: cur[1] }), {})
var point_out_split = this.getDisplay("out").split(' ');
let key = Object.keys(facets).find(k => facets[k] === point_out_split[0]);
if (key == undefined) {
key = point_out_split[0];
}
var modify_target_device = {
"device_number": target_device_number ? target_device_number : null,
"point_name": point_name ? point_name : null,
"value": key
}
//取得component當下就更新設備點位
if (baja_subscribe_device_callback_func != undefined && baja_subscribe_device_callback_func != null) {
baja_subscribe_device_callback_func(modify_target_device);
}
baja.Ord.make("local:|foxs:|station:|" + this.getDisplay("slotPath"))
.get()
.then(function (component) {
component_index++;
var target_device_number = component.$parent.getDisplayName().split('_').slice(0, 5).join('_');
var point_name = component.getDisplayName();
// //依據Facets判斷回傳的內容值為何
// var facets_split = component.getFacets1().$cEncStr.split('|');
// var facets_arr = [];
// facets_split.forEach(function (item, index) {
// facets_arr.push(item.split('=s:'));
// });
// var facets = facets_arr.reduce((obj, cur) => ({ ...obj, [cur[0]]: cur[1] }), {})
// var point_out_split = component.getOutDisplay().split(' ');
// let key = Object.keys(facets).find(k => facets[k] === point_out_split[0]);
// if (key == undefined) {
// key = point_out_split[0];
// }
// var modify_target_device = {
// "device_number": target_device_number ? target_device_number : null,
// "point_name": point_name ? point_name : null,
// "value": key
// }
// //取得component當下就更新設備點位
// if (baja_subscribe_device_callback_func != undefined && baja_subscribe_device_callback_func != null) {
// if (component_index == total_component_index) {
// baja_subscribe_device_callback_func(modify_target_device, true);
// }
// else {
// baja_subscribe_device_callback_func(modify_target_device);
// }
// }
sub.subscribe({
comps: component,
});
subFinish = new Date(Date.now());
$("#sub-end").html(subFinish.toISOString());
$("#sub-time").html((subFinish.getTime() - subStart.getTime()) / 1000 + "sec");
// console.log("訂閱完成時間", (subFinish.getTime() - subStart.getTime()) / 1000 + "sec");
});
},
after: function () {
tableFinish = new Date(Date.now());
// $("#table-finish-timestamp").html(tableFinish.toISOString());
// $("#table-time").html((tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec");
console.log("表格完成時間", (tableFinish.getTime() - tableStart.getTime()) / 1000 + "sec");
},
limit: -1,
offset: 0
});
});
});
}
function getElevatorInfoByBaja(path, callback) {
var _result = "";
var _ss = '{';
var _index = 0;
//
require(['baja!'], function (baja) {
baja.Ord.make("local:|foxs:|station:|slot:/TPE/B1/ELEV/EL/R2F/NA/ELEV1/N1|bql:select name, displayName, out, out.value, slotPath, parent.name as 'device_number' from control:ControlPoint where name = 'CP' or name = 'RD' or name = 'DS' or name = 'ST' or name = 'LOAD' or name = 'MID' or name = 'HAND' or name = 'IND' or name = 'MD' or name = 'DNO'").get()
.then(function (table) {
return table.cursor({
each: function (record) {
var item = null;
var value = null;
if (record.get('name') == "CP") {
item = "floor";
value = record.get('out').get('value');
}
else if (record.get('name') == "RD") { //UP or DOWN
item = "direction";
value = record.get('out').get('value');
}
else if (record.get('name') == "DS") {
item = "door_state";
value = record.get('out').get('value') == true ? "OPEN" : "CLOSE";;
}
else if (record.get('name') == "ST") {
item = "running_status";
value = record.get('out').get('value');
}
else if (record.get('name') == "LOAD") {
item = "loading";
value = record.get('out').get('value');
}
else if (record.get('name') == "MID") {
item = "maintenance";
value = record.get('out').get('value');
}
else if (record.get('name') == "HAND") {
item = "manual";
value = record.get('out').get('value');
}
else if (record.get('name') == "IND") {
item = "independent";
value = record.get('out').get('value');
}
else if (record.get('name') == "MD") {
item = "vip";
value = record.get('out').get('value');
}
else if (record.get('name') == "DNO") {
item = "automatic";
value = record.get('out').get('value');
}
if (item != null && item != "")
{
if (_index == 0)
_ss += '{"item":"' + item + '", "value":"' + value + '"}';
else
_ss += ',{"item":"' + item + '", "value":"' + value + '"}';
_index++;
}
},
after: function () {
_result += '{' + '"count": ' + _index + ', "data":[';
_result += _ss;
_result += ']}';
if (typeof callback === 'function') {
callback(_result);
}
}
});
});
});
}

View File

@ -8,6 +8,32 @@
* @param {any} company * @param {any} company
* @param {any} callback * @param {any} callback
*/ */
// function getHistoryDataByBaja(devicePath, startDate_millisecond, endDate_millisecond, deviceName, company, callback) {
// var _result = "";
// var _ss = "";
// var _index = 0;
// require(['baja!'], function (baja) {
// 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) {
// return table.cursor({
// each: function (record) {
// _ss += ', "' + _index + '": {"deviceName":"' + deviceName + '", "value":' + record.get('value') + ', "timestamp":"' + record.get('timestamp') + '"}';
// _index++;
// },
// after: function () {
// _result += '{' + '"count": ' + _index;
// _result += _ss;
// _result += '}';
// if (typeof callback === 'function') {
// callback(_result);
// }
// }
// });
// });
// });
// }
function getHistoryDataByBaja(devicePath, startDate_millisecond, endDate_millisecond, deviceName, company, callback) { function getHistoryDataByBaja(devicePath, startDate_millisecond, endDate_millisecond, deviceName, company, callback) {
var _result = ""; var _result = "";
var _ss = ""; var _ss = "";
@ -36,5 +62,3 @@ function getHistoryDataByBaja(devicePath, startDate_millisecond, endDate_millise
}); });
}); });
} }

View File

@ -31,6 +31,8 @@ function setDropdownItem(menuEle) {
let actText = $(menuEle).find(".dropdown-item.active").first().text(); let actText = $(menuEle).find(".dropdown-item.active").first().text();
let actEleId = $(menuEle).prop("id"); let actEleId = $(menuEle).prop("id");
$(`.dropdown-toggle[data-target=${actEleId}]`).text(actText); $(`.dropdown-toggle[data-target=${actEleId}]`).text(actText);
/*actChaCallback($(menuEle).find(".dropdown-item.active"))*/
$(menuEle).trigger("active:change", $(menuEle).find(".dropdown-item.active")); $(menuEle).trigger("active:change", $(menuEle).find(".dropdown-item.active"));
//點選選項 add active class //點選選項 add active class

View File

@ -362,13 +362,13 @@ function initTableEvent() {
/// <summary> /// <summary>
/// jquery loaded 事件 /// jquery loaded 事件
/// </summary> /// </summary>
function loadCallback(callback) { //function loadCallback(callback) {
select2bs4(); // select2bs4();
Date_Pic(); // Date_Pic();
dataReadAttrbuite(); // dataReadAttrbuite();
callback ? callback() : ""; // callback ? callback() : "";
initCkeditor(); // initCkeditor();
} //}

10872
Frontend/js/yourteam/jquery.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -522,66 +522,66 @@ var initApp = (function(app) {
* @param anchor * @param anchor
* @return * @return
*/ */
app.listFilter = function (list, input, anchor) { //app.listFilter = function (list, input, anchor) {
/* add class to filter hide/show */ // /* add class to filter hide/show */
if (anchor) { // if (anchor) {
$(anchor).addClass('js-list-filter'); // $(anchor).addClass('js-list-filter');
} else { // } else {
$(list).addClass('js-list-filter'); // $(list).addClass('js-list-filter');
} // }
/* on change keyboard */ // /* on change keyboard */
$(input).change( function () { // $(input).change( function () {
var filter = $(this).val().toLowerCase(), // var filter = $(this).val().toLowerCase(),
listPrev = $(list).next().filter('.js-filter-message'); // listPrev = $(list).next().filter('.js-filter-message');
/* when user types more than 1 letter start search filter */ // /* when user types more than 1 letter start search filter */
if(filter.length > 1) { // if(filter.length > 1) {
/* this finds all data-filter-tags in a list that contain the input val, // /* this finds all data-filter-tags in a list that contain the input val,
hiding the ones not containing the input while showing the ones that do */ // hiding the ones not containing the input while showing the ones that do */
/* (1) hide all that does not match */ // /* (1) hide all that does not match */
$(list).find($("[data-filter-tags]:not([data-filter-tags*='" + filter + "'])")) // $(list).find($("[data-filter-tags]:not([data-filter-tags*='" + filter + "'])"))
.parentsUntil(list).removeClass('js-filter-show') // .parentsUntil(list).removeClass('js-filter-show')
.addClass('js-filter-hide'); // .addClass('js-filter-hide');
/* (2) hide all that does match */ // /* (2) hide all that does match */
$(list).find($("[data-filter-tags*='" + filter + "']")) // $(list).find($("[data-filter-tags*='" + filter + "']"))
.parentsUntil(list).removeClass('js-filter-hide') // .parentsUntil(list).removeClass('js-filter-hide')
.addClass('js-filter-show'); // .addClass('js-filter-show');
/* if element exists then print results */ // /* if element exists then print results */
if (listPrev){ // if (listPrev){
listPrev.text("showing " + $(list).find('li.js-filter-show').length + " from " + $(list).find('[data-filter-tags]').length + " total"); // listPrev.text("showing " + $(list).find('li.js-filter-show').length + " from " + $(list).find('[data-filter-tags]').length + " total");
} // }
} else { // } else {
/* when filter length is blank reset the classes */ // /* when filter length is blank reset the classes */
$(list).find('[data-filter-tags]').parentsUntil(list).removeClass('js-filter-hide js-filter-show'); // $(list).find('[data-filter-tags]').parentsUntil(list).removeClass('js-filter-hide js-filter-show');
/* if element exists reset print results */ // /* if element exists reset print results */
if (listPrev){ // if (listPrev){
listPrev.text(""); // listPrev.text("");
} // }
} // }
return false; // return false;
}).keyup( $.debounce( myapp_config.filterDelay, function (e) { // }).keyup( $.debounce( myapp_config.filterDelay, function (e) {
/* fire the above change event after every letter is typed with a delay of 250ms */ // /* fire the above change event after every letter is typed with a delay of 250ms */
$(this).change(); // $(this).change();
/*if(e.keyCode == 13) { // /*if(e.keyCode == 13) {
console.log( $(list).find(".filter-show:not(.filter-hide) > a") ); // console.log( $(list).find(".filter-show:not(.filter-hide) > a") );
}*/ // }*/
})); // }));
}; //};
/** /**
* Load scripts using lazyload method * Load scripts using lazyload method
@ -1296,15 +1296,15 @@ var initApp = (function(app) {
* Activate listFilters * Activate listFilters
* usage: <input id="inputID" data-listfilter="listFilter" /> * usage: <input id="inputID" data-listfilter="listFilter" />
**/ **/
if( typeof initApp.listFilter !== 'undefined' && $.isFunction(initApp.listFilter) && $('[data-listfilter]').length ) { //if( typeof initApp.listFilter !== 'undefined' && $.isFunction(initApp.listFilter) && $('[data-listfilter]').length ) {
var inputID = $('[data-listfilter]').attr('id'), // var inputID = $('[data-listfilter]').attr('id'),
listFilter = $('[data-listfilter]').attr("data-listfilter"); // listFilter = $('[data-listfilter]').attr("data-listfilter");
/* initApp.listFilter($('.list'), $('#intput-id')); */ // /* initApp.listFilter($('.list'), $('#intput-id')); */
initApp.listFilter(listFilter, '#' + inputID); // initApp.listFilter(listFilter, '#' + inputID);
} //}
/** /**
* Start bootstrap tooltips * Start bootstrap tooltips
@ -2147,7 +2147,7 @@ document.addEventListener('DOMContentLoaded', function() {
/** /**
* c. initialize nav filter * c. initialize nav filter
**/ **/
initApp.listFilter(myapp_config.navHooks, myapp_config.navFilterInput, myapp_config.navAnchor); /*initApp.listFilter(myapp_config.navHooks, myapp_config.navFilterInput, myapp_config.navAnchor);*/
/** /**
* d. run DOM misc functions * d. run DOM misc functions

5
Frontend/lib/require.js Normal file

File diff suppressed because one or more lines are too long