_Layout.cshtml 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
  6. <title>@ViewData["Title"] - UniversalApi_WebConsole_App</title>
  7. <link rel="stylesheet" href="~/WebConsole/lib/bootstrap/dist/css/bootstrap.min.css" />
  8. <link rel="stylesheet" href="~/WebConsole/css/site.css" />
  9. <link rel="stylesheet" href="~/WebConsole/css/commonlayout.css"/>
  10. <link rel="stylesheet" href="~/WebConsole/css/hint.css" />
  11. <link rel="stylesheet" href="~/WebConsole/css/index.css"/>
  12. <style type="text/css">
  13. .mydiv {
  14. position: absolute;
  15. bottom:0%;
  16. left: 0.8%;
  17. width: 83%;
  18. z-index: 9999;
  19. visibility: hidden;
  20. }
  21. .mydivNumber {
  22. position: absolute;
  23. z-index: 9999;
  24. visibility: hidden;
  25. top: 50%;
  26. left: 40%;
  27. width: 30%;
  28. }
  29. </style>
  30. </head>
  31. <body id="mainscreen_body">
  32. <header>
  33. <div id="common_header" class="commonheader" onclick="AlarmBarClicked(this.id)">
  34. <img id="common_header_left_normal" v-show="currentAlarmBarItem === undefined ||currentAlarmBarItem.Severity==='Information'"
  35. src="~/WebConsole/images/shared/headblueLeft.png" />
  36. <img id="common_header_left_warning" src="~/WebConsole/images/shared/headYellowLeft.png"
  37. v-show="currentAlarmBarItem !== undefined&&currentAlarmBarItem.Severity==='Warning'" />
  38. <img id="common_header_left_alarm" src="~/WebConsole/images/shared/headRedLeft.png"
  39. v-show="currentAlarmBarItem !== undefined&&(currentAlarmBarItem.Severity==='Error'||
  40. currentAlarmBarItem.Severity==='Fatal')" />
  41. <div id="common_header_informations">
  42. <span id="common_header_left_text" v-if="currentAlarmBarItem !== undefined" style="left: 0%; width: 100%;visibility:hidden;">
  43. {{currentAlarmBarItem.Title}}
  44. </span>
  45. </div>
  46. <img id="common_header_right_date_img" src="~/WebConsole/images/shared/headRight.png" />
  47. <span id="common_header_right_text">
  48. @DateTime.Now.ToShortDateString()
  49. </span>
  50. </div>
  51. </header>
  52. <div id="smartfuel_main_view">
  53. @RenderBody()
  54. <div id="alarm_information" @*v-show="showAlarmHistoryForm"*@ style="visibility:hidden;">
  55. <div id="alarm_table">
  56. <table id="alarm_table_infos" class="alarmTable">
  57. <thead class="tableRow">
  58. <tr>
  59. <th v-for="(h,i) in headers" :key="i" :class="h.class" style="text-align:center;">{{h.text}}</th>
  60. </tr>
  61. </thead>
  62. <tbody class="alarmTableBody">
  63. <tr class="tableRow" v-for="(alarm,i) in genericAlarmList" :key="i">
  64. @*<td class="tableData2">{{alarm.Severity}}</td>*@
  65. <td class="tableDataSeverity">
  66. <i :class="(alarm.Severity==='Fatal'||alarm.Severity==='Error')?'redCircle':
  67. (alarm.Severity==='Warning'?'yellowCircle':'blueCircle')"></i>
  68. </td>
  69. <td class="tableData2Hide" onclick="showDetails(this)">{{alarm.Title}}</td>
  70. <td class="tableData2Hide" onclick="showDetails(this)">{{alarm.OriginatorDisplayName}}</td>
  71. <td class="tableData2" v-if="alarm.ClosedTimestamp===null">{{formatTime(alarm.OpeningTimestamp)}}</td>
  72. <td class="tableData2" v-else>{{formatTime(alarm.OpeningTimestamp)}}({{formatTime(alarm.ClosedTimestamp)}}<a @@click="showCloseReason(alarm)" style="color: #1cd4f8; font-size: 1.2rem; text-decoration: underline; text-decoration-color: #0094ff;">关结</a>)</td>
  73. <td class="tableData3" onclick="showDetails(this)">{{alarm.Detail}}</td>
  74. <td class="tableData1">
  75. <img v-show="alarm.AckedTimestamp === null" class="muteImg" @@click="AckGenericAlarm(alarm)" />
  76. <img v-show="alarm.AckedTimestamp !== null" class="alarmImg" @@click="AckGenericAlarm(alarm)" />
  77. <img v-show="alarm.ClosedTimestamp===null" class="closeImg" @@click="closeAlarm(alarm)" />
  78. <img v-show="alarm.ClosedTimestamp !==null" class="closedImg" />
  79. </td>
  80. </tr>
  81. </tbody>
  82. </table>
  83. <div id="details" style="position:absolute;visibility:hidden;background-color: rgba(0, 0, 0, .4)">
  84. <div id="detail_button" class="messageButtonDiv">
  85. <input type="button" class="messageButton" value="關閉" onclick="hidenTheDetailsForm()" />
  86. </div>
  87. <div id="detail_message" class="messageDiv">{{detailMessage}}</div>
  88. </div>
  89. </div>
  90. <div id="alarm_pageInfo">
  91. <div class="pageStepDiv" onclick="previous()"><img class="pageStepImg" src="~/WebConsole/images/smartFuel/prePage.png"/></div>
  92. <div class="pageStepDiv" onclick="next()"><img class="pageStepImg" src="~/WebConsole/images/smartFuel/nextPage.png" /></div>
  93. </div>
  94. <img id="alarm_closeButton" src="/WebConsole/images/shared/closeButton.png" class="closeAlarmFormButton" onclick="AlarmBarClicked(this.id)" />
  95. <img id="alarm_query" src="/WebConsole/images/device/filter.png" class="alarmFilter" onclick="showAlarmQuery()" />
  96. <div id="alarm_query_form" v-show="showFilterForm" class="alarmQueryForm">
  97. <div id="alarm_query_option1" class="option1Div">
  98. <p>篩選條件:</p>
  99. <select v-model="option1" @@change="option1Change">
  100. <option v-for="(item, i) in options1" :key="i" :value="item.value">{{ item.text }}</option>
  101. </select>
  102. </div>
  103. <div v-show="option1!==0" id="alarm_query_option2" class="option2Div">
  104. @*<p>详细信息:</p>*@
  105. <ul class="queryUl">
  106. <li v-for="(item, i) in selectedList" :key="i">
  107. <p><input type="checkbox" v-model="item.checked" value="item.value" />{{item.value}}</p>
  108. </li>
  109. </ul>
  110. </div>
  111. <div id="alarm_query_search" class="searchDiv">
  112. <img id="alarm_query_search_img" src="~/WebConsole/images/onlineMonitor/chartView/table.png" class="searchImg" onclick="showQueryReslut()" />
  113. </div>
  114. </div>
  115. </div>
  116. <div class="alarmInfoWrap hide">
  117. <div class="wrap-dialog hide">
  118. <div class="dialog">
  119. <div class="dialog-header">
  120. <span class="dialog-title"></span>
  121. </div>
  122. <div class="dialog-body">
  123. <span class="dialog-message"></span>
  124. </div>
  125. <div class="dialog-footer">
  126. <input type="button" class="btn" id="confirm" value="確認" />
  127. <input type="button" class="btn ml50" id="cancel" value="取消" />
  128. </div>
  129. </div>
  130. </div>
  131. </div>
  132. </div>
  133. <div class="fullScrrenWrap hide">
  134. <div class="input-dialog" id="input_dialog_wrap">
  135. <div class="dialog">
  136. <div class="dialog-header">
  137. <span class="input-dialog-title"></span>
  138. </div>
  139. <div class="dialog-body">
  140. <input class="input-box" id="input_value" type="password"/>
  141. </div>
  142. <div class="dialog-footer">
  143. <input type="button" class="btn" id="input_confirm" value="確認" />
  144. <input type="button" class="btn ml50" id="input_cancel" value="取消" />
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. <div id="mydiv" class="mydiv"><div id="mydivheader" class="simple-keyboard"></div></div>
  150. <div id="common_popupMenu">
  151. <div class="popupMenuItem" v-for="(menuItem, i) in bottomPopupMenuItems " :key="i" @@click="menuItemClicked(menuItem)">
  152. {{menuItem.dispalyText}}
  153. </div>
  154. </div>
  155. <footer>
  156. @*<div id="mydiv"><div id="mydivheader" class="simple-keyboard"></div></div>*@
  157. <div id="common_footer">
  158. <img id="common_footer_img" draggable="false" src="~/WebConsole/images/shared/smartFuelFooter.png" />
  159. <div class="menuItemDiv">
  160. <a class="menuItem" draggable="false" v-for="(item, i) in bottonMenuItems" :key="i" @@click="menuItemClicked(item)" @*:href="item.LinkUrl"*@>
  161. <img draggable="false" class="menuItemImg" :src="item.IconUrl" />
  162. </a>
  163. </div>
  164. <!--<a id="common_footer_smartfuel" draggable="false" asp-controller="SmartFuel" asp-action="Index" style="left:40.625%;">
  165. <img draggable="false" src="/WebConsole/images/shared/nozzle.png">
  166. </a>
  167. <a id="common_footer_tank" draggable="false" asp-controller="TankDetails" asp-action="Index" style="left:50.234%;">
  168. <img draggable="false" src="/WebConsole/images/shared/tank.png">
  169. </a>
  170. <a id="common_footer_fairbanks" draggable="false" asp-controller="FairBanks" asp-action="Index" style="left:59.844%;">
  171. <img draggable="false" src="/WebConsole/images/shared/fairBanks.png">
  172. </a>
  173. <a id="common_footer_settings" draggable="false" asp-controller="Config" asp-action="Index" style="left:69.453%;">
  174. <img draggable="false" src="/WebConsole/images/shared/settings.png">
  175. </a>
  176. <a id="common_footer_restart" draggable="false"-->
  177. @*asp-controller="" asp-action=""*@
  178. <!--style="left:79.063%;">
  179. <img draggable="false" src="/WebConsole/images/shared/restart.png">
  180. </a>
  181. <a id="common_footer_exist" draggable="false"-->
  182. @*asp-controller="" asp-action=""*@
  183. <!--style="left:88.672%;">
  184. <img draggable="false" src="/WebConsole/images/shared/exit.png">
  185. </a>-->
  186. </div>
  187. </footer>
  188. <script src="~/WebConsole/js/index.js"></script>
  189. <script src="~/WebConsole/lib/jquery/dist/jquery.min.js"></script>
  190. <script src="~/WebConsole/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
  191. <script src="~/WebConsole/js/site.js" asp-append-version="true"></script>
  192. @*<script src="~/WebConsole/js/signalr/dist/browser/signalr.js"></script>*@
  193. @*<script src="~/WebConsole/js/alarmBar.js"></script>*@
  194. <script src="~/WebConsole/js/mqtt.min.js"></script>
  195. @*<script src="~/WebConsole/js/AlarmBarClient.js"></script>*@
  196. <script type="text/javascript" src="~/WebConsole/js/vue.min.js"></script>
  197. <script src="~/WebConsole/js/alarms.js"></script>
  198. @RenderSection("Scripts", required: false)
  199. <script>
  200. // Make the DIV element draggable:
  201. dragElement(document.getElementById("mydiv"));
  202. function dragElement(elmnt) {
  203. var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
  204. if (document.getElementById(elmnt.id + "header")) {
  205. // if present, the header is where you move the DIV from:
  206. document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
  207. } else {
  208. // otherwise, move the DIV from anywhere inside the DIV:
  209. elmnt.onmousedown = dragMouseDown;
  210. }
  211. function dragMouseDown(e) {
  212. e = e || window.event;
  213. e.preventDefault();
  214. // get the mouse cursor position at startup:
  215. pos3 = e.clientX;
  216. pos4 = e.clientY;
  217. document.onmouseup = closeDragElement;
  218. // call a function whenever the cursor moves:
  219. document.onmousemove = elementDrag;
  220. }
  221. function elementDrag(e) {
  222. e = e || window.event;
  223. e.preventDefault();
  224. // calculate the new cursor position:
  225. pos1 = pos3 - e.clientX;
  226. pos2 = pos4 - e.clientY;
  227. pos3 = e.clientX;
  228. pos4 = e.clientY;
  229. // set the element's new position:
  230. elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
  231. elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
  232. }
  233. function closeDragElement() {
  234. // stop moving when mouse button is released:
  235. document.onmouseup = null;
  236. document.onmousemove = null;
  237. }
  238. }
  239. </script>
  240. <script>
  241. var alarmsCategoryMap = new Map();
  242. var alarmsOriginalMap = new Map();
  243. var layoutvm = new Vue({
  244. el: '#alarm_information',
  245. data: {
  246. page: 1,
  247. pageCount: 10,
  248. genericAlarmList: [],
  249. showAlarmHistoryForm: false,
  250. showFilterForm: false,
  251. alarmCount: 0,
  252. warningCount: 0,
  253. alarmBarItem: null,
  254. option1: 0,
  255. categoryList: [],
  256. orignialList: [],
  257. selectedList: [],
  258. tableDataSource: [],
  259. detailMessage: "",
  260. options1: [{ text: "所有", value: 0 }, { text: "來源", value: 1 }, { text: "分類", value: 2 }],
  261. headers: [{ text: "級別", class: "tableData0" }, { text: "標題", class: "tableData2" }, { text: "來源", class: "tableData2" },
  262. { text: "發生時間", class: "tableData2" }, { text: "詳情", class: "tableData3" }, { text: "操作", class: "tableData1" }]
  263. },
  264. methods: {
  265. },
  266. mounted: function () {
  267. console.log("layout mouted");
  268. }
  269. });
  270. var alarmBarVm = new Vue({
  271. el: '#common_header',
  272. data: {
  273. currentAlarmBarItem: { Title: "", Severity: "Information", PersistId: -1 },
  274. },
  275. }
  276. );//Information Fatal,Error,Warning,
  277. var hrefTemp = window.location.href;
  278. var pathTemp = window.location.pathname;
  279. let basicUrlTemp = href.slice(0, href.indexOf(path));
  280. var defaultBottomMenu = [{ "IconUrl": "/WebConsole/images/shared/nozzle.png", "LinkUrl": basicUrlTemp + "/SmartFuel", "Action": "" },
  281. { "IconUrl": "/WebConsole/images/shared/tank.png", "LinkUrl": basicUrlTemp + "/TankDetails", "Action": "" },
  282. { "IconUrl": "/WebConsole/images/shared/fairBanks.png", "LinkUrl": basicUrlTemp + "/FairBanks", "Action": "" },
  283. { "IconUrl": "/WebConsole/images/shared/settings.png", "LinkUrl": basicUrlTemp + "/Config", "Action": "" },
  284. { "IconUrl": "/WebConsole/images/shared/restart.png", "LinkUrl": "", "Action": "" },
  285. { "IconUrl": "/WebConsole/images/shared/exit.png", "LinkUrl": "", "Action": "" }
  286. ];
  287. var bottomMenuVm = new Vue({
  288. el: '#common_footer',
  289. data: {
  290. bottonMenuItems: []
  291. }
  292. });
  293. var bottomPopupMenuVm = new Vue({
  294. el: '#common_popupMenu',
  295. data: {
  296. bottomPopupMenuItems: []
  297. }
  298. });
  299. function getGenericAlarmHistory(initialget, severity, category, originator) {
  300. var href = window.location.href;
  301. var path = window.location.pathname;
  302. let basicUrl = href.slice(0, href.indexOf(path));
  303. let clientAcceptLanguage = navigator.language;
  304. let serviceUrl = basicUrl + "/u/?apitype=service&an=GetGenericAlarmHistoryAsync&pn=ProcessorsDispatcher&en=Edge.Core.Processor.Dispatcher.DefaultDispatcher";
  305. let parameter = [null, null, severity, originator, category, true, false, layoutvm.page - 1, layoutvm.pageCount, clientAcceptLanguage];
  306. //[null, null, null, severity,null, true, false, 0, 9999, ""];
  307. $.ajax({
  308. url: serviceUrl,
  309. datatype: "application/json",
  310. type: 'post',
  311. contentType: "application/json;charset=utf-8;",
  312. data: JSON.stringify(parameter),
  313. beforeSend: function () {
  314. },
  315. success: function (data) {
  316. console.log(data);
  317. layoutvm.genericAlarmList = Array.isArray(data) ? data : [];
  318. if (initialget) {
  319. if (data.length > 0 && alarmBarVm.currentAlarmBarItem.PersistId === -1)
  320. alarmBarVm.currentAlarmBarItem = data[0];
  321. var alarmTextSpan = document.getElementById("common_header_left_text");
  322. if (alarmTextSpan && alarmTextSpan.style.visibility === 'hidden') {
  323. alarmTextSpan.style.visibility = 'visible';
  324. }
  325. }
  326. toAddAlarmAudio();
  327. },
  328. error: function (err) {
  329. layoutvm.genericAlarmList = [];
  330. }
  331. });
  332. }
  333. //如果当前页或者顶部栏有报警,需要响警报
  334. function toAddAlarmAudio() {
  335. var hasFatalAlarm = false;
  336. var topBarAlarmInList = false;
  337. if (layoutvm.genericAlarmList && Array.isArray(layoutvm.genericAlarmList) && layoutvm.genericAlarmList.length > 0) {
  338. layoutvm.genericAlarmList.forEach(function (alarm) {
  339. if ((alarm.Severity === 'Error' || alarm.Severity === "Fatal") &&
  340. alarm.AckedTimestamp === null && alarm.ClosedTimestamp === null) {
  341. hasFatalAlarm = true;
  342. }
  343. if (alarmBarVm.currentAlarmBarItem !== undefined &&
  344. (alarm.Id === alarmBarVm.currentAlarmBarItem.PersistId ||
  345. alarmBarVm.currentAlarmBarItem.Id === alarm.Id)) {
  346. topBarAlarmInList = true;
  347. }
  348. });
  349. }
  350. if (hasFatalAlarm)
  351. {
  352. addAlarmAudio();
  353. } else if (topBarAlarmInList) {
  354. removeAlarmAudio();
  355. }
  356. }
  357. function getGenericAlarmsSummaryAsync() {
  358. var href = window.location.href;
  359. var path = window.location.pathname;
  360. let basicUrl = href.slice(0, href.indexOf(path));
  361. let clientAcceptLanguage = navigator.language;
  362. let serviceUrl = basicUrl + "/u/?apitype=service&an=GetGenericAlarmsSummaryAsync&pn=ProcessorsDispatcher&en=Edge.Core.Processor.Dispatcher.DefaultDispatcher";
  363. let parameter = [clientAcceptLanguage];
  364. $.ajax({
  365. url: serviceUrl,
  366. datatype: "application/json",
  367. type: 'post',
  368. contentType: "application/json;charset=utf-8;",
  369. data: JSON.stringify(parameter),
  370. beforeSend: function () {
  371. },
  372. success: function (data) {
  373. console.log(data);
  374. layoutvm.categoryList = [];
  375. layoutvm.orignialList = [];
  376. if (data !== null && Array.isArray(data.Categories)) {
  377. data.Categories.forEach(function (category, i) {
  378. if (category !== null) {
  379. layoutvm.categoryList.push({ checked: false, value: category });
  380. }
  381. });
  382. }
  383. if (data && Array.isArray(data.Originators)) {
  384. data.Originators.forEach(function (originator, i) {
  385. if (originator !== null) {
  386. layoutvm.orignialList.push({ checked: false, value: originator });
  387. }
  388. });
  389. }
  390. },
  391. error: function (err) {
  392. layoutvm.categoryList = [];
  393. layoutvm.orignialList = [];
  394. }
  395. });
  396. }
  397. $(document).ready(function () {
  398. //console.log("Joy layout ready");
  399. getGenericAlarmHistory(true, null, null, null);
  400. getWebConsoleAPI(["webapi", ["WebConsole"]], function (apiPath) {
  401. if (apiPath === null || apiPath === undefined || apiPath === "") {
  402. bottomMenuVm.bottonMenuItems = defaultBottomMenu.reverse();
  403. return;
  404. }
  405. var href = window.location.href;
  406. var path = window.location.pathname;
  407. let basicUrl = href.slice(0, href.indexOf(path));
  408. var serviceUrl = basicUrl + apiPath;
  409. $.ajax({
  410. url: serviceUrl,
  411. datatype: "application/json",
  412. type: 'post',
  413. contentType: "application/json;charset=utf-8;",
  414. beforeSend: function () {
  415. },
  416. success: function (data) {
  417. console.log(data);
  418. if (data !== null && data.LayoutConfig !== null && data.LayoutConfig !== undefined &&
  419. data.LayoutConfig.NaviMenuConfig && data.LayoutConfig.NaviMenuConfig.MenuItemConfigs !== undefined &&
  420. Array.isArray(data.LayoutConfig.NaviMenuConfig.MenuItemConfigs) &&
  421. data.LayoutConfig.NaviMenuConfig.MenuItemConfigs.length > 0) {
  422. var tempItems = [];
  423. data.LayoutConfig.NaviMenuConfig.MenuItemConfigs.forEach(function (item, i) {
  424. if (item !== null) {
  425. tempItems.push(item);
  426. }
  427. });
  428. bottomMenuVm.bottonMenuItems = tempItems.length > 0 ? tempItems.reverse() : defaultBottomMenu.reverse();
  429. } else {
  430. bottomMenuVm.bottonMenuItems = defaultBottomMenu.reverse();
  431. }
  432. },
  433. error: function (err) {
  434. console.log(err);
  435. bottomMenuVm.bottonMenuItems = defaultBottomMenu.reverse();
  436. }
  437. });
  438. });
  439. });
  440. function showDetails(obj) {
  441. if (obj.offsetWidth < obj.scrollWidth) {
  442. //var that = this;
  443. layoutvm.detailMessage = obj.textContent;
  444. var messageDiv = document.getElementById("details");
  445. if (messageDiv === null) return;
  446. messageDiv.style = "position:absolute;width:" + obj.offsetWidth + "px;height:" + 3 * obj.offsetHeight + "px;left:" +
  447. obj.offsetLeft + "px;top:" + obj.offsetTop + "px;visibility:visible;border:none;background-color: rgba(0, 0, 0, .4);" +
  448. "box-shadow:gainsboro 2px 2px 3px 2px;";
  449. }
  450. };
  451. function showCloseReason(alarm) {
  452. layoutvm.detailMessage = alarm.ClosedReason;
  453. //alert(alarm.ClosedReason);
  454. var messageDiv = document.getElementById("details");
  455. if (messageDiv === null) return;
  456. messageDiv.style = "position:absolute;width:20%;height:20%;left:40%;top:30%;visibility:visible;background-image:url('/WebConsole/images/onlineMonitor/chartView/background_query.png');background-repeat:no-repeat;background-size:100% 100%; border:none;" +
  457. "box-shadow:gainsboro 2px 2px 3px 2px;";
  458. }
  459. function hidenTheDetailsForm() {
  460. layoutvm.detailMessage = "";
  461. var messageDiv = document.getElementById("details");
  462. if (messageDiv === null) return;
  463. messageDiv.style.visibility = "hidden";
  464. }
  465. function option1Change() {
  466. //console.log("Joy option1Change");
  467. //选择所有时不需要展示其他选项
  468. layoutvm.selectedList = layoutvm.option1 === 1 ? layoutvm.orignialList :
  469. (layoutvm.option1 === 2 ? layoutvm.categoryList : []);
  470. }
  471. function previous() {
  472. if (layoutvm.page === 1) { dialogBox("提示信息", "已經是第一頁", null, null); return; }
  473. layoutvm.page = layoutvm.page - 1;
  474. if (layoutvm.option1 === 0) {
  475. getGenericAlarmHistory(true, null, null, null);
  476. return;
  477. }
  478. var temp = [];
  479. if (layoutvm.selectedList !== null && Array.isArray(layoutvm.selectedList)) {
  480. layoutvm.selectedList.forEach(function (item, i) {
  481. if (item.checked)
  482. temp.push(item.value);
  483. });
  484. }
  485. if (layoutvm.option1 === 1) {
  486. getGenericAlarmHistory(true, null, null, temp);
  487. return;
  488. }
  489. if (layoutvm.option1 === 2) {
  490. getGenericAlarmHistory(true, null, temp, null);
  491. return;
  492. }
  493. //if (layoutvm.tableDataSource.length === 0) {
  494. // layoutvm.genericAlarmList = [];
  495. // return;
  496. //}
  497. //let dataLength = layoutvm.tableDataSource.length;
  498. //let startIndex = (layoutvm.page - 1) * layoutvm.pageCount;
  499. //var count =
  500. // (dataLength - layoutvm.pageCount * (layoutvm.page - 1)) > layoutvm.pageCount
  501. // ? layoutvm.pageCount
  502. // : (dataLength - layoutvm.pageCount * (layoutvm.page - 1));
  503. //layoutvm.genericAlarmList = layoutvm.tableDataSource.slice(startIndex, startIndex + count);
  504. }
  505. function next() {
  506. //if (layoutvm.option1 !== 0 &&
  507. // !(layoutvm.tableDataSource.length > layoutvm.page * layoutvm.pageCount)) {
  508. // alert("已是最后一页");
  509. // return;
  510. //}
  511. if (layoutvm.genericAlarmList.length < layoutvm.pageCount) {
  512. //alertDialog("已經是最後一頁");
  513. dialogBox("提示信息", "已經是最後一頁", null, null)
  514. return;
  515. }
  516. layoutvm.page = layoutvm.page + 1;
  517. if (layoutvm.option1 === 0) {
  518. getGenericAlarmHistory(true, null, null, null);
  519. return;
  520. }
  521. var temp = [];
  522. if (layoutvm.selectedList !== null && Array.isArray(layoutvm.selectedList)) {
  523. layoutvm.selectedList.forEach(function (item, i) {
  524. if (item.checked)
  525. temp.push(item.value);
  526. });
  527. }
  528. if (layoutvm.option1 === 1) {
  529. getGenericAlarmHistory(true, null, null, temp);
  530. return;
  531. }
  532. if (layoutvm.option1 === 2) {
  533. getGenericAlarmHistory(true, null, temp, null);
  534. return;
  535. }
  536. //if (layoutvm.tableDataSource.length === 0) {
  537. // layoutvm.genericAlarmList = [];
  538. // return;
  539. //}
  540. //let dataLength = layoutvm.tableDataSource.length;
  541. //let startIndex = (layoutvm.page - 1) * layoutvm.pageCount;
  542. //var count =
  543. // (dataLength - layoutvm.pageCount * (layoutvm.page - 1)) > layoutvm.pageCount
  544. // ? layoutvm.pageCount
  545. // : (dataLength - layoutvm.pageCount * (layoutvm.page - 1));
  546. //layoutvm.genericAlarmList = layoutvm.tableDataSource.slice(startIndex, startIndex + count);
  547. }
  548. function formatTime(timeString) {
  549. if (timeString === null) {
  550. return "";
  551. }
  552. var currentYear = new Date().getFullYear();
  553. return (currentYear === new Date(timeString).getFullYear() ? "" : (new Date(timeString).getFullYear() + "-")) + Pad1(new Date(timeString).getMonth()
  554. + 1, 2) + "-" + Pad1(new Date(timeString).getDate(), 2) + " " + Pad1(new Date(timeString).getHours(), 2) +
  555. ":" + Pad1(new Date(timeString).getMinutes(), 2);
  556. }
  557. function Pad1(num, n) {
  558. var len = num.toString().length;
  559. while (len < n) {
  560. num = "0" + num;
  561. len++;
  562. }
  563. return num;
  564. }
  565. function AlarmBarClicked(id) {
  566. var alarmForm = document.getElementById("alarm_information");
  567. if (alarmForm === null || alarmForm === undefined) return;
  568. layoutvm.showAlarmHistoryForm = id === "common_header" ? true : false;
  569. if (layoutvm.showAlarmHistoryForm) {
  570. layoutvm.page = 1;
  571. layoutvm.option1 = 0;
  572. layoutvm.showFilterForm = false;
  573. alarmForm.style.visibility = "visible";
  574. getGenericAlarmHistory(true, null);
  575. } else {
  576. alarmForm.style.visibility = "hidden";
  577. }
  578. }
  579. function AckGenericAlarm(alarm) {
  580. if (alarm === undefined || alarm === null) return;
  581. var href = window.location.href;
  582. var path = window.location.pathname;
  583. let basicUrl = href.slice(0, href.indexOf(path));
  584. var preAlertMsg = alarm.AckedTimestamp === null ? "靜音" : "解除靜音";
  585. let serviceUrl = basicUrl + "/u/?apitype=service&an=AckGenericAlarmAsync&pn=ProcessorsDispatcher&en=Edge.Core.Processor.Dispatcher.DefaultDispatcher";
  586. let parameter = [alarm.Id, preAlertMsg + "from webconsole", alarm.AckedTimestamp === null ? false : true];
  587. $.ajax({
  588. url: serviceUrl,
  589. datatype: "application/json",
  590. type: 'post',
  591. contentType: "application/json;charset=utf-8;",
  592. data: JSON.stringify(parameter),
  593. beforeSend: function () {
  594. },
  595. success: function (data) {
  596. console.log(data);
  597. if (data === true) {
  598. alarm.AckedTimestamp = alarm.AckedTimestamp === null ? " " : null;
  599. toAddAlarmAudio();
  600. //alertDialog(preAlertMsg + "成功");
  601. dialogBox("提示信息", preAlertMsg + "成功", null, null);
  602. }
  603. },
  604. error: function (err) {
  605. //alertDialog(preAlertMsg + "失敗");
  606. dialogBox("提示信息", preAlertMsg + "失敗", null, null);
  607. }
  608. });
  609. }
  610. function closeAlarm(alarm) {
  611. if (alarm === undefined || alarm === null) return;
  612. dialogBox("確定問題已解決?", "標記此问题为已经解决,系统不再追踪此问题( 但如果系统再次检测到问题,则仍会发出通知)", function () {
  613. var href = window.location.href;
  614. var path = window.location.pathname;
  615. let basicUrl = href.slice(0, href.indexOf(path));
  616. let serviceUrl = basicUrl + "/u/?apitype=service&an=CloseGenericAlarmAsync&pn=ProcessorsDispatcher&en=Edge.Core.Processor.Dispatcher.DefaultDispatcher";
  617. let parameter = [alarm.Id, "從webconsole關結"];
  618. $.ajax({
  619. url: serviceUrl,
  620. datatype: "application/json",
  621. type: 'post',
  622. contentType: "application/json;charset=utf-8;",
  623. data: JSON.stringify(parameter),
  624. beforeSend: function () {
  625. },
  626. success: function (data) {
  627. console.log(data);
  628. if (data === true) {
  629. alarm.ClosedTimestamp = new Date();
  630. alarm.ClosedReason = "页面手动关闭";
  631. toAddAlarmAudio();
  632. //removeAlarmAudio();
  633. dialogBox("提示信息", "關閉成功", null, null);
  634. }
  635. },
  636. error: function (err) {
  637. dialogBox("提示信息", "關閉失敗", null, null);
  638. }
  639. });
  640. }, null, true);
  641. }
  642. function dialogBox(title, message, yesCallback, noCallback) {
  643. if (message) {
  644. $('.dialog-title').html(title);
  645. $('.dialog-message').html(message);
  646. }
  647. // 显示遮罩和对话框
  648. $('.wrap-dialog').removeClass("hide");
  649. $('.alarmInfoWrap').removeClass("hide");
  650. // 确定按钮
  651. $('#confirm').click(function () {
  652. $('.wrap-dialog').addClass("hide");
  653. $('.alarmInfoWrap').addClass("hide");
  654. noCallback = null;
  655. if (yesCallback !== null && yesCallback !== undefined) {
  656. yesCallback();
  657. yesCallback = null;
  658. }
  659. });
  660. // 取消按钮
  661. $('#cancel').click(function () {
  662. yesCallback = null;
  663. $('.wrap-dialog').addClass("hide");
  664. $('.alarmInfoWrap').addClass("hide");
  665. if (noCallback !== null && noCallback !== undefined) {
  666. noCallback();
  667. noCallback = null;
  668. }
  669. });
  670. }
  671. function inputDialog(title, value, yesCallback, noCallback) {
  672. if (title) {
  673. $('.input-dialog-title').html(title);
  674. }
  675. // 显示遮罩和对话框
  676. $('.fullScrrenWrap').removeClass("hide");
  677. $('#input_value').click(function (e) {
  678. showKeyboard('number', e.currentTarget);
  679. });
  680. // 确定按钮
  681. $('#input_confirm').click(function () {
  682. $('.fullScrrenWrap').addClass("hide");
  683. noCallback = null;
  684. hideKeyboard();
  685. if (yesCallback !== null && yesCallback !== undefined) {
  686. yesCallback($('#input_value')[0].value);
  687. $('#input_value')[0].value = "";
  688. //var inputValueItem = document.getElementById("input_value");
  689. //inputValueItem.value = "";
  690. yesCallback = null;
  691. }
  692. });
  693. // 取消按钮
  694. $('#input_cancel').click(function () {
  695. yesCallback = null;
  696. $('.fullScrrenWrap').addClass("hide");
  697. $('#input_value')[0].value = "";
  698. hideKeyboard();
  699. //var inputValueItem = document.getElementById("input_value");
  700. //inputValueItem.value = "";
  701. if (noCallback !== null && noCallback !== undefined) {
  702. noCallback();
  703. noCallback = null;
  704. }
  705. });
  706. }
  707. function menuItemClicked(menuItem) {
  708. var displayPopupMenu = false;
  709. var action = null;
  710. if (typeof (menuItem.Action) === "object") {
  711. action = menuItem.Action;
  712. } else {
  713. action = menuItem.Action === undefined || menuItem.Action === null ? null : parsJsonStr(menuItem.Action);
  714. }
  715. let popUpMenu = null;
  716. if (action !== null && action.type === "menu" && action.items) {
  717. if (!bottomPopupMenuVm) return;
  718. popUpMenu = document.getElementById("common_popupMenu");
  719. if (popUpMenu && popUpMenu.style.visibility === "visible") {
  720. popUpMenu.style.visibility = "hidden";
  721. return;
  722. }
  723. bottomPopupMenuVm.bottomPopupMenuItems = action.items;
  724. displayPopupMenu = true;
  725. }else if (action !== null && action.type === "input") {
  726. inputDialog(action.prompt, action.value, function (inputText) {
  727. if (inputText !== action.value) {
  728. dialogBox("提示信息", "輸入信息錯誤!", null, null);
  729. return;
  730. }
  731. window.location = menuItem.LinkUrl;
  732. }, null);
  733. } else {
  734. window.location = menuItem.LinkUrl;
  735. }
  736. if (popUpMenu) {
  737. popUpMenu.style.visibility = displayPopupMenu ? "visible" : "hidden";
  738. }
  739. }
  740. function parsJsonStr(jsonStr) {
  741. var reslut = null
  742. try {
  743. reslut = JSON.parse(jsonStr);
  744. } catch (e) {
  745. reslut = null;
  746. }
  747. return reslut;
  748. }
  749. function showAlarmQuery() {
  750. //alarmsCategoryMap.clear();
  751. //alarmsOriginalMap.clear();
  752. layoutvm.orignialList = [];
  753. layoutvm.categoryList = [];
  754. getGenericAlarmsSummaryAsync();
  755. //if (!layoutvm.showFilterForm)
  756. // getGenericAlarmHistory(false, null);
  757. layoutvm.showFilterForm = !layoutvm.showFilterForm;
  758. }
  759. function processAlarms(alarmsList) {
  760. if (alarmsList === null) {
  761. layoutvm.categoryList = [];
  762. layoutvm.orignialList = [];
  763. return;
  764. }
  765. alarmsList.forEach(function (alarm, index) {
  766. if (alarmsCategoryMap.size > 0 && !alarmsCategoryMap.has(alarm.Category) ||
  767. alarmsCategoryMap.size === 0) {
  768. if (alarm.Category !== null) {
  769. let tempArray = new Array();
  770. tempArray.push(alarm);
  771. alarmsCategoryMap.set(alarm.Category, tempArray);
  772. layoutvm.categoryList.push({ checked: false, value: alarm.Category });
  773. }
  774. } else if (alarmsCategoryMap.has(alarm.Category)) {
  775. alarmsCategoryMap.get(alarm.Category).push(alarm);
  776. }
  777. if (alarmsOriginalMap.size > 0 && !alarmsOriginalMap.has(alarm.OriginatorDisplayName) ||
  778. alarmsOriginalMap.size === 0) {
  779. if (alarm.OriginatorDisplayName !== null) {
  780. let tempArray = new Array();
  781. tempArray.push(alarm);
  782. alarmsOriginalMap.set(alarm.OriginatorDisplayName, tempArray);
  783. layoutvm.orignialList.push({ checked: true, value: alarm.OriginatorDisplayName });
  784. }
  785. } else if (alarmsOriginalMap.has(alarm.OriginatorDisplayName)) {
  786. alarmsOriginalMap.get(alarm.OriginatorDisplayName).push(alarm);
  787. }
  788. });
  789. }
  790. function showQueryReslut() {
  791. layoutvm.tableDataSource = [];
  792. layoutvm.page = 1;
  793. layoutvm.showFilterForm = false;
  794. //所有
  795. if (layoutvm.option1 === 0) {
  796. getGenericAlarmHistory(true, null, null, null);
  797. return;
  798. }
  799. var temp = [];
  800. if (layoutvm.selectedList !== null && Array.isArray(layoutvm.selectedList)) {
  801. layoutvm.selectedList.forEach(function (item, i) {
  802. if (item.checked)
  803. temp.push(item.value);
  804. });
  805. }
  806. if (layoutvm.option1 === 1) {
  807. getGenericAlarmHistory(true, null, null, temp);
  808. return;
  809. }
  810. if (layoutvm.option1 === 2) {
  811. getGenericAlarmHistory(true, null, temp, null);
  812. return;
  813. }
  814. ////来源
  815. //if (layoutvm.option1 === 1) {
  816. // layoutvm.selectedList.forEach(function (item, index) {
  817. // if (item.checked && alarmsOriginalMap.has(item.value)) {
  818. // layoutvm.tableDataSource = layoutvm.tableDataSource.concat(alarmsOriginalMap.get(item.value));
  819. // }
  820. // });
  821. //} else if (layoutvm.option1 === 2) {
  822. // layoutvm.selectedList.forEach(function (item, index) {
  823. // if (item.checked && alarmsCategoryMap.has(item.value)) {
  824. // layoutvm.tableDataSource = layoutvm.tableDataSource.concat(alarmsCategoryMap.get(item.value));
  825. // }
  826. // });
  827. //}
  828. //if (layoutvm.tableDataSource.length > 0) {
  829. // let count = layoutvm.tableDataSource.length < layoutvm.pageCount ? layoutvm.tableDataSource.length : layoutvm.pageCount;
  830. // layoutvm.genericAlarmList = layoutvm.tableDataSource.slice(0, count);
  831. //} else
  832. // layoutvm.genericAlarmList = [];
  833. }
  834. const Keyboard = window.SimpleKeyboard.default;
  835. var currentElement = null;
  836. const myKeyboard = new Keyboard({
  837. onChange: input => onChange(input),
  838. onKeyPress: button => onKeyPress(button),
  839. layout: {
  840. 'number': [
  841. '1 2 3 {bksp}',
  842. '4 5 6 {close}',
  843. '7 8 9 0'
  844. ],
  845. 'default': [
  846. '{close} 1 2 3 4 5 6 7 8 9 0 - = {bksp}',
  847. '{tab} q w e r t y u i o p [ ] \\',
  848. '{lock} a s d f g h j k l ; \' {enter}',
  849. '{shift} z x c v b n m , . / `',
  850. '.com @@ {space}'
  851. ],
  852. 'shift': [
  853. '{close} ! @@ # $ % ^ & * ( ) _ + {bksp}',
  854. '{tab} Q W E R T Y U I O P { } |',
  855. '{lock} A S D F G H J K L : " {enter}',
  856. '{shift} Z X C V B N M < > ? ~',
  857. '.com {space}'
  858. ]
  859. },
  860. display: {
  861. '{bksp}': 'Backspace',
  862. '{tab}': 'Tab',
  863. '{lock}': 'CapsLock',
  864. '{enter}': 'Enter',
  865. '{shift}': 'Shift',
  866. '{close}': 'Close',
  867. '{space}': 'Space'
  868. }
  869. });
  870. function onChange(input) {
  871. if (input === "") return;
  872. var temp = document.querySelector(".input");
  873. var keyBoardInput = myKeyboard.input;
  874. var tmp = myKeyboard.getOptions("theme");
  875. //document.querySelector(".input").value = input;
  876. if (currentElement !== null) {
  877. var currentElementValue = currentElement.value;
  878. if (currentElementValue !== null && currentElementValue !== "") {
  879. var selectStart = currentElement.selectionStart;
  880. var startValue = currentElementValue.slice(0, selectStart);
  881. var endValue = currentElementValue.slice(selectStart);
  882. currentElement.value = startValue + input + endValue;
  883. currentElement.selectionEnd = currentElement.selectionStart = selectStart + 1;
  884. } else {
  885. currentElement.value = input;
  886. }
  887. currentElement.dispatchEvent(new Event('input'))
  888. }
  889. myKeyboard.input.default = "";
  890. //selectionEnd: 5
  891. //selectionStart: 5
  892. console.log("Input changed", input);
  893. }
  894. function showKeyboard(layout, element) {
  895. var mydivel = document.getElementById("mydiv");
  896. if (mydivel === null || mydivel === undefined) return;
  897. mydivel.className = layout === "number" ? "mydivNumber" : "mydiv";
  898. if (layout === "number") {
  899. myKeyboard.setOptions({ theme: "hg-theme-default hg-layout-numeric numeric-theme" });
  900. } else {
  901. myKeyboard.setOptions({ theme: "hg-theme-default"});
  902. }
  903. currentElement = element;
  904. myKeyboard.setOptions({ layoutName: layout });
  905. mydivel.style.visibility = 'visible'
  906. }
  907. function hideKeyboard() {
  908. var keyboardEl = document.getElementById("mydiv");
  909. if (keyboardEl && keyboardEl.style.visibility === 'visible') {
  910. keyboardEl.style.visibility = 'hidden';
  911. }
  912. }
  913. function onKeyPress(button) {
  914. if (button === "{close}") {
  915. currentElement = null;
  916. hideKeyboard();
  917. }
  918. else if (button === "{shift}") {
  919. handleShift();
  920. } else if (button === "{bksp}") {
  921. if (currentElement === null || currentElement.selectionStart === 0) {
  922. return;
  923. }
  924. var tempValue = currentElement.value;
  925. if (myKeyboard.input.default === "" && tempValue !== null && tempValue !== "") {
  926. var selectionStart = currentElement.selectionStart;
  927. var startValue = tempValue.slice(0, selectionStart-1);
  928. var endValue = tempValue.slice(selectionStart);
  929. currentElement.value = startValue + endValue;
  930. currentElement.dispatchEvent(new Event('input'));
  931. currentElement.selectionEnd = currentElement.selectionStart = selectionStart - 1;
  932. //currentElement.value = tempValue.slice(0, tempValue.length - 1);
  933. }
  934. }
  935. else
  936. console.log("Button pressed", button);
  937. }
  938. function handleShift() {
  939. let currentLayout = myKeyboard.options.layoutName;
  940. let shiftToggle = currentLayout === "default" ? "shift" : "default";
  941. myKeyboard.setOptions({ layoutName: shiftToggle });
  942. }
  943. setInterval(function () {
  944. var textspan = document.getElementById("common_header_right_text");
  945. if (textspan != null) {
  946. var currentDate = new Date();
  947. var month = (currentDate.getMonth() + 1).toString().length < 2
  948. ? "0" + (currentDate.getMonth() + 1).toString()
  949. : (currentDate.getMonth() + 1).toString();
  950. var date = currentDate.getDate() < 10
  951. ? "0" + currentDate.getDate().toString()
  952. : currentDate.getDate().toString();
  953. textspan.innerHTML = currentDate.getFullYear() + "/" + month + "/" + date;
  954. }
  955. }, 10 * 60 * 1000);
  956. </script>
  957. </body>
  958. </html>