applicationServer.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. applicationServer_parameter = {};
  2. function applicationServer_create() {
  3. $('#content').html('');
  4. $('#result').html('');
  5. var str = '<table border="1" width="100%">';
  6. str += '<tr><td colspan="2"><a href="#" id="post">post</a></td></tr>';
  7. str += '<tr><td>name:</td><td><input type="text" style="width:95%" id="name"/></td></tr>';
  8. str += '<tr><td>containerType:</td><td><select id="containerType"><option value="tomcat8">tomcat8</option></select></td></tr>';
  9. str += '<tr><td>host:</td><td><input type="text" style="width:95%" id="host"/></td></tr>';
  10. str += '<tr><td>port:</td><td><input type="text" style="width:95%" id="port"/></td></tr>';
  11. str += '<tr><td>proxyHost:</td><td><input type="text" style="width:95%" id="proxyHost"/></td></tr>';
  12. str += '<tr><td>proxyPort:</td><td><input type="text" style="width:95%" id="proxyPort"/></td></tr>';
  13. str += '<tr><td>username:</td><td><input type="text" style="width:95%" id="username"/></td></tr>';
  14. str += '<tr><td>password:</td><td><input type="password" style="width:95%" id="password"/></td></tr>';
  15. str += '<tr><td>deployableList:</td><td id= "deployableList">&nbsp;</td></tr>';
  16. str += '</table>';
  17. $('#content').html(str);
  18. $.ajax({
  19. type : 'get',
  20. dataType : 'json',
  21. contentType : 'application/json; charset=utf-8',
  22. url : '../jaxrs/applicationserver/list/depolyable',
  23. xhrFields : {
  24. 'withCredentials' : true
  25. },
  26. crossDomain : true
  27. }).done(
  28. function(json) {
  29. $('#result').append(JSON.stringify(json, null, 4));
  30. if (json.type == 'success') {
  31. if (json.data) {
  32. var str = '<table><tr><th>name</th><th>context</th><th>plan</th><th>weight</th></tr>';
  33. $.each(json.data, function(index, item) {
  34. str += '<tr><td>' + item.name + '</td><td id="context_' + item.name + '">false</td><td><input type="checkbox" value="' + item.name + '" id="plan_' + item.name
  35. + '"/></td><td><input type="text" style="width:95%" id="weight_' + item.name + '"/></td></tr>';
  36. });
  37. str += '</table>';
  38. $('#deployableList').html(str);
  39. }
  40. } else {
  41. failure(json);
  42. }
  43. });
  44. $('#post').click(function() {
  45. applicationServer_post();
  46. });
  47. }
  48. function applicationServer_edit(name) {
  49. $('#content').html('');
  50. $('#result').html('');
  51. var str = '<table border="1" width="100%">';
  52. str += '<tr><td colspan="2"><a href="#" id="put">put</a></td></tr>';
  53. str += '<tr><td>name:</td><td><input type="text" style="width:95%" id="name"/></td></tr>';
  54. str += '<tr><td>order:</td><td><input type="text" style="width:95%" id="order"/></td></tr>';
  55. str += '<tr><td>containerType:</td><td><select id="containerType"><option value="tomcat8">tomcat8</option></select></td></tr>';
  56. str += '<tr><td>host:</td><td><input type="text" style="width:95%" id="host"/></td></tr>';
  57. str += '<tr><td>port:</td><td><input type="text" style="width:95%" id="port"/></td></tr>';
  58. str += '<tr><td>proxyHost:</td><td><input type="text" style="width:95%" id="proxyHost"/></td></tr>';
  59. str += '<tr><td>proxyPort:</td><td><input type="text" style="width:95%" id="proxyPort"/></td></tr>';
  60. str += '<tr><td>username:</td><td><input type="text" style="width:95%" id="username"/></td></tr>';
  61. str += '<tr><td>password:</td><td><input type="text" style="width:95%" id="password"/></td></tr>';
  62. str += '<tr><td>deployableList:</td><td id= "deployableList">&nbsp;</td></tr>';
  63. str += '</table>';
  64. $('#content').html(str);
  65. $.ajax({
  66. type : 'get',
  67. dataType : 'json',
  68. contentType : 'application/json; charset=utf-8',
  69. url : '../jaxrs/applicationserver/list/depolyable',
  70. xhrFields : {
  71. 'withCredentials' : true
  72. },
  73. crossDomain : true
  74. }).done(
  75. function(json) {
  76. $('#result').html(JSON.stringify(json, null, 4));
  77. if (json.type == 'success') {
  78. if (json.data) {
  79. var str = '<table><tr><th>name</th><th>deployed</th><th>plan</th><th>weight</th></tr>';
  80. $.each(json.data, function(index, item) {
  81. str += '<tr><td>' + item.name + '</td><td id="context_' + item.name + '">false</td><td><input type="checkbox" value="' + item.name + '" id="plan_' + item.name
  82. + '"/></td><td><input type="text" style="width:95%" id="weight_' + item.name + '"/></td></tr>';
  83. });
  84. str += '</table>';
  85. $('#deployableList').html(str);
  86. $.ajax({
  87. type : 'get',
  88. dataType : 'json',
  89. contentType : 'application/json; charset=utf-8',
  90. url : '../jaxrs/applicationserver/name/' + name,
  91. xhrFields : {
  92. 'withCredentials' : true
  93. },
  94. crossDomain : true
  95. }).done(function(json) {
  96. $('#result').html(JSON.stringify(json, null, 4));
  97. if (json.type == 'success') {
  98. if (json.data) {
  99. $('#order').val(json.data.order);
  100. $('#name').val(json.data.name);
  101. $('#containerType').val(json.data.containerType);
  102. $('#host').val(json.data.host);
  103. $('#port').val(json.data.port);
  104. $('#proxyHost').val(json.data.proxyHost);
  105. $('#proxyPort').val(json.data.proxyPort);
  106. $('#username').val(json.data.username);
  107. $('#password').val(json.data.password);
  108. if (json.data.contextList) {
  109. $.each(json.data.contextList, function(idxm, m) {
  110. if ($('#context_' + m)) {
  111. $('#context_' + m).html('true');
  112. }
  113. });
  114. }
  115. if (json.data.planList) {
  116. $.each(json.data.planList, function(idxn, n) {
  117. if ($('#plan_' + n.name)) {
  118. $('#plan_' + n.name).attr("checked", true);
  119. $('#weight_' + n.name).val(n.weight);
  120. }
  121. });
  122. }
  123. }
  124. } else {
  125. failure(json);
  126. }
  127. });
  128. }
  129. } else {
  130. failure(json);
  131. }
  132. });
  133. $('#put', '#content').click(function() {
  134. applicationServer_put(name);
  135. });
  136. }
  137. function applicationServer_post() {
  138. alert($('input[type="checkbox"]:checked').val());
  139. $('#result').html('');
  140. $.ajax({
  141. type : 'post',
  142. dataType : 'json',
  143. url : '../jaxrs/applicationserver',
  144. contentType : 'application/json; charset=utf-8',
  145. data : JSON.stringify({
  146. name : $('#name').val(),
  147. containerType : $('#containerType').val(),
  148. host : $('#host').val(),
  149. port : $('#port').val(),
  150. proxyHost : $('#proxyHost').val(),
  151. proxyPort : $('#proxyPort').val(),
  152. username : $('#username').val(),
  153. password : $('#password').val(),
  154. planList : applicationServer_planListValue()
  155. }),
  156. xhrFields : {
  157. 'withCredentials' : true
  158. },
  159. crossDomain : true
  160. }).done(function(json) {
  161. $('#result').html(JSON.stringify(json, null, 4));
  162. });
  163. }
  164. function applicationServer_put(name) {
  165. $('#result').html('');
  166. $.ajax({
  167. type : 'put',
  168. dataType : 'json',
  169. url : '../jaxrs/applicationserver/name/' + name,
  170. contentType : 'application/json; charset=utf-8',
  171. data : JSON.stringify({
  172. name : $('#name').val(),
  173. order : $('#order').val(),
  174. containerType : $('#containerType').val(),
  175. host : $('#host').val(),
  176. port : $('#port').val(),
  177. proxyHost : $('#proxyHost').val(),
  178. proxyPort : $('#proxyPort').val(),
  179. username : $('#username').val(),
  180. password : $('#password').val(),
  181. weight : $('#weight').val(),
  182. planList : applicationServer_planListValue()
  183. }),
  184. xhrFields : {
  185. 'withCredentials' : true
  186. },
  187. crossDomain : true
  188. }).done(function(json) {
  189. $('#result').html(JSON.stringify(json, null, 4));
  190. });
  191. }
  192. function applicationServer_delete(name) {
  193. $('#result').html('');
  194. $.ajax({
  195. type : 'delete',
  196. dataType : 'json',
  197. url : '../jaxrs/applicationserver/name/' + name,
  198. contentType : 'application/json; charset=utf-8',
  199. xhrFields : {
  200. 'withCredentials' : true
  201. },
  202. crossDomain : true
  203. }).done(function(json) {
  204. $('#result').html(JSON.stringify(json, null, 4));
  205. });
  206. }
  207. function applicationServer_deploy(name, forceRedeploy) {
  208. $('#result').html('');
  209. $.ajax({
  210. type : 'get',
  211. dataType : 'json',
  212. url : '../jaxrs/applicationserver/name/' + name + '/deploy/' + forceRedeploy,
  213. contentType : 'application/json; charset=utf-8',
  214. xhrFields : {
  215. 'withCredentials' : true
  216. },
  217. crossDomain : true
  218. }).done(function(json) {
  219. $('#result').html(JSON.stringify(json, null, 4));
  220. });
  221. }
  222. function applicationServer_planListValue() {
  223. var arr = new Array();
  224. $('input[type="checkbox"]:checked').each(function() {
  225. var obj = {};
  226. obj.name = $(this).val();
  227. obj.weight = $('#weight_' + obj.name).val();
  228. arr.push(obj);
  229. });
  230. return arr;
  231. }