index.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Aisky-Sixth</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  7. <!-- 新 Bootstrap4 核心 CSS 文件 -->
  8. <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.1.0/css/bootstrap.min.css">
  9. <!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
  10. <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
  11. <!-- popper.min.js 用于弹窗、提示、下拉菜单 -->
  12. <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
  13. <!-- 最新的 Bootstrap4 核心 JavaScript 文件 -->
  14. <script src="https://cdn.bootcss.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  15. <!--可用來建立使用者小圖示-->
  16. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  17. <style>
  18. body {
  19. margin:0;
  20. }
  21. .navbar-dark .navbar-nav .nav-link {
  22. color: white;
  23. cursor: pointer;
  24. text-decoration:none;
  25. width: 110px;
  26. height: 46px;
  27. }
  28. .nav-top {
  29. line-height:40px;
  30. background-color: #C4C4C4;
  31. }
  32. .website_title{
  33. font-family: Roboto;
  34. font-style: normal;
  35. font-weight: normal;
  36. font-size: 30px;
  37. color: #000000;
  38. }
  39. .navbar-nav > li{
  40. float: none;
  41. display: inline-block;
  42. width: 110px;
  43. margin: 0 auto;
  44. text-align: center;
  45. }
  46. .navbar-nav > li a{
  47. font-size: 20px;
  48. }
  49. .main-page {
  50. margin-top: 150px;
  51. }
  52. .page-title {
  53. font-family: Roboto;
  54. font-style: normal;
  55. font-weight: bold;
  56. font-size: 36px;
  57. }
  58. .flex {
  59. display: flex;
  60. flex-direction: row;
  61. flex-wrap: wrap;
  62. justify-content: center;
  63. }
  64. .set-link {
  65. display: inline-block;
  66. width: 350px;
  67. height: 100px;
  68. line-height: 100px;
  69. background: #008CBA;
  70. border: 1px solid #CFCFCF;
  71. box-sizing: border-box;
  72. color: #FFFFFF;
  73. border-radius: 10px;
  74. font-size: 36px;
  75. }
  76. .fa{
  77. display: inline-block;
  78. font: normal normal normal 14px/1 FontAwesome;
  79. font-size: inherit;
  80. text-rendering: auto;
  81. -webkit-font-smoothing: antialiased;
  82. }
  83. .fa-user-o:before{
  84. content: "\f2c0";
  85. }
  86. .abc {background:lightgreen;border:1px #000 solid;cursor:pointer;padding:10px 5px;}
  87. .draggable {min-width:50px;height:45px;display:inline-block;font-size:.9em;z-index:1;text-align:center;}
  88. .abc2 {background:white;border:1px #000 solid;cursor:pointer;padding:10px 5px;}
  89. .draggable2 {min-width:200px;height:200px;display:inline-block;font-size:.9em;z-index:1;text-align:center;}
  90. img:not(:first-child):hover {
  91. cursor: pointer;
  92. }
  93. #show_img {
  94. width:300px;
  95. height:400px;
  96. border:1px solid gray;
  97. }
  98. @media(max-width:373px){
  99. .card {
  100. margin-right: 0px;
  101. }
  102. }
  103. @media(max-width:577px){
  104. }
  105. @media(min-width:576px){
  106. }
  107. @media(min-width:768px){
  108. .navbar-nav > li {
  109. margin-left: 0px;
  110. }
  111. .navbar-nav .li-block {
  112. display:none;
  113. }
  114. }
  115. @media(min-width:991px){
  116. .navbar-nav > li {
  117. margin-left: 20px;
  118. }
  119. .navbar-nav .li-block {
  120. display:none;
  121. }
  122. }
  123. @media(min-width:1200px){
  124. .navbar-nav > li {
  125. margin-left: 35px;
  126. }
  127. .navbar-nav .li-block {
  128. display: inline-block;
  129. width: 100px;
  130. }
  131. }
  132. @media(min-width:1400px){
  133. .navbar-nav .li-block {
  134. display: inline-block;
  135. width: 200px;
  136. }
  137. }
  138. @media(min-width:1689px) {
  139. .navbar-nav > li {
  140. margin-left: 50px;
  141. }
  142. .navbar-nav .li-block {
  143. display: inline-block;
  144. width: 500px;
  145. }
  146. }
  147. </style>
  148. <style>
  149. html, body, #map-canvas{
  150. width:100%;
  151. height: 100%;
  152. }
  153. </style>
  154. <script>
  155. var img_id = 0;
  156. $(function(){
  157. //判斷客戶如果是上傳圖片
  158. {% if params.path %}
  159. var path = '{{params.path}}';
  160. $("#farm_img").attr('src', path);
  161. $("#map-canvas").css('display', 'none');
  162. img_id = "farm_img";
  163. var node_div = document.getElementById('node-list');
  164. var i = 1;
  165. var num = 0;
  166. {% for node in params.nodes %}
  167. if(i < 10){
  168. i = "0" + i
  169. };
  170. if(i > 1){
  171. num = num + 50;
  172. };
  173. var div = document.createElement('div');
  174. var html = '';
  175. html += '<p style="font-weight: bold;">' + '{{node.node_name}}' + '</p>';
  176. div.innerHTML = html;
  177. div.setAttribute('id', 'a' + i);
  178. div.setAttribute('class', 'draggable abc');
  179. div.setAttribute('onclick', 'ShowImg("' + i + '")');
  180. div.style.position = 'relative';
  181. div.style.inset = '{{node.pos_lng}}px' + ' auto auto ' + (Number({{node.pos_lat}})-15-num) + 'px';
  182. node_div.appendChild(div);
  183. i ++;
  184. {% endfor %}
  185. //判斷用戶如果是輸入地址
  186. {% else %}
  187. img_id = "map-canvas";
  188. {% endif %}
  189. });
  190. function ShowImg(evt){
  191. if(Number(evt) < 10){
  192. evt = evt.toString();
  193. evt.substring(1);
  194. };
  195. var num = evt;
  196. Number(num);
  197. var node = document.getElementById('a' + evt);
  198. var show_img = document.getElementById('show_img');
  199. var node_imgs = {{params.nodeimg_paths|tojson}};
  200. console.log(node_imgs);
  201. var html = '';
  202. html += '<h1>節點' + evt + '</h1><img src="' + node_imgs[num-1] + '" style="width:300px;height:300px;" onclick="EnvInfo(' + evt + ');"><h5 style="color:blue;">可點擊圖片進入環境資訊</h5>';
  203. show_img.innerHTML = html;
  204. };
  205. function EnvInfo(evt){
  206. window.location.href='/env_info/' + evt;
  207. };
  208. <!--function img_error() {-->
  209. <!--//this.src='./inimage/psfi.jpg';-->
  210. <!--console.log(img_id);-->
  211. <!--document.getElementById(img_id).src="../static/img/psfi.jpg";-->
  212. <!--$('#a01').draggable('option','disabled', true);-->
  213. <!--$('#a01').css('background-color', 'red');-->
  214. <!--$('#a02').draggable('option','disabled', true);-->
  215. <!--$('#a02').css('background-color', 'red');-->
  216. <!--$('#a03').draggable('option','disabled', true);-->
  217. <!--$('#a03').css('background-color', 'red');-->
  218. <!--$('#a04').draggable('option','disabled', true);-->
  219. <!--$('#a04').css('background-color', 'red');-->
  220. <!--$('#a05').draggable('option','disabled', true);-->
  221. <!--$('#a05').css('background-color', 'red');-->
  222. <!--$('#a06').draggable('option','disabled', true);-->
  223. <!--$('#a06').css('background-color', 'red');-->
  224. <!--};-->
  225. </script>
  226. </head>
  227. <body>
  228. <nav class="fixed-top">
  229. <nav class="navbar navbar-expand-md nav-top justify-content-center">
  230. <div>
  231. <span class="website_title">首頁</span>
  232. </div>
  233. </nav>
  234. <nav class="navbar navbar-expand-md bg-dark navbar-dark nav-bottom">
  235. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
  236. <span class="navbar-toggler-icon"></span>
  237. </button>
  238. <div class="collapse navbar-collapse" id="collapsibleNavbar">
  239. <ul class="navbar-nav">
  240. <li class="nav-item">
  241. <a class="nav-link" href="/">首頁</a>
  242. </li>
  243. <li class="nav-item">
  244. <a class="nav-link" href="/env_info/1">環境資訊</a>
  245. </li>
  246. <li class="nav-item">
  247. <a class="nav-link" href="#">報表輸出</a>
  248. </li>
  249. <li class="nav-item">
  250. <a class="nav-link" href="#">RMA</a>
  251. </li>
  252. <li class="nav-item">
  253. <a class="nav-link" href="#">故障紀錄</a>
  254. </li>
  255. <li class="nav-item">
  256. <a class="nav-link" href="#">求助</a>
  257. </li>
  258. <li class="li-block"></li>
  259. <li class="nav-item">
  260. <a class="nav-link" href="#"><i class="fa fa-user-o"></i> {{params.username}}</a>
  261. </li>
  262. <li class="nav-item">
  263. <a class="nav-link" href="/logout">Logout</a>
  264. </li>
  265. </ul>
  266. </div>
  267. </nav>
  268. </nav>
  269. <div class="main-page">
  270. <form method="" action="">
  271. {% if params.path %}
  272. <div class="container-fluid">
  273. {% else %}
  274. <div class="container">
  275. {% endif %}
  276. <div class="row">
  277. <div id="node-list" class="col-12" style="width:100%;"></div>
  278. <div class="col-9">
  279. <img id="farm_img" src="" style='width:1080px;height:650px;' onError="" ondragstart="return false;">
  280. </div>
  281. <div id="map-canvas" class="col-12" style="text-align:center;background-color:#f2f2f2;padding:280px;border:1px;border-radius: 35px;"></div>
  282. <div class="col-3" id="show_img" style="text-align:center;">
  283. <h2 style="color:blue;">請點擊感測點顯示圖片</h2>
  284. </div>
  285. </div>
  286. </div>
  287. </form>
  288. </div>
  289. </body>
  290. <script>
  291. {% if params.lat %}
  292. $("#farm_img").css('display', 'none');
  293. $("#show_img").css('display', 'none');
  294. function initialize() {
  295. var a = -1;
  296. var mapOptions = {
  297. center: { lat: {{params.lat}}, lng: {{params.lng}}},
  298. <!--center: { lat: 22.707340, lng: 120.531000},-->
  299. zoom: 19,
  300. mapTypeId: 'satellite',
  301. };
  302. var map = new google.maps.Map(
  303. document.getElementById('map-canvas'),
  304. mapOptions);
  305. var node_imgs = {{params.nodeimg_paths|tojson}};
  306. var i = 1;
  307. var s = 1;
  308. var num = 0;
  309. {% for node in params.nodes %}
  310. if(i < 10){
  311. i = "0" + i
  312. };
  313. var defineStr = "var position" + i.toString();
  314. var defineStr2 = "var marker" + i.toString();
  315. var defineStr3 = "var infowindow" + i.toString();
  316. //使用eval()函數執行字串
  317. eval(defineStr);
  318. eval(defineStr2);
  319. eval(defineStr3);
  320. //為position賦值
  321. eval("position" + i.toString() + " = " + "{lat:" + {{node.pos_lat}} + ",lng:" + {{node.pos_lng}} + "};");
  322. //為marker賦值
  323. eval("marker" + i.toString() + " = " + "new google.maps.Marker({position:" + ("position" + i.toString()) + ",map:map,label:'" + i + "'});");
  324. var contentString = '<h2>節點' + s + '</h2><img src="' + node_imgs[num] + '" style="width:200px;height:200px;" onclick="EnvInfo(' + s + ');"><h5 style="color:blue;">可點擊圖片進入環境資訊</h5>';
  325. //為Infowindow賦值
  326. eval("infowindow" + i.toString() + " = " + "new google.maps.InfoWindow({content: contentString, position:" + ("position" + i.toString()) + "});");
  327. //監聽marker點擊事件開啟資訊視窗
  328. eval("marker" + i.toString() + ".addListener('click',function(){infowindow" + i.toString() + ".open(map," + "marker" + i.toString() + ");});");
  329. <!--var contentString = '<h1>大家好我是資訊視窗</h1><button id="btn">點我</button>';-->
  330. <!--var infowindow = new google.maps.InfoWindow({-->
  331. <!--content: contentString,-->
  332. <!--position: position01-->
  333. <!--});-->
  334. i ++;
  335. num ++;
  336. s ++;
  337. {% endfor %}
  338. };
  339. <!--google.maps.event.addDomListener(-->
  340. <!--window, 'load', initialize);-->
  341. {% endif %}
  342. </script>
  343. <script async defer src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDKVm-6LBJqxrDJLEzJujGjZLVTfK0RiAE&callback=initialize"></script>
  344. </html>