subservices.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Subservices</title>
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
  7. <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
  8. <script type="text/javascript" src="../../script/jquery.min.js"></script>
  9. <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
  10. <script type="text/javascript" src="../../script/applocale.js"></script>
  11. <!-- <script type="text/javascript" src="../../script/ao_module.js"></script> -->
  12. </head>
  13. <body>
  14. <br>
  15. <div class="ui container">
  16. <div class="ui container">
  17. <div class="ui header">
  18. <i class="server icon"></i>
  19. <div class="content">
  20. <span locale="subservices/Title">Manage Subservice</span>
  21. <div class="sub header"><span locale="subservices/Subtitle">Glue services together using subservices</span></div>
  22. </div>
  23. </div>
  24. <div class="ui accordion">
  25. <div class="title">
  26. <i class="dropdown icon"></i>
  27. <span locale="subservices/WhatIs">What is Subservice?</span>
  28. </div>
  29. <div class="content">
  30. <p class="transition hidden"><span locale="subservices/Desc">Subservice is one type of ArOZ Online Module that is not build in to the system core but act like one. It is powered by reverse proxy build into the ArOZ Online Core so it can serve web content just like a build in module. Unlike the core modules that cannot be toggle off, you can switch subservices off to save power when needed.</span></p>
  31. </div>
  32. </div>
  33. </div>
  34. <h4 locale="subservices/Running">Running Services</h4>
  35. <table class="ui celled striped table">
  36. <thead>
  37. <tr>
  38. <th locale="subservices/Module">Corresponding Module</th>
  39. <th locale="subservices/Port">Port</th>
  40. <th locale="subservices/ProxyPath">Reverse Proxy Path</th>
  41. <th locale="subservices/Executable">Executable (Process ID)</th>
  42. <th locale="subservices/Action">Action</th>
  43. </tr>
  44. </thead>
  45. <tbody id="sslist">
  46. </tbody>
  47. </table>
  48. <h4 locale="subservices/Disabled">Disabled Services</h4>
  49. <table class="ui celled table">
  50. <thead>
  51. <tr>
  52. <th locale="subservices/ServiceName">Service Name</th>
  53. <th locale="subservices/Executable">Executable</th>
  54. <th locale="subservices/Action">Action</th>
  55. </tr>
  56. </thead>
  57. <tbody id="disServiceList">
  58. </tbody>
  59. </div>
  60. <script>
  61. $('.ui.accordion').accordion();
  62. initSubserviceList();
  63. function initSubserviceList(){
  64. $("#sslist").html("");
  65. $("#disServiceList").html("");
  66. $.get("../../system/subservice/list",function(data){
  67. if (data.error !== undefined){
  68. }else{
  69. for (var i = 0; i < data.Enabled.length; i++){
  70. var ss = data.Enabled[i];
  71. var port = ss.Port;
  72. if (port == 0){
  73. //This module is not using reverse proxy
  74. port = "NO_PROXY";
  75. }
  76. var rpe = ss.RpEndpoint;
  77. if (rpe == ""){
  78. rpe = "N/A";
  79. }else{
  80. rpe = "/" + rpe;
  81. }
  82. $("#sslist").append(`<tr>
  83. <td>
  84. <h4 class="ui image header">
  85. <img src="../../${ss.Info.IconPath}" class="ui mini rounded image">
  86. <div class="content">
  87. ${ss.Info.Name}
  88. <div class="sub header"${ss.Info.Group}
  89. </div>
  90. </div>
  91. </h4>
  92. </td>
  93. <td class="">${port}</td>
  94. <td class="left aligned">${rpe}</td>
  95. <td class="">${ss.Path} (${ss.ProcessID})</td>
  96. <td class=""><button name="${ss.Info.Name}" sd="${ss.ServiceDir}" class="ui primary tiny button" onclick="kill(this);">DISABLE</button></td>
  97. </tr>`);
  98. }
  99. for (var i = 0; i < data.Disabled.length; i++){
  100. var thisDisabledService = data.Disabled[i];
  101. $("#disServiceList").append(` <tr>
  102. <td>${thisDisabledService.ServiceDir}</td>
  103. <td>${thisDisabledService.Path}</td>
  104. <td><button onclick="start(this);" dir="${thisDisabledService.ServiceDir}" class="ui positive tiny button"><span locale="subservices/Start">Start</span></button></td>
  105. </tr>`);
  106. }
  107. }
  108. });
  109. }
  110. function kill(object){
  111. var name = $(object).attr("name");
  112. var sd = $(object).attr("sd");
  113. $.ajax({
  114. url: "../../system/subservice/kill",
  115. data: {serviceDir: sd, moduleName: name},
  116. method: "POST",
  117. success: function(data){
  118. console.log(data);
  119. //Update the launchMenu
  120. parent.initModuleList();
  121. //Update the list
  122. initSubserviceList();
  123. }
  124. });
  125. }
  126. function start(object){
  127. var dir = $(object).attr("dir");
  128. $.ajax({
  129. url: "../../system/subservice/start",
  130. data: {serviceDir: dir},
  131. method: "POST",
  132. success: function(data){
  133. console.log(data);
  134. //Update the launchMenu
  135. parent.initModuleList();
  136. //Update the list
  137. setTimeout(function(){
  138. //Allow 1 seconds to it to startup
  139. initSubserviceList();
  140. }, 1000);
  141. }
  142. });
  143. }
  144. $(document).ready(function(){
  145. if (applocale){
  146. //Applocale found. Do localization
  147. applocale.init("../locale/subservices_setting.json", function(){
  148. applocale.translate();
  149. });
  150. }else{
  151. //App locale not found. Is this a trim down version of ArozOS?
  152. applocale = {
  153. getString: function(key, original){
  154. return original;
  155. }
  156. }
  157. }
  158. });
  159. </script>
  160. </body>
  161. </html>