burn_program.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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: 130px;
  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: 200px;
  67. height: 70px;
  68. line-height: 70px;
  69. background: #008CBA;
  70. border: 1px solid #CFCFCF;
  71. box-sizing: border-box;
  72. color: #FFFFFF;
  73. border-radius: 10px;
  74. font-size: 25px;
  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. button {
  87. cursor: pointer;
  88. }
  89. @media(max-width:373px){
  90. .card {
  91. margin-right: 0px;
  92. }
  93. }
  94. @media(max-width:577px){
  95. }
  96. @media(min-width:576px){
  97. }
  98. @media(min-width:768px){
  99. .navbar-nav > li {
  100. margin-left: 0px;
  101. }
  102. .navbar-nav .li-block {
  103. display:none;
  104. }
  105. }
  106. @media(min-width:991px){
  107. .navbar-nav > li {
  108. margin-left: 20px;
  109. }
  110. .navbar-nav .li-block {
  111. display:none;
  112. }
  113. }
  114. @media(min-width:1200px){
  115. .navbar-nav > li {
  116. margin-left: 35px;
  117. }
  118. .navbar-nav .li-block {
  119. display: inline-block;
  120. width: 100px;
  121. }
  122. }
  123. @media(min-width:1400px){
  124. .navbar-nav .li-block {
  125. display: inline-block;
  126. width: 200px;
  127. }
  128. }
  129. @media(min-width:1689px) {
  130. .navbar-nav > li {
  131. margin-left: 50px;
  132. }
  133. .navbar-nav .li-block {
  134. display: inline-block;
  135. width: 500px;
  136. }
  137. }
  138. </style>
  139. <style>
  140. html, body, #map-canvas{
  141. width:100%;
  142. height: 100%;
  143. }
  144. </style>
  145. <script>
  146. //燒錄程式函數
  147. function BurnProgram(en_name, ch_name){
  148. if(!confirm("你確定要燒錄" + ch_name + "嗎?")){
  149. return false;
  150. };
  151. var sensor_name = {en_name:'1'};
  152. console.log("sensor_name: " + sensor_name);
  153. // $.post('/burn_program',en_name,function(resText){
  154. $.post('/burn_program', sensor_name, function(resText){
  155. if(resText.status){
  156. alert("燒錄成功!");
  157. };
  158. },'json');
  159. };
  160. //驗證token,如果不符合或過期就登出回登入頁
  161. var str = localStorage.getItem('Hello');
  162. $.ajax({
  163. type: "GET",
  164. url: "/auth",
  165. headers: {'Authorization': 'Bearer ' + str},
  166. success: function(result){
  167. console.log(result.identity);
  168. },
  169. error: function(result){
  170. window.location.href='/logout';
  171. }
  172. });
  173. $(function(){
  174. var sensor_list = $("#sensor_list");
  175. var html = '';
  176. // var sensor_list = '{{params.sensor_list|tojson}}';
  177. // console.log("TT: " + sensor_list);
  178. // {"ch_name": "空氣溫度", "en_name": "airTem", "version": "v1.0"}
  179. $.each({{params.sensor_list|tojson}},function(index, obj){
  180. html += '<div class="col-xl-2 col-lg-2 col-md-2 col-sm-8 col-xs-8" style="margin-right: 20px ;margin-left: 20px; margin-top:50px; margin-bottom:50px;">';
  181. html += ' <div class="page-title text-center">';
  182. html += ' <button class="set-link" name="' + obj.en_name + '" type="button" onclick="BurnProgram(' + '\'' + obj.en_name + '\',\'' + obj.ch_name + ' ' + obj.version + '\')">' + obj.ch_name + ' ' + obj.version + '</button>';
  183. html += ' </div>';
  184. html += '</div>';
  185. });
  186. sensor_list.html(html);
  187. });
  188. </script>
  189. </head>
  190. <body>
  191. <nav class="fixed-top">
  192. <nav class="navbar navbar-expand-md nav-top justify-content-center">
  193. <div>
  194. <span class="website_title">感測器燒錄</span>
  195. </div>
  196. </nav>
  197. <nav class="navbar navbar-expand-md bg-dark navbar-dark nav-bottom">
  198. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
  199. <span class="navbar-toggler-icon"></span>
  200. </button>
  201. <div class="collapse navbar-collapse" id="collapsibleNavbar">
  202. <ul class="navbar-nav">
  203. <li class="nav-item">
  204. <a class="nav-link" href="/">首頁</a>
  205. </li>
  206. <li class="nav-item">
  207. <a class="nav-link" href="/incoming_check">進貨檢測</a>
  208. </li>
  209. <li class="nav-item">
  210. <a class="nav-link" href="/burn_program">感測器燒錄</a>
  211. </li>
  212. <li class="nav-item">
  213. <a class="nav-link" href="/modify_permissions">權限設置</a>
  214. </li>
  215. <li class="nav-item">
  216. <a class="nav-link" href="/add_sensor">新增感測器</a>
  217. </li>
  218. <li class="nav-item">
  219. <a class="nav-link" href="/add_server">伺服器建置</a>
  220. </li>
  221. <li class="li-block"></li>
  222. <li class="nav-item">
  223. <a class="nav-link" href="#"><i class="fa fa-user-o"></i> {{params.username}}</a>
  224. </li>
  225. <li class="nav-item">
  226. <a class="nav-link" href="/logout">Logout</a>
  227. </li>
  228. </ul>
  229. </div>
  230. </nav>
  231. </nav>
  232. <div class="main-page">
  233. <div class="container-fluid">
  234. <div class="row">
  235. <div class="col-12 text-center"><h3 style="color:red;">請點擊以下感測器進行燒錄</h3></div>
  236. <div id="sensor_list" class="col flex" style="margin: auto; ">
  237. <!--<div class="col-xl-3 col-lg-4 col-md-5 col-sm-8 col-xs-8" style="margin-right: 20px ;margin-left: 20px; margin-top:50px; margin-bottom:50px;">-->
  238. <!--<div class="page-title text-center">-->
  239. <!--<button class="set-link" name="airTem" type="button" onclick="BurnProgram('airTem')">空氣溫度</button>-->
  240. <!--</div>-->
  241. <!--</div>-->
  242. <!--<div class="col-xl-3 col-lg-4 col-md-5 col-sm-8 col-xs-8" style="margin-right: 20px ;margin-left: 20px; margin-top:50px; margin-bottom:50px;">-->
  243. <!--<div class="page-title text-center">-->
  244. <!--<button class="set-link" name="airHum" type="button" onclick="BurnProgram('airHum')">空氣濕度</button>-->
  245. <!--</div>-->
  246. <!--</div>-->
  247. <!--<div class="col-xl-3 col-lg-4 col-md-5 col-sm-8 col-xs-8" style="margin-right: 20px ;margin-left: 20px; margin-top:50px; margin-bottom:50px;">-->
  248. <!--<div class="page-title text-center">-->
  249. <!--<button class="set-link" name="dewPoint" type="button" onclick="BurnProgram('dewPoint')">露點</button>-->
  250. <!--</div>-->
  251. <!--</div>-->
  252. <!--<div class="col-xl-3 col-lg-4 col-md-5 col-sm-8 col-xs-8" style="margin-right: 20px ;margin-left: 20px; margin-top:50px; margin-bottom:50px;">-->
  253. <!--<div class="page-title text-center">-->
  254. <!--<button class="set-link" name="sun" type="button" onclick="BurnProgram('sun')">日照</button>-->
  255. <!--</div>-->
  256. <!--</div>-->
  257. <!--<div class="col-xl-3 col-lg-4 col-md-5 col-sm-8 col-xs-8" style="margin-right: 20px ;margin-left: 20px; margin-top:50px; margin-bottom:50px;">-->
  258. <!--<div class="page-title text-center">-->
  259. <!--<button class="set-link" name="soilHum" type="button" onclick="BurnProgram('soilHum')">土壤含水率</button>-->
  260. <!--</div>-->
  261. <!--</div>-->
  262. <!--<div class="col-xl-3 col-lg-4 col-md-5 col-sm-8 col-xs-8" style="margin-right: 20px ;margin-left: 20px; margin-top:50px; margin-bottom:50px;">-->
  263. <!--<div class="page-title text-center">-->
  264. <!--<button class="set-link" name="soilTem" type="button" onclick="BurnProgram('soilTem')">土壤溫度</button>-->
  265. <!--</div>-->
  266. <!--</div>-->
  267. <!--<div class="col-xl-3 col-lg-4 col-md-5 col-sm-8 col-xs-8" style="margin-right: 20px ;margin-left: 20px; margin-top:50px; margin-bottom:50px;">-->
  268. <!--<div class="page-title text-center">-->
  269. <!--<button class="set-link" name="soilEC" type="button" onclick="BurnProgram('soilEC')">土壤EC值</button>-->
  270. <!--</div>-->
  271. <!--</div>-->
  272. <!--<div class="col-xl-3 col-lg-4 col-md-5 col-sm-8 col-xs-8" style="margin-right: 20px ;margin-left: 20px; margin-top:50px; margin-bottom:50px;">-->
  273. <!--<div class="page-title text-center">-->
  274. <!--<button class="set-link" name="windSpd" type="button" onclick="BurnProgram('windSpd')">風速</button>-->
  275. <!--</div>-->
  276. <!--</div>-->
  277. <!--<div class="col-xl-3 col-lg-4 col-md-5 col-sm-8 col-xs-8" style="margin-right: 20px ;margin-left: 20px; margin-top:50px; margin-bottom:50px;">-->
  278. <!--<div class="page-title text-center">-->
  279. <!--<button class="set-link" name="windDin" type="button" onclick="BurnProgram('windDin')">風向</button>-->
  280. <!--</div>-->
  281. <!--</div>-->
  282. <!--<div class="col-xl-3 col-lg-4 col-md-5 col-sm-8 col-xs-8" style="margin-right: 20px ;margin-left: 20px; margin-top:50px; margin-bottom:50px;">-->
  283. <!--<div class="page-title text-center">-->
  284. <!--<button class="set-link" name="rain" type="button" onclick="BurnProgram('rain')">降雨量</button>-->
  285. <!--</div>-->
  286. <!--</div>-->
  287. <!--<div class="col-xl-3 col-lg-4 col-md-5 col-sm-8 col-xs-8" style="margin-right: 20px ;margin-left: 20px; margin-top:50px; margin-bottom:50px;">-->
  288. <!--<div class="page-title text-center">-->
  289. <!--<button class="set-link" name="atmosphere" type="button" onclick="BurnProgram('atmosphere')">大氣壓</button>-->
  290. <!--</div>-->
  291. <!--</div>-->
  292. </div>
  293. </div>
  294. </div>
  295. </div>
  296. </body>
  297. </html>