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 =
"XDAQContextTable";
201 var _XDAQAPP_BASE_PATH =
"XDAQApplicationTable";
203 var _DEFAULT_WIZ_COMMENT=
"Generated by Record Creation Wiz";
208 Debug.log(
"RecordWiz.wiz constructed");
209 RecordWiz.wiz =
this;
211 var windowTooltip =
"Welcome to the Record Wizard GUI. Here you can create new records for " +
212 "your <i>otsdaq</i> system. \n\n" +
213 "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" +
215 "Briefly, here is a description of the steps: " +
216 "\n\t- 'What type of record do you want to add?'" +
217 "\n\t- 'Do you want to add it to an existing context or create a new one?'";
218 if(!recordsAliasFastForward || recordsAliasFastForward ==
"")
220 DesktopContent.tooltip(
"Record Wizard Introduction",
223 DesktopContent.setWindowTooltip(windowTooltip);
225 showPrompt(_STEP_WHICH_RECORD_TYPE);
229 _recordAlias = recordsAliasFastForward;
230 if(!localParameterCheck())
232 Debug.log(
"Invalid parameters to the Record Creation Wizard!", Debug.HIGH_PRIORITY);
237 DesktopContent.tooltip(_recordAlias +
" Wizard Introduction",
238 "Welcome to the " + _recordAlias +
" Wizard GUI. Here you can create new records for " +
239 "your <i>otsdaq</i> system. \n\n" +
240 "The " + _recordAlias +
" Wizard is presented as a step-by-step process that will walk you through creating the skeleton for your new " +
241 _recordAlias +
".\n\n" +
242 "Briefly, here is a description of the steps: " +
243 "\n\t- 'Do you want to add your " + _recordAlias +
" to an existing context or create a new one?'"
258 function xdaqContextTooltip()
260 DesktopContent.tooltip(
"XDAQ Contexts",
261 "The lowest level parent for your record, in the <i>otsdaq</i> configuration tree, is a XDAQ Context. " +
262 "What is a XDAQ Context? Why do I need a XDAQ Context? Do I want a new one for my " + _recordAlias +
" or not?" +
264 "XDAQ Contexts are the fundamental executable program building blocks of <i>otsdaq</i>. " +
265 "A XDAQ Context runs a group of XDAQ Applications inside of it. If one of those XDAQ Applications crashes, " +
266 "then only the parent XDAQ Context will crash. This is one reason organizing your <i>otsdaq</i> entities into separate XDAQ Contexts makes sense." +
268 "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 " +
269 "they can easily be distributed to other nodes (computers) in your DAQ system when your system scales up."
274 function xdaqApplicationTooltip()
276 DesktopContent.tooltip(
"XDAQ Applications",
277 "The second level parent for your record, in the <i>otsdaq</i> configuration tree, is a XDAQ Application. " +
278 "What is a XDAQ Application? Why do I need a XDAQ Application? Do I want a new one for my " + _recordAlias +
" or not?" +
280 "XDAQ Applications are server processes that can be controlled by <i>otsdaq</i> through network messages. " +
281 "Ther can be one or many XDAQ Applciation in a XDAQ Context. If one of those XDAQ Applications crashes, " +
282 "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." +
284 "Two other useful features of XDAQ Applications are that they can respond to web requests and state machine transitions."
292 function initRecordWizard()
295 _modifiedTables = undefined;
302 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
305 el.parentNode.removeChild(el);
306 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
312 ConfigurationAPI.getAliasesAndGroups(
315 _systemGroups = retObj;
316 console.log(
"_systemGroups",_systemGroups);
317 console.log(
"ConfigurationAPI._activeGroups",ConfigurationAPI._activeGroups);
321 ConfigurationAPI.getSubsetRecords(
322 getRecordConfiguration(),
326 _subsetUIDs = records;
327 Debug.log(
"records found = " + records.length);
328 console.log(records);
330 showPrompt(_STEP_GET_RECORD_NAME);
342 function showPrompt(stepIndex,paramObj)
345 if(!stepIndex) stepIndex = 0;
347 if(stepIndex > _furthestStep &&
348 _furthestStep < _STEP_OUT_OF_SEQUENCE)
349 _furthestStep = stepIndex;
351 Debug.log(
"showPrompt " + stepIndex);
352 Debug.log(
"_furthestStep " + _furthestStep);
355 if(!_paramObjMap) _paramObjMap = {};
359 _paramObjMap[stepIndex] = paramObj;
360 else if(_paramObjMap[stepIndex])
361 paramObj = _paramObjMap[stepIndex];
365 _paramObjMap[stepIndex] = {};
366 paramObj = _paramObjMap[stepIndex];
369 console.log(
"_paramObjMap",_paramObjMap);
370 console.log(
"paramObj",paramObj);
372 var el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
377 el.parentNode.removeChild(el);
378 el = document.getElementById(ConfigurationAPI._POP_UP_DIALOG_ID);
387 var stepString =
"stepIndex-" + stepIndex +
"-";
389 var showPrevButton =
true;
390 var showNextButton =
true;
391 var prevStepIndex = stepIndex-1;
392 if(prevStepIndex > _lastNextStep)
393 prevStepIndex = _lastNextStep;
394 _lastNextStep = stepIndex;
396 var nextStepIndex = stepIndex+1;
397 var prevButtonText =
"Go Back";
398 var nextButtonText =
"Next Step";
403 recordName = _paramObjMap[_STEP_GET_RECORD_NAME][
"recordName"];
410 function localAddContent()
414 case _STEP_PROC_WHICH_BUFFER:
418 showNextButton =
false;
421 Debug.log(
"_STEP_PROC_WHICH_BUFFER " + recordName);
425 str +=
"Do you want to add the " + _recordAlias +
" named '" +
426 recordName +
"' to a new Data Manager Buffer " +
427 "or an existing one in the Data Manager '" +
428 _paramObjMap[_STEP_WHICH_APP][
"appName"] +
"'?";
431 str +=
"<table style='margin-bottom: 10px;'>";
435 str +=
"<tr><td><b>New Buffer:</b></td><td>";
437 str += htmlOpen(
"input",
440 "id" : stepString +
"bufferName",
441 "value": (paramObj[
"bufferName"]?paramObj[
"bufferName"]:
442 ConfigurationAPI.createNewRecordName(
"Buffer",
443 paramObj[
"allBuffers"])),
446 str += htmlOpen(
"input",
448 "id": stepString +
"addToNew",
450 "value":
"Add to New",
451 "title":
"Create a new Buffer and add the new " +
452 _recordAlias +
" to it."
458 if(paramObj[
"buffers"].length)
460 str +=
"<tr><td><b>Existing Buffers:</b></td><td>";
462 str += htmlOpen(
"select",
464 "id" : stepString +
"buffers",
467 for(var i=0;i<paramObj[
"buffers"].length;++i)
469 str += htmlOpen(
"option",
472 paramObj[
"buffers"][i] ,
true );
475 str += htmlOpen(
"input",
477 "id": stepString +
"addToExisting",
479 "value":
"Add to Existing",
480 "title":
"Add new " + _recordAlias +
481 " to the chosen existing Buffer."
491 if(paramObj[
"allBuffers"].length)
495 str += htmlClearDiv();
496 str +=
"Here is a dropdown of all existing Buffers " +
497 " to help you in creating standardized names (Note: shown above are " +
498 "only the Buffers in the chosen Data Manager '" +
499 _paramObjMap[_STEP_WHICH_APP][
"appName"] +
502 str += htmlClearDiv();
503 str += htmlOpen(
"select",
505 "id" : stepString +
"allBuffers",
506 "style" :
"margin-bottom: 16px;"
509 for(var i=0;i<paramObj[
"allBuffers"].length;++i)
511 str += htmlOpen(
"option",
514 paramObj[
"allBuffers"][i] ,
true );
524 case _STEP_SET_RECORD_FIELDS:
526 Debug.log(
"_STEP_SET_RECORD_FIELDS ");
528 nextButtonText =
"Done!";
531 str +=
"Please edit the fields for your record and then click 'Done!' to save " +
532 " your new " + _recordAlias +
" named '" + recordName +
"':";
534 str += htmlClearDiv();
535 str += htmlOpen(
"div",
537 "id" : stepString +
"fields",
538 "style" :
"margin: 20px;",
541 str += htmlClearDiv();
545 case _STEP_WHICH_APP:
549 xdaqApplicationTooltip();
551 showNextButton =
false;
554 Debug.log(
"_STEP_WHICH_APP " + recordName);
558 str +=
"Do you want to add the " + _recordAlias +
" named '" +
559 recordName +
"' to a new XDAQ " + getAppClass() +
560 " Application or an existing one in the context '" +
561 _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"] +
"'?";
564 str +=
"<table style='margin-bottom: 10px;'>";
568 str +=
"<tr><td><b>New XDAQ App:</b></td><td>";
570 str += htmlOpen(
"input",
573 "id" : stepString +
"appName",
574 "value": (paramObj[
"appName"]?paramObj[
"appName"]:
575 ConfigurationAPI.createNewRecordName(getApp(),paramObj[
"allApps"])),
578 str += htmlOpen(
"input",
580 "id": stepString +
"addToNew",
582 "value":
"Add to New",
583 "title":
"Create a new XDAQ Application and add the new " + _recordAlias +
" to it."
589 if(paramObj[
"apps"].length)
591 str +=
"<tr><td><b>Existing Apps:</b></td><td>";
593 str += htmlOpen(
"select",
595 "id" : stepString +
"apps",
598 for(var i=0;i<paramObj[
"apps"].length;++i)
600 str += htmlOpen(
"option",
603 paramObj[
"apps"][i] ,
true );
606 str += htmlOpen(
"input",
608 "id": stepString +
"addToExisting",
610 "value":
"Add to Existing",
611 "title":
"Add new " + _recordAlias +
" to the chosen existing XDAQ Application."
621 if(paramObj[
"allApps"].length)
625 str += htmlClearDiv();
626 str +=
"Here is a dropdown of all existing XDAQ Applications " +
627 " to help you in creating standardized names (Note: shown above are " +
628 "only apps with class " + getAppClass() +
" and in the chosen context '" +
629 _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"] +
632 str += htmlClearDiv();
633 str += htmlOpen(
"select",
635 "id" : stepString +
"allApps",
636 "style" :
"margin-bottom: 16px;"
639 for(var i=0;i<paramObj[
"allApps"].length;++i)
641 str += htmlOpen(
"option",
644 paramObj[
"allApps"][i] ,
true );
654 case _STEP_SET_CONTEXT_HOST:
656 if(paramObj[
"isNewContext"])
657 str +=
"Please enter the Host Address and Port for the " +
658 "new Context named '" +
659 _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"] +
"':";
661 str +=
"Please verify the Host Address and Port for the " +
662 "existing Context named '" +
663 _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"] +
"':";
666 str +=
"<table style=''>";
670 str +=
"<tr><td><b>Address:</b></td><td>";
672 str += htmlOpen(
"input",
675 "id" : stepString +
"address",
676 "value" : (paramObj[
"address"]?paramObj[
"address"]:
""),
683 str +=
"<tr><td><b>Port:</b></td><td>";
685 str += htmlOpen(
"input",
688 "id" : stepString +
"port",
689 "value" : (paramObj[
"port"]?paramObj[
"port"]:
""),
700 str += htmlClearDiv();
701 str +=
"Here is a dropdown of existing Host Addresses " +
702 " to help you in creating standardized addresses:";
703 str += htmlClearDiv();
704 str += htmlOpen(
"select",
706 "id" : stepString +
"addresses",
707 "style" :
"margin-bottom: 16px;"
711 for(var i=0;i<paramObj[
"hostAddresses"].length;++i)
713 str += htmlOpen(
"option",
715 },paramObj[
"hostAddresses"][i] ,
true );
721 str += htmlClearDiv();
722 str +=
"Here is a dropdown of existing Host Ports " +
723 " to help you in creating standardized ports:";
724 str += htmlClearDiv();
725 str += htmlOpen(
"select",
727 "id" : stepString +
"ports",
732 for(var i=0;i<paramObj[
"hostPorts"].length;++i)
734 str += htmlOpen(
"option",
736 },paramObj[
"hostPorts"][i] ,
true );
742 case _STEP_WHICH_CONTEXT:
744 xdaqContextTooltip();
746 showNextButton =
false;
749 Debug.log(
"_STEP_WHICH_CONTEXT " + recordName);
753 str +=
"Do you want to add the " + _recordAlias +
" named '" +
754 recordName +
"' to a new XDAQ Context or an existing one?";
758 str +=
"<table style='margin-bottom: 10px;'>";
762 str +=
"<tr><td><b>New XDAQ Context:</b></td><td>";
764 str += htmlOpen(
"input",
767 "id" : stepString +
"contextName",
768 "value": (paramObj[
"contextName"]?paramObj[
"contextName"]:
""),
771 str += htmlOpen(
"input",
773 "id": stepString +
"addToNew",
775 "value":
"Add to New",
776 "title":
"Create a new XDAQ Context and add the new " + _recordAlias +
" to it."
782 if(paramObj[
"contexts"].length)
784 str +=
"<tr><td><b>Existing Contexts:</b></td><td>";
786 str += htmlOpen(
"select",
788 "id" : stepString +
"contexts",
791 for(var i=0;i<paramObj[
"contexts"].length;++i)
793 str += htmlOpen(
"option",
796 paramObj[
"contexts"][i] ,
true );
799 str += htmlOpen(
"input",
801 "id": stepString +
"addToExisting",
803 "value":
"Add to Existing",
804 "title":
"Add new " + _recordAlias +
" to the chosen existing XDAQ Context."
816 case _STEP_CHANGE_GROUP:
819 showNextButton =
false;
820 nextStepIndex = _STEP_GET_RECORD_NAME;
821 prevStepIndex = _STEP_GET_RECORD_NAME;
823 str +=
"Choose a '" + paramObj[
"groupType"] +
824 "' group to activate (either a System Alias or specific group):";
826 str += htmlClearDiv();
829 str +=
"<table style='margin-bottom: 10px;'>";
830 if(_systemGroups.aliases[paramObj[
"groupType"]].length)
832 str +=
"<tr><td><b>System Aliases:</b></td><td>";
834 str += htmlOpen(
"select",
836 "id" : stepString +
"aliases",
839 for(var i=0;i<_systemGroups.aliases[paramObj[
"groupType"]].length;++i)
841 str += htmlOpen(
"option",
844 _systemGroups.aliases[paramObj[
"groupType"]]
848 str += htmlOpen(
"input",
850 "id": stepString +
"activateAlias",
852 "value":
"Activate Alias",
853 "title":
"Activate chosen System Alias and return to creating your new " + _recordAlias +
"."
860 str +=
"<tr><td colspan='2'>No system aliases of type Context found.</td></tr>";
862 var groupNames = Object.keys(_systemGroups.groups[paramObj[
"groupType"]]);
863 if(groupNames.length)
865 str +=
"<tr><td><b>Group Names:</b></td><td>";
867 str += htmlOpen(
"select",
869 "id" : stepString +
"groupNames",
872 for(var i=0;i<groupNames.length;++i)
874 str += htmlOpen(
"option",
877 groupNames[i] ,
true );
885 str +=
"<tr><td colspan='2'>No groups of type Context found.</td></tr>";
887 if(groupNames.length)
889 str +=
"<tr><td><b>Group Keys:</b></td><td>";
891 str += htmlOpen(
"select",
893 "id" : stepString +
"groupKeys",
896 for(var i=0;i<_systemGroups.groups[paramObj[
"groupType"]]
897 [groupNames[0]].keys.length;++i)
899 str += htmlOpen(
"option",
902 _systemGroups.groups[paramObj[
"groupType"]]
903 [groupNames[0]].keys[i] ,
true );
906 str += htmlOpen(
"input",
908 "id": stepString +
"activateGroup",
910 "value":
"Activate Group",
911 "title":
"Activate chosen Group and Key pair and return to creating your new " + _recordAlias +
"."
922 case _STEP_GET_RECORD_NAME:
925 prevStepIndex = _STEP_WHICH_RECORD_TYPE;
929 str += htmlOpen(
"div",
931 "style" :
"font-weight:bold; margin: 6px 0 20px 0;"
933 (_aRecordWasModified?
934 (
"Would you like to create another " + _recordAlias +
"?"):
935 (
"Welcome to the " + _recordAlias +
" creation Wizard!")) ,
937 str += htmlClearDiv();
941 str +=
"Enter the unique record name for your " + _recordAlias +
": ";
942 str += htmlClearDiv();
943 str += htmlOpen(
"input",
946 "id" : stepString +
"recordName",
947 "style" :
"margin-bottom: 16px;",
948 "value" : (paramObj[
"recordName"]?paramObj[
"recordName"]:
""),
955 str += htmlClearDiv();
956 str +=
"Here is a dropdown of existing " + _recordAlias +
957 " records to help you in creating standardized record names:";
958 str += htmlClearDiv();
961 str += htmlOpen(
"select",
963 "id" : stepString +
"records",
964 "style" :
"margin-bottom: 16px;",
968 for(var i=0;i<_subsetUIDs.length;++i)
970 str += htmlOpen(
"option",
972 },_subsetUIDs[i] ,
true );
977 str += htmlOpen(
"div",
979 "id" : stepString +
"deleteRecordIcon",
980 "class": ConfigurationAPI._POP_UP_DIALOG_ID +
"-deleteIcon",
981 "style" :
"float: right; margin: 6px 112px -16px -200px; display: block;",
987 str += htmlOpen(
"div",
989 "id" : ConfigurationAPI._POP_UP_DIALOG_ID +
990 "-preloadImage-editIconHover",
991 "class": ConfigurationAPI._POP_UP_DIALOG_ID +
"-preloadImage",
993 str += htmlOpen(
"div",
995 "id" : ConfigurationAPI._POP_UP_DIALOG_ID +
996 "-preloadImage-treeEditTrashIconHover",
997 "class": ConfigurationAPI._POP_UP_DIALOG_ID +
"-preloadImage",
1003 str += htmlClearDiv();
1004 str +=
"Note you are currently editing these active groups:";
1006 str +=
"<table style='margin-bottom: 10px;'>";
1007 str +=
"<tr><td><b>Active Context:</b></td><td>";
1008 str += ConfigurationAPI._activeGroups.Context.groupName +
" (" + ConfigurationAPI._activeGroups.Context.groupKey +
")";
1011 str += htmlOpen(
"div",
1013 "id": stepString +
"editContext",
1014 "class": ConfigurationAPI._POP_UP_DIALOG_ID +
"-editIcon",
1015 "style":
"float:right; display:block; margin: -3px 0 0 10px;",
1016 "title":
"Click to activate a different Context group.",
1020 str +=
"</td></tr>";
1021 str +=
"<tr><td><b>Active Configuration:</b></td><td>";
1022 str += _systemGroups.activeGroups.Configuration.groupName +
" (" + _systemGroups.activeGroups.Configuration.groupKey +
")";
1024 str += htmlOpen(
"div",
1026 "id": stepString +
"editConfig",
1027 "class": ConfigurationAPI._POP_UP_DIALOG_ID +
"-editIcon",
1028 "style":
"float:right; display:block; margin: -3px 0 0 10px;",
1029 "title":
"Click to activate a different Configuration group.",
1032 str +=
"</td></tr>";
1038 case _STEP_WHICH_RECORD_TYPE:
1040 nextStepIndex = _STEP_GET_RECORD_NAME;
1041 prevButtonText =
"Close Wizard";
1045 str += htmlOpen(
"div",
1047 "style" :
"font-weight:bold; margin: 6px 0 20px 0;"
1049 "Welcome to the record creation Wizard!" ,
1051 str += htmlClearDiv();
1055 str += htmlClearDiv();
1056 str +=
"Below is a dropdown of record types that this Wizard can help you create. " +
1057 " Choose one and proceed through the steps to create your new record:";
1058 str += htmlClearDiv();
1059 str += htmlOpen(
"select",
1061 "id" : stepString +
"recordTypes",
1062 "style" :
"margin-bottom: 16px;"
1065 for(var i=0;i<_validRecordTypes.length;++i)
1067 str += htmlOpen(
"option",
1069 },_validRecordTypes[i] ,
true );
1075 Debug.log(
"Should never happen - bad stepIndex (" + stepIndex +
1076 ")!",Debug.HIGH_PRIORITY);
1084 if(stepIndex && showPrevButton)
1085 ctrlStr += htmlOpen(
"input",
1087 "class":
"prevButton " + stepString +
"prevButton",
1089 "value": prevButtonText,
1090 "title":
"Return to the previous step in the " + _recordAlias +
" creation wizard."
1094 ctrlStr += htmlOpen(
"input",
1096 "class":
"nextButton " + stepString +
"nextButton",
1098 "value": nextButtonText,
1099 "title":
"Proceed to the next step in the " + _recordAlias +
" creation wizard."
1105 el = document.createElement(
"div");
1106 el.setAttribute(
"id", ConfigurationAPI._POP_UP_DIALOG_ID);
1108 ConfigurationAPI.setPopUpPosition(el,w ,h );
1110 el.innerHTML = ctrlStr + htmlClearDiv() + str + htmlClearDiv() + ctrlStr;
1111 document.body.appendChild(el);
1119 function localAddHandlers()
1121 var newParamObj = {};
1127 case _STEP_SET_RECORD_FIELDS:
1131 scopeForSetRecordFieldsContent();
1133 function scopeForSetRecordFieldsContent()
1135 var recordFields = paramObj[
"fields"];
1137 var fieldContainerEl = document.getElementById(stepString +
"fields");
1140 ConfigurationAPI.editableField_SELECTED_COLOR_ =
"transparent";
1147 for(var i=0;i<recordFields.length;++i)
1149 el = document.createElement(
"div");
1150 el.setAttribute(
"id",
"cfg_subset_field-" + i);
1151 el.setAttribute(
"style",
"white-space:nowrap;" +
1153 fieldContainerEl.appendChild(el);
1156 el.appendChild(ConfigurationAPI.createEditableFieldElement(
1157 recordFields[i],i));
1160 el = document.createElement(
"div");
1161 el.setAttribute(
"id",
"clearDiv");
1162 fieldContainerEl.appendChild(el);
1169 case _STEP_PROC_WHICH_BUFFER:
1174 document.getElementById(stepString +
"buffers").onclick = localAppSelectHandler;
1175 document.getElementById(stepString +
"buffers").onchange = localAppSelectHandler;
1176 document.getElementById(stepString +
"allBuffers").onclick = localAppSelectHandler;
1177 document.getElementById(stepString +
"allBuffers").onchange = localAppSelectHandler;
1179 function localAppSelectHandler(event) {
1180 Debug.log(
"Selected " + this.value);
1183 document.getElementById(stepString +
"bufferName").value =
1184 ConfigurationAPI.incrementName(this.value);
1188 document.getElementById(stepString +
"addToNew").onclick =
1191 var name = document.getElementById(stepString +
"bufferName").value.trim();
1192 Debug.log(
"addToNew " + name);
1195 paramObj[
"bufferName"] = name;
1197 localCreateIntermediateLevelRecord(name);
1201 document.getElementById(stepString +
"addToExisting").onclick =
1204 var name = document.getElementById(stepString +
"buffers").value.trim();
1205 Debug.log(
"addToExisting " + name);
1208 paramObj[
"bufferName"] = name;
1210 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER][
"buffers"]) _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"buffers"] = [];
1211 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"isNew" + getIntermediateTypeName()] =
false;
1214 localGetExistingIntermediateTargetGroupID(name);
1225 case _STEP_WHICH_APP:
1230 document.getElementById(stepString +
"apps").onclick = localAppSelectHandler;
1231 document.getElementById(stepString +
"apps").onchange = localAppSelectHandler;
1232 document.getElementById(stepString +
"allApps").onclick = localAppSelectHandler;
1233 document.getElementById(stepString +
"allApps").onchange = localAppSelectHandler;
1235 function localAppSelectHandler(event) {
1236 Debug.log(
"Selected " + this.value);
1239 document.getElementById(stepString +
"appName").value =
1240 ConfigurationAPI.incrementName(this.value);
1244 document.getElementById(stepString +
"addToNew").onclick =
1247 var name = document.getElementById(stepString +
"appName").value.trim();
1248 Debug.log(
"addToNew " + name);
1251 paramObj[
"appName"] = name;
1253 localCreateApp(name);
1257 document.getElementById(stepString +
"addToExisting").onclick =
1260 var name = document.getElementById(stepString +
"apps").value.trim();
1261 Debug.log(
"addToExisting " + name);
1264 paramObj[
"appName"] = name;
1266 if(!_paramObjMap[_STEP_WHICH_APP][
"apps"]) _paramObjMap[_STEP_WHICH_APP][
"apps"] = [];
1267 _paramObjMap[_STEP_WHICH_APP][
"isNewApp"] =
false;
1270 localGetExistingSupervisorTargetGroupID(name);
1281 case _STEP_SET_CONTEXT_HOST:
1285 document.getElementById(stepString +
"addresses").onclick = localAddressSelectHandler;
1286 document.getElementById(stepString +
"addresses").onchange = localAddressSelectHandler;
1288 function localAddressSelectHandler(event) {
1289 Debug.log(
"Selected " + this.value);
1290 document.getElementById(stepString +
"address").value =
1295 document.getElementById(stepString +
"ports").onclick = localPortSelectHandler;
1296 document.getElementById(stepString +
"ports").onchange = localPortSelectHandler;
1298 function localPortSelectHandler(event) {
1299 Debug.log(
"Selected " + this.value);
1300 document.getElementById(stepString +
"port").value =
1308 case _STEP_WHICH_CONTEXT:
1312 document.getElementById(stepString +
"contexts").onclick = localContextSelectHandler;
1313 document.getElementById(stepString +
"contexts").onchange = localContextSelectHandler;
1315 function localContextSelectHandler(event) {
1316 Debug.log(
"Selected " + this.value);
1319 document.getElementById(stepString +
"contextName").value =
1320 ConfigurationAPI.incrementName(this.value);
1324 document.getElementById(stepString +
"addToNew").onclick =
1327 var name = document.getElementById(stepString +
"contextName").value.trim();
1328 Debug.log(
"addToNew " + name);
1331 paramObj[
"contextName"] = name;
1336 ConfigurationAPI.addSubsetRecords(
1340 function(modifiedTables,err)
1342 Debug.log(
"modifiedTables length " + modifiedTables.length);
1343 if(!modifiedTables.length)
1346 Debug.log(
"There was an error while creating the XDAQ Context '" +
1348 Debug.HIGH_PRIORITY);
1351 _modifiedTables = modifiedTables;
1354 Debug.log(
"New context '" + name +
"' was successfully created!");
1356 newParamObj[
"isNewContext"] =
true;
1359 if(paramObj[
"contexts"].indexOf(name) == -1)
1360 paramObj[
"contexts"].push(name);
1362 localGetAllHostInfo();
1371 document.getElementById(stepString +
"addToExisting").onclick =
1374 var name = document.getElementById(stepString +
"contexts").value.trim();
1375 Debug.log(
"addToExisting " + name);
1378 paramObj[
"contextName"] = name;
1380 newParamObj[
"isNewContext"] =
false;
1383 ConfigurationAPI.getFieldValuesForRecords(
1386 [
"Address",
"Port",
"ApplicationGroupID"],
1389 console.log(objArr);
1390 newParamObj[
"address"] = objArr[0].fieldValue;
1391 newParamObj[
"port"] = objArr[1].fieldValue;
1392 newParamObj[
"appGroupId"] = objArr[2].fieldValue;
1394 localGetAllHostInfo();
1404 function localGetAllHostInfo()
1406 Debug.log(
"localGetExistingHostInfo()");
1408 ConfigurationAPI.getUniqueFieldValuesForRecords(
1414 console.log(objArr);
1415 newParamObj[
"hostAddresses"] = objArr[0].fieldUniqueValueArray;
1416 newParamObj[
"hostPorts"] = objArr[1].fieldUniqueValueArray;
1418 showPrompt(nextStepIndex,newParamObj);
1426 case _STEP_GET_RECORD_NAME:
1431 document.getElementById(stepString +
"records").onclick = localRecordsSelectHandler;
1432 document.getElementById(stepString +
"records").onchange = localRecordsSelectHandler;
1435 function localRecordsSelectHandler(event) {
1436 Debug.log(
"Selected " + this.value);
1439 document.getElementById(stepString +
"recordName").value =
1440 ConfigurationAPI.incrementName(this.value);
1444 document.getElementById(stepString +
"editConfig").onclick =
1447 newParamObj[
"groupType"] =
"Configuration";
1449 paramObj[
"recordName"] = document.getElementById(stepString +
"recordName").value.trim();
1450 showPrompt(_STEP_CHANGE_GROUP,newParamObj);
1453 document.getElementById(stepString +
"editContext").onclick =
1456 newParamObj[
"groupType"] =
"Context";
1458 paramObj[
"recordName"] = document.getElementById(stepString +
"recordName").value.trim();
1459 showPrompt(_STEP_CHANGE_GROUP,newParamObj);
1462 document.getElementById(stepString +
"deleteRecordIcon").onclick =
1465 var selectedIndex = document.getElementById(stepString +
"records").selectedIndex;
1466 var recordName = _subsetUIDs[selectedIndex];
1467 Debug.log(
"deleteRecord " + selectedIndex +
" : " + recordName);
1468 Debug.log(
"getRecordConfiguration " + getRecordConfiguration());
1469 Debug.log(
"getAppConfiguration " + getAppConfiguration());
1472 Debug.log(
"getIntermediateTable " + getIntermediateTable());
1473 Debug.log(
"getIntermediateTypeName " + getIntermediateTypeName());
1475 Debug.log(
"No intermediate table: " + e);
1478 var generationsBack = 0;
1479 var lastGenerationsBack, parentCheckParentIndex;
1483 _modifiedTables = undefined;
1485 localPromptAndHandleRecordDeletion(_recordAlias,recordName);
1487 function localPromptAndHandleRecordDeletion(recordType,recordName)
1500 if(generationsBack == 0)
1501 prompt =
"Are you sure you want to remove the " + recordType +
" named '" +
1502 recordName +
"' from the active configuration?";
1504 prompt =
"Alert! A parent node, " + generationsBack +
" level(s) up in the " +
1505 "configuration tree from the " +
1506 "origial " + _recordAlias +
" '" + _subsetUIDs[selectedIndex] +
",' was found to " +
1507 "have no children.<br><br>Do you want to remove the childless " + recordType +
" named '" +
1508 recordName +
"' from the active configuration?";
1510 DesktopContent.popUpVerification(
1515 Debug.log(
"do deleteRecord " + recordType +
" : " + recordName);
1520 ConfigurationAPI.deleteSubsetRecords(
1521 getParentTable(generationsBack),
1524 function(modifiedTables,err)
1526 Debug.log(
"modifiedTables length " + modifiedTables.length);
1527 if(!modifiedTables.length)
1530 Debug.log(
"There was an error while creating the XDAQ Context '" +
1531 recordName +
".' " + err,
1532 Debug.HIGH_PRIORITY);
1535 _modifiedTables = modifiedTables;
1536 console.log(_modifiedTables);
1539 Debug.log(
"The " + recordType +
" named '" +
1540 recordName +
"' was successfully removed!",
1541 Debug.INFO_PRIORITY);
1543 parentCheckParentIndex = 0;
1549 ConfigurationAPI.saveModifiedTables(_modifiedTables,
1550 function(savedTables, savedGroups, savedAliases)
1552 if(!savedTables.length)
1554 Debug.log(
"There was an error while saving the changes.",
1555 Debug.HIGH_PRIORITY);
1560 _recordAlias +
" named '" + recordName +
"' was successfully removed!",
1561 Debug.INFO_PRIORITY);
1563 _modifiedTables = undefined;
1565 _aRecordWasModified =
true;
1567 if(generationsBack == 0)
1569 generationsBack = 1;
1570 localCheckParentChildren();
1573 localCheckParentChildren();
1598 Debug.log(
"User opted not to delete node.");
1602 localCheckParentChildren();
1608 function localCheckParentChildren()
1610 if(lastGenerationsBack != generationsBack)
1613 Debug.log(
"Starting new generation of checking...");
1614 parentCheckParentIndex = 0;
1615 lastGenerationsBack = generationsBack;
1617 Debug.log(
"localCheckParentChildren generationsBack=" + generationsBack +
1618 " parentCheckParentIndex=" + parentCheckParentIndex);
1626 Debug.log(
"getAppConfiguration " + getAppConfiguration());
1628 var modifiedTablesListStr =
"";
1629 for(var i=0;_modifiedTables && i<_modifiedTables.length;++i)
1631 if(i) modifiedTablesListStr +=
",";
1632 modifiedTablesListStr += _modifiedTables[i].tableName +
"," +
1633 _modifiedTables[i].tableVersion;
1637 DesktopContent.XMLHttpRequest(
"Request?RequestType=getTreeView" +
1639 "&tableGroupKey=-1" +
1640 "&hideStatusFalse=0" +
1642 "startPath=/" + getParentTable(generationsBack) +
1643 "&filterList=" + getParentFilter(generationsBack) +
1644 "&modifiedTables=" + modifiedTablesListStr,
1648 var tree = DesktopContent.getXMLNode(req,
"tree");
1657 for(i=parentCheckParentIndex;i<tree.children.length;++i)
1659 ++parentCheckParentIndex;
1661 parentName = tree.children[i].getAttribute(
"value");
1662 Debug.log(
"Checking parent record " +
1663 parentCheckParentIndex +
":" +
1667 for(j=0;j<tree.children[i].children.length;++j)
1668 if(tree.children[i].children[j].getAttribute(
"value") ==
1669 getParentLinkField(generationsBack))
1672 parentChildren = DesktopContent.getXMLChildren(
1673 tree.children[i].children[j],
1675 Debug.log(
"Num of children " + parentChildren.length);
1677 if(parentChildren.length == 0)
1679 localPromptAndHandleRecordDeletion(
1680 getParentType(generationsBack),
1688 Debug.log("No childless parent nodes found");
1692 localCheckParentChildren();
1698 Debug.log(
"Giving up on childless parent node check. " +
1699 "Ignoring errors: " + e);
1714 case _STEP_CHANGE_GROUP:
1719 document.getElementById(stepString +
"activateAlias").onclick =
1723 var alias = document.getElementById(stepString +
"aliases").value;
1724 Debug.log(
"activateAlias " + alias);
1729 _systemGroups.aliases[paramObj[
"groupType"]].length;++i)
1730 if(_systemGroups.aliases[paramObj[
"groupType"]][i].alias ==
1733 aliasObj = _systemGroups.aliases[paramObj[
"groupType"]][i];
1737 Debug.log(
"activateAlias group " + aliasObj.name +
1738 "-" + aliasObj.key);
1740 ConfigurationAPI.activateGroup(aliasObj.name, aliasObj.key,
1745 Debug.log(
"The System Alias '" + alias +
1746 "' (" + aliasObj.name +
" (" +
1747 aliasObj.key +
")) was successfully activated!", Debug.INFO_PRIORITY);
1754 document.getElementById(stepString +
"groupNames").onchange =
1758 Debug.log(
"Filling dropdown with keys for " + this.value);
1760 for(var i=0;i<_systemGroups.groups[paramObj[
"groupType"]]
1761 [this.value].keys.length;++i)
1763 str += htmlOpen(
"option",
1766 _systemGroups.groups[paramObj[
"groupType"]]
1767 [this.value].keys[i] ,
true );
1769 document.getElementById(stepString +
"groupKeys").innerHTML =
1774 document.getElementById(stepString +
"activateGroup").onclick =
1778 var name = document.getElementById(stepString +
"groupNames").value;
1779 var key = document.getElementById(stepString +
"groupKeys").value;
1781 Debug.log(
"activateGroup " + name +
1784 ConfigurationAPI.activateGroup(name, key,
1789 Debug.log(
"The Group '" + name +
" (" +
1790 key +
") was successfully activated!", Debug.INFO_PRIORITY);
1811 function localCreateIntermediateLevelRecord(name)
1813 Debug.log(
"localCreateIntermediateLevelRecord " + name);
1817 ConfigurationAPI.addSubsetRecords(
1818 getIntermediateTable(),
1821 function(modifiedTables,err)
1823 Debug.log(
"modifiedTables length " + modifiedTables.length);
1824 if(!modifiedTables.length)
1827 Debug.log(
"There was an error while creating the XDAQ Application '" +
1829 Debug.HIGH_PRIORITY);
1832 _modifiedTables = modifiedTables;
1835 Debug.log(
"New intermediate record '" + name +
"' was successfully created!");
1837 newParamObj[
"isNew" + getIntermediateTypeName()] =
true;
1839 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
1841 if(_intermediateLevel == 0)
1845 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]) _paramObjMap[_STEP_PROC_WHICH_BUFFER] = {};
1846 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER][
"allBuffers"]) _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"allBuffers"] = [];
1847 if(_paramObjMap[_STEP_PROC_WHICH_BUFFER][
"allBuffers"].indexOf(name) == -1)
1848 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"allBuffers"].push(name);
1856 localSetupIntermediateLevelRecord(name);
1864 function localSetupIntermediateLevelRecord(name)
1867 var recordGroupId =
"";
1868 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
1870 if(_intermediateLevel == 0)
1872 recordGroupId = _paramObjMap[_STEP_WHICH_APP][
"appChildGroupName"];
1881 Debug.log(
"localSetupIntermediateLevelRecord " + name +
1882 " into groupId=" + recordGroupId);
1884 var fieldArr,valueArr;
1886 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
1888 if(_intermediateLevel == 0)
1892 "DataManagerGroupID",
1893 "LinkToDataProcessorTable",
1894 "LinkToDataBufferGroupID",
1895 "CommentDescription"
1901 getRecordConfiguration(),
1902 name+
"ProcessorGroup",
1903 _DEFAULT_WIZ_COMMENT
1911 ConfigurationAPI.setFieldValuesForRecords(
1912 getIntermediateTable(),
1916 function(modifiedTables)
1918 Debug.log(
"modifiedTables length " + modifiedTables.length);
1920 if(!modifiedTables.length)
1922 Debug.log(
"There was an error while writing the values for the App.",
1923 Debug.HIGH_PRIORITY);
1926 _modifiedTables = modifiedTables;
1931 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]) _paramObjMap[_STEP_PROC_WHICH_BUFFER] = {};
1932 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"recordGroupName"] = name+
"ProcessorGroup";
1934 localCreateRecord(getRecordConfiguration());
1941 function localCreateApp(name)
1943 Debug.log(
"localCreateApp " + name);
1946 ConfigurationAPI.addSubsetRecords(
1950 function(modifiedTables,err)
1952 Debug.log(
"modifiedTables length " + modifiedTables.length);
1953 if(!modifiedTables.length)
1956 Debug.log(
"There was an error while creating the XDAQ Application '" +
1958 Debug.HIGH_PRIORITY);
1961 _modifiedTables = modifiedTables;
1964 Debug.log(
"New app '" + name +
"' was successfully created!");
1968 if(!_paramObjMap[_STEP_WHICH_APP]) _paramObjMap[_STEP_WHICH_APP] = {};
1969 if(!_paramObjMap[_STEP_WHICH_APP][
"apps"]) _paramObjMap[_STEP_WHICH_APP][
"apps"] = [];
1970 if(_paramObjMap[_STEP_WHICH_APP][
"apps"].indexOf(name) == -1)
1971 _paramObjMap[_STEP_WHICH_APP][
"apps"].push(name);
1972 _paramObjMap[_STEP_WHICH_APP][
"isNewApp"] =
true;
1974 localSetupApp(name);
1982 function localSetupApp(name)
1984 var context = _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"];
1985 var appGroupId = _paramObjMap[_STEP_SET_CONTEXT_HOST][
"appGroupId"];
1987 Debug.log(
"localSetupApp " + name +
" in context=" + context +
" groupId=" + appGroupId);
1989 var fieldArr,valueArr;
1995 "ApplicationGroupID",
1996 "LinkToSupervisorTable",
1997 "LinkToSupervisorUID",
2001 "CommentDescription"
2007 getAppConfiguration(),
2012 _DEFAULT_WIZ_COMMENT
2021 ConfigurationAPI.setFieldValuesForRecords(
2026 function(modifiedTables)
2028 Debug.log(
"modifiedTables length " + modifiedTables.length);
2030 if(!modifiedTables.length)
2032 Debug.log(
"There was an error while writing the values for the App.",
2033 Debug.HIGH_PRIORITY);
2036 _modifiedTables = modifiedTables;
2039 localCreateAppConfig(name+
"Config");
2046 function localCreateAppConfig(name)
2048 Debug.log(
"localCreateAppConfig " + name);
2051 ConfigurationAPI.addSubsetRecords(
2052 getAppConfiguration(),
2055 function(modifiedTables,err)
2057 Debug.log(
"modifiedTables length " + modifiedTables.length);
2058 if(!modifiedTables.length)
2061 Debug.log(
"There was an error while creating the XDAQ Application '" +
2063 Debug.HIGH_PRIORITY);
2066 _modifiedTables = modifiedTables;
2069 Debug.log(
"New app config '" + name +
"' was successfully created!");
2072 localSetupAppConfig(name);
2080 function localSetupAppConfig(name)
2082 var context = _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"];
2083 Debug.log(
"localSetupAppConfig " + name +
" in context=" + context);
2085 var fieldArr,valueArr;
2088 _intermediateLevel = 0;
2090 if(_recordAlias == _RECORD_TYPE_FE)
2093 "LinkToFEInterfaceTable",
2094 "LinkToFEInterfaceGroupID",
2095 "CommentDescription"
2097 groupSuffix =
"FEGroup";
2100 getRecordConfiguration(),
2102 _DEFAULT_WIZ_COMMENT
2105 else if(_recordAlias == _RECORD_TYPE_PROCESSOR
2110 "LinkToDataBufferTable",
2111 "LinkToDataManagerGroupID",
2112 "CommentDescription"
2115 groupSuffix =
"DMGroup";
2118 getIntermediateTable(),
2120 _DEFAULT_WIZ_COMMENT
2125 ConfigurationAPI.setFieldValuesForRecords(
2126 getAppConfiguration(),
2130 function(modifiedTables)
2132 Debug.log(
"modifiedTables length " + modifiedTables.length);
2134 if(!modifiedTables.length)
2136 Debug.log(
"There was an error while writing the values for the App.",
2137 Debug.HIGH_PRIORITY);
2140 _modifiedTables = modifiedTables;
2144 if(!_paramObjMap[_STEP_WHICH_APP]) _paramObjMap[_STEP_WHICH_APP] = {};
2147 _paramObjMap[_STEP_WHICH_APP][
"appChildGroupName"] = name+groupSuffix;
2149 if(_recordAlias == _RECORD_TYPE_FE)
2151 Debug.log(
"Creating record...");
2153 localCreateRecord(getRecordConfiguration());
2155 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2157 Debug.log(
"Setting up extra buffer level...");
2158 localHandleIntermediateLevel();
2169 function localHandleIntermediateLevel()
2171 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2173 switch(_intermediateLevel)
2178 var bufferGroupId = _paramObjMap[_STEP_WHICH_APP][
"appChildGroupName"];
2179 var appName = _paramObjMap[_STEP_WHICH_APP][
"appName"];
2182 Debug.log(
"localCreateIntermediateLevel-" + _intermediateLevel +
2183 " DataManager=" + appName);
2191 ConfigurationAPI.getSubsetRecords(
2192 getIntermediateTable(),
2194 function(allRecords)
2196 Debug.log(
"all buffers found = " + allRecords.length);
2197 console.log(allRecords);
2200 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]) _paramObjMap[_STEP_PROC_WHICH_BUFFER] = {};
2201 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"allBuffers"] = allRecords;
2204 ConfigurationAPI.getSubsetRecords(
2205 getIntermediateTable(),
2206 "DataManagerGroupID="+
2207 encodeURIComponent(bufferGroupId) ,
2210 Debug.log(
"buffers of DataManager '" + appName +
2211 "' found = " + records.length);
2212 console.log(records);
2223 if(records.length == 0)
2228 var bufferName = ConfigurationAPI.createNewRecordName(
"Buffer",allRecords);
2231 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"bufferName"] = bufferName;
2233 localCreateIntermediateLevelRecord(appName);
2237 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"buffers"] = records;
2238 showPrompt(_STEP_PROC_WHICH_BUFFER);
2250 default:
throw(
"?");
2260 function localGetExistingIntermediateTargetGroupID(intermediateName)
2263 Debug.log(
"localGetExistingSupervisorTargetGroupID " + intermediateName +
2264 " of type " + getIntermediateTypeName());
2266 ConfigurationAPI.getTree(
2267 getIntermediateTable() +
"/" + intermediateName,
2280 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2283 if(tree.children[1].children[0].nodeName !=
2285 throw(
"Invalid GroupID location in tree.");
2286 if(tree.children[1].children[1].nodeName !=
2288 throw(
"Invalid Link Table location in tree.");
2291 tree.children[1].children[0].getAttribute(
"value");
2293 tree.children[1].children[1].getAttribute(
"value");
2299 Debug.log(
"Error locating group in configuration for the new record. " + e,
2300 Debug.HIGH_PRIORITY);
2303 Debug.log(
"Group Link found as " + table +
":" + groupId);
2309 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2311 if(!_paramObjMap[_STEP_PROC_WHICH_BUFFER]) _paramObjMap[_STEP_PROC_WHICH_BUFFER] = {};
2312 _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"recordGroupName"] = groupId;
2313 localCreateRecord(table);
2314 Debug.log(
"Setting up extra buffer level...");
2326 function localGetExistingSupervisorTargetGroupID(supervisorName)
2328 Debug.log(
"localGetExistingSupervisorTargetGroupID " + supervisorName);
2330 ConfigurationAPI.getTree(
2331 _XDAQAPP_BASE_PATH +
"/" + supervisorName,
2344 if(tree.children[1].children[4].children[0].nodeName !=
2346 throw(
"Invalid GroupID location in tree.");
2347 if(tree.children[1].children[4].children[1].nodeName !=
2349 throw(
"Invalid Link Table location in tree.");
2352 tree.children[1].children[4].children[0].getAttribute(
"value");
2354 tree.children[1].children[4].children[1].getAttribute(
"value");
2359 Debug.log(
"Error locating group in configuration for the new record. " + e,
2360 Debug.HIGH_PRIORITY);
2363 Debug.log(
"Group Link found as " + table +
":" + groupId);
2367 if(!_paramObjMap[_STEP_WHICH_APP]) _paramObjMap[_STEP_WHICH_APP] = {};
2368 _paramObjMap[_STEP_WHICH_APP][
"appChildGroupName"] = groupId;
2370 if(_recordAlias == _RECORD_TYPE_FE)
2372 Debug.log(
"Creating record...");
2373 localCreateRecord(table);
2375 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2377 Debug.log(
"Setting up extra buffer level...");
2378 _intermediateLevel = 0;
2379 localHandleIntermediateLevel();
2390 function localCreateRecord(table)
2392 Debug.log(
"localCreateRecord " + recordName +
" in table=" + table);
2396 ConfigurationAPI.addSubsetRecords(
2400 function(modifiedTables,err)
2402 Debug.log(
"modifiedTables length " + modifiedTables.length);
2403 if(!modifiedTables.length || err)
2405 var reallyAnError =
true;
2406 if(_furthestStep >= _STEP_SET_RECORD_FIELDS)
2409 if(err.indexOf(
"Entries in UID are not unique") >= 0)
2411 Debug.log(
"Ignoring UID not unique error since likely already created..." +
2413 reallyAnError =
false;
2420 Debug.log(
"There was an error while creating the " + _recordAlias +
2422 recordName +
".' " + err,
2423 Debug.HIGH_PRIORITY);
2428 _modifiedTables = modifiedTables;
2430 console.log(
"_modifiedTables",_modifiedTables);
2433 Debug.log(
"New " + _recordAlias +
" record named '" + recordName +
"' was successfully created!");
2436 localGetHelperValuesForRecord();
2445 function localGetHelperValuesForRecord()
2447 Debug.log(
"localGetHelperValuesForRecord " + recordName);
2449 ConfigurationAPI.getFieldsOfRecords(
2450 getRecordConfiguration(),
2452 "!*Comment*,!*SlowControls*,!Status,!" + getRecordGroupIDField(),
2454 function(recordFields)
2456 newParamObj[
"fields"] = recordFields;
2457 Debug.log(
"recordFields found = " + recordFields.length);
2458 console.log(recordFields);
2461 showPrompt(_STEP_SET_RECORD_FIELDS,newParamObj);
2479 document.getElementsByClassName(stepString +
"nextButton")[0].onclick =
2480 localNextButtonHandler;
2481 document.getElementsByClassName(stepString +
"nextButton")[1].onclick =
2482 localNextButtonHandler;
2484 function localNextButtonHandler()
2490 case _STEP_SET_RECORD_FIELDS:
2493 localScopeSetRecordFieldsDoIt();
2496 function localScopeSetRecordFieldsDoIt()
2498 Debug.log(
"localScopeSetRecordFieldsDoIt");
2500 var recordFields = paramObj[
"fields"];
2504 if(_recordAlias == _RECORD_TYPE_FE)
2505 groupName = _paramObjMap[_STEP_WHICH_APP][
"appChildGroupName"];
2506 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2507 groupName = _paramObjMap[_STEP_PROC_WHICH_BUFFER][
"recordGroupName"];
2516 for(var i=0;i<recordFields.length;++i)
2518 fieldArr.push(recordFields[i].fieldRelativePath +
2519 recordFields[i].fieldColumnName);
2520 valueArr.push(ConfigurationAPI.getEditableFieldValue(
2527 fieldArr.push(getRecordGroupIDField());
2528 valueArr.push(groupName);
2529 fieldArr.push(
"CommentDescription");
2530 valueArr.push(_DEFAULT_WIZ_COMMENT);
2531 fieldArr.push(
"Status");
2534 ConfigurationAPI.setFieldValuesForRecords(
2535 getRecordConfiguration(),
2539 function(modifiedTables)
2541 Debug.log(
"modifiedTables length " + modifiedTables.length);
2543 if(!modifiedTables.length)
2545 Debug.log(
"There was an error while writing the values.",
2546 Debug.HIGH_PRIORITY);
2550 _modifiedTables = modifiedTables;
2553 ConfigurationAPI.saveModifiedTables(_modifiedTables,
2554 function(savedTables, savedGroups, savedAliases)
2556 if(!savedTables.length)
2558 Debug.log(
"There was an error while saving the values.",
2559 Debug.HIGH_PRIORITY);
2563 Debug.log(
"The new " +
2564 _recordAlias +
" named '" + recordName +
"' was successfully created!",
2565 Debug.INFO_PRIORITY);
2567 _modifiedTables = undefined;
2569 _aRecordWasModified =
true;
2584 case _STEP_SET_CONTEXT_HOST:
2587 localHandleSetupContext();
2590 function localHandleSetupContext()
2592 Debug.log(
"localHandleSetupContext");
2594 var context = _paramObjMap[_STEP_WHICH_CONTEXT][
"contextName"];
2595 var address = document.getElementById(stepString +
"address").value.trim();
2596 var port = document.getElementById(stepString +
"port").value.trim();
2599 paramObj[
"address"] = address;
2602 paramObj[
"port"] = port;
2604 var appGroupId = context+
"Apps";
2605 if(!paramObj[
"isNewContext"])
2606 appGroupId = paramObj[
"appGroupId"];
2608 paramObj[
"appGroupId"] = appGroupId;
2610 var fieldArr = [
"Status",
2611 "LinkToApplicationTable",
2612 "ApplicationGroupID",
2615 "CommentDescription"
2618 var valueArr = [
"1",
2623 _DEFAULT_WIZ_COMMENT
2626 ConfigurationAPI.setFieldValuesForRecords(
2631 function(modifiedTables)
2633 Debug.log(
"modifiedTables length " + modifiedTables.length);
2635 if(!modifiedTables.length)
2637 Debug.log(
"There was an error while writing the values.",
2638 Debug.HIGH_PRIORITY);
2641 _modifiedTables = modifiedTables;
2658 function localGetAppInfo()
2660 var appGroupId = paramObj[
"appGroupId"];
2661 Debug.log(
"localGetAppInfo for context app group " + appGroupId);
2664 ConfigurationAPI.getSubsetRecords(
2669 Debug.log(
"all apps found = " + allApps.length);
2671 console.log(allApps);
2673 if(!_paramObjMap[_STEP_WHICH_APP]) _paramObjMap[_STEP_WHICH_APP] = {};
2676 _paramObjMap[_STEP_WHICH_APP][
"allApps"] = allApps;
2679 ConfigurationAPI.getSubsetRecords(
2682 encodeURIComponent(getAppClass()) +
2683 ";ApplicationGroupID="+
2685 encodeURIComponent(appGroupId) ,
2688 Debug.log(
"apps of appClass found = " + records.length);
2689 console.log(records);
2691 if(records.length == 0)
2696 var appName = ConfigurationAPI.createNewRecordName(
2698 _paramObjMap[_STEP_GET_RECORD_NAME].recordName,
2702 _paramObjMap[_STEP_WHICH_APP][
"appName"] = appName;
2704 localCreateApp(appName);
2708 _paramObjMap[_STEP_WHICH_APP][
"apps"] = records;
2709 showPrompt(_STEP_WHICH_APP);
2724 case _STEP_GET_RECORD_NAME:
2727 recordName = document.getElementById(stepString +
"recordName").value.trim();
2728 paramObj[
"recordName"] = recordName;
2730 if(recordName.length < 1)
2732 Debug.log(
"Invalid " + _recordAlias +
" name ' " +
2733 recordName +
"' (too short). Please enter a valid name.",
2734 Debug.HIGH_PRIORITY);
2738 for(var i=0;i<_subsetUIDs.length;++i)
2739 if(_subsetUIDs[i] == recordName)
2741 Debug.log(
"Invalid " + _recordAlias +
" name ' " +
2742 recordName +
"' (name already in use in the active configuration). Please enter a valid name.",
2743 Debug.HIGH_PRIORITY);
2748 ConfigurationAPI.getSubsetRecords(
2753 newParamObj[
"contexts"] = records;
2754 Debug.log(
"contexts found = " + records.length);
2755 console.log(records);
2757 showPrompt(nextStepIndex,newParamObj);
2763 case _STEP_WHICH_RECORD_TYPE:
2766 if(scopeWhichRecordTypeNext())
2769 function scopeWhichRecordTypeNext()
2771 var newRecordAlias = document.getElementById(stepString +
"recordTypes").value.trim();
2773 var needToInit = (_recordAlias != newRecordAlias);
2775 _recordAlias = newRecordAlias;
2776 Debug.log(
"_recordAlias chosen as " + _recordAlias);
2778 if(needToInit) initRecordWizard();
2785 showPrompt(nextStepIndex,newParamObj);
2788 catch(e){ Debug.log(
"Caught ERROR: " + e.stack);}
2792 document.getElementsByClassName(stepString +
"prevButton")[0].onclick =
2793 localPrevButtonHandler;
2794 document.getElementsByClassName(stepString +
"prevButton")[1].onclick =
2795 localPrevButtonHandler;
2797 function localPrevButtonHandler()
2802 case _STEP_WHICH_RECORD_TYPE:
2807 _modifiedTables = undefined;
2813 ConfigurationAPI.removeAllPopUps();
2815 if(_doneHandler) _doneHandler(_aRecordWasModified);
2820 showPrompt(prevStepIndex);
2823 catch(e){ Debug.log(
"Caught ERROR: " + e.stack);}
2835 if(_recordAlias == _RECORD_TYPE_FE)
2836 retVal =
"FESupervisor";
2837 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2838 retVal =
"DataManagerSupervisor";
2847 function getAppClass()
2849 return "ots::" + getApp();
2854 function getAppModule()
2857 if(_recordAlias == _RECORD_TYPE_FE)
2858 otsModule =
"${OTSDAQ_LIB}/libCoreSupervisors.so";
2859 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2860 otsModule =
"${OTSDAQ_LIB}/libCoreSupervisors.so";
2869 function getAppConfiguration()
2872 if(_recordAlias == _RECORD_TYPE_FE)
2873 retVal =
"FESupervisorTable";
2874 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2875 retVal =
"DataManagerSupervisorTable";
2884 function getRecordConfiguration()
2887 if(_recordAlias == _RECORD_TYPE_FE)
2888 retVal =
"FEInterfaceTable";
2889 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2890 retVal =
"DataBufferTable";
2899 function getRecordGroupIDField()
2902 if(_recordAlias == _RECORD_TYPE_FE)
2903 retVal =
"FEInterfaceGroupID";
2904 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2905 retVal =
"DataBufferGroupID";
2915 function getRecordFilter()
2918 if(_recordAlias == _RECORD_TYPE_FE)
2920 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2924 throw(
"Invalid getRecordFilter");
2933 function getIntermediateTable()
2936 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2938 if(_intermediateLevel == 0)
2939 retVal =
"DataManagerTable";
2943 throw(
"Invalid getIntermediateTable");
2951 function getIntermediateTypeName()
2954 if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2956 if(_intermediateLevel == 0)
2961 throw(
"Invalid getIntermediateTypeName");
2969 function getParentTable(generationsBack)
2971 if(generationsBack == 0)
return getRecordConfiguration();
2975 if(_recordAlias == _RECORD_TYPE_FE)
2977 if(generationsBack == 1)
2978 retVal =
"FESupervisorTable";
2979 else if(generationsBack == 2)
2980 retVal = _XDAQAPP_BASE_PATH;
2982 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
2984 if(generationsBack == 1)
2985 retVal =
"DataManagerTable";
2986 else if(generationsBack == 2)
2987 retVal =
"DataManagerSupervisorTable";
2988 else if(generationsBack == 3)
2989 retVal = _XDAQAPP_BASE_PATH;
2993 throw(
"Invalid getParentTable");
3001 function getParentType(generationsBack)
3003 if(generationsBack == 0)
return _recordAlias;
3007 if(_recordAlias == _RECORD_TYPE_FE)
3009 if(generationsBack == 1)
3010 retVal =
"FESupervisorTable";
3011 else if(generationsBack == 2)
3012 retVal =
"FESupervisor";
3014 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
3016 if(generationsBack == 1)
3018 else if(generationsBack == 2)
3019 retVal =
"DataManagerSupervisorTable";
3020 else if(generationsBack == 3)
3021 retVal =
"DataManagerSupervisor";
3025 throw(
"Invalid getParentType");
3033 function getParentLinkField(generationsBack)
3037 if(_recordAlias == _RECORD_TYPE_FE)
3039 if(generationsBack == 1)
3040 retVal =
"LinkToFEInterfaceTable";
3041 else if(generationsBack == 2)
3042 retVal =
"LinkToSupervisorTable";
3044 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
3046 if(generationsBack == 1)
3047 retVal =
"LinkToDataProcessorTable";
3048 else if(generationsBack == 2)
3049 retVal =
"LinkToDataBufferTable";
3050 else if(generationsBack == 3)
3051 retVal =
"LinkToSupervisorTable";
3055 throw(
"Invalid getParentLinkField");
3063 function getParentFilter(generationsBack)
3067 if(_recordAlias == _RECORD_TYPE_FE)
3069 if(generationsBack == 1)
3071 else if(generationsBack == 2)
3072 retVal =
"Class=ots::FESupervisor";
3074 else if(_recordAlias == _RECORD_TYPE_PROCESSOR)
3076 if(generationsBack == 1)
3078 else if(generationsBack == 2)
3080 else if(generationsBack == 3)
3081 retVal =
"Class=ots::DataManagerSupervisor,ots::ARTDAQDataManagerSupervisor," +
3082 "ots::VisualSupervisor";
3086 throw(
"Invalid getParentFilter");
3094 function htmlOpen(tag,attObj,innerHTML,doCloseTag)
3097 var attKeys = Object.keys(attObj);
3098 str +=
"<" + tag +
" ";
3099 for(var i=0;i<attKeys.length;++i)
3100 str +=
" " + attKeys[i] +
"='" +
3101 attObj[attKeys[i]] +
"' ";
3103 if(innerHTML) str += innerHTML;
3105 str +=
"</" + tag +
">";
3111 function htmlClearDiv()
3113 return "<div id='clearDiv'></div>";