From f5d984a1153031705a4153acec333cecb94cd4be Mon Sep 17 00:00:00 2001 From: dev01 Date: Fri, 13 Jan 2023 18:45:39 +0800 Subject: [PATCH] =?UTF-8?q?[Frontend]=20=E5=91=8A=E8=AD=A6=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E8=AA=BF=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/index.html | 15 +++++++------- .../yourteam/plugins/yt-notice/yt-notice.js | 20 ++++++++++++++++++- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/Frontend/index.html b/Frontend/index.html index f925835..a311627 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -1009,17 +1009,18 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li }) - onEvent("click", "button[id^=noticeChkBtn]", function () { - $(this).parents(".toast").YTNotice("hide"); - }) + //onEvent("click", "button[id^=noticeChkBtn]", function () { + // $(this).parents(".toast").YTNotice("hide"); + //}) - onEvent("click", "button[id^=bajaAckBtn]", function () { + onEvent("click", "button[id^=noticeChkBtn]", function () { /**button[id^=bajaAckBtn] */ let uuid = $(this).data("uuid"); let url = window.location.origin + "/obix/alarm/" + uuid + "/ack"; let myBaja = new MyBaja(); myBaja.setMyUserAccount((data) => { let sendData = ''; $.post(url, sendData, (rel) => { + console.log(rel) $(this).parents(".toast").YTNotice("hide"); }, "text") }) @@ -1659,6 +1660,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li let notices = []; $.each(datas, (idx, data) => { if (noticeOptArr.findIndex(x => x.id == data.id) == -1) { + /* */ let content = `
異常編號:${data.id} @@ -1676,8 +1678,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li 異常訊息:${data.errMsg}
- - +
` let main = { @@ -1685,7 +1686,7 @@ License: You must have a valid license purchased only from wrapbootstrap.com (li content: content, type: "warning", id: data.id, - hasCloseBtn: false, + hasCloseBtn: true, timeText: displayDate(data.timestamp), } noticeOptArr.push(main); diff --git a/Frontend/js/yourteam/plugins/yt-notice/yt-notice.js b/Frontend/js/yourteam/plugins/yt-notice/yt-notice.js index 9e01431..216c6b9 100644 --- a/Frontend/js/yourteam/plugins/yt-notice/yt-notice.js +++ b/Frontend/js/yourteam/plugins/yt-notice/yt-notice.js @@ -173,7 +173,7 @@ class YTNoticeBlock { setTimeout(() => { $(toast).remove(); - let tarNoticeId = $(obj)[0]._ytNotice.id + let tarNoticeId = $(toast)[0]._ytNotice.id let tarNoticeIdx = this.noticeArr.findIndex(x => x.obj.id == tarNoticeId); if (tarNoticeIdx != -1) { this.noticeArr[tarNoticeIdx].canShow = false; @@ -220,6 +220,7 @@ class YTNoticeBlock { if (this.noticeArr.findIndex(x => x.obj.id == option.id) == -1) { let notice = new YTNotice(option); this.noticeArr.push({ obj: notice, time: (new Date()).getTime(), canShow: true }); + this.setEvent(notice); } this.updEleObj(); } @@ -227,6 +228,23 @@ class YTNoticeBlock { updEleObj = function () { $(this.element)[0]._noticeBlock = this; } + + setEvent = function (notice) { + let _this = this; + $(notice.container).on("hidden.bs.toast", function () { + setTimeout(() => { + $(notice.container).remove(); + + let tarNoticeId = $(notice.container)[0]._ytNotice.id + let tarNoticeIdx = _this.noticeArr.findIndex(x => x.obj.id == tarNoticeId); + if (tarNoticeIdx != -1) { + _this.noticeArr[tarNoticeIdx].canShow = false; + } + _this.showNotices(); + }, 100) + }) + } + } $.fn.YTNotice = function (method = "init", ...args) {