view.ui.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. window.checkServiceStatus = function(){
  2. toggleLoading('#serviceContent', true);
  3. $.get($.createLink('zanode', 'ajaxGetServiceStatus', 'nodeID=' + nodeID), function(response)
  4. {
  5. var resultData = JSON.parse(response);
  6. var isSuccess = true
  7. for (var key in resultData.data)
  8. {
  9. if(key == "ZTF")
  10. {
  11. if(resultData.data[key] == 'ready')
  12. {
  13. $('.dot-ztf').removeClass("text-danger")
  14. $('.dot-ztf').addClass("text-success")
  15. }
  16. else{
  17. $('.dot-ztf').removeClass("text-success")
  18. $('.dot-ztf').addClass("text-danger")
  19. }
  20. if(resultData.data[key] == 'ready' || resultData.data[key] == 'not_available')
  21. {
  22. $('.service-status').removeClass('hidden');
  23. $('.ztf-status').text(zanodeLang.init[resultData.data[key]])
  24. $('.ztf-install').text('');
  25. $('.ztf-install-icon').hide();
  26. }
  27. else
  28. {
  29. if(resultData.data[key] == 'unknown')
  30. {
  31. if(hostType == 'physics')
  32. {
  33. $('.ztf-status').text(zanodeLang.init.not_install)
  34. }
  35. else
  36. {
  37. $('.ztf-status').text(zanodeLang.init.unknown)
  38. }
  39. }
  40. else
  41. {
  42. $('.ztf-status').text(zanodeLang.initializing)
  43. }
  44. $('.ztf-install').text(zanodeLang.install);
  45. }
  46. }
  47. else if(key == "node")
  48. {
  49. if(resultData.data[key] && zanodeLang.statusList[nodeStatus] != zanodeLang.statusList[resultData.data[key]])
  50. {
  51. loadCurrentPage();
  52. }
  53. }
  54. else
  55. {
  56. if(resultData.data[key] == 'ready')
  57. {
  58. $('.dot-zenagent').removeClass("text-danger")
  59. $('.dot-zenagent').addClass("text-success")
  60. }
  61. else{
  62. $('.dot-zenagent').removeClass("text-success")
  63. $('.dot-zenagent').addClass("text-danger")
  64. }
  65. $('.zenagent-status').text(zanodeLang.init[resultData.data[key]])
  66. if(resultData.data[key] == 'ready')
  67. {
  68. $('.node-init-install').removeClass('hidden');
  69. }
  70. else
  71. {
  72. if(resultData.data[key] == 'unknown')
  73. {
  74. $('.ztf-zenagent').text(zanodeLang.init.unknown)
  75. }
  76. else
  77. {
  78. $('.zenagent-status').text(zanodeLang.initializing)
  79. }
  80. }
  81. }
  82. if(resultData.data[key] !== 'ready' && key != 'node')
  83. {
  84. isSuccess = false
  85. }
  86. };
  87. if(!isSuccess)
  88. {
  89. $('.init-fail').removeClass('hidden');
  90. $('.init-success').addClass('hidden');
  91. }
  92. else
  93. {
  94. $('.init-success').removeClass('hidden');
  95. $('.init-fail').addClass('hidden');
  96. }
  97. setTimeout(function() {
  98. toggleLoading('#serviceContent', false);
  99. $(".service-status, .status-notice").removeClass('hidden')
  100. }, 500);
  101. });
  102. }
  103. function copyToClipboard(text) {
  104. var tempInput = document.createElement("input");
  105. document.body.appendChild(tempInput);
  106. tempInput.value = text;
  107. tempInput.select();
  108. document.execCommand("copy");
  109. document.body.removeChild(tempInput);
  110. }
  111. function sshCopy()
  112. {
  113. copyToClipboard($('#ssh-copy').val());
  114. zui.Messager.show({
  115. type: 'success',
  116. content: zanodeLang.copied,
  117. time: 2000
  118. });
  119. }
  120. function pwdCopy()
  121. {
  122. copyToClipboard($('#pwd-copy').val());
  123. zui.Messager.show({
  124. type: 'success',
  125. content: zanodeLang.copied,
  126. time: 2000
  127. });
  128. }
  129. function pwdShow()
  130. {
  131. var pwd = $('#pwd-copy').val();
  132. var pwdStar = "******".padEnd(pwd.length, '*')
  133. var html = $('.btn-pwd-show').html()
  134. if(html.indexOf('icon-eye-off') != -1)
  135. {
  136. $('#pwd-text').text(pwdStar)
  137. $('.btn-pwd-show').html("<i class='icon-common-eye icon-eye' title='" + zanodeLang.showPwd + "'></i>")
  138. }
  139. else
  140. {
  141. $('#pwd-text').text(pwd)
  142. $('.btn-pwd-show').html("<i class='icon-common-eye icon-eye-off' title='" + zanodeLang.hidePwd + "'></i>")
  143. }
  144. }
  145. function onCopy()
  146. {
  147. copyToClipboard($('#initBash').val());
  148. zui.Messager.show({
  149. type: 'success',
  150. content: zanodeLang.copied,
  151. time: 2000
  152. });
  153. }
  154. $(function()
  155. {
  156. $('.create-snapshot i').replaceWith("<img src='static/svg/snapshot.svg' />");
  157. checkServiceStatus();
  158. });
  159. window.editSnapshot = function(url)
  160. {
  161. openUrl(url, {load: 'modal'});
  162. }