From 0d08a0c569e76042a8b8814432b94414a7e048c2 Mon Sep 17 00:00:00 2001 From: vincent <1341870251@qq.com> Date: 星期一, 01 六月 2020 18:30:47 +0800 Subject: [PATCH] # --- src/main/webapp/views/console.html | 67 ++++++++++++++++++++++++++++++--- 1 files changed, 61 insertions(+), 6 deletions(-) diff --git a/src/main/webapp/views/console.html b/src/main/webapp/views/console.html index 7457191..8b0fb49 100644 --- a/src/main/webapp/views/console.html +++ b/src/main/webapp/views/console.html @@ -11,6 +11,7 @@ <link rel="stylesheet" type="text/css" href="../static/css/common.css"> <link rel="stylesheet" type="text/css" href="../static/css/console.css"> <script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script> + <script type="text/javascript" src="../static/js/common.js"></script> <script type="text/javascript" src="../static/js/layer/layer.js"></script> <style> @@ -88,7 +89,7 @@ <div class="site-row site-row-2"> <div id="site-32" class="site" style="width: 80px; height: 50px;line-height: 50px">32</div> <div id="site-31" class="site" >31</div> - <div id="site-30" class="site" style="width: 80px; height: 30px;line-height: 30px; background-color: red;">30</div> + <div id="site-30" class="site" style="width: 80px; height: 30px;line-height: 30px;">30</div> <div id="site-23" class="site" >23</div> <div id="site-22" class="site" style="width: 80px; height: 50px;line-height: 50px">22</div> <div id="site-20" class="site" >20</div> @@ -400,15 +401,65 @@ </div> <!-- 鍙宠緭閫佺嚎 --> - + <!--<input id="val" type="text">--> + <!--<button id="animate">animate</button>--> </main> </body> <script> + var crn1Position = 0; var crn2Position = 0; - $('#animate').click(function () { - crnAnimate(1, $('#val').val()); - }); + // 鍒濆鍖� + getSitesInfo(); + getCrnInfo(); + // 瀹炴椂璁块棶 + setInterval(function () { + getSitesInfo(); + getCrnInfo(); + }, 1000); + + // 杈撻�佽澶囧疄鏃舵暟鎹幏鍙� + function getSitesInfo(){ + $.ajax({ + url: baseUrl+ "/console/latest/data/site", + headers: {'token': localStorage.getItem('token')}, + method: 'POST', + success: function (res) { + if (res.code === 200){ + var sites = res.data; + for (var i = 0; i < sites.length; i++){ + $("#site-"+sites[i].siteId).attr("class", "site " + sites[i].siteStatus); + } + } else if (res.code === 403){ + top.location.href = baseUrl+"/login"; + } else { + alert(res.msg); + } + } + }); + } + + // 鍫嗗灈鏈哄疄鏃舵暟鎹幏鍙� + function getCrnInfo(){ + $.ajax({ + url: baseUrl+ "/console/latest/data/crn", + headers: {'token': localStorage.getItem('token')}, + method: 'POST', + success: function (res) { + if (res.code === 200){ + var crns = res.data; + console.log(crns); + for (var i = 0; i < crns.length; i++){ + crnAnimate(crns[i].crnId, crns[i].offset); + } + } else if (res.code === 403){ + top.location.href = baseUrl+"/login"; + } else { + alert(res.msg); + } + } + }); + } // 鍫嗗灈鏈哄亸绉诲姩鐢� function crnAnimate(id, leftVal) { @@ -426,13 +477,17 @@ } } + $('.item').on('click', function () { layer.open({ type: 1, shadeClose: true, //鐐瑰嚮閬僵鍏抽棴灞� content: 'text' }); - }) + }); + $('#animate').click(function () { + crnAnimate(1, $('#val').val()); + }); </script> </html> \ No newline at end of file -- Gitblit v1.9.1