118 var RecordWiz = RecordWiz || {};
120 if (typeof Debug ==
'undefined')
121 console.log(
'ERROR: Debug is undefined! Must include Debug.js before RecordWiz_ConfigurationGUI.js');
122 else if (typeof Globals ==
'undefined')
123 console.log(
'ERROR: Globals is undefined! Must include Globals.js before RecordWiz_ConfigurationGUI.js');
133 RecordWiz.createWiz =
function(doneHandler, recordsAliasFastForward) {
136 var _TABLE_BOOL_TYPE_TRUE_COLOR =
"rgb(201, 255, 201)";
137 var _TABLE_BOOL_TYPE_FALSE_COLOR =
"rgb(255, 178, 178)";
143 var _doneHandler = doneHandler;
144 var _aRecordWasModified =
false;
146 var _RECORD_TYPE_FE =
"Front-end";
147 var _RECORD_TYPE_PROCESSOR =
"Processor";
148 var _RECORD_TYPE_CONSUMER =
"Consumer";
149 var _RECORD_TYPE_PRODUCER =
"Producer";
150 var _validRecordTypes = [_RECORD_TYPE_FE,_RECORD_TYPE_PROCESSOR];
154 function localParameterCheck()
157 var i=_validRecordTypes.length-1;
159 if(_validRecordTypes[i] == _recordAlias)
break;
162 var str =
"Invalid Record Alias '" + _recordAlias +
"' was specified. " +
163 "The only valid record aliases are as follows: ";
165 for(i=_validRecordTypes.length-1;i>=0;--i)
166 str +=
"<br>\t" + _validRecordTypes[i];
167 Debug.log(str,Debug.HIGH_PRIORITY);
177 var _furthestStep = -1;
178 var _lastNextStep = -1;
179 var _intermediateLevel = -1;
185 var _STEP_OUT_OF_SEQUENCE = 1000;
188 _STEP_PROC_WHICH_BUFFER = 200,
189 _STEP_SET_RECORD_FIELDS = 104,
190 _STEP_WHICH_APP = 103,
191 _STEP_SET_CONTEXT_HOST = 102,
192 _STEP_WHICH_CONTEXT = 101,
193 _STEP_CHANGE_GROUP = 1000,
194 _STEP_GET_RECORD_NAME = 100,
195 _STEP_WHICH_RECORD_TYPE = 20;
198 var _START_STEP_INDEX = _STEP_GET_RECORD_NAME;
200 var _XDAQ_BASE_PATH =
"XDAQContextConfiguration";
201 var _XDAQAPP_BASE_PATH =
"XDAQApplicationConfiguration";
203 var _DEFAULT_WIZ_COMMENT=
"Generated by Record Creation Wiz";
208 Debug.log(
"RecordWiz.wiz constructed");
209 RecordWiz.wiz =
this;
212 if(!recordsAliasFastForward || recordsAliasFastForward ==
"")
214 DesktopContent.tooltip(
"Record Wizard Introduction",
215 "Welcome to the Record Wizard GUI. Here you can create new records for "+
216 "your <i>otsdaq</i> system. \n\n" +
217 "The Record Wizard is presented as a step-by-step process that will walk you through creating the skeleton for your new record.\n\n" +
219 "Briefly, here is a description of the steps: " +
220 "\n\t- 'What type of record do you want to add?'" +
221 "\n\t- 'Do you want to add it to an existing context or create a new one?'"
224 showPrompt(_STEP_WHICH_RECORD_TYPE);
228 _recordAlias = recordsAliasFastForward;
229 if(!localParameterCheck())
231 Debug.log(
"Invalid parameters to the Record Creation Wizard!", Debug.HIGH_PRIORITY);
236 DesktopContent.tooltip(_recordAlias +
" Wizard Introduction",
237 "Welcome to the " + _recordAlias +
" Wizard GUI. Here you can create new records for " +
238 "your <i>otsdaq</i> system. \n\n" +
239 "The " + _recordAlias +
" Wizard is presented as a step-by-step process that will walk you through creating the skeleton for your new " +
240 _recordAlias +
".\n\n" +
241 "Briefly, here is a description of the steps: " +
242 "\n\t- 'Do you want to add your " + _recordAlias +
" to an existing context or create a new one?'"
257 function xdaqContextTooltip()
259 DesktopContent.tooltip(
"XDAQ Contexts",
260 "The lowest level parent for your record, in the <i>otsdaq</i> configuration tree, is a XDAQ Context. " +
261 "What is a XDAQ Context? Why do I need a XDAQ Context? Do I want a new one for my " + _recordAlias +
" or not?" +
263 "XDAQ Contexts are the fundamental executable program building blocks of <i>otsdaq</i>. " +
264 "A XDAQ Context runs a group of XDAQ Applications inside of it. If one of those XDAQ Applications crashes, " +
265 "then only the parent XDAQ Context will crash. This is one reason organizing your <i>otsdaq</i> entities into separate XDAQ Contexts makes sense." +
267 "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 " +
268 "they can easily be distributed to other nodes (computers) in your DAQ system when your system scales up."
273 function xdaqApplicationTooltip()
275 DesktopContent.tooltip(
"XDAQ Applications",
276 "The second level parent for your record, in the <i>otsdaq</i> configuration tree, is a XDAQ Application. " +
277 "What is a XDAQ Application? Why do I need a XDAQ Application? Do I want a new one for my " + _recordAlias +
" or not?" +
279 "XDAQ Applications are server processes that can be controlled by <i>otsdaq</i> through network messages. " +
280 "Ther can be one or many XDAQ Applciation in a XDAQ Context. If one of those XDAQ Applications crashes, " +
281 "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." +
283 "Two other useful features of XDAQ Applications are that they can respond to web requests and state machine transitions."
291 function initRecordWizard()
294 _modifiedTables = undefined;
301 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
304 el.parentNode.removeChild(el);
305 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
311 ConfigurationAPI.getAliasesAndGroups(
314 _systemGroups = retObj;
315 console.log(
"_systemGroups",_systemGroups);
316 console.log(
"ConfigurationAPI._activeGroups",ConfigurationAPI._activeGroups);
320 ConfigurationAPI.getSubsetRecords(
321 getRecordConfiguration(),
325 _subsetUIDs = records;
326 Debug.log(
"records found = " + records.length);
327 console.log(records);
329 showPrompt(_STEP_GET_RECORD_NAME);
341 function showPrompt(stepIndex,paramObj)
344 if(!stepIndex) stepIndex = 0;
346 if(stepIndex > _furthestStep &&
347 _furthestStep < _STEP_OUT_OF_SEQUENCE)
348 _furthestStep = stepIndex;
350 Debug.log(
"showPrompt " + stepIndex);
351 Debug.log(
"_furthestStep " + _furthestStep);
354 if(!_paramObjMap) _paramObjMap = {};
358 _paramObjMap[stepIndex] = paramObj;
359 else if(_paramObjMap[stepIndex])
360 paramObj = _paramObjMap[stepIndex];
364 _paramObjMap[stepIndex] = {};
365 paramObj = _paramObjMap[stepIndex];
368 console.log(
"_paramObjMap",_paramObjMap);
369 console.log(
"paramObj",paramObj);
371 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
376 el.parentNode.removeChild(el);
377 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
386 var stepString =
"stepIndex-" + stepIndex +
"-";
388 var showPrevButton =
true;
389 var showNextButton =
true;
390 var prevStepIndex = stepIndex-1;
391 if(prevStepIndex > _lastNextStep)
392 prevStepIndex = _lastNextStep;
393 _lastNextStep = stepIndex;
395 var nextStepIndex = stepIndex+1;
396 var prevButtonText =
"Go Back";
397 var nextButtonText =
"Next Step";
402 recordName = _paramObjMap[_STEP_GET_RECORD_NAME][
"recordName"];
409 function localAddContent()
413 case _STEP_PROC_WHICH_BUFFER:
417 showNextButton =
false;
420 Debug.log(
"_STEP_PROC_WHICH_BUFFER " + recordName);
424 str +=
"Do you want to add the " + _recordAlias +
" named '" +
425 recordName +
"' to a new Data Manager Buffer " +
426 "or an existing one in the Data Manager '" +
427 _paramObjMap[_STEP_WHICH_APP][
"appName"] +
"'?";
430 str +=
"<table style='margin-bottom: 10px;'>";
434 str +=
"<tr><td><b>New Buffer:</b></td><td>";
436 str += htmlOpen(
"input",
439 "id" : stepString +
"bufferName",
440 "value": (paramObj[
"bufferName"]?paramObj[
"bufferName"]:
441 ConfigurationAPI.createNewRecordName(
"Buffer",
442 paramObj[
"allBuffers"])),
445 str += htmlOpen(
"input",
447 "id": stepString +
"addToNew",
449 "value":
"Add to New",
450 "title":
"Create a new Buffer and add the new " +
451 _recordAlias +
" to it."
457 if(paramObj[
"buffers"].length)
459 str +=
"<tr><td><b>Existing Buffers:</b></td><td>";
461 str += htmlOpen(
"select",
463 "id" : stepString +
"buffers",
466 for(var i=0;i<paramObj[
"buffers"].length;++i)
468 str += htmlOpen(
"option",
471 paramObj[
"buffers"][i] ,
true );
474 str += htmlOpen(
"input",
476 "id": stepString +
"addToExisting",
478 "value":
"Add to Existing",
479 "title":
"Add new " + _recordAlias +
480 " to the chosen existing Buffer."
490 if(paramObj[
"allBuffers"].length)
494 str += htmlClearDiv();
495 str +=
"Here is a dropdown of all existing Buffers " +
496 " to help you in creating standardized names (Note: shown above are " +
497 "only the Buffers in the chosen Data Manager '" +
498 _paramObjMap[_STEP_WHICH_APP][
"appName"] +
501 str += htmlClearDiv();
502 str += htmlOpen(
"select",
504 "id" : stepString +
"allBuffers",
505 "style" :
"margin-bottom: 16px;"
508 for(var i=0;i<paramObj[
"allBuffers"].length;++i)
510 str += htmlOpen(
"option",
513 paramObj[
"allBuffers"][i] ,
true );
523 case _STEP_SET_RECORD_FIELDS:
525 Debug.log(
"_STEP_SET_RECORD_FIELDS ");
527 nextButtonText =
"Done!";
530 str +=
"Please edit the fields for your record and then click 'Done!' to save " +
531 " your new " + _recordAlias +
" named '" + recordName +
"':";
533 str += htmlClearDiv();
534 str += htmlOpen(
"div",
536 "id" : stepString +
"fields",
537 "style" :
"margin: 20px;",
540 str += htmlClearDiv();
544 case _STEP_WHICH_APP:
548 xdaqApplicationTooltip();
550 showNextButton =
false;
553 Debug.log(
"_STEP_WHICH_APP " + recordName);
557 str +=
"Do you want to add the " + _recordAlias +
" named '" +
558 recordName +
"' to a new XDAQ " + getAppClass() +
559 " Application or an existing one in the context '" +
560 _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"] +
"'?";
563 str +=
"<table style='margin-bottom: 10px;'>";
567 str +=
"<tr><td><b>New XDAQ App:</b></td><td>";
569 str += htmlOpen(
"input",
572 "id" : stepString +
"appName",
573 "value": (paramObj[
"appName"]?paramObj[
"appName"]:
574 ConfigurationAPI.createNewRecordName(getApp(),paramObj[
"allApps"])),
577 str += htmlOpen(
"input",
579 "id": stepString +
"addToNew",
581 "value":
"Add to New",
582 "title":
"Create a new XDAQ Application and add the new " + _recordAlias +
" to it."
588 if(paramObj[
"apps"].length)
590 str +=
"<tr><td><b>Existing Apps:</b></td><td>";
592 str += htmlOpen(
"select",
594 "id" : stepString +
"apps",
597 for(var i=0;i<paramObj[
"apps"].length;++i)
599 str += htmlOpen(
"option",
602 paramObj[
"apps"][i] ,
true );
605 str += htmlOpen(
"input",
607 "id": stepString +
"addToExisting",
609 "value":
"Add to Existing",
610 "title":
"Add new " + _recordAlias +
" to the chosen existing XDAQ Application."
620 if(paramObj[
"allApps"].length)
624 str += htmlClearDiv();
625 str +=
"Here is a dropdown of all existing XDAQ Applications " +
626 " to help you in creating standardized names (Note: shown above are " +
627 "only apps with class " + getAppClass() +
" and in the chosen context '" +
628 _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"] +
631 str += htmlClearDiv();
632 str += htmlOpen(
"select",
634 "id" : stepString +
"allApps",
635 "style" :
"margin-bottom: 16px;"
638 for(var i=0;i<paramObj[
"allApps"].length;++i)
640 str += htmlOpen(
"option",
643 paramObj[
"allApps"][i] ,
true );
653 case _STEP_SET_CONTEXT_HOST:
655 if(paramObj[
"isNewContext"])
656 str +=
"Please enter the Host Address and Port for the " +
657 "new Context named '" +
658 _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"] +
"':";
660 str +=
"Please verify the Host Address and Port for the " +
661 "existing Context named '" +
662 _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"] +
"':";
665 str +=
"<table style=''>";
669 str +=
"<tr><td><b>Address:</b></td><td>";
671 str += htmlOpen(
"input",
674 "id" : stepString +
"address",
675 "value" : (paramObj[
"address"]?paramObj[
"address"]:
""),
682 str +=
"<tr><td><b>Port:</b></td><td>";
684 str += htmlOpen(
"input",
687 "id" : stepString +
"port",
688 "value" : (paramObj[
"port"]?paramObj[
"port"]:
""),
699 str += htmlClearDiv();
700 str +=
"Here is a dropdown of existing Host Addresses " +
701 " to help you in creating standardized addresses:";
702 str += htmlClearDiv();
703 str += htmlOpen(
"select",
705 "id" : stepString +
"addresses",
706 "style" :
"margin-bottom: 16px;"
710 for(var i=0;i<paramObj[
"hostAddresses"].length;++i)
712 str += htmlOpen(
"option",
714 },paramObj[
"hostAddresses"][i] ,
true );
720 str += htmlClearDiv();
721 str +=
"Here is a dropdown of existing Host Ports " +
722 " to help you in creating standardized ports:";
723 str += htmlClearDiv();
724 str += htmlOpen(
"select",
726 "id" : stepString +
"ports",
731 for(var i=0;i<paramObj[
"hostPorts"].length;++i)
733 str += htmlOpen(
"option",
735 },paramObj[
"hostPorts"][i] ,
true );
741 case _STEP_WHICH_CONTEXT:
743 xdaqContextTooltip();
745 showNextButton =
false;
748 Debug.log(
"_STEP_WHICH_CONTEXT " + recordName);
752 str +=
"Do you want to add the " + _recordAlias +
" named '" +
753 recordName +
"' to a new XDAQ Context or an existing one?";
757 str +=
"<table style='margin-bottom: 10px;'>";
761 str +=
"<tr><td><b>New XDAQ Context:</b></td><td>";
763 str += htmlOpen(
"input",
766 "id" : stepString +
"contextName",
767 "value": (paramObj[
"contextName"]?paramObj[
"contextName"]:
""),
770 str += htmlOpen(
"input",
772 "id": stepString +
"addToNew",
774 "value":
"Add to New",
775 "title":
"Create a new XDAQ Context and add the new " + _recordAlias +
" to it."
781 if(paramObj[
"contexts"].length)
783 str +=
"<tr><td><b>Existing Contexts:</b></td><td>";
785 str += htmlOpen(
"select",
787 "id" : stepString +
"contexts",
790 for(var i=0;i<paramObj[
"contexts"].length;++i)
792 str += htmlOpen(
"option",
795 paramObj[
"contexts"][i] ,
true );
798 str += htmlOpen(
"input",
800 "id": stepString +
"addToExisting",
802 "value":
"Add to Existing",
803 "title":
"Add new " + _recordAlias +
" to the chosen existing XDAQ Context."
815 case _STEP_CHANGE_GROUP:
818 showNextButton =
false;
819 nextStepIndex = _STEP_GET_RECORD_NAME;
820 prevStepIndex = _STEP_GET_RECORD_NAME;
822 str +=
"Choose a '" + paramObj[
"groupType"] +
823 "' group to activate (either a System Alias or specific group):";
825 str += htmlClearDiv();
828 str +=
"<table style='margin-bottom: 10px;'>";
829 if(_systemGroups.aliases[paramObj[
"groupType"]].length)
831 str +=
"<tr><td><b>System Aliases:</b></td><td>";
833 str += htmlOpen(
"select",
835 "id" : stepString +
"aliases",
838 for(var i=0;i<_systemGroups.aliases[paramObj[
"groupType"]].length;++i)
840 str += htmlOpen(
"option",
843 _systemGroups.aliases[paramObj[
"groupType"]]
847 str += htmlOpen(
"input",
849 "id": stepString +
"activateAlias",
851 "value":
"Activate Alias",
852 "title":
"Activate chosen System Alias and return to creating your new " + _recordAlias +
"."
859 str +=
"<tr><td colspan='2'>No system aliases of type Context found.</td></tr>";
861 var groupNames = Object.keys(_systemGroups.groups[paramObj[
"groupType"]]);
862 if(groupNames.length)
864 str +=
"<tr><td><b>Group Names:</b></td><td>";
866 str += htmlOpen(
"select",
868 "id" : stepString +
"groupNames",
871 for(var i=0;i<groupNames.length;++i)
873 str += htmlOpen(
"option",
876 groupNames[i] ,
true );
884 str +=
"<tr><td colspan='2'>No groups of type Context found.</td></tr>";
886 if(groupNames.length)
888 str +=
"<tr><td><b>Group Keys:</b></td><td>";
890 str += htmlOpen(
"select",
892 "id" : stepString +
"groupKeys",
895 for(var i=0;i<_systemGroups.groups[paramObj[
"groupType"]]
896 [groupNames[0]].keys.length;++i)
898 str += htmlOpen(
"option",
901 _systemGroups.groups[paramObj[
"groupType"]]
902 [groupNames[0]].keys[i] ,
true );
905 str += htmlOpen(
"input",
907 "id": stepString +
"activateGroup",
909 "value":
"Activate Group",
910 "title":
"Activate chosen Group and Key pair and return to creating your new " + _recordAlias +
"."
921 case _STEP_GET_RECORD_NAME:
924 prevStepIndex = _STEP_WHICH_RECORD_TYPE;
928 str += htmlOpen(
"div",
930 "style" :
"font-weight:bold; margin: 6px 0 20px 0;"
932 (_aRecordWasModified?
933 (
"Would you like to create another " + _recordAlias +
"?"):
934 (
"Welcome to the " + _recordAlias +
" creation Wizard!")) ,
936 str += htmlClearDiv();
940 str +=
"Enter the unique record name for your " + _recordAlias +
": ";
941 str += htmlClearDiv();
942 str += htmlOpen(
"input",
945 "id" : stepString +
"recordName",
946 "style" :
"margin-bottom: 16px;",
947 "value" : (paramObj[
"recordName"]?paramObj[
"recordName"]:
""),
954 str += htmlClearDiv();
955 str +=
"Here is a dropdown of existing " + _recordAlias +
956 " records to help you in creating standardized record names:";
957 str += htmlClearDiv();
960 str += htmlOpen(
"select",
962 "id" : stepString +
"records",
963 "style" :
"margin-bottom: 16px;",
967 for(var i=0;i<_subsetUIDs.length;++i)
969 str += htmlOpen(
"option",
971 },_subsetUIDs[i] ,
true );
976 str += htmlOpen(
"div",
978 "id" : stepString +
"deleteRecordIcon",
979 "class": ConfigurationAPI._POP_UP_DIALOG_ID +
"-deleteIcon",
980 "style" :
"float: right; margin: 6px 112px -16px -200px; display: block;",
986 str += htmlOpen(
"div",
988 "id" : ConfigurationAPI._POP_UP_DIALOG_ID +
989 "-preloadImage-editIconHover",
990 "class": ConfigurationAPI._POP_UP_DIALOG_ID +
"-preloadImage",
992 str += htmlOpen(
"div",
994 "id" : ConfigurationAPI._POP_UP_DIALOG_ID +
995 "-preloadImage-treeEditTrashIconHover",
996 "class": ConfigurationAPI._POP_UP_DIALOG_ID +
"-preloadImage",
1002 str += htmlClearDiv();
1003 str +=
"Note you are currently editing these active groups:";
1005 str +=
"<table style='margin-bottom: 10px;'>";
1006 str +=
"<tr><td><b>Active Context:</b></td><td>";
1007 str += ConfigurationAPI._activeGroups.Context.groupName +
" (" + ConfigurationAPI._activeGroups.Context.groupKey +
")";
1010 str += htmlOpen(
"div",
1012 "id": stepString +
"editContext",
1013 "class": ConfigurationAPI._POP_UP_DIALOG_ID +
"-editIcon",
1014 "style":
"float:right; display:block; margin: -3px 0 0 10px;",
1015 "title":
"Click to activate a different Context group.",
1019 str +=
"</td></tr>";
1020 str +=
"<tr><td><b>Active Configuration:</b></td><td>";
1021 str += _systemGroups.activeGroups.Configuration.groupName +
" (" + _systemGroups.activeGroups.Configuration.groupKey +
")";
1023 str += htmlOpen(
"div",
1025 "id": stepString +
"editConfig",
1026 "class": ConfigurationAPI._POP_UP_DIALOG_ID +
"-editIcon",
1027 "style":
"float:right; display:block; margin: -3px 0 0 10px;",
1028 "title":
"Click to activate a different Configuration group.",
1031 str +=
"</td></tr>";
1037 case _STEP_WHICH_RECORD_TYPE:
1039 nextStepIndex = _STEP_GET_RECORD_NAME;
1040 prevButtonText =
"Close Wizard";
1044 str += htmlOpen(
"div",
1046 "style" :
"font-weight:bold; margin: 6px 0 20px 0;"
1048 "Welcome to the record creation Wizard!" ,
1050 str += htmlClearDiv();
1054 str += htmlClearDiv();
1055 str +=
"Below is a dropdown of record types that this Wizard can help you create. " +
1056 " Choose one and proceed through the steps to create your new record:";
1057 str += htmlClearDiv();
1058 str += htmlOpen(
"select",
1060 "id" : stepString +
"recordTypes",
1061 "style" :
"margin-bottom: 16px;"
1064 for(var i=0;i<_validRecordTypes.length;++i)
1066 str += htmlOpen(
"option",
1068 },_validRecordTypes[i] ,
true );
1074 Debug.log(
"Should never happen - bad stepIndex (" + stepIndex +
1075 ")!",Debug.HIGH_PRIORITY);
1083 if(stepIndex && showPrevButton)
1084 ctrlStr += htmlOpen(
"input",
1086 "class":
"prevButton " + stepString +
"prevButton",
1088 "value": prevButtonText,
1089 "title":
"Return to the previous step in the " + _recordAlias +
" creation wizard."
1093 ctrlStr += htmlOpen(
"input",
1095 "class":
"nextButton " + stepString +
"nextButton",
1097 "value": nextButtonText,
1098 "title":
"Proceed to the next step in the " + _recordAlias +
" creation wizard."
1104 el = document.createElement(
"div");
1105 el.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID);
1107 ConfigurationAPI.setPopUpPosition(el,w ,h );
1109 el.innerHTML = ctrlStr + htmlClearDiv() + str + htmlClearDiv() + ctrlStr;
1110 document.body.appendChild(el);
1118 function localAddHandlers()
1120 var newParamObj = {};
1126 case _STEP_SET_RECORD_FIELDS:
1130 scopeForSetRecordFieldsContent();
1132 function scopeForSetRecordFieldsContent()
1134 var recordFields = paramObj[
"fields"];
1136 var fieldContainerEl = document.getElementById(stepString +
"fields");
1139 ConfigurationAPI.editableField_SELECTED_COLOR_ =
"transparent";
1146 for(var i=0;i<recordFields.length;++i)
1148 el = document.createElement(
"div");
1149 el.setAttribute(
"id",
"cfg_subset_field-" + i);
1150 el.setAttribute(
"style",
"white-space:nowrap;" +
1152 fieldContainerEl.appendChild(el);
1155 el.appendChild(ConfigurationAPI.createEditableFieldElement(
1156 recordFields[i],i));
1159 el = document.createElement(
"div");
1160 el.setAttribute(
"id",
"clearDiv");
1161 fieldContainerEl.appendChild(el);
1168 case _STEP_PROC_WHICH_BUFFER:
1173 document.getElementById(stepString +
"buffers").onclick = localAppSelectHandler;
1174 document.getElementById(stepString +
"buffers").onchange = localAppSelectHandler;
1175 document.getElementById(stepString +
"allBuffers").onclick = localAppSelectHandler;
1176 document.getElementById(stepString +
"allBuffers").onchange = localAppSelectHandler;
1178 function localAppSelectHandler(event) {
1179 Debug.log(
"Selected " + this.value);
1182 document.getElementById(stepString +
"bufferName").value =
1183 ConfigurationAPI.incrementName(this.value);
1187 document.getElementById(stepString +
"addToNew").onclick =
1190 var name = document.getElementById(stepString +
"bufferName").value.trim();
1191 Debug.log(
"addToNew " + name);
1194 paramObj[
"bufferName"] = name;
1196 localCreateIntermediateLevelRecord(name);
1200 document.getElementById(stepString +
"addToExisting").onclick =
1203 var name = document.getElementById(stepString +
"buffers").value.trim();
1204 Debug.log(
"addToExisting " + name);
1207 paramObj[
"bufferName"] = name;
1209 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER][
"buffers"]) _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"buffers"] = [];
1210 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"isNew" + getIntermediateTypeName()] =
false;
1213 localGetExistingIntermediateTargetGroupID(name);
1224 case _STEP_WHICH_APP:
1229 document.getElementById(stepString +
"apps").onclick = localAppSelectHandler;
1230 document.getElementById(stepString +
"apps").onchange = localAppSelectHandler;
1231 document.getElementById(stepString +
"allApps").onclick = localAppSelectHandler;
1232 document.getElementById(stepString +
"allApps").onchange = localAppSelectHandler;
1234 function localAppSelectHandler(event) {
1235 Debug.log(
"Selected " + this.value);
1238 document.getElementById(stepString +
"appName").value =
1239 ConfigurationAPI.incrementName(this.value);
1243 document.getElementById(stepString +
"addToNew").onclick =
1246 var name = document.getElementById(stepString +
"appName").value.trim();
1247 Debug.log(
"addToNew " + name);
1250 paramObj[
"appName"] = name;
1252 localCreateApp(name);
1256 document.getElementById(stepString +
"addToExisting").onclick =
1259 var name = document.getElementById(stepString +
"apps").value.trim();
1260 Debug.log(
"addToExisting " + name);
1263 paramObj[
"appName"] = name;
1265 if(!_paramObjMap[_STEP_WHICH_APP][
"apps"]) _paramObjMap[_STEP_WHICH_APP][
"apps"] = [];
1266 _paramObjMap[_STEP_WHICH_APP][
"isNewApp"] =
false;
1269 localGetExistingSupervisorTargetGroupID(name);
1280 case _STEP_SET_CONTEXT_HOST:
1284 document.getElementById(stepString +
"addresses").onclick = localAddressSelectHandler;
1285 document.getElementById(stepString +
"addresses").onchange = localAddressSelectHandler;
1287 function localAddressSelectHandler(event) {
1288 Debug.log(
"Selected " + this.value);
1289 document.getElementById(stepString +
"address").value =
1294 document.getElementById(stepString +
"ports").onclick = localPortSelectHandler;
1295 document.getElementById(stepString +
"ports").onchange = localPortSelectHandler;
1297 function localPortSelectHandler(event) {
1298 Debug.log(
"Selected " + this.value);
1299 document.getElementById(stepString +
"port").value =
1307 case _STEP_WHICH_CONTEXT:
1311 document.getElementById(stepString +
"contexts").onclick = localContextSelectHandler;
1312 document.getElementById(stepString +
"contexts").onchange = localContextSelectHandler;
1314 function localContextSelectHandler(event) {
1315 Debug.log(
"Selected " + this.value);
1318 document.getElementById(stepString +
"contextName").value =
1319 ConfigurationAPI.incrementName(this.value);
1323 document.getElementById(stepString +
"addToNew").onclick =
1326 var name = document.getElementById(stepString +
"contextName").value.trim();
1327 Debug.log(
"addToNew " + name);
1330 paramObj[
"contextName"] = name;
1335 ConfigurationAPI.addSubsetRecords(
1339 function(modifiedTables,err)
1341 Debug.log(
"modifiedTables length " + modifiedTables.length);
1342 if(!modifiedTables.length)
1345 Debug.log(
"There was an error while creating the XDAQ Context '" +
1347 Debug.HIGH_PRIORITY);
1350 _modifiedTables = modifiedTables;
1353 Debug.log(
"New context '" + name +
"' was successfully created!");
1355 newParamObj[
"isNewContext"] =
true;
1358 if(paramObj[
"contexts"].indexOf(name) == -1)
1359 paramObj[
"contexts"].push(name);
1361 localGetAllHostInfo();
1370 document.getElementById(stepString +
"addToExisting").onclick =
1373 var name = document.getElementById(stepString +
"contexts").value.trim();
1374 Debug.log(
"addToExisting " + name);
1377 paramObj[
"contextName"] = name;
1379 newParamObj[
"isNewContext"] =
false;
1382 ConfigurationAPI.getFieldValuesForRecords(
1385 [
"Address",
"Port",
"ApplicationGroupID"],
1388 console.log(objArr);
1389 newParamObj[
"address"] = objArr[0].fieldValue;
1390 newParamObj[
"port"] = objArr[1].fieldValue;
1391 newParamObj[
"appGroupId"] = objArr[2].fieldValue;
1393 localGetAllHostInfo();
1403 function localGetAllHostInfo()
1405 Debug.log(
"localGetExistingHostInfo()");
1407 ConfigurationAPI.getUniqueFieldValuesForRecords(
1413 console.log(objArr);
1414 newParamObj[
"hostAddresses"] = objArr[0].fieldUniqueValueArray;
1415 newParamObj[
"hostPorts"] = objArr[1].fieldUniqueValueArray;
1417 showPrompt(nextStepIndex,newParamObj);
1425 case _STEP_GET_RECORD_NAME:
1430 document.getElementById(stepString +
"records").onclick = localRecordsSelectHandler;
1431 document.getElementById(stepString +
"records").onchange = localRecordsSelectHandler;
1434 function localRecordsSelectHandler(event) {
1435 Debug.log(
"Selected " + this.value);
1438 document.getElementById(stepString +
"recordName").value =
1439 ConfigurationAPI.incrementName(this.value);
1443 document.getElementById(stepString +
"editConfig").onclick =
1446 newParamObj[
"groupType"] =
"Configuration";
1448 paramObj[
"recordName"] = document.getElementById(stepString +
"recordName").value.trim();
1449 showPrompt(_STEP_CHANGE_GROUP,newParamObj);
1452 document.getElementById(stepString +
"editContext").onclick =
1455 newParamObj[
"groupType"] =
"Context";
1457 paramObj[
"recordName"] = document.getElementById(stepString +
"recordName").value.trim();
1458 showPrompt(_STEP_CHANGE_GROUP,newParamObj);
1461 document.getElementById(stepString +
"deleteRecordIcon").onclick =
1464 var selectedIndex = document.getElementById(stepString +
"records").selectedIndex;
1465 var recordName = _subsetUIDs[selectedIndex];
1466 Debug.log(
"deleteRecord " + selectedIndex +
" : " + recordName);
1467 Debug.log(
"getRecordConfiguration " + getRecordConfiguration());
1468 Debug.log(
"getAppConfiguration " + getAppConfiguration());
1471 Debug.log(
"getIntermediateTable " + getIntermediateTable());
1472 Debug.log(
"getIntermediateTypeName " + getIntermediateTypeName());
1474 Debug.log(
"No intermediate table: " + e);
1477 var generationsBack = 0;
1478 var lastGenerationsBack, parentCheckParentIndex;
1482 _modifiedTables = undefined;
1484 localPromptAndHandleRecordDeletion(_recordAlias,recordName);
1486 function localPromptAndHandleRecordDeletion(recordType,recordName)
1499 if(generationsBack == 0)
1500 prompt =
"Are you sure you want to remove the " + recordType +
" named '" +
1501 recordName +
"' from the active configuration?";
1503 prompt =
"Alert! A parent node, " + generationsBack +
" level(s) up in the " +
1504 "configuration tree from the " +
1505 "origial " + _recordAlias +
" '" + _subsetUIDs[selectedIndex] +
",' was found to " +
1506 "have no children.<br><br>Do you want to remove the childless " + recordType +
" named '" +
1507 recordName +
"' from the active configuration?";
1509 DesktopContent.popUpVerification(
1514 Debug.log(
"do deleteRecord " + recordType +
" : " + recordName);
1519 ConfigurationAPI.deleteSubsetRecords(
1520 getParentTable(generationsBack),
1523 function(modifiedTables,err)
1525 Debug.log(
"modifiedTables length " + modifiedTables.length);
1526 if(!modifiedTables.length)
1529 Debug.log(
"There was an error while creating the XDAQ Context '" +
1530 recordName +
".' " + err,
1531 Debug.HIGH_PRIORITY);
1534 _modifiedTables = modifiedTables;
1535 console.log(_modifiedTables);
1538 Debug.log(
"The " + recordType +
" named '" +
1539 recordName +
"' was successfully removed!",
1540 Debug.INFO_PRIORITY);
1542 parentCheckParentIndex = 0;
1548 ConfigurationAPI.saveModifiedTables(_modifiedTables,
1549 function(savedTables, savedGroups, savedAliases)
1551 if(!savedTables.length)
1553 Debug.log(
"There was an error while saving the changes.",
1554 Debug.HIGH_PRIORITY);
1559 _recordAlias +
" named '" + recordName +
"' was successfully removed!",
1560 Debug.INFO_PRIORITY);
1562 _modifiedTables = undefined;
1564 _aRecordWasModified =
true;
1566 if(generationsBack == 0)
1568 generationsBack = 1;
1569 localCheckParentChildren();
1572 localCheckParentChildren();
1597 Debug.log(
"User opted not to delete node.");
1601 localCheckParentChildren();
1607 function localCheckParentChildren()
1609 if(lastGenerationsBack != generationsBack)
1612 Debug.log(
"Starting new generation of checking...");
1613 parentCheckParentIndex = 0;
1614 lastGenerationsBack = generationsBack;
1616 Debug.log(
"localCheckParentChildren generationsBack=" + generationsBack +
1617 " parentCheckParentIndex=" + parentCheckParentIndex);
1625 Debug.log(
"getAppConfiguration " + getAppConfiguration());
1627 var modifiedTablesListStr =
"";
1628 for(var i=0;_modifiedTables && i<_modifiedTables.length;++i)
1630 if(i) modifiedTablesListStr +=
",";
1631 modifiedTablesListStr += _modifiedTables[i].tableName +
"," +
1632 _modifiedTables[i].tableVersion;
1636 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeView" +
1638 "&configGroupKey=-1" +
1639 "&hideStatusFalse=0" +
1641 "startPath=/" + getParentTable(generationsBack) +
1642 "&filterList=" + getParentFilter(generationsBack) +
1643 "&modifiedTables=" + modifiedTablesListStr,
1647 var tree = DesktopContent.getXMLNode(req,
"tree");
1656 for(i=parentCheckParentIndex;i<tree.children.length;++i)
1658 ++parentCheckParentIndex;
1660 parentName = tree.children[i].getAttribute(
"value");
1661 Debug.log(
"Checking parent record " +
1662 parentCheckParentIndex +
":" +
1666 for(j=0;j<tree.children[i].children.length;++j)
1667 if(tree.children[i].children[j].getAttribute(
"value") ==
1668 getParentLinkField(generationsBack))
1671 parentChildren = DesktopContent.getXMLChildren(
1672 tree.children[i].children[j],
1674 Debug.log(
"Num of children " + parentChildren.length);
1676 if(parentChildren.length == 0)
1678 localPromptAndHandleRecordDeletion(
1679 getParentType(generationsBack),
1687 Debug.log("No childless parent nodes found");
1691 localCheckParentChildren();
1697 Debug.log(
"Giving up on childless parent node check. " +
1698 "Ignoring errors: " + e);
1713 case _STEP_CHANGE_GROUP:
1718 document.getElementById(stepString +
"activateAlias").onclick =
1722 var alias = document.getElementById(stepString +
"aliases").value;
1723 Debug.log(
"activateAlias " + alias);
1728 _systemGroups.aliases[paramObj[
"groupType"]].length;++i)
1729 if(_systemGroups.aliases[paramObj[
"groupType"]][i].alias ==
1732 aliasObj = _systemGroups.aliases[paramObj[
"groupType"]][i];
1736 Debug.log(
"activateAlias group " + aliasObj.name +
1737 "-" + aliasObj.key);
1739 ConfigurationAPI.activateGroup(aliasObj.name, aliasObj.key,
1744 Debug.log(
"The System Alias '" + alias +
1745 "' (" + aliasObj.name +
" (" +
1746 aliasObj.key +
")) was successfully activated!", Debug.INFO_PRIORITY);
1753 document.getElementById(stepString +
"groupNames").onchange =
1757 Debug.log(
"Filling dropdown with keys for " + this.value);
1759 for(var i=0;i<_systemGroups.groups[paramObj[
"groupType"]]
1760 [this.value].keys.length;++i)
1762 str += htmlOpen(
"option",
1765 _systemGroups.groups[paramObj[
"groupType"]]
1766 [this.value].keys[i] ,
true );
1768 document.getElementById(stepString +
"groupKeys").innerHTML =
1773 document.getElementById(stepString +
"activateGroup").onclick =
1777 var name = document.getElementById(stepString +
"groupNames").value;
1778 var key = document.getElementById(stepString +
"groupKeys").value;
1780 Debug.log(
"activateGroup " + name +
1783 ConfigurationAPI.activateGroup(name, key,
1788 Debug.log(
"The Group '" + name +
" (" +
1789 key +
") was successfully activated!", Debug.INFO_PRIORITY);
1810 function localCreateIntermediateLevelRecord(name)
1812 Debug.log(
"localCreateIntermediateLevelRecord " + name);
1816 ConfigurationAPI.addSubsetRecords(
1817 getIntermediateTable(),
1820 function(modifiedTables,err)
1822 Debug.log(
"modifiedTables length " + modifiedTables.length);
1823 if(!modifiedTables.length)
1826 Debug.log(
"There was an error while creating the XDAQ Application '" +
1828 Debug.HIGH_PRIORITY);
1831 _modifiedTables = modifiedTables;
1834 Debug.log(
"New intermediate record '" + name +
"' was successfully created!");
1836 newParamObj[
"isNew" + getIntermediateTypeName()] =
true;
1838 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
1840 if(_intermediateLevel == 0)
1844 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]) _paramObjMap[_STEP_PROC_WHICH_BUFFER] = {};
1845 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER][
"allBuffers"]) _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"allBuffers"] = [];
1846 if(_paramObjMap[_STEP_PROC_WHICH_BUFFER][
"allBuffers"].indexOf(name) == -1)
1847 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"allBuffers"].push(name);
1855 localSetupIntermediateLevelRecord(name);
1863 function localSetupIntermediateLevelRecord(name)
1866 var recordGroupId =
"";
1867 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
1869 if(_intermediateLevel == 0)
1871 recordGroupId = _paramObjMap[_STEP_WHICH_APP][
"appChildGroupName"];
1880 Debug.log(
"localSetupIntermediateLevelRecord " + name +
1881 " into groupId=" + recordGroupId);
1883 var fieldArr,valueArr;
1885 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
1887 if(_intermediateLevel == 0)
1891 "DataManagerGroupID",
1892 "LinkToDataProcessorTable",
1893 "LinkToDataBufferGroupID",
1894 "CommentDescription"
1900 getRecordConfiguration(),
1901 name+
"ProcessorGroup",
1902 _DEFAULT_WIZ_COMMENT
1910 ConfigurationAPI.setFieldValuesForRecords(
1911 getIntermediateTable(),
1915 function(modifiedTables)
1917 Debug.log(
"modifiedTables length " + modifiedTables.length);
1919 if(!modifiedTables.length)
1921 Debug.log(
"There was an error while writing the values for the App.",
1922 Debug.HIGH_PRIORITY);
1925 _modifiedTables = modifiedTables;
1930 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]) _paramObjMap[_STEP_PROC_WHICH_BUFFER] = {};
1931 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"recordGroupName"] = name+
"ProcessorGroup";
1933 localCreateRecord(getRecordConfiguration());
1940 function localCreateApp(name)
1942 Debug.log(
"localCreateApp " + name);
1945 ConfigurationAPI.addSubsetRecords(
1949 function(modifiedTables,err)
1951 Debug.log(
"modifiedTables length " + modifiedTables.length);
1952 if(!modifiedTables.length)
1955 Debug.log(
"There was an error while creating the XDAQ Application '" +
1957 Debug.HIGH_PRIORITY);
1960 _modifiedTables = modifiedTables;
1963 Debug.log(
"New app '" + name +
"' was successfully created!");
1967 if(!_paramObjMap[_STEP_WHICH_APP]) _paramObjMap[_STEP_WHICH_APP] = {};
1968 if(!_paramObjMap[_STEP_WHICH_APP][
"apps"]) _paramObjMap[_STEP_WHICH_APP][
"apps"] = [];
1969 if(_paramObjMap[_STEP_WHICH_APP][
"apps"].indexOf(name) == -1)
1970 _paramObjMap[_STEP_WHICH_APP][
"apps"].push(name);
1971 _paramObjMap[_STEP_WHICH_APP][
"isNewApp"] =
true;
1973 localSetupApp(name);
1981 function localSetupApp(name)
1983 var context = _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"];
1984 var appGroupId = _paramObjMap[_STEP_SET_CONTEXT_HOST][
"appGroupId"];
1986 Debug.log(
"localSetupApp " + name +
" in context=" + context +
" groupId=" + appGroupId);
1988 var fieldArr,valueArr;
1994 "ApplicationGroupID",
1995 "LinkToSupervisorConfiguration",
1996 "LinkToSupervisorUID",
2000 "CommentDescription"
2006 getAppConfiguration(),
2011 _DEFAULT_WIZ_COMMENT
2020 ConfigurationAPI.setFieldValuesForRecords(
2025 function(modifiedTables)
2027 Debug.log(
"modifiedTables length " + modifiedTables.length);
2029 if(!modifiedTables.length)
2031 Debug.log(
"There was an error while writing the values for the App.",
2032 Debug.HIGH_PRIORITY);
2035 _modifiedTables = modifiedTables;
2038 localCreateAppConfig(name+
"Config");
2045 function localCreateAppConfig(name)
2047 Debug.log(
"localCreateAppConfig " + name);
2050 ConfigurationAPI.addSubsetRecords(
2051 getAppConfiguration(),
2054 function(modifiedTables,err)
2056 Debug.log(
"modifiedTables length " + modifiedTables.length);
2057 if(!modifiedTables.length)
2060 Debug.log(
"There was an error while creating the XDAQ Application '" +
2062 Debug.HIGH_PRIORITY);
2065 _modifiedTables = modifiedTables;
2068 Debug.log(
"New app config '" + name +
"' was successfully created!");
2071 localSetupAppConfig(name);
2079 function localSetupAppConfig(name)
2081 var context = _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"];
2082 Debug.log(
"localSetupAppConfig " + name +
" in context=" + context);
2084 var fieldArr,valueArr;
2087 _intermediateLevel = 0;
2089 if(_recordAlias == _RECORD_TYPE_FE)
2092 "LinkToFEInterfaceTable",
2093 "LinkToFEInterfaceGroupID",
2094 "CommentDescription"
2096 groupSuffix =
"FEGroup";
2099 getRecordConfiguration(),
2101 _DEFAULT_WIZ_COMMENT
2104 else if(_recordAlias == _RECORD_TYPE_PROCESSOR
2109 "LinkToDataBufferTable",
2110 "LinkToDataManagerGroupID",
2111 "CommentDescription"
2114 groupSuffix =
"DMGroup";
2117 getIntermediateTable(),
2119 _DEFAULT_WIZ_COMMENT
2124 ConfigurationAPI.setFieldValuesForRecords(
2125 getAppConfiguration(),
2129 function(modifiedTables)
2131 Debug.log(
"modifiedTables length " + modifiedTables.length);
2133 if(!modifiedTables.length)
2135 Debug.log(
"There was an error while writing the values for the App.",
2136 Debug.HIGH_PRIORITY);
2139 _modifiedTables = modifiedTables;
2143 if(!_paramObjMap[_STEP_WHICH_APP]) _paramObjMap[_STEP_WHICH_APP] = {};
2146 _paramObjMap[_STEP_WHICH_APP][
"appChildGroupName"] = name+groupSuffix;
2148 if(_recordAlias == _RECORD_TYPE_FE)
2150 Debug.log(
"Creating record...");
2152 localCreateRecord(getRecordConfiguration());
2154 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2156 Debug.log(
"Setting up extra buffer level...");
2157 localHandleIntermediateLevel();
2168 function localHandleIntermediateLevel()
2170 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2172 switch(_intermediateLevel)
2177 var bufferGroupId = _paramObjMap[_STEP_WHICH_APP][
"appChildGroupName"];
2178 var appName = _paramObjMap[_STEP_WHICH_APP][
"appName"];
2181 Debug.log(
"localCreateIntermediateLevel-" + _intermediateLevel +
2182 " DataManager=" + appName);
2190 ConfigurationAPI.getSubsetRecords(
2191 getIntermediateTable(),
2193 function(allRecords)
2195 Debug.log(
"all buffers found = " + allRecords.length);
2196 console.log(allRecords);
2199 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]) _paramObjMap[_STEP_PROC_WHICH_BUFFER] = {};
2200 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"allBuffers"] = allRecords;
2203 ConfigurationAPI.getSubsetRecords(
2204 getIntermediateTable(),
2205 "DataManagerGroupID="+
2206 encodeURIComponent(bufferGroupId) ,
2209 Debug.log(
"buffers of DataManager '" + appName +
2210 "' found = " + records.length);
2211 console.log(records);
2222 if(records.length == 0)
2227 var bufferName = ConfigurationAPI.createNewRecordName(
"Buffer",allRecords);
2230 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"bufferName"] = bufferName;
2232 localCreateIntermediateLevelRecord(appName);
2236 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"buffers"] = records;
2237 showPrompt(_STEP_PROC_WHICH_BUFFER);
2249 default:
throw(
"?");
2259 function localGetExistingIntermediateTargetGroupID(intermediateName)
2262 Debug.log(
"localGetExistingSupervisorTargetGroupID " + intermediateName +
2263 " of type " + getIntermediateTypeName());
2265 ConfigurationAPI.getTree(
2266 getIntermediateTable() +
"/" + intermediateName,
2279 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2282 if(tree.children[1].children[0].nodeName !=
2284 throw(
"Invalid GroupID location in tree.");
2285 if(tree.children[1].children[1].nodeName !=
2286 "LinkConfigurationName")
2287 throw(
"Invalid Link Table location in tree.");
2290 tree.children[1].children[0].getAttribute(
"value");
2292 tree.children[1].children[1].getAttribute(
"value");
2298 Debug.log(
"Error locating group in configuration for the new record. " + e,
2299 Debug.HIGH_PRIORITY);
2302 Debug.log(
"Group Link found as " + table +
":" + groupId);
2308 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2310 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]) _paramObjMap[_STEP_PROC_WHICH_BUFFER] = {};
2311 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"recordGroupName"] = groupId;
2312 localCreateRecord(table);
2313 Debug.log(
"Setting up extra buffer level...");
2325 function localGetExistingSupervisorTargetGroupID(supervisorName)
2327 Debug.log(
"localGetExistingSupervisorTargetGroupID " + supervisorName);
2329 ConfigurationAPI.getTree(
2330 _XDAQAPP_BASE_PATH +
"/" + supervisorName,
2343 if(tree.children[1].children[4].children[0].nodeName !=
2345 throw(
"Invalid GroupID location in tree.");
2346 if(tree.children[1].children[4].children[1].nodeName !=
2347 "LinkConfigurationName")
2348 throw(
"Invalid Link Table location in tree.");
2351 tree.children[1].children[4].children[0].getAttribute(
"value");
2353 tree.children[1].children[4].children[1].getAttribute(
"value");
2358 Debug.log(
"Error locating group in configuration for the new record. " + e,
2359 Debug.HIGH_PRIORITY);
2362 Debug.log(
"Group Link found as " + table +
":" + groupId);
2366 if(!_paramObjMap[_STEP_WHICH_APP]) _paramObjMap[_STEP_WHICH_APP] = {};
2367 _paramObjMap[_STEP_WHICH_APP][
"appChildGroupName"] = groupId;
2369 if(_recordAlias == _RECORD_TYPE_FE)
2371 Debug.log(
"Creating record...");
2372 localCreateRecord(table);
2374 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2376 Debug.log(
"Setting up extra buffer level...");
2377 _intermediateLevel = 0;
2378 localHandleIntermediateLevel();
2389 function localCreateRecord(table)
2391 Debug.log(
"localCreateRecord " + recordName +
" in table=" + table);
2395 ConfigurationAPI.addSubsetRecords(
2399 function(modifiedTables,err)
2401 Debug.log(
"modifiedTables length " + modifiedTables.length);
2402 if(!modifiedTables.length || err)
2404 var reallyAnError =
true;
2405 if(_furthestStep >= _STEP_SET_RECORD_FIELDS)
2408 if(err.indexOf(
"Entries in UID are not unique") >= 0)
2410 Debug.log(
"Ignoring UID not unique error since likely already created..." +
2412 reallyAnError =
false;
2419 Debug.log(
"There was an error while creating the " + _recordAlias +
2421 recordName +
".' " + err,
2422 Debug.HIGH_PRIORITY);
2427 _modifiedTables = modifiedTables;
2429 console.log(
"_modifiedTables",_modifiedTables);
2432 Debug.log(
"New " + _recordAlias +
" record named '" + recordName +
"' was successfully created!");
2435 localGetHelperValuesForRecord();
2444 function localGetHelperValuesForRecord()
2446 Debug.log(
"localGetHelperValuesForRecord " + recordName);
2448 ConfigurationAPI.getFieldsOfRecords(
2449 getRecordConfiguration(),
2451 "!*Comment*,!*SlowControls*,!Status,!" + getRecordGroupIDField(),
2453 function(recordFields)
2455 newParamObj[
"fields"] = recordFields;
2456 Debug.log(
"recordFields found = " + recordFields.length);
2457 console.log(recordFields);
2460 showPrompt(_STEP_SET_RECORD_FIELDS,newParamObj);
2478 document.getElementsByClassName(stepString +
"nextButton")[0].onclick =
2479 localNextButtonHandler;
2480 document.getElementsByClassName(stepString +
"nextButton")[1].onclick =
2481 localNextButtonHandler;
2483 function localNextButtonHandler()
2489 case _STEP_SET_RECORD_FIELDS:
2492 localScopeSetRecordFieldsDoIt();
2495 function localScopeSetRecordFieldsDoIt()
2497 Debug.log(
"localScopeSetRecordFieldsDoIt");
2499 var recordFields = paramObj[
"fields"];
2503 if(_recordAlias == _RECORD_TYPE_FE)
2504 groupName = _paramObjMap[_STEP_WHICH_APP][
"appChildGroupName"];
2505 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2506 groupName = _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"recordGroupName"];
2515 for(var i=0;i<recordFields.length;++i)
2517 fieldArr.push(recordFields[i].fieldRelativePath +
2518 recordFields[i].fieldColumnName);
2519 valueArr.push(ConfigurationAPI.getEditableFieldValue(
2526 fieldArr.push(getRecordGroupIDField());
2527 valueArr.push(groupName);
2528 fieldArr.push(
"CommentDescription");
2529 valueArr.push(_DEFAULT_WIZ_COMMENT);
2530 fieldArr.push(
"Status");
2533 ConfigurationAPI.setFieldValuesForRecords(
2534 getRecordConfiguration(),
2538 function(modifiedTables)
2540 Debug.log(
"modifiedTables length " + modifiedTables.length);
2542 if(!modifiedTables.length)
2544 Debug.log(
"There was an error while writing the values.",
2545 Debug.HIGH_PRIORITY);
2549 _modifiedTables = modifiedTables;
2552 ConfigurationAPI.saveModifiedTables(_modifiedTables,
2553 function(savedTables, savedGroups, savedAliases)
2555 if(!savedTables.length)
2557 Debug.log(
"There was an error while saving the values.",
2558 Debug.HIGH_PRIORITY);
2562 Debug.log(
"The new " +
2563 _recordAlias +
" named '" + recordName +
"' was successfully created!",
2564 Debug.INFO_PRIORITY);
2566 _modifiedTables = undefined;
2568 _aRecordWasModified =
true;
2583 case _STEP_SET_CONTEXT_HOST:
2586 localHandleSetupContext();
2589 function localHandleSetupContext()
2591 Debug.log(
"localHandleSetupContext");
2593 var context = _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"];
2594 var address = document.getElementById(stepString +
"address").value.trim();
2595 var port = document.getElementById(stepString +
"port").value.trim();
2598 paramObj[
"address"] = address;
2601 paramObj[
"port"] = port;
2603 var appGroupId = context+
"Apps";
2604 if(!paramObj[
"isNewContext"])
2605 appGroupId = paramObj[
"appGroupId"];
2607 paramObj[
"appGroupId"] = appGroupId;
2609 var fieldArr = [
"Status",
2610 "LinkToApplicationConfiguration",
2611 "ApplicationGroupID",
2614 "CommentDescription"
2617 var valueArr = [
"1",
2622 _DEFAULT_WIZ_COMMENT
2625 ConfigurationAPI.setFieldValuesForRecords(
2630 function(modifiedTables)
2632 Debug.log(
"modifiedTables length " + modifiedTables.length);
2634 if(!modifiedTables.length)
2636 Debug.log(
"There was an error while writing the values.",
2637 Debug.HIGH_PRIORITY);
2640 _modifiedTables = modifiedTables;
2657 function localGetAppInfo()
2659 var appGroupId = paramObj[
"appGroupId"];
2660 Debug.log(
"localGetAppInfo for context app group " + appGroupId);
2663 ConfigurationAPI.getSubsetRecords(
2668 Debug.log(
"all apps found = " + allApps.length);
2670 console.log(allApps);
2672 if(!_paramObjMap[_STEP_WHICH_APP]) _paramObjMap[_STEP_WHICH_APP] = {};
2675 _paramObjMap[_STEP_WHICH_APP][
"allApps"] = allApps;
2678 ConfigurationAPI.getSubsetRecords(
2681 encodeURIComponent(getAppClass()) +
2682 ";ApplicationGroupID="+
2684 encodeURIComponent(appGroupId) ,
2687 Debug.log(
"apps of appClass found = " + records.length);
2688 console.log(records);
2690 if(records.length == 0)
2695 var appName = ConfigurationAPI.createNewRecordName(getApp(),allApps);
2698 _paramObjMap[_STEP_WHICH_APP][
"appName"] = appName;
2700 localCreateApp(appName);
2704 _paramObjMap[_STEP_WHICH_APP][
"apps"] = records;
2705 showPrompt(_STEP_WHICH_APP);
2720 case _STEP_GET_RECORD_NAME:
2723 recordName = document.getElementById(stepString +
"recordName").value.trim();
2724 paramObj[
"recordName"] = recordName;
2726 if(recordName.length < 1)
2728 Debug.log(
"Invalid " + _recordAlias +
" name ' " +
2729 recordName +
"' (too short). Please enter a valid name.",
2730 Debug.HIGH_PRIORITY);
2734 for(var i=0;i<_subsetUIDs.length;++i)
2735 if(_subsetUIDs[i] == recordName)
2737 Debug.log(
"Invalid " + _recordAlias +
" name ' " +
2738 recordName +
"' (name already in use in the active configuration). Please enter a valid name.",
2739 Debug.HIGH_PRIORITY);
2744 ConfigurationAPI.getSubsetRecords(
2749 newParamObj[
"contexts"] = records;
2750 Debug.log(
"contexts found = " + records.length);
2751 console.log(records);
2753 showPrompt(nextStepIndex,newParamObj);
2759 case _STEP_WHICH_RECORD_TYPE:
2762 if(scopeWhichRecordTypeNext())
2765 function scopeWhichRecordTypeNext()
2767 var newRecordAlias = document.getElementById(stepString +
"recordTypes").value.trim();
2769 var needToInit = (_recordAlias != newRecordAlias);
2771 _recordAlias = newRecordAlias;
2772 Debug.log(
"_recordAlias chosen as " + _recordAlias);
2774 if(needToInit) initRecordWizard();
2781 showPrompt(nextStepIndex,newParamObj);
2784 catch(e){ Debug.log(
"Caught ERROR: " + e.stack);}
2788 document.getElementsByClassName(stepString +
"prevButton")[0].onclick =
2789 localPrevButtonHandler;
2790 document.getElementsByClassName(stepString +
"prevButton")[1].onclick =
2791 localPrevButtonHandler;
2793 function localPrevButtonHandler()
2798 case _STEP_WHICH_RECORD_TYPE:
2803 _modifiedTables = undefined;
2809 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2812 el.parentNode.removeChild(el);
2813 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
2816 if(_doneHandler) _doneHandler(_aRecordWasModified);
2821 showPrompt(prevStepIndex);
2824 catch(e){ Debug.log(
"Caught ERROR: " + e.stack);}
2836 if(_recordAlias == _RECORD_TYPE_FE)
2837 retVal =
"FESupervisor";
2838 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2839 retVal =
"DataManagerSupervisor";
2848 function getAppClass()
2850 return "ots::" + getApp();
2855 function getAppModule()
2858 if(_recordAlias == _RECORD_TYPE_FE)
2859 otsModule =
"${OTSDAQ_LIB}/libCoreSupervisors.so";
2860 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2861 otsModule =
"${OTSDAQ_LIB}/libCoreSupervisors.so";
2870 function getAppConfiguration()
2873 if(_recordAlias == _RECORD_TYPE_FE)
2874 retVal =
"FESupervisorConfiguration";
2875 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2876 retVal =
"DataManagerSupervisorConfiguration";
2885 function getRecordConfiguration()
2888 if(_recordAlias == _RECORD_TYPE_FE)
2889 retVal =
"FEInterfaceConfiguration";
2890 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2891 retVal =
"DataBufferConfiguration";
2900 function getRecordGroupIDField()
2903 if(_recordAlias == _RECORD_TYPE_FE)
2904 retVal =
"FEInterfaceGroupID";
2905 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2906 retVal =
"DataBufferGroupID";
2916 function getRecordFilter()
2919 if(_recordAlias == _RECORD_TYPE_FE)
2921 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2925 throw(
"Invalid getRecordFilter");
2934 function getIntermediateTable()
2937 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2939 if(_intermediateLevel == 0)
2940 retVal =
"DataManagerConfiguration";
2944 throw(
"Invalid getIntermediateTable");
2952 function getIntermediateTypeName()
2955 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2957 if(_intermediateLevel == 0)
2962 throw(
"Invalid getIntermediateTypeName");
2970 function getParentTable(generationsBack)
2972 if(generationsBack == 0)
return getRecordConfiguration();
2976 if(_recordAlias == _RECORD_TYPE_FE)
2978 if(generationsBack == 1)
2979 retVal =
"FESupervisorConfiguration";
2980 else if(generationsBack == 2)
2981 retVal = _XDAQAPP_BASE_PATH;
2983 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2985 if(generationsBack == 1)
2986 retVal =
"DataManagerConfiguration";
2987 else if(generationsBack == 2)
2988 retVal =
"DataManagerSupervisorConfiguration";
2989 else if(generationsBack == 3)
2990 retVal = _XDAQAPP_BASE_PATH;
2994 throw(
"Invalid getParentTable");
3002 function getParentType(generationsBack)
3004 if(generationsBack == 0)
return _recordAlias;
3008 if(_recordAlias == _RECORD_TYPE_FE)
3010 if(generationsBack == 1)
3011 retVal =
"FESupervisorConfiguration";
3012 else if(generationsBack == 2)
3013 retVal =
"FESupervisor";
3015 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
3017 if(generationsBack == 1)
3019 else if(generationsBack == 2)
3020 retVal =
"DataManagerSupervisorConfiguration";
3021 else if(generationsBack == 3)
3022 retVal =
"DataManagerSupervisor";
3026 throw(
"Invalid getParentType");
3034 function getParentLinkField(generationsBack)
3038 if(_recordAlias == _RECORD_TYPE_FE)
3040 if(generationsBack == 1)
3041 retVal =
"LinkToFEInterfaceTable";
3042 else if(generationsBack == 2)
3043 retVal =
"LinkToSupervisorConfiguration";
3045 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
3047 if(generationsBack == 1)
3048 retVal =
"LinkToDataProcessorTable";
3049 else if(generationsBack == 2)
3050 retVal =
"LinkToDataBufferTable";
3051 else if(generationsBack == 3)
3052 retVal =
"LinkToSupervisorConfiguration";
3056 throw(
"Invalid getParentLinkField");
3064 function getParentFilter(generationsBack)
3068 if(_recordAlias == _RECORD_TYPE_FE)
3070 if(generationsBack == 1)
3072 else if(generationsBack == 2)
3073 retVal =
"Class=ots::FESupervisor";
3075 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
3077 if(generationsBack == 1)
3079 else if(generationsBack == 2)
3081 else if(generationsBack == 3)
3082 retVal =
"Class=ots::DataManagerSupervisor,ots::ARTDAQDataManagerSupervisor," +
3083 "ots::VisualSupervisor";
3087 throw(
"Invalid getParentFilter");
3095 function htmlOpen(tag,attObj,innerHTML,doCloseTag)
3098 var attKeys = Object.keys(attObj);
3099 str +=
"<" + tag +
" ";
3100 for(var i=0;i<attKeys.length;++i)
3101 str +=
" " + attKeys[i] +
"='" +
3102 attObj[attKeys[i]] +
"' ";
3104 if(innerHTML) str += innerHTML;
3106 str +=
"</" + tag +
">";
3112 function htmlClearDiv()
3114 return "<div id='clearDiv'></div>";