00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00030
00031
00032
00033
00034
00035
00036
00037
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081 var DeleteWiz = DeleteWiz || {};
00082
00083 if (typeof Debug == 'undefined')
00084 console.log('ERROR: Debug is undefined! Must include Debug.js before DeleteWiz_ConfigurationGUI.js');
00085 else if (typeof Globals == 'undefined')
00086 console.log('ERROR: Globals is undefined! Must include Globals.js before DeleteWiz_ConfigurationGUI.js');
00087 else
00088 DeleteWiz.wiz;
00089
00090
00093
00096 DeleteWiz.createWiz = function(doneHandler) {
00097
00098
00099 var _TABLE_BOOL_TYPE_TRUE_COLOR = "rgb(201, 255, 201)";
00100 var _TABLE_BOOL_TYPE_FALSE_COLOR = "rgb(255, 178, 178)";
00101
00102
00103
00104
00105 var _recordAlias;
00106 var _doneHandler = doneHandler;
00107 var _aRecordWasDeleted = false;
00108
00109 var _RECORD_TYPE_CONTEXT = "Context";
00110 var _RECORD_TYPE_APP = "Supervisor";
00111 var _validRecordTypes = [_RECORD_TYPE_CONTEXT,_RECORD_TYPE_APP];
00112
00113
00115 function localParameterCheck()
00116 {
00117
00118 var i=_validRecordTypes.length-1;
00119 for(i;i>=0;--i)
00120 if(_validRecordTypes[i] == _recordAlias) break;
00121 if(i<0)
00122 {
00123 var str = "Invalid Record Alias '" + _recordAlias + "' was specified. " +
00124 "The only valid record aliases are as follows: ";
00125
00126 for(i=_validRecordTypes.length-1;i>=0;--i)
00127 str += "<br>\t_validRecordTypes[i]";
00128 Debug.log(str,Debug.HIGH_PRIORITY);
00129 return;
00130 }
00131 }
00132
00133
00134 var _subsetUIDs;
00135 var _systemGroups;
00136 var _paramObjMap;
00137 var _furthestStep = -1;
00138 var _lastNextStep = -1;
00139
00140
00141 var _modifiedTables;
00142
00143
00144 var _STEP_OUT_OF_SEQUENCE = 1000;
00145
00146 var
00147
00148
00149
00150
00151 _STEP_ALSO_DESCENDANTS = 101,
00152 _STEP_CHANGE_GROUP = 1000,
00153 _STEP_GET_RECORD_NAME = 100,
00154 _STEP_SAVE_MODIFIED = 500,
00155 _STEP_WHICH_RECORD_TYPE = 20;
00156
00157
00160
00161 Debug.log("DeleteWiz.wiz constructed");
00162 DeleteWiz.wiz = this;
00163
00164
00165 DesktopContent.tooltip("Delete Wizard Introduction",
00166 "Welcome to the Delete Wizard GUI. Here you can delete hierarchical records for "+
00167 "your <i>otsdaq</i> system. \n\n" +
00168 "The Delete Wizard is presented as a step-by-step process that will walk you through deleting a record and its children.\n\n" +
00169
00170 "Briefly, here is a description of the steps: " +
00171 "\n\t- 'What is the name of your record?'" +
00172 "\n\t- 'How deep into the hierachy do you want to delete?'"
00173 );
00174 xdaqContextTooltip();
00175 xdaqApplicationTooltip();
00176
00177 showPrompt(_STEP_WHICH_RECORD_TYPE);
00178
00179
00180 return;
00181
00184
00185
00186
00187
00188
00189 function xdaqContextTooltip()
00190 {
00191 DesktopContent.tooltip("XDAQ Contexts",
00192 "The lowest level parent for all records, in the <i>otsdaq</i> configuration tree, is a XDAQ Context. " +
00193 "What is a XDAQ Context? Why do I need a XDAQ Context? Do I want a new one for my " + _recordAlias + " or not?" +
00194 "<br><br>" +
00195 "XDAQ Contexts are the fundamental executable program building blocks of <i>otsdaq</i>. " +
00196 "A XDAQ Context runs a group of XDAQ Applications inside of it. If one of those XDAQ Applications crashes, " +
00197 "then only the parent XDAQ Context will crash. This is one reason organizing your <i>otsdaq</i> entities into separate XDAQ Contexts makes sense." +
00198 "<br><br>" +
00199 "Two other useful features of XDAQ Contexts are that they can easily be turned on and off (enabled and disabled through the configuration editors), and " +
00200 "they can easily be distributed to other nodes (computers) in your DAQ system when your system scales up."
00201 );
00202 }
00203
00204
00205 function xdaqApplicationTooltip()
00206 {
00207 DesktopContent.tooltip("XDAQ Applications",
00208 "The second level parent for all records, in the <i>otsdaq</i> configuration tree, is a XDAQ Application. " +
00209 "What is a XDAQ Application? Why do I need a XDAQ Application? Do I want a new one for my " + _recordAlias + " or not?" +
00210 "<br><br>" +
00211 "XDAQ Applications are server processes that can be controlled by <i>otsdaq</i> through network messages. " +
00212 "Ther can be one or many XDAQ Applciation in a XDAQ Context. If one of those XDAQ Applications crashes, " +
00213 "then all of the other XDAQ Applications in the parent XDAQ Context will crash. This is one reason organizing your <i>otsdaq</i> entities into separate XDAQ Contexts makes sense." +
00214 "<br><br>" +
00215 "Two other useful features of XDAQ Applications are that they can respond to web requests and state machine transitions."
00216 );
00217 }
00218
00219
00220
00221
00222
00223 function initDeleteWizard()
00224 {
00225 _subsetUIDs = [];
00226 _modifiedTables = [];
00227 _furthestStep = -1;
00228 _paramObjMap = {};
00229 _systemGroups = {};
00230
00231 {
00232
00233 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
00234 while(el)
00235 {
00236 el.parentNode.removeChild(el);
00237 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
00238 }
00239 }
00240
00241
00242
00243 ConfigurationAPI.getAliasesAndGroups(
00244 function(retObj)
00245 {
00246 _systemGroups = retObj;
00247 console.log("_systemGroups",_systemGroups);
00248 console.log("ConfigurationAPI._activeGroups",ConfigurationAPI._activeGroups);
00249
00250
00251
00252 ConfigurationAPI.getSubsetRecords(
00253 getRecordConfiguration(),
00254 getRecordFilter() ,
00255 function(records)
00256 {
00257 _subsetUIDs = records;
00258 Debug.log("records found = " + records.length);
00259 console.log(records);
00260
00261 showPrompt(_STEP_GET_RECORD_NAME);
00262
00263 },_modifiedTables);
00264
00265 });
00266
00267 }
00268
00269
00270
00271
00272
00273 function showPrompt(stepIndex,paramObj)
00274 {
00275
00276 if(!stepIndex) stepIndex = 0;
00277
00278 if(stepIndex > _furthestStep &&
00279 _furthestStep < _STEP_OUT_OF_SEQUENCE)
00280 _furthestStep = stepIndex;
00281
00282 Debug.log("showPrompt " + stepIndex);
00283 Debug.log("_furthestStep " + _furthestStep);
00284
00285
00286 if(!_paramObjMap) _paramObjMap = {};
00287
00288
00289 if(paramObj)
00290 _paramObjMap[stepIndex] = paramObj;
00291 else if(_paramObjMap[stepIndex])
00292 paramObj = _paramObjMap[stepIndex];
00293 else
00294 {
00295
00296 _paramObjMap[stepIndex] = {};
00297 paramObj = _paramObjMap[stepIndex];
00298 }
00299
00300 console.log("_paramObjMap",_paramObjMap);
00301 console.log("paramObj",paramObj);
00302
00303 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
00304
00305
00306 while(el)
00307 {
00308 el.parentNode.removeChild(el);
00309 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
00310 }
00311
00312
00313
00314 var w = 480;
00315 var h = 340;
00316
00317 var str = "";
00318 var stepString = "stepIndex-" + stepIndex + "-";
00319
00320 var showPrevButton = true;
00321 var showNextButton = true;
00322 var prevStepIndex = stepIndex-1;
00323 if(prevStepIndex > _lastNextStep)
00324 prevStepIndex = _lastNextStep;
00325 _lastNextStep = stepIndex;
00326
00327 var nextStepIndex = stepIndex+1;
00328 var prevButtonText = "Go Back";
00329 var nextButtonText = "Next Step";
00330
00331 var recordName = "";
00332 try
00333 {
00334 recordName = _paramObjMap[_STEP_GET_RECORD_NAME]["recordName"];
00335 } catch(e){;}
00336
00339
00340 localAddContent();
00341 function localAddContent()
00342 {
00343 switch(stepIndex)
00344 {
00345
00346
00347 case _STEP_SAVE_MODIFIED:
00348
00349 Debug.log("_STEP_SAVE_MODIFIED ");
00350
00351 nextButtonText = "Done!";
00352
00353 str += "<br>";
00354 str += "Things are getting real! Are you sure you want to proceed?<br><br>" +
00355 "To finalize your deletions, please click 'Done!'";
00356 str += "<br>";
00357 str += "<br>";
00358
00359 Debug.log("All deletions, so far, were made temporarily. For them to persist, " +
00360 "you must follow the prompt and click the 'Done!' button.",
00361 Debug.INFO_PRIORITY);
00362
00363 break;
00364
00365 case _STEP_ALSO_DESCENDANTS:
00366
00367 localAlsoDescendantContent();
00368 function localAlsoDescendantContent()
00369 {
00370 showNextButton = false;
00371
00372
00373 Debug.log("_STEP_ALSO_DESCENDANTS " + recordName);
00374
00375
00376 str += "<br>";
00377
00378 var children = paramObj["rootChildren"];
00379 if(children.length)
00380 {
00381 str += "Do you want to delete all the descendants along with the parent " + _recordAlias + " named '" +
00382 recordName + ",' or only the chosen " + _recordAlias + " record named '" +
00383 recordName + "?'";
00384 str += "<br>";
00385 str += "<br>";
00386
00387 str += "<b>For reference, here are the first-level children of the chosen " + _recordAlias +
00388 " named '" +
00389 recordName + "':</b><br>";
00390 {
00391 str += htmlOpen("select",
00392 {
00393 "id" : stepString + "rootChildren",
00394 });
00395
00396 for(var i=0;i<children.length;++i)
00397 {
00398 str += htmlOpen("option",
00399 {
00400 },
00401 ConfigurationAPI.getTreeRecordName(children[i]) ,
00402 true );
00403 }
00404 str += "</select>";
00405
00406 str += htmlClearDiv();
00407 str += htmlOpen("input",
00408 {
00409 "id": stepString + "deleteDescendants",
00410 "type": "button",
00411 "value": "Delete " + _recordAlias + " and ALL Descendants",
00412 "title": "Delete all children of the chosen " + _recordAlias + " named '" +
00413 recordName + ".'"
00414 },
00415 0 , true );
00416 }
00417 }
00418 else
00419 str += "There were no Supervisor children found for the parent " + _recordAlias + " named '" +
00420 recordName + "' - do you want to delete the " + _recordAlias + " named '" +
00421 recordName + "?'";
00422
00423
00424 str += htmlClearDiv();
00425
00426 str += htmlOpen("input",
00427 {
00428 "style": "margin:20px;",
00429 "id": stepString + "deleteOnlyRoot",
00430 "type": "button",
00431 "value": "Delete Only the " + _recordAlias,
00432 "title": "Delete only the chosen " + _recordAlias + " named '" +
00433 recordName + ".'"
00434 },
00435 0 , true );
00436
00437 }
00438
00439
00440
00441
00442
00443 break;
00444
00445 case _STEP_CHANGE_GROUP:
00446
00447
00448 showNextButton = false;
00449 nextStepIndex = _STEP_GET_RECORD_NAME;
00450 prevStepIndex = _STEP_GET_RECORD_NAME;
00451
00452 str += "Choose a '" + paramObj["groupType"] +
00453 "' group to activate (either a System Alias or specific group):";
00454
00455 str += htmlClearDiv();
00456
00457 str += "<center>";
00458 str += "<table style='margin-bottom: 10px;'>";
00459 if(_systemGroups.aliases[paramObj["groupType"]].length)
00460 {
00461 str += "<tr><td><b>System Aliases:</b></td><td>";
00462 {
00463 str += htmlOpen("select",
00464 {
00465 "id" : stepString + "aliases",
00466 });
00467
00468 for(var i=0;i<_systemGroups.aliases[paramObj["groupType"]].length;++i)
00469 {
00470 str += htmlOpen("option",
00471 {
00472 },
00473 _systemGroups.aliases[paramObj["groupType"]]
00474 [i].alias , true );
00475 }
00476 str += "</select>";
00477 str += htmlOpen("input",
00478 {
00479 "id": stepString + "activateAlias",
00480 "type": "button",
00481 "value": "Activate Alias",
00482 "title": "Activate chosen System Alias and return to creating your new " + _recordAlias + "."
00483 },
00484 0 , true );
00485 }
00486 str += "</td></tr>";
00487 }
00488 else
00489 str += "<tr><td colspan='2'>No system aliases of type Context found.</td></tr>";
00490
00491 var groupNames = Object.keys(_systemGroups.groups[paramObj["groupType"]]);
00492 if(groupNames.length)
00493 {
00494 str += "<tr><td><b>Group Names:</b></td><td>";
00495 {
00496 str += htmlOpen("select",
00497 {
00498 "id" : stepString + "groupNames",
00499 });
00500
00501 for(var i=0;i<groupNames.length;++i)
00502 {
00503 str += htmlOpen("option",
00504 {
00505 },
00506 groupNames[i] , true );
00507 }
00508 str += "</select>";
00509
00510 }
00511 str += "</td></tr>";
00512 }
00513 else
00514 str += "<tr><td colspan='2'>No groups of type Context found.</td></tr>";
00515
00516 if(groupNames.length)
00517 {
00518 str += "<tr><td><b>Group Keys:</b></td><td>";
00519 {
00520 str += htmlOpen("select",
00521 {
00522 "id" : stepString + "groupKeys",
00523 });
00524
00525 for(var i=0;i<_systemGroups.groups[paramObj["groupType"]]
00526 [groupNames[0]].keys.length;++i)
00527 {
00528 str += htmlOpen("option",
00529 {
00530 },
00531 _systemGroups.groups[paramObj["groupType"]]
00532 [groupNames[0]].keys[i] , true );
00533 }
00534 str += "</select>";
00535 str += htmlOpen("input",
00536 {
00537 "id": stepString + "activateGroup",
00538 "type": "button",
00539 "value": "Activate Group",
00540 "title": "Activate chosen Group and Key pair and return to creating your new " + _recordAlias + "."
00541 },
00542 0 , true );
00543 }
00544 str += "</td></tr>";
00545 }
00546 str += "</table>";
00547 str += "</center>";
00548
00549 break;
00550
00551 case _STEP_GET_RECORD_NAME:
00552
00553
00554 Debug.log("_STEP_GET_RECORD_NAME " + _recordAlias);
00555
00556 _modifiedTables = [];
00557
00558 prevStepIndex = _STEP_WHICH_RECORD_TYPE;
00559
00561
00562 str += htmlOpen("div",
00563 {
00564 "style" : "font-weight:bold; margin: 6px 0 20px 0;"
00565 },
00566 (_aRecordWasDeleted?
00567 ("Would you like to delete another " + _recordAlias + "?"):
00568 ("Welcome to the " + _recordAlias + " deletion Wizard!")) ,
00569 true );
00570 str += htmlClearDiv();
00571
00573
00574 str += "Choose the " + _recordAlias + " record name to be deleted: ";
00575 str += htmlClearDiv();
00576
00577 str += htmlOpen("select",
00578 {
00579 "id" : stepString + "recordName",
00580 "style" : "margin-bottom: 16px;"
00581 });
00582
00583
00584 for(var i=0;i<_subsetUIDs.length;++i)
00585 {
00586 str += "<option " +
00587 (paramObj["recordName"] &&
00588 paramObj["recordName"]==_subsetUIDs[i]?"selected":"") +
00589 ">";
00590 str += _subsetUIDs[i];
00591 str += "</option>";
00592 }
00593 str += "</select>";
00594
00595
00597
00598 str += htmlClearDiv();
00599 str += "Note you are currently editing these active groups:";
00600 str += "<center>";
00601 str += "<table style='margin-bottom: 10px;'>";
00602 str += "<tr><td><b>Active Context:</b></td><td>";
00603 str += ConfigurationAPI._activeGroups.Context.groupName + " (" + ConfigurationAPI._activeGroups.Context.groupKey + ")";
00604
00605
00606 str += htmlOpen("div",
00607 {
00608 "id": stepString + "editContext",
00609 "class": ConfigurationAPI._POP_UP_DIALOG_ID + "-editIcon",
00610 "style": "float:right; display:block; margin: -3px 0 0 10px;",
00611 "title": "Click to activate a different Context group.",
00612
00613 }, 0 , true );
00614
00615 str += "</td></tr>";
00616 str += "<tr><td><b>Active Configuration:</b></td><td>";
00617 str += _systemGroups.activeGroups.Configuration.groupName + " (" + _systemGroups.activeGroups.Configuration.groupKey + ")";
00618
00619 str += htmlOpen("div",
00620 {
00621 "id": stepString + "editConfig",
00622 "class": ConfigurationAPI._POP_UP_DIALOG_ID + "-editIcon",
00623 "style": "float:right; display:block; margin: -3px 0 0 10px;",
00624 "title": "Click to activate a different Configuration group.",
00625 }, 0 , true );
00626
00627 str += "</td></tr>";
00628 str += "</table>";
00629 str += "</center>";
00630
00631
00632 break;
00633
00634 case _STEP_WHICH_RECORD_TYPE:
00635
00636 Debug.log("_STEP_WHICH_RECORD_TYPE ");
00637
00638 nextStepIndex = _STEP_GET_RECORD_NAME;
00639 prevButtonText = "Close Wizard";
00640
00642
00643 str += htmlOpen("div",
00644 {
00645 "style" : "font-weight:bold; margin: 6px 0 20px 0;"
00646 },
00647 "Welcome to the record deletion Wizard!" ,
00648 true );
00649 str += htmlClearDiv();
00650
00652
00653 str += htmlClearDiv();
00654 str += "Below is a dropdown of record types that this Wizard can help you delete. " +
00655 " Choose one and proceed through the steps to delete the chosen record and its children:";
00656 str += htmlClearDiv();
00657 str += htmlOpen("select",
00658 {
00659 "id" : stepString + "recordTypes",
00660 "style" : "margin-bottom: 16px;"
00661 });
00662
00663 for(var i=0;i<_validRecordTypes.length;++i)
00664 {
00665 str += htmlOpen("option",
00666 {
00667 },_validRecordTypes[i] , true );
00668 }
00669 str += "</select>";
00670
00671 break;
00672 default:
00673 Debug.log("Should never happen - bad stepIndex (" + stepIndex +
00674 ")!",Debug.HIGH_PRIORITY);
00675 return;
00676 }
00677
00678
00679
00680 var ctrlStr = "";
00681
00682 if(stepIndex && showPrevButton)
00683 ctrlStr += htmlOpen("input",
00684 {
00685 "class": "prevButton " + stepString + "prevButton",
00686 "type": "button",
00687 "value": prevButtonText,
00688 "title": "Return to the previous step in the " + _recordAlias + " creation wizard."
00689 },
00690 0 , true );
00691 if(showNextButton)
00692 ctrlStr += htmlOpen("input",
00693 {
00694 "class": "nextButton " + stepString + "nextButton",
00695 "type": "button",
00696 "value": nextButtonText,
00697 "title": "Proceed to the next step in the " + _recordAlias + " creation wizard."
00698 },
00699 0 , true );
00700
00701
00702
00703 el = document.createElement("div");
00704 el.setAttribute("id", ConfigurationAPI._POP_UP_DIALOG_ID);
00705
00706 ConfigurationAPI.setPopUpPosition(el,w ,h );
00707
00708 el.innerHTML = ctrlStr + htmlClearDiv() + str + htmlClearDiv() + ctrlStr;
00709 document.body.appendChild(el);
00710 }
00711
00712
00715
00716 localAddHandlers();
00717 function localAddHandlers()
00718 {
00719 var newParamObj = {};
00720
00722
00723
00724
00725 switch(stepIndex)
00726 {
00727
00728 case _STEP_ALSO_DESCENDANTS:
00729
00730 localAlsoDescendantsHandlers();
00731
00733 function localAlsoDescendantsHandlers()
00734 {
00735
00736
00738 document.getElementById(stepString + "deleteOnlyRoot").onclick =
00739 function()
00740 {
00741 localDeleteRootRecord();
00742 };
00743
00745 var deleteDescendantsButton = document.getElementById(stepString + "deleteDescendants");
00746 if(!deleteDescendantsButton) return;
00747
00748 deleteDescendantsButton.onclick =
00749 function()
00750 {
00751 Debug.log("deleteDescendants " + recordName);
00752
00753
00754
00755
00756
00757
00758 var deleteMap = {};
00759
00760
00761 if(_recordAlias == _RECORD_TYPE_CONTEXT)
00762 localRecurseDeleteChildren(_paramObjMap[_STEP_ALSO_DESCENDANTS]["rootChildren"],
00763 "XDAQApplicationConfiguration",0);
00764 else if(_recordAlias == _RECORD_TYPE_APP)
00765 localRecurseDeleteChildren([_paramObjMap[_STEP_ALSO_DESCENDANTS]["root"]],
00766 "XDAQApplicationConfiguration",0);
00767 else
00768 throw("?");
00770 function localRecurseDeleteChildren(children, table, depth)
00771 {
00772 if(table == "NO_LINK") return;
00773
00774 console.log(depth,table,children);
00775
00776 var childLinks;
00777 var name;
00778
00779
00780 for(var i=0;i<children.length;++i)
00781 {
00782 try
00783 {
00784 name = ConfigurationAPI.getTreeRecordName(children[i]);
00785 }
00786 catch(e)
00787 {
00788 Debug.log("Name extraction failed. Assuming disconnected link: " + e);
00789 console.log(deleteMap);
00790 continue;
00791 }
00792
00793 if(!deleteMap[table]) deleteMap[table] = [];
00794
00795
00796 if(deleteMap[table].indexOf(name) >= 0) continue;
00797
00798 deleteMap[table].push(name);
00799 console.log(deleteMap);
00800
00801
00802 childLinks = ConfigurationAPI.getTreeRecordLinks(children[i]);
00803
00804 for(var j=0;j<childLinks.length;++j)
00805 localRecurseDeleteChildren(
00806 ConfigurationAPI.getTreeLinkChildren(childLinks[j]),
00807 ConfigurationAPI.getTreeLinkTable(childLinks[j]),
00808 depth+1);
00809 }
00810 }
00811
00812 console.log(deleteMap);
00813
00814
00815 var requestCount = 0;
00816 var recordCount = 0;
00817 var tableCount = 0;
00818 _modifiedTables = [];
00819 for(var table in deleteMap)
00820 {
00821 Debug.log("table " + table);
00822
00823 if(_recordAlias == _RECORD_TYPE_CONTEXT)
00824 {
00825 if( table == "XDAQContextConfiguration")
00826 continue;
00827 }
00828 else if(table == "XDAQContextConfiguration" ||
00829 table == "XDAQApplicationConfiguration")
00830 continue;
00831
00832 ++requestCount;
00834
00835 ConfigurationAPI.deleteSubsetRecords(
00836 table,
00837 deleteMap[table],
00839 function(modifiedTables,err,table,deletionCount)
00840 {
00841
00842 Debug.log("modifiedTables length " + modifiedTables.length);
00843 if(err)
00844 {
00845
00846 Debug.log("There was an error while deleting " + deletionCount +
00847 " records from table '" +
00848 table + ".' " + err,
00849 Debug.HIGH_PRIORITY);
00850 return;
00851 }
00852
00853 --requestCount;
00854 ++tableCount;
00855 recordCount += deletionCount;
00856
00857
00858 if(modifiedTables && modifiedTables[0])
00859 _modifiedTables.push(modifiedTables[0]);
00860
00861
00862 Debug.log(deletionCount + " records in table '" +
00863 table + " were successfully removed!", Debug.INFO_PRIORITY);
00864
00865 if(requestCount == 0)
00866 {
00867 Debug.log("Descendant Summary: " + recordCount + " records from " +
00868 tableCount + " tables were successfully removed!",
00869 Debug.INFO_PRIORITY);
00870 localDeleteRootRecord();
00871 }
00872
00873 },
00874 _modifiedTables,
00875 true );
00876
00877 }
00878
00879 if(!requestCount)
00880 localDeleteRootRecord();
00881
00882 };
00883
00884
00885 }
00886
00887 break;
00888
00889 case _STEP_GET_RECORD_NAME:
00890
00891 {
00892
00893
00895 document.getElementById(stepString + "editConfig").onclick =
00896 function()
00897 {
00898 newParamObj["groupType"] = "Configuration";
00899
00900 paramObj["recordName"] = document.getElementById(stepString + "recordName").value.trim();
00901 showPrompt(_STEP_CHANGE_GROUP,newParamObj);
00902 };
00904 document.getElementById(stepString + "editContext").onclick =
00905 function()
00906 {
00907 newParamObj["groupType"] = "Context";
00908
00909 paramObj["recordName"] = document.getElementById(stepString + "recordName").value.trim();
00910 showPrompt(_STEP_CHANGE_GROUP,newParamObj);
00911 };
00912 }
00913
00914 break;
00915
00916 case _STEP_CHANGE_GROUP:
00917
00918 {
00919
00921 document.getElementById(stepString + "activateAlias").onclick =
00922 function()
00923 {
00924
00925 var alias = document.getElementById(stepString + "aliases").value;
00926 Debug.log("activateAlias " + alias);
00927
00928
00929 var aliasObj;
00930 for(var i=0;i<
00931 _systemGroups.aliases[paramObj["groupType"]].length;++i)
00932 if(_systemGroups.aliases[paramObj["groupType"]][i].alias ==
00933 alias)
00934 {
00935 aliasObj = _systemGroups.aliases[paramObj["groupType"]][i];
00936 break;
00937 }
00938
00939 Debug.log("activateAlias group " + aliasObj.name +
00940 "-" + aliasObj.key);
00941
00942 ConfigurationAPI.activateGroup(aliasObj.name, aliasObj.key,
00943 true ,
00944
00945 function()
00946 {
00947 Debug.log("The System Alias '" + alias +
00948 "' (" + aliasObj.name + " (" +
00949 aliasObj.key + ")) was successfully activated!", Debug.INFO_PRIORITY);
00950
00951 initDeleteWizard();
00952 });
00953 };
00954
00956 document.getElementById(stepString + "groupNames").onchange =
00957 function()
00958 {
00959
00960 Debug.log("Filling dropdown with keys for " + this.value);
00961 var str = "";
00962 for(var i=0;i<_systemGroups.groups[paramObj["groupType"]]
00963 [this.value].keys.length;++i)
00964 {
00965 str += htmlOpen("option",
00966 {
00967 },
00968 _systemGroups.groups[paramObj["groupType"]]
00969 [this.value].keys[i] , true );
00970 }
00971 document.getElementById(stepString + "groupKeys").innerHTML =
00972 str;
00973 };
00974
00976 document.getElementById(stepString + "activateGroup").onclick =
00977 function()
00978 {
00979
00980 var name = document.getElementById(stepString + "groupNames").value;
00981 var key = document.getElementById(stepString + "groupKeys").value;
00982
00983 Debug.log("activateGroup " + name +
00984 "-" + key);
00985
00986 ConfigurationAPI.activateGroup(name, key,
00987 true ,
00988
00989 function()
00990 {
00991 Debug.log("The Group '" + name + " (" +
00992 key + ") was successfully activated!", Debug.INFO_PRIORITY);
00993
00994 initDeleteWizard();
00995 });
00996 };
00997
00998 }
00999
01000 break;
01001 default:;
01002 }
01003
01004
01005
01006
01008
01009 {
01010
01012
01013
01014 function localDeleteRootRecord()
01015 {
01016 Debug.log("localDeleteRootRecord " + recordName);
01017
01018
01020
01021 ConfigurationAPI.deleteSubsetRecords(
01022 getRecordConfiguration(),
01023 recordName,
01025 function(modifiedTables,err)
01026 {
01027 Debug.log("modifiedTables length " + modifiedTables.length);
01028 if(!modifiedTables.length)
01029 {
01030
01031 Debug.log("There was an error while removing the " + _recordAlias +
01032 " named '" +
01033 recordName + ".' " + err,
01034 Debug.HIGH_PRIORITY);
01035 return;
01036 }
01037 _modifiedTables = modifiedTables;
01038
01039
01040 Debug.log("The " + _recordAlias + " named '" +
01041 recordName + "' was successfully removed!",
01042 Debug.INFO_PRIORITY);
01043
01044 showPrompt(_STEP_SAVE_MODIFIED);
01045
01046 },
01047 _modifiedTables,
01048 true );
01049
01050
01051 }
01052
01053
01054 }
01055
01056
01057
01058
01059
01060
01062
01063 try
01064 {
01065 document.getElementsByClassName(stepString + "nextButton")[0].onclick =
01066 localNextButtonHandler;
01067 document.getElementsByClassName(stepString + "nextButton")[1].onclick =
01068 localNextButtonHandler;
01069
01070 function localNextButtonHandler()
01071 {
01072
01073
01074 switch(stepIndex)
01075 {
01076 case _STEP_SAVE_MODIFIED:
01077
01078
01079 localScopeSetRecordSaveModifiedDoIt();
01080
01082 function localScopeSetRecordSaveModifiedDoIt()
01083 {
01084 Debug.log("localScopeSetRecordSaveModifiedDoIt");
01085
01086
01087 ConfigurationAPI.saveModifiedTables(_modifiedTables,
01088 function(savedTables, savedGroups, savedAliases)
01089 {
01090 if(!savedTables.length)
01091 {
01092 Debug.log("There was an error while deleting the records.",
01093 Debug.HIGH_PRIORITY);
01094 return;
01095 }
01096
01097 Debug.log("The deletions were successfully completed!", Debug.INFO_PRIORITY);
01098
01099
01100
01101
01102
01103 _modifiedTables = [];
01104
01105 _aRecordWasDeleted = true;
01106
01107 initDeleteWizard();
01108
01109 });
01110
01111 }
01112
01113 return;
01114
01115 break;
01116
01117
01118
01119 case _STEP_GET_RECORD_NAME:
01120
01121
01122 recordName = document.getElementById(stepString + "recordName").value.trim();
01123 paramObj["recordName"] = recordName;
01124
01125
01126
01127 ConfigurationAPI.getTree(
01128 getRecordConfiguration() + "/" + recordName,
01129 40 ,
01130 _modifiedTables,
01131 function(tree)
01132 {
01133 console.log(tree);
01134
01135
01136 if(!_paramObjMap[_STEP_ALSO_DESCENDANTS]) _paramObjMap[_STEP_ALSO_DESCENDANTS] = {};
01137
01138 var links = ConfigurationAPI.getTreeRecordLinks(tree);
01139
01140 _paramObjMap[_STEP_ALSO_DESCENDANTS]["root"] = tree;
01141 _paramObjMap[_STEP_ALSO_DESCENDANTS]["rootChildren"] = [];
01142
01143
01144 for(var i=0;i<links.length;++i)
01145 _paramObjMap[_STEP_ALSO_DESCENDANTS]["rootChildren"] =
01146 _paramObjMap[_STEP_ALSO_DESCENDANTS]["rootChildren"].concat(
01147 ConfigurationAPI.getTreeLinkChildren(links[i]));
01148
01149 showPrompt(_STEP_ALSO_DESCENDANTS);
01150
01151
01152 });
01153 return;
01154 break;
01155
01156 case _STEP_WHICH_RECORD_TYPE:
01157
01159 if(scopeWhichRecordTypeNext())
01160 return;
01161
01162 function scopeWhichRecordTypeNext()
01163 {
01164 var newRecordAlias = document.getElementById(stepString + "recordTypes").value.trim();
01165
01166 var needToInit = (_recordAlias != newRecordAlias);
01167
01168 _recordAlias = newRecordAlias;
01169 Debug.log("_recordAlias chosen as " + _recordAlias);
01170
01171 if(needToInit) initDeleteWizard();
01172 return needToInit;
01173 }
01174
01175 break;
01176 default:;
01177 }
01178 showPrompt(nextStepIndex,newParamObj);
01179 }
01180 }
01181 catch(e){ Debug.log("Caught ERROR: " + e.stack);}
01182
01183 try
01184 {
01185 document.getElementsByClassName(stepString + "prevButton")[0].onclick =
01186 localPrevButtonHandler;
01187 document.getElementsByClassName(stepString + "prevButton")[1].onclick =
01188 localPrevButtonHandler;
01189
01190 function localPrevButtonHandler()
01191 {
01192
01193 switch(stepIndex)
01194 {
01195 case _STEP_WHICH_RECORD_TYPE:
01196
01197
01198
01199 _subsetUIDs = [];
01200 _modifiedTables = [];
01201 _furthestStep = -1;
01202 _paramObjMap = {};
01203 _systemGroups = {};
01204
01205
01206 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
01207 while(el)
01208 {
01209 el.parentNode.removeChild(el);
01210 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
01211 }
01212
01213 if(_doneHandler) _doneHandler(_aRecordWasDeleted);
01214 return;
01215 break;
01216 default:;
01217 }
01218 showPrompt(prevStepIndex);
01219 }
01220 }
01221 catch(e){ Debug.log("Caught ERROR: " + e.stack);}
01222
01223 }
01224
01225 }
01226
01227
01228
01229
01230 function getRecordConfiguration()
01231 {
01232 var retVal = "";
01233 if(_recordAlias == _RECORD_TYPE_CONTEXT)
01234 retVal = "XDAQContextConfiguration";
01235 else if(_recordAlias == _RECORD_TYPE_APP)
01236 retVal = "XDAQApplicationConfiguration";
01237 else
01238 throw("?");
01239
01240 return retVal;
01241 }
01242
01243
01244
01245
01246
01247 function getRecordFilter()
01248 {
01249 var retVal = "";
01250 if(_recordAlias == _RECORD_TYPE_CONTEXT)
01251 retVal = "";
01252 else if(_recordAlias == _RECORD_TYPE_APP)
01253 retVal = "";
01254
01255 return retVal;
01256 }
01257
01258
01259
01260
01261
01262 function htmlOpen(tag,attObj,innerHTML,closeTag)
01263 {
01264 var str = "";
01265 var attKeys = Object.keys(attObj);
01266 str += "<" + tag + " ";
01267 for(var i=0;i<attKeys.length;++i)
01268 str += " " + attKeys[i] + "='" +
01269 attObj[attKeys[i]] + "' ";
01270 str += ">";
01271 if(innerHTML) str += innerHTML;
01272 if(closeTag)
01273 str += "</" + tag + ">";
01274 return str;
01275 }
01276
01277
01278
01279 function htmlClearDiv()
01280 {
01281 return "<div id='clearDiv'></div>";
01282 }
01283
01284
01285 };
01286
01287
01288
01289
01290
01291
01292
01293
01294