add_server.html 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897
  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. <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.dev.js"></script>
  18. <!-- <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/socket.io/1.3.6/socket.io.min.js"></script>-->
  19. <!-- <script src="https://cdn.socket.io/4.0.1/socket.io.min.js" integrity="sha384-LzhRnpGmQP+lOvWruF/lgkcqD+WDVt9fU3H4BWmwP5u5LTmkUGafMcpZKNObVMLU" crossorigin="anonymous"></script>-->
  20. <style>
  21. body {
  22. margin:0;
  23. }
  24. .navbar-dark .navbar-nav .nav-link {
  25. color: white;
  26. cursor: pointer;
  27. text-decoration:none;
  28. width: 130px;
  29. height: 46px;
  30. }
  31. .nav-top {
  32. line-height:40px;
  33. background-color: #C4C4C4;
  34. }
  35. .website_title{
  36. font-family: Roboto;
  37. font-style: normal;
  38. font-weight: normal;
  39. font-size: 30px;
  40. color: #000000;
  41. }
  42. .navbar-nav > li{
  43. float: none;
  44. display: inline-block;
  45. width: 110px;
  46. margin: 0 auto;
  47. text-align: center;
  48. }
  49. .navbar-nav > li a{
  50. font-size: 20px;
  51. }
  52. .main-page {
  53. margin-top: 150px;
  54. }
  55. .page-title {
  56. font-family: Roboto;
  57. font-style: normal;
  58. font-weight: bold;
  59. font-size: 36px;
  60. }
  61. .flex {
  62. display: flex;
  63. flex-direction: row;
  64. flex-wrap: wrap;
  65. justify-content: center;
  66. }
  67. .set-link {
  68. display: inline-block;
  69. width: 350px;
  70. height: 100px;
  71. line-height: 100px;
  72. background: #008CBA;
  73. border: 1px solid #CFCFCF;
  74. box-sizing: border-box;
  75. color: #FFFFFF;
  76. border-radius: 10px;
  77. font-size: 36px;
  78. }
  79. .fa{
  80. display: inline-block;
  81. font: normal normal normal 14px/1 FontAwesome;
  82. font-size: inherit;
  83. text-rendering: auto;
  84. -webkit-font-smoothing: antialiased;
  85. }
  86. .fa-user-o:before{
  87. content: "\f2c0";
  88. }
  89. button {
  90. cursor: pointer;
  91. }
  92. @media(max-width:373px){
  93. .card {
  94. margin-right: 0px;
  95. }
  96. }
  97. @media(max-width:577px){
  98. }
  99. @media(min-width:576px){
  100. }
  101. @media(min-width:768px){
  102. .navbar-nav > li {
  103. margin-left: 0px;
  104. }
  105. .navbar-nav .li-block {
  106. display:none;
  107. }
  108. }
  109. @media(min-width:991px){
  110. .navbar-nav > li {
  111. margin-left: 20px;
  112. }
  113. .navbar-nav .li-block {
  114. display:none;
  115. }
  116. }
  117. @media(min-width:1200px){
  118. .navbar-nav > li {
  119. margin-left: 35px;
  120. }
  121. .navbar-nav .li-block {
  122. display: inline-block;
  123. width: 100px;
  124. }
  125. }
  126. @media(min-width:1400px){
  127. .navbar-nav .li-block {
  128. display: inline-block;
  129. width: 200px;
  130. }
  131. }
  132. @media(min-width:1689px) {
  133. .navbar-nav > li {
  134. margin-left: 50px;
  135. }
  136. .navbar-nav .li-block {
  137. display: inline-block;
  138. width: 500px;
  139. }
  140. }
  141. </style>
  142. <script>
  143. // // 原本就註解
  144. // //驗證token,如果不符合或過期就登出回登入頁
  145. // var str = localStorage.getItem('Hello');
  146. // $.ajax({
  147. // type: "GET",
  148. // url: "/auth",
  149. // headers: {'Authorization': 'Bearer ' + str},
  150. // success: function(result){
  151. // console.log(result.identity);
  152. // },
  153. // error: function(result){
  154. // window.location.href='/logout';
  155. // }
  156. // });
  157. $(function(){
  158. console.log("OK")
  159. var aa = 'AA';
  160. // 0429 Rita eval 測試
  161. // eval('var ' + aa + 'name = $("input[name=user_loginname]").val();')
  162. // console.log(AAname);
  163. var namespace = '/test_conn';
  164. var url = 'http://127.0.0.1';
  165. var port = '5000';
  166. // var socket = io.connect(url + ':' + port + namespace);
  167. // var item = document.getElementById('python3.8-status');
  168. // item.style.width = '0%';
  169. // item.innerText = '0%';
  170. // timer_python38 = window.setInterval("AddBarIndex('python3.8-status')", 2000);
  171. // window.setInterval("abs_update()", 1000);
  172. // socket.on('connect', function() {
  173. // socket.emit('connect_event', {data: 'connected!'});
  174. // print("SOCKET CONNECT")
  175. // });
  176. // socket.on('user-confirm', function(msg) {
  177. // console.log(msg);
  178. // if(msg == 'pass'){
  179. // var item = document.getElementById('python3.8-status');
  180. // item.style.width = '2%';
  181. // item.innerText = '2%';
  182. // timer_python38 = window.setInterval("AddBarIndex('python3.8-status')", 2000);
  183. // };
  184. // });
  185. // socket.on('stdout', function(msg) {
  186. // if(msg.indexOf('python3.8') != -1){
  187. // ItemInstallSuccess(timer_python38, 'python3.8');
  188. // timer_python3_pip = window.setInterval("AddBarIndex('python3-pip-status')", 2000);
  189. // };
  190. // if(msg.indexOf('python3-pip') != -1){
  191. // ItemInstallSuccess(timer_python3_pip, 'python3-pip');
  192. // timer_git = window.setInterval("AddBarIndex('git-status')", 2000);
  193. // };
  194. // if(msg.indexOf('git') != -1){
  195. // ItemInstallSuccess(timer_git, 'git');
  196. // timer_wget = window.setInterval("AddBarIndex('wget-status')", 2000);
  197. // };
  198. // if(msg.indexOf('wget') != -1){
  199. // ItemInstallSuccess(timer_wget, 'wget');
  200. // timer_grep = window.setInterval("AddBarIndex('grep-status')", 2000);
  201. // };
  202. // if(msg.indexOf('grep') != -1){
  203. // ItemInstallSuccess(timer_grep, 'grep');
  204. // timer_tasksel = window.setInterval("AddBarIndex('tasksel-status')", 2000);
  205. // };
  206. // if(msg.indexOf('tasksel') != -1){
  207. // ItemInstallSuccess(timer_tasksel, 'tasksel');
  208. // timer_lamp_server = window.setInterval("AddBarIndex('lamp-server-status')", 2000);
  209. // };
  210. // if(msg.indexOf('lamp-server') != -1){
  211. // ItemInstallSuccess(timer_lamp_server, 'lamp-server');
  212. // timer_phpMyAdmin510_all_languages = window.setInterval("AddBarIndex('phpMyAdmin-5.1.0-all-languages.tar.gz-status')", 2000);
  213. // };
  214. // // // 原本就註解
  215. // // if(msg.indexOf('phpMyAdmin-5.1.0-all-languages.tar.gz') != -1){
  216. // // ItemInstallSuccess(timer_phpMyAdmin510_all_languages, 'phpMyAdmin-5.1.0-all-languages.tar.gz');
  217. // // timer_openssl = window.setInterval("AddBarIndex('openssl-status')", 2000);
  218. // // };
  219. // if(msg.indexOf('install phpmyadmin done') != -1){
  220. // ItemInstallSuccess(timer_phpMyAdmin510_all_languages, 'phpMyAdmin-5.1.0-all-languages.tar.gz');
  221. // timer_openssl = window.setInterval("AddBarIndex('openssl-status')", 2000);
  222. // };
  223. // if(msg.indexOf('openssl') != -1){
  224. // ItemInstallSuccess(timer_openssl, 'openssl');
  225. // timer_php_common = window.setInterval("AddBarIndex('php-common-status')", 2000);
  226. // };
  227. // if(msg.indexOf('php-common') != -1){
  228. // ItemInstallSuccess(timer_php_common, 'php-common');
  229. // timer_php_curl = window.setInterval("AddBarIndex('php-curl-status')", 2000);
  230. // };
  231. // if(msg.indexOf('php-curl') != -1){
  232. // ItemInstallSuccess(timer_php_curl, 'php-curl');
  233. // timer_php_json = window.setInterval("AddBarIndex('php-json-status')", 2000);
  234. // };
  235. // if(msg.indexOf('php-json') != -1){
  236. // ItemInstallSuccess(timer_php_json, 'php-json');
  237. // timer_php_mbstring = window.setInterval("AddBarIndex('php-mbstring')", 2000);
  238. // };
  239. // if(msg.indexOf('php-mbstring') != -1){
  240. // ItemInstallSuccess(timer_php_mbstring, 'php-mbstring');
  241. // timer_php_mysql = window.setInterval("AddBarIndex('php-mysql')", 2000);
  242. // };
  243. // if(msg.indexOf('php-mysql') != -1){
  244. // ItemInstallSuccess(timer_php_mysql, 'php-mysql');
  245. // timer_php_xml = window.setInterval("AddBarIndex('php-xml-status')", 2000);
  246. // };
  247. // if(msg.indexOf('php-xml') != -1){
  248. // ItemInstallSuccess(timer_php_xml, 'php-xml');
  249. // timer_php_zip = window.setInterval("AddBarIndex('php-zip-status')", 2000);
  250. // };
  251. // if(msg.indexOf('php-zip') != -1){
  252. // ItemInstallSuccess(timer_php_zip, 'php-zip');
  253. // timer_php72_mbstring = window.setInterval("AddBarIndex('php7.2-mbstring-status')", 2000);
  254. // };
  255. // if(msg.indexOf('php7.2-mbstring') != -1){
  256. // ItemInstallSuccess(timer_php72_mbstring, 'php7.2-mbstring');
  257. // timer_php72_xml = window.setInterval("AddBarIndex('php7.2-xml-status')", 2000);
  258. // };
  259. // if(msg.indexOf('php7.2-xml') != -1){
  260. // ItemInstallSuccess(timer_php72_xml, 'php7.2-xml');
  261. // timer_php72_mysql = window.setInterval("AddBarIndex('php7.2-mysql-status')", 2000);
  262. // };
  263. // if(msg.indexOf('php7.2-mysql') != -1){
  264. // ItemInstallSuccess(timer_php72_mysql, 'php7.2-mysql');
  265. // timer_php72_common = window.setInterval("AddBarIndex('php7.2-common-status')", 2000);
  266. // };
  267. // if(msg.indexOf('php7.2-common') != -1){
  268. // ItemInstallSuccess(timer_php72_common, 'php7.2-common');
  269. // timer_php72_curl = window.setInterval("AddBarIndex('php7.2-curl-status')", 2000);
  270. // };
  271. // if(msg.indexOf('php7.2-curl') != -1){
  272. // ItemInstallSuccess(timer_php72_curl, 'php7.2-curl');
  273. // timer_php72_json = window.setInterval("AddBarIndex('php7.2-json-status')", 2000);
  274. // };
  275. // if(msg.indexOf('php7.2-json') != -1){
  276. // ItemInstallSuccess(timer_php72_json, 'php7.2-json');
  277. // timer_php72_zip = window.setInterval("AddBarIndex('php7.2-zip-status')", 2000);
  278. // };
  279. // if(msg.indexOf('php7.2-zip') != -1){
  280. // ItemInstallSuccess(timer_php72_zip, 'php7.2-zip');
  281. // timer_service_apache2 = window.setInterval("AddBarIndex('service-apache2-start-status')", 2000);
  282. // };
  283. // if(msg.indexOf('service apache2 start') != -1){
  284. // ItemInstallSuccess(timer_service_apache2, 'service-apache2-start');
  285. // timer_setting_mysql = window.setInterval("AddBarIndex('setting-mysql-status')", 2000);
  286. // };
  287. // console.log(msg);
  288. // console.log('test1');
  289. // });
  290. // socket.on('stderr', function(msg) {
  291. // if(msg.indexOf('python3.8') != -1){
  292. // ItemInstallFail(timer_python38, 'python3.8');
  293. // timer_python3_pip = window.setInterval("AddBarIndex('python3-pip-status')", 2000);
  294. // };
  295. // if(msg.indexOf('python3-pip') != -1){
  296. // ItemInstallFail(timer_python3_pip, 'python3-pip');
  297. // timer_git = window.setInterval("AddBarIndex('git-status')", 2000);
  298. // };
  299. // if(msg.indexOf('git') != -1){
  300. // ItemInstallFail(timer_git, 'git');
  301. // timer_wget = window.setInterval("AddBarIndex('wget-status')", 2000);
  302. // };
  303. // if(msg.indexOf('wget') != -1){
  304. // ItemInstallFail(timer_wget, 'wget');
  305. // timer_grep = window.setInterval("AddBarIndex('grep-status')", 2000);
  306. // };
  307. // if(msg.indexOf('grep') != -1){
  308. // ItemInstallFail(timer_grep, 'grep');
  309. // timer_tasksel = window.setInterval("AddBarIndex('tasksel-status')", 2000);
  310. // };
  311. // if(msg.indexOf('tasksel') != -1){
  312. // ItemInstallFail(timer_tasksel, 'tasksel');
  313. // timer_lamp_server = window.setInterval("AddBarIndex('lamp-server-status')", 2000);
  314. // };
  315. // if(msg.indexOf('lamp-server') != -1){
  316. // ItemInstallFail(timer_lamp_server, 'lamp-server');
  317. // timer_phpMyAdmin = window.setInterval("AddBarIndex('phpMyAdmin-5.1.0-all-languages.tar.gz-status')", 2000);
  318. // };
  319. // // // 原本就註解
  320. // // if(msg.indexOf('phpMyAdmin-5.1.0-all-languages.tar.gz') != -1){
  321. // // ItemInstallFail(timer_phpMyAdmin, 'phpMyAdmin-5.1.0-all-languages.tar.gz');
  322. // // timer_openssl = window.setInterval("AddBarIndex('openssl-status')", 2000);
  323. // // };
  324. // if(msg.indexOf('openssl') != -1){
  325. // ItemInstallFail(timer_openssl, 'openssl');
  326. // timer_php_common = window.setInterval("AddBarIndex('php-common-status')", 2000);
  327. // };
  328. // if(msg.indexOf('php-common') != -1){
  329. // ItemInstallFail(timer_php_common, 'php-common');
  330. // timer_php_curl = window.setInterval("AddBarIndex('php-curl-status')", 2000);
  331. // };
  332. // if(msg.indexOf('php-curl') != -1){
  333. // ItemInstallFail(timer_php_curl, 'php-curl');
  334. // timer_php_json = window.setInterval("AddBarIndex('php-json-status')", 2000);
  335. // };
  336. // if(msg.indexOf('php-json') != -1){
  337. // ItemInstallFail(timer_php_json, 'php-json');
  338. // timer_php_mbstring = window.setInterval("AddBarIndex('php-mbstring')", 2000);
  339. // };
  340. // if(msg.indexOf('php-mbstring') != -1){
  341. // ItemInstallFail(timer_php_mbstring, 'php-mbstring');
  342. // timer_php_mysql = window.setInterval("AddBarIndex('php-mysql')", 2000);
  343. // };
  344. // if(msg.indexOf('php-mysql') != -1){
  345. // ItemInstallFail(timer_php_mysql, 'php-mysql');
  346. // timer_php_xml = window.setInterval("AddBarIndex('php-xml-status')", 2000);
  347. // };
  348. // if(msg.indexOf('php-xml') != -1){
  349. // ItemInstallFail(timer_php_xml, 'php-xml');
  350. // timer_php_zip = window.setInterval("AddBarIndex('php-zip-status')", 2000);
  351. // };
  352. // if(msg.indexOf('php-zip') != -1){
  353. // ItemInstallFail(timer_php_zip, 'php-zip');
  354. // timer_php72_mbstring = window.setInterval("AddBarIndex('php7.2-mbstring-status')", 2000);
  355. // };
  356. // if(msg.indexOf('php7.2-mbstring') != -1){
  357. // ItemInstallFail(timer_php72_mbstring, 'php7.2-mbstring');
  358. // timer_php72_xml = window.setInterval("AddBarIndex('php7.2-xml-status')", 2000);
  359. // };
  360. // if(msg.indexOf('php7.2-xml') != -1){
  361. // ItemInstallFail(timer_php72_xml, 'php7.2-xml');
  362. // timer_php72_mysql = window.setInterval("AddBarIndex('php7.2-mysql-status')", 2000);
  363. // };
  364. // if(msg.indexOf('php7.2-mysql') != -1){
  365. // ItemInstallFail(timer_php72_mysql, 'php7.2-mysql');
  366. // timer_php72_common = window.setInterval("AddBarIndex('php7.2-common-status')", 2000);
  367. // };
  368. // if(msg.indexOf('php7.2-common') != -1){
  369. // ItemInstallFail(timer_php72_common, 'php7.2-common');
  370. // timer_php72_curl = window.setInterval("AddBarIndex('php7.2-curl-status')", 2000);
  371. // };
  372. // if(msg.indexOf('php7.2-curl') != -1){
  373. // ItemInstallFail(timer_php72_curl, 'php7.2-curl');
  374. // timer_php72_json = window.setInterval("AddBarIndex('php7.2-json-status')", 2000);
  375. // };
  376. // if(msg.indexOf('php7.2-json') != -1){
  377. // ItemInstallFail(timer_php72_json, 'php7.2-json');
  378. // timer_php72_zip = window.setInterval("AddBarIndex('php7.2-zip-status')", 2000);
  379. // };
  380. // if(msg.indexOf('php7.2-zip') != -1){
  381. // ItemInstallFail(timer_php72_zip, 'php7.2-zip');
  382. // timer_service_apache2 = window.setInterval("AddBarIndex('service-apache2-start-status')", 2000);
  383. // };
  384. // if(msg.indexOf('service apache2 start') != -1){
  385. // ItemInstallFail(timer_service_apache2, 'service-apache2-start');
  386. // timer_setting_mysql = window.setInterval("AddBarIndex('setting-mysql-status')", 2000);
  387. // };
  388. // console.log(msg);
  389. // console.log('test2');
  390. // });
  391. });
  392. </script>
  393. </head>
  394. <body>
  395. <nav class="fixed-top">
  396. <nav class="navbar navbar-expand-md nav-top justify-content-center">
  397. <div>
  398. <span class="website_title">伺服器建置</span>
  399. </div>
  400. </nav>
  401. <nav class="navbar navbar-expand-md bg-dark navbar-dark nav-bottom">
  402. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
  403. <span class="navbar-toggler-icon"></span>
  404. </button>
  405. <div class="collapse navbar-collapse" id="collapsibleNavbar">
  406. <ul class="navbar-nav">
  407. <li class="nav-item">
  408. <a class="nav-link" href="/">首頁</a>
  409. </li>
  410. <li class="nav-item">
  411. <a class="nav-link" href="/incoming_check">進貨檢測</a>
  412. </li>
  413. <li class="nav-item">
  414. <a class="nav-link" href="/burn_program">感測器燒錄</a>
  415. </li>
  416. <li class="nav-item">
  417. <a class="nav-link" href="/modify_permissions">權限設置</a>
  418. </li>
  419. <li class="nav-item">
  420. <a class="nav-link" href="/add_sensor">新增感測器</a>
  421. </li>
  422. <li class="nav-item">
  423. <a class="nav-link" href="/add_server">伺服器建置</a>
  424. </li>
  425. <li class="li-block"></li>
  426. <li class="nav-item">
  427. <a class="nav-link" href="#"><i class="fa fa-user-o"></i> {{params.username}}</a>
  428. </li>
  429. <li class="nav-item">
  430. <a class="nav-link" href="/logout">Logout</a>
  431. </li>
  432. </ul>
  433. </div>
  434. </nav>
  435. </nav>
  436. <div class="main-page">
  437. <div class="container">
  438. <div class="row">
  439. <div class="col" style="margin: auto; ">
  440. <table class="table table-bordered" style="font-size:23px;margin-top:30px;">
  441. <tbody>
  442. <tr>
  443. <td>1.請輸入您的IP位置:</td>
  444. <td><input type="text" name="user_ip" value="60.250.156.232"></td>
  445. </tr>
  446. <tr>
  447. <td>2.請輸入您的登入帳號:</td>
  448. <td><input type="text" name="user_loginname" value="root"></td>
  449. </tr>
  450. <tr>
  451. <td>3.請輸入您的username:</td>
  452. <td><input type="text" name="user_username" value="gs1802"></td>
  453. </tr>
  454. <tr>
  455. <td>4.請輸入您的password:</td>
  456. <td><input type="password" name="user_password" value="g53743001"></td>
  457. </tr>
  458. </tbody>
  459. </table>
  460. <div class="text-center">
  461. <input type="button" value="建置" name="add_server" style="cursor:pointer;" onclick="AddServer()">
  462. </div>
  463. <div class="text-center" id="addServer-status" style="margin-top:30px;color:red;visibility:hidden;">
  464. <h2>伺服器建置中...</h2>
  465. </div>
  466. <div>
  467. <h1>Item install status</h1>
  468. <table class="table table-bordered" style="font-size:23px;margin-top:30px;">
  469. <tbody>
  470. <tr>
  471. <th>Item</th>
  472. <th>Status</th>
  473. </tr>
  474. {% for item in params.L %}
  475. <tr>
  476. <td>{{loop.index}}.{{item}}</td>
  477. <td>
  478. <div class="progress" style="height:35px;">
  479. <div id="{{item}}-status" name="{{item}}-status" class="progress-bar progress-bar-striped"
  480. style="width:0%; height:35px; font-size:20px; color:black; text-align:center;">0%
  481. </div>
  482. </div>
  483. </td>
  484. </tr>
  485. {% endfor %}
  486. <!-- <tr>-->
  487. <!-- <td>1.pymysql</td>-->
  488. <!--&lt;!&ndash; <td><span name="pymysql-status"></span></td>&ndash;&gt;-->
  489. <!-- <td>-->
  490. <!-- <div class="progress" style="height:35px;">-->
  491. <!-- <div id="pymysql-status" class="progress-bar progress-bar-striped" style="width:0%;height:35px;font-size:20px;color:black;text-align:center;">0%</div>-->
  492. <!-- </div>-->
  493. <!-- </td>-->
  494. <!-- </tr>-->
  495. <!-- <tr>-->
  496. <!-- <td>2.eventlet</td>-->
  497. <!--&lt;!&ndash; <td><span name="eventlet-status"></span></td>&ndash;&gt;-->
  498. <!-- <td>-->
  499. <!-- <div class="progress" style="height:35px;">-->
  500. <!-- <div id="eventlet-status" class="progress-bar progress-bar-striped" style="width:0%;height:35px;font-size:20px;color:black;text-align:center;">0%</div>-->
  501. <!-- </div>-->
  502. <!-- </td>-->
  503. <!-- </tr>-->
  504. <!-- <tr>-->
  505. <!-- <td>3.flask</td>-->
  506. <!--&lt;!&ndash; <td><span name="eventlet-status"></span></td>&ndash;&gt;-->
  507. <!-- <td>-->
  508. <!-- <div class="progress" style="height:35px;">-->
  509. <!-- <div id="flask-status" class="progress-bar progress-bar-striped" style="width:0%;height:35px;font-size:20px;color:black;text-align:center;">0%</div>-->
  510. <!-- </div>-->
  511. <!-- </td>-->
  512. <!-- </tr>-->
  513. </tbody>
  514. </table>
  515. </div>
  516. </div>
  517. </div>
  518. </div>
  519. </div>
  520. </body>
  521. <script>
  522. // var timer_python38 = 0;
  523. // var timer_python3_pip = 0;
  524. // var timer_git = 0;
  525. // var timer_wget = 0;
  526. // var timer_grep = 0;
  527. // var timer_tasksel = 0;
  528. // var timer_lamp_server = 0;
  529. // var timer_phpMyAdmin = 0;
  530. // var timer_openssl = 0;
  531. // var timer_php_common = 0;
  532. // var timer_php_curl = 0;
  533. // var timer_php_json = 0;
  534. // var timer_php_mbstring = 0;
  535. // var timer_php_mysql = 0;
  536. // var timer_php_xml = 0;
  537. // var timer_php_zip = 0;
  538. // var timer_php72_mbstring = 0;
  539. // var timer_php72_xml = 0;
  540. // var timer_php72_mysql = 0;
  541. // var timer_php72_common = 0;
  542. // var timer_php72_curl = 0;
  543. // var timer_php72_json = 0;
  544. // var timer_php72_zip = 0;
  545. // var timer_service_apache2 = 0;
  546. // var timer_setting_mysql = 0;
  547. // var timer_paho_mqtt = 0;
  548. // var timer_mosquitto = 0;
  549. // var timer_mqtt_server = 0;
  550. // var timer_watchdog = 0;
  551. // var timer_golang = 0;
  552. // var timer_Git_server = 0;
  553. // var timer_flask = 0;
  554. // var timer_Flask_SQLAlchemy = 0;
  555. // var timer_pymysql = 0;
  556. // var timer_flask_mqtt = 0;
  557. // var timer_flask_migrate = 0;
  558. // var timer_flask_jwt_extended = 0;
  559. // var timer_numpy = 0;
  560. // var timer_pandas = 0;
  561. // var timer_opencv_python = 0;
  562. // var timer_BeautifulSoup4 = 0;
  563. // var timer_selenium = 0;
  564. // var timer_geocoder = 0;
  565. // var timer_AP = 0;
  566. // var timer_chrony_ntpdate = 0;
  567. // var timer_deb_ros_packages_and_keyserver = 0;
  568. // var timer_update = 0;
  569. // var timer_upgrade = 0;
  570. // var timer_ros_melodic_desktop_full = 0;
  571. // var timer_ros_melodic_rqt = 0;
  572. // var timer_pythonrosdep = 0;
  573. // var timer_python_rosinstall = 0;
  574. // var timer_ROS = 0;
  575. function AddBarIndex(obj){
  576. var item = document.getElementById(obj);
  577. //因假設元素id內有.或是空格的使用jQuery選擇器會找不到,所以改成用js的節點來設置
  578. //[0].style.width 讓width顯示為%值,使用css.('width')會顯示px
  579. //var width = obj[0].style.width;
  580. var width = item.style.width;
  581. // console.log("width: " + width);
  582. var current_width = width.substring(0, width.length-1);
  583. console.log("current_width: " + current_width);
  584. item.style.width = Number(current_width) + 2 + '%';
  585. // console.log("item.style.width: " + item.style.width);
  586. item.innerText = Number(current_width) + 2 + '%';
  587. // console.log("item.innerText: " + item.innerText);
  588. if (current_width == 94) {
  589. console.log(obj + ' INSTALLATION AddBar Pause');
  590. // eval('clearInterval(timer)');
  591. clearInterval(timer);
  592. }
  593. };
  594. function AddServer(){
  595. //var item = document.getElementById('python3.8-status');
  596. //item.style.width = '2%';
  597. //item.innerText = '2%';
  598. //timer_python38 = window.setInterval("AddBarIndex('python3.8-status')", 2000);
  599. $("#addServer-status").css('visibility','visible');
  600. var ip = $("input[name=user_ip]").val();
  601. var loginname = $("input[name=user_loginname]").val();
  602. var username = $("input[name=user_username]").val();
  603. var password = $("input[name=user_password]").val();
  604. var json = {"ip":ip, "loginname":loginname, "username":username, "password":password};
  605. var abs_update_interval = window.setInterval("abs_update()", 1000);
  606. $.post('/add_server', json, function(resText){
  607. $("#addServer-status").css('visibility','hidden');
  608. if(resText == 'Authentication failed.'){
  609. resText = '您輸入的密碼有誤,請重新輸入!';
  610. $("input[name=user_ip]").val('');
  611. $("input[name=user_username]").val('');
  612. $("input[name=user_password]").val('');
  613. };
  614. clearInterval(abs_update_interval);
  615. setTimeout(alert(resText), 1000);
  616. }, 'text');
  617. // 再次確認所以的狀態寫入狀態條中
  618. // for (const key of Object.entries(response)) {
  619. // if (response[key[0]] == 'Install') {
  620. // if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Wait') {
  621. // Automatic_Build_System_installation[key[0] + '-installation'] = 'Install';
  622. // timer = window.setInterval("AddBarIndex('" + key[0] + "-status')", 2000);
  623. // }
  624. // } else if (response[key[0]] == '0') {
  625. // // pass
  626. // } else if (response[key[0]] == 'Error') {
  627. // if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Install') {
  628. // Automatic_Build_System_installation[key[0] + '-installation'] = 'Error';
  629. // ItemInstallFail(timer, key[0]);
  630. // }
  631. // // } else if (response[key[0]] == 'Success') {
  632. // // if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Install') {
  633. // // Automatic_Build_System_installation[key[0] + '-installation'] = 'Success';
  634. // // ItemInstallSuccess(timer, key[0]);
  635. // // }
  636. // // // ========== Rita 0428 測試保留 ==========
  637. // // } else if (Number(response[key[0]]) !== NaN) {
  638. // // if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Install') {
  639. // // Automatic_Build_System_installation[key[0] + '-installation'] = 'Success';
  640. // // ItemInstallSuccess(timer, key[0], response[key[0]]);
  641. // // }
  642. // // // ========== Rita 0428 測試保留 ==========
  643. // } else if (Number(response[key[0]]) !== NaN) {
  644. // if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Install') {
  645. // Automatic_Build_System_installation[key[0] + '-installation'] = response[key[0]];
  646. // ItemInstallSuccess(timer, key[0], response[key[0]]);
  647. // }
  648. // } else {
  649. // console.log("response[key[0]]: " + response[key[0]]);
  650. // }
  651. // }
  652. };
  653. Automatic_Build_System_installation = {
  654. 'python3.8-installation': 'Wait',
  655. 'python3-pip-installation': 'Wait',
  656. 'cryptography-installation': 'Wait',
  657. 'upgrade-installation': 'Wait',
  658. 'grep-installation': 'Wait',
  659. 'git-installation': 'Wait',
  660. 'gitpython-installation': 'Wait',
  661. 'python3-tk-installation': 'Wait',
  662. 'wget-installation': 'Wait',
  663. 'python3-dev-installation': 'Wait',
  664. 'default-libmysqlclient-dev-installation': 'Wait',
  665. 'build-essential-installation': 'Wait',
  666. 'tasksel-installation': 'Wait',
  667. 'lamp-server-installation': 'Wait',
  668. 'phpMyAdmin-5.1.0-all-languages.tar.gz-installation': 'Wait',
  669. 'openssl-installation': 'Wait',
  670. 'php-common-installation': 'Wait',
  671. 'php-curl-installation': 'Wait',
  672. 'php-json-installation': 'Wait',
  673. 'php-mbstring-installation': 'Wait',
  674. 'php-mysql-installation': 'Wait',
  675. 'php-xml-installation': 'Wait',
  676. 'php-zip-installation': 'Wait',
  677. 'php7.2-mbstring-installation': 'Wait',
  678. 'php7.2-xml-installation': 'Wait',
  679. 'php7.2-mysql-installation': 'Wait',
  680. 'php7.2-common-installation': 'Wait',
  681. 'php7.2-curl-installation': 'Wait',
  682. 'php7.2-json-installation': 'Wait',
  683. 'php7.2-zip-installation': 'Wait',
  684. 'apache2-installation': 'Wait',
  685. 'paho-mqtt-installation': 'Wait',
  686. 'mosquitto-installation': 'Wait',
  687. 'mqtt_server_setting-installation': 'Wait',
  688. 'rclocal/rc.local-installation': 'Wait',
  689. 'golang-installation': 'Wait',
  690. 'gogsfile.git-installation': 'Wait',
  691. 'requirements-installation': 'Wait',
  692. 'CoffeeProject.git-installation': 'Wait',
  693. 'BBend-Test-JWT.git-installation': 'Wait',
  694. 'Coffee_MySQL.sql-installation': 'Wait',
  695. 'chrony-installation': 'Wait',
  696. 'ntpdate-installation': 'Wait',
  697. '--keyserver-installation': 'Wait',
  698. 'update-installation': 'Wait',
  699. 'ros-melodic-desktop-full-installation': 'Wait',
  700. 'ros-melodic-rqt*-installation': 'Wait',
  701. 'python-rosdep-installation': 'Wait',
  702. 'python-rosinstall-installation': 'Wait',
  703. 'python-rosinstall-generator-installation': 'Wait',
  704. 'python-wstool-installation': 'Wait',
  705. 'catkin_make-installation': 'Wait'
  706. }
  707. var abs_update_process = 0;
  708. var timer;
  709. function abs_update() {
  710. if (abs_update_process === 1) {
  711. return;
  712. }
  713. abs_update_process = 1;
  714. $.ajax({
  715. async:false,
  716. type:"GET",
  717. url:"/ABS_update",
  718. dataType:"JSON",
  719. success:function(response){
  720. for (const key of Object.entries(response)) {
  721. if (response[key[0]] == 'Install') {
  722. if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Wait') {
  723. Automatic_Build_System_installation[key[0] + '-installation'] = 'Install';
  724. timer = window.setInterval("AddBarIndex(\"" + key[0] + "-status\")", 2000);
  725. // eval('var ' + key[0] + '_timer = window.setInterval("AddBarIndex(\"' + key[0] + '-status\")", 2000);')
  726. // alert('!!!')
  727. }
  728. } else if (response[key[0]] == '0') {
  729. // pass
  730. } else if (response[key[0]] == 'Error') {
  731. if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Install') {
  732. Automatic_Build_System_installation[key[0] + '-installation'] = 'Error';
  733. ItemInstallFail(timer, key[0]);
  734. }
  735. // } else if (response[key[0]] == 'Success') {
  736. // if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Install') {
  737. // Automatic_Build_System_installation[key[0] + '-installation'] = 'Success';
  738. // ItemInstallSuccess(timer, key[0]);
  739. // }
  740. // // ========== Rita 0428 測試保留 ==========
  741. // } else if (Number(response[key[0]]) !== NaN) {
  742. // if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Install') {
  743. // Automatic_Build_System_installation[key[0] + '-installation'] = 'Success';
  744. // ItemInstallSuccess(timer, key[0], response[key[0]]);
  745. // }
  746. // // ========== Rita 0428 測試保留 ==========
  747. } else if (Number(response[key[0]]) !== NaN) {
  748. // Automatic_Build_System_installation[key[0] + '-installation'] = response[key[0]];
  749. // ItemInstallSuccess(timer, key[0], response[key[0]]);
  750. if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Install') {
  751. Automatic_Build_System_installation[key[0] + '-installation'] = response[key[0]];
  752. ItemInstallSuccess(timer, key[0], response[key[0]]);
  753. } else if (Automatic_Build_System_installation[key[0] + '-installation'] == 'Wait') {
  754. Automatic_Build_System_installation[key[0] + '-installation'] = response[key[0]];
  755. console.log(key[0] + " : " + response[key[0]]);
  756. ItemInstallSuccess(timer, key[0], response[key[0]]);
  757. }
  758. } else {
  759. console.log("response[key[0]]: " + response[key[0]]);
  760. }
  761. }
  762. abs_update_process = 0;
  763. },
  764. error:function(thrownError){
  765. console.log("thrownError: " + thrownError);
  766. abs_update_process = 0;
  767. }
  768. });
  769. };
  770. function ItemInstallSuccess(timer_item, item_name, execution_time){
  771. eval('clearInterval(' + timer_item + ')');
  772. var item = document.getElementById(item_name + '-status');
  773. item.style.width = '100%';
  774. item.innerText = execution_time + 's';
  775. };
  776. function ItemInstallFail(timer_item, item_name){
  777. eval('clearInterval(' + timer_item + ')');
  778. var item = document.getElementById(item_name + '-status');
  779. item.style.width = '0%';
  780. item.innerText = 'Fail';
  781. item.style.color = 'red';
  782. item.style.fontWeight = 'bold';
  783. };
  784. </script>
  785. </html>