ws_roxieconfig_deploytab.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /*##############################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################## */
  16. var dtDeploy, dsDeploy;
  17. var addEclPanel;
  18. var uploader;
  19. (function() {
  20. var btnDeploySelected = new YAHOO.widget.Button({
  21. label: "Deploy",
  22. id: "deploySelected",
  23. container: "btnDeployments",
  24. onclick: { fn: deployWorkunits }
  25. });
  26. })();
  27. function createDroplist(SelectedNameService, DroplistArray, oRecord, oColumn) {
  28. var d = "<select onChange=\"onEditDroplistChange('" + oColumn.getField() + "', '" + oRecord.getId() + "', this.value)\">";
  29. for (var i = 0; i < DroplistArray.length; i++) {
  30. d += '<option value="' + DroplistArray[i].value + '" ' + (DroplistArray[i].value == SelectedNameService ? 'selected = "1"' : '') + '>' + DroplistArray[i].label + '</option>';
  31. }
  32. d += '</select>';
  33. return d;
  34. }
  35. var formatInlinePassword = function(elCell, oRecord, oColumn, sData) {
  36. elCell.innerHTML = createEntry(sData, oRecord, oColumn, true);
  37. };
  38. function onEditDroplistChange(ColumnName, RecordId, Value) {
  39. var record = dtDeploy.getRecord(RecordId);
  40. record.setData(ColumnName, Value);
  41. dtDeploy.render();
  42. }
  43. var formatMaskedLabel = function(elCell, oRecord, oColumn, sData) {
  44. elCell.innerHTML = sData.replace(/./g, '*');
  45. };
  46. var formatProcessAction = function(elCell, oRecord, oColumn, sData) {
  47. if (sData == "1") {
  48. elCell.innerHTML = '<img src="/esp/files/yui/build/assets/skins/sam/loading.gif" />';
  49. }
  50. if (sData == "2") {
  51. elCell.innerHTML = '<img src="/esp/files/yui/build/assets/skins/sam/menuitem_checkbox.png" />';
  52. }
  53. };
  54. function checkNotifyRoxieCheck() {
  55. if (document.getElementById('deploySavePending') && !document.getElementById('checkNotifyRoxie5')) {
  56. var d = document.createElement("span");
  57. var notifyChecked = '';
  58. if (notifyRoxie) {
  59. notifyChecked = ' checked="true"';
  60. }
  61. d.innerHTML = '<input type="checkbox" name="checkNotifyRoxie5" id="checkNotifyRoxie5" ' + notifyChecked + ' onclick="setNotifyRoxie(this.checked);">Notify Roxie?</input>';
  62. document.getElementById('btnDeployments').appendChild(d);
  63. }
  64. }
  65. var WorkunitCellClickedHandler = function(oArgs) {
  66. var record = dtDeploy.getRecord(oArgs.target);
  67. var column = dtDeploy.getColumn(oArgs.target);
  68. if (column && column.field == 'Mark') {
  69. var isChecked = record.getData(column.field) == '1' ? true : false;
  70. record.setData(column.field, isChecked ? '0' : '1');
  71. record.setData('Activation', '1');
  72. dtDeploy.render();
  73. return;
  74. }
  75. dtDeploy.onEventShowCellEditor(oArgs);
  76. }
  77. var ar_Activate = new Array({ label: "Don't Activate", value: "0" }, { label: "Activate", value: "1" }, { label: "Suspend Previous", value: "2" }, { label: "Delete Previous", value: "3" });
  78. var formatActivate = function(elCell, oRecord, oColumn, sData) {
  79. var iActivate = 1;
  80. if (sData && sData.length > 0) { // not setting
  81. iActivate = parseInt(sData);
  82. }
  83. if (oRecord.getData('Mark') == '1') {
  84. elCell.innerHTML = createDroplist(iActivate, ar_Activate, oRecord, oColumn);
  85. } else {
  86. elCell.innerHTML = '';
  87. }
  88. };
  89. function onEditDroplistChange(ColumnName, RecordId, Value) {
  90. var record = dtDeploy.getRecord(RecordId);
  91. record.setData(ColumnName, Value);
  92. dtDeploy.render();
  93. }
  94. function createDroplist(SelectedNameService, DroplistArray, oRecord, oColumn) {
  95. var d = "<select onChange=\"onEditDroplistChange('" + oColumn.getField() + "', '" + oRecord.getId() + "', this.value)\">";
  96. for (var i = 0; i < DroplistArray.length; i++) {
  97. d += '<option value="' + DroplistArray[i].value + '" ' + (DroplistArray[i].value == SelectedNameService ? 'selected = "1"' : '') + '>' + DroplistArray[i].label + '</option>';
  98. }
  99. d += '</select>';
  100. return d;
  101. }
  102. function loadPendingDeployments(ElementId, Resize) {
  103. if (Resize) {
  104. createDeploymentDataTable(ElementId);
  105. return;
  106. }
  107. var connectionCallback = {
  108. success: function(o) {
  109. var xmlDoc = o.responseXML;
  110. dsDeploy = new YAHOO.util.DataSource(xmlDoc);
  111. dsDeploy.responseType = YAHOO.util.DataSource.TYPE_XML;
  112. dsDeploy.responseSchema = {
  113. resultNode: "RoxieECLWorkunitInfo",
  114. fields: ["Wuid", "Owner", "Cluster", "Jobname", "StateID", "State", "Protected", "IsPausing"]
  115. };
  116. createDeploymentDataTable(ElementId);
  117. checkNotifyRoxieCheck();
  118. },
  119. failure: function(o) {
  120. alert('Failure:' + o.statusText);
  121. }
  122. };
  123. clearDeploymentDataTable();
  124. createDeploymentDataTable(ElementId);
  125. dtDeploy.showTableMessage(dtDeploy.get("MSG_LOADING"), dtDeploy.CLASS_LOADING);
  126. var postBody = '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://webservices.seisint.com/ws_roxieconfig"><soap:Body><RoxieWUQueryRequest><Cluster></Cluster><TargetClusterType>roxie</TargetClusterType><Owner/><Jobname/></RoxieWUQueryRequest></soap:Body></soap:Envelope>';
  127. YAHOO.util.Connect.initHeader("SOAPAction", "/ws_roxieconfig/RoxieWUQuery?ver_=" + WS_ROXIECONFIG_VER);
  128. YAHOO.util.Connect.initHeader("Content-Type", "text/xml");
  129. YAHOO.util.Connect._use_default_post_header = false;
  130. var getXML = YAHOO.util.Connect.asyncRequest("POST",
  131. "/ws_roxieconfig/RoxieWUQuery",
  132. connectionCallback, postBody);
  133. return {
  134. };
  135. }
  136. function clearDeploymentDataTable() {
  137. if (dtDeploy) {
  138. dtDeploy.destroy();
  139. dtDeploy = null;
  140. dsDeploy = null;
  141. }
  142. dsDeploy = new YAHOO.util.DataSource();
  143. }
  144. function createDeploymentDataTable(ElementId) {
  145. var myColumnDefs = [{ key: "Mark", label: "", formatter: formatInlineEditCheckbox, width: 40 },
  146. { key: "Wuid", lable: "Workunit", sortable: true, resizeable: false, width: 300 },
  147. { key: "Owner", label: "Owner", sortable: true, resizeable: false, width: 180 },
  148. { key: "Jobname", label: "Jobname", editor: new YAHOO.widget.TextboxCellEditor({disableBtns:true}), sortable: true, resizeable: false, width: 120 },
  149. { key: "State", label: "State", sortable: true, resizeable: false, width: 150 },
  150. { key: "Activation", label: "Activation", formatter: formatActivate, sortable: true, resizeable: false, width: 150 },
  151. { key: "Action", label: "Action", formatter: formatProcessAction, sortable: true, resizeable: false, width: 150 },
  152. { key: "Protected", label: "Protected", formatter: formatCheckboxDisabled, sortable: true, resizeable: false, width: 100}];
  153. //dtDeploy = new YAHOO.widget.ScrollingDataTable(ElementId, myColumnDefs, dsDeploy, { width: "100%", height: "100%" });
  154. dtDeploy = new YAHOO.widget.ScrollingDataTable(ElementId, myColumnDefs, dsDeploy, { width: "100%" });
  155. var highlightEditableCell = function(oArgs) {
  156. var elCell = oArgs.target;
  157. if (YAHOO.util.Dom.hasClass(elCell, "yui-dt-editable")) {
  158. dtDeploy.highlightCell(elCell);
  159. }
  160. };
  161. dtDeploy.subscribe("cellMouseoverEvent", highlightEditableCell);
  162. dtDeploy.subscribe("cellMouseoutEvent", dtDeploy.onEventUnhighlightCell);
  163. dtDeploy.subscribe("cellClickEvent", WorkunitCellClickedHandler);
  164. }
  165. function deployWorkunits() {
  166. var records = dtDeploy.getRecordSet().getRecords();
  167. for (var i = 0; i < records.length; i++) {
  168. var mark = records[i].getData('Mark');
  169. var wuid = records[i].getData('Wuid');
  170. var jobName = records[i].getData('Jobname');
  171. var activate = records[i].getData('Activation');
  172. if (mark == '1') {
  173. // set ui to show 'deploying' and turn off when the ajax call completes.
  174. records[i].setData('Action', '1');
  175. deployWorkunit(wuid, jobName, activate);
  176. }
  177. }
  178. dtDeploy.render();
  179. }
  180. function deployWorkunit(Workunit, JobName, Activate) {
  181. var connectionCallback = {
  182. success: function(o) {
  183. var xmlDoc = o.responseXML;
  184. // find workunit in dtDeploy and set to deployed Action = '2'.
  185. var records = dtDeploy.getRecordSet().getRecords();
  186. for (var i = 0; i < records.length; i++) {
  187. var wuid = records[i].getData('Wuid');
  188. if (wuid == Workunit) {
  189. // set ui to show 'deploying' and turn off when the ajax call completes.
  190. records[i].setData('Mark', '');
  191. records[i].setData('Action', '2');
  192. }
  193. }
  194. dtDeploy.render();
  195. },
  196. failure: function(o) {
  197. alert('Failure:' + o.statusText);
  198. }
  199. };
  200. var postBody = '<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns="http://webservices.seisint.com/ws_roxieconfig"><soap:Body><RoxieDeployWorkunit><Wuid>' + Workunit + '</Wuid><QueryName>' + JobName + '</QueryName><Options><Activate>' + Activate + '</Activate><NotifyRoxie>' + notifyRoxie + '</NotifyRoxie></Options></RoxieDeployWorkunit></soap:Body></soap:Envelope>';
  201. YAHOO.util.Connect.initHeader("SOAPAction", "/ws_roxieconfig/DeployWorkunit?ver_=" + WS_ROXIECONFIG_VER);
  202. YAHOO.util.Connect.initHeader("Content-Type", "text/xml");
  203. YAHOO.util.Connect._use_default_post_header = false;
  204. var getXML = YAHOO.util.Connect.asyncRequest("POST",
  205. "/ws_roxieconfig/DeployWorkunit",
  206. connectionCallback, postBody);
  207. return {};
  208. }
  209. var statusPanel;
  210. function showDeployStatus(RecId) {
  211. var recordSet = dtDeploy.getRecordSet();
  212. var record = recordSet.getRecord(RecId);
  213. if (!record) {
  214. recordSet = dt_Action.getRecordSet();
  215. record = recordSet.getRecord(RecId);
  216. }
  217. var handleOk = function() {
  218. statusPanel.hide();
  219. statusPanel = null;
  220. };
  221. if (!statusPanel) {
  222. statusPanel = new YAHOO.widget.SimpleDialog("showDeploymentStatus",
  223. { width: "500px",
  224. fixedcenter: true,
  225. visible: true,
  226. close: true,
  227. effect: {
  228. effect: YAHOO.widget.ContainerEffect.FADE,
  229. duration: 0.25
  230. },
  231. icon: YAHOO.widget.SimpleDialog.ICON_INFO,
  232. constraintoviewport: true,
  233. buttons: [{ text: "Ok", handler: handleOk, isDefault: true}]
  234. });
  235. }
  236. statusPanel.setHeader(record.getData('OriginalName') + ' Status');
  237. statusPanel.setBody('<div style="text-align:left; height:200px; overflow:scroll;">' + record.getData('Status').replace(/\n/gi, '<br />') + '</div>');
  238. statusPanel.render("statusdiv");
  239. statusPanel.show()
  240. }