subservices.html 6.7 KB

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