admin.js 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: cogadmin
  4. //
  5. // (C) Copyright IBM Corp. 2005, 2015
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. //
  9. //
  10. // Copyright (C) 2008 Cognos ULC, an IBM Company. All rights reserved.
  11. // Cognos (R) is a trademark of Cognos ULC, (formerly Cognos Incorporated).
  12. //----------------------------------------------------------
  13. /*
  14. * namespace for cogadmin local javascript library.
  15. */
  16. if (!window.CognosObjectFactory) {
  17. window.CognosObjectFactory = function() {
  18. throw 'RuntimeException: CognosObjectFactory is a static class and may not be instantiated';
  19. }
  20. CognosObjectFactory.init = function(objName) {
  21. var namespace = objName.split(".");
  22. var obj=window;
  23. for (var i=0; i < namespace.length;i++) {
  24. if (!obj[namespace[i]]) {
  25. obj = obj[namespace[i]] = {};
  26. } else {
  27. obj = obj[namespace[i]];
  28. if (typeof(obj) != "object")
  29. throw new Error(objName
  30. + " already exists and is not an object");
  31. }
  32. }
  33. return obj;
  34. }
  35. }
  36. //returns either val or the result of evaluating val
  37. function evalParm(val) {
  38. var ret = window[val];
  39. return ret ? ret : val;
  40. }
  41. // table actions: expand/collapse, select row, ...
  42. function toggleGroupVisibility(imgID, rowID) {
  43. var row = document.getElementById(rowID);
  44. if (!row) {
  45. return;
  46. }
  47. var sibling = getNextSibling(row);
  48. var collapsing = true;
  49. // get all the siblings until we hit the next group TR
  50. while (sibling.id == '') {
  51. if (sibling.style.display == '') {
  52. sibling.style.display = 'none';
  53. collapsing = false;
  54. } else {
  55. sibling.style.display = '';
  56. }
  57. sibling = getNextSibling(sibling);
  58. if (!sibling) {
  59. break;
  60. }
  61. }
  62. // change the image
  63. var image = document.getElementById(imgID);
  64. if (!image) {
  65. return;
  66. }
  67. if (collapsing) {
  68. image.src = image.src.substring(0, image.src.indexOf('expand.gif'))
  69. + 'collapse.gif';
  70. } else {
  71. image.src = image.src.substring(0, image.src.indexOf('collapse.gif'))
  72. + 'expand.gif';
  73. }
  74. }
  75. //getNextSibling
  76. // We need to do this to workaround a firefox issue since firefox treats
  77. // linebreaks as nodes.
  78. function getNextSibling(startNode){
  79. endNode=startNode.nextSibling;
  80. while(endNode.nodeType!=1){
  81. endNode = endNode.nextSibling;
  82. }
  83. return endNode;
  84. }
  85. // selectTableRow
  86. // @rowPrefix: the ID prefix used to loop through all the selectable rows in the
  87. // table
  88. // @rowID: the ID for the row that will get selected
  89. // @skipColumns: the number of columns that should get skipped when selecting a
  90. // row
  91. function selectTableRow(rowPrefix, rowID, skipColumns) {
  92. var row = document.getElementById(rowID);
  93. if (!row) {
  94. return;
  95. }
  96. // get the parent of the TR
  97. var parent = row.parentNode;
  98. if (!parent) {
  99. return;
  100. }
  101. // need to clear all the other selections and select only the one row
  102. for (rowIndex=0; rowIndex < parent.childNodes.length; rowIndex++) {
  103. var row = parent.childNodes[rowIndex];
  104. // we found a selectable row
  105. if (row.nodeName == 'TR' && row.id.indexOf(rowPrefix) == 0) {
  106. var skippedCols = 0;
  107. // loop through the TD's of the TR
  108. for (colIndex=0; colIndex < row.childNodes.length; colIndex++) {
  109. var col = row.childNodes[colIndex];
  110. if (col.nodeName == 'TD') {
  111. // is this the row that should be selected?
  112. if (row.id == rowID) {
  113. if (skippedCols >= skipColumns) {
  114. col.style.background = '#DEE7EF';
  115. } else {
  116. skippedCols++;
  117. }
  118. } else {
  119. // TODO; this doesn't work in firefox
  120. // TODO: fix alternating backgrouns
  121. // if (rowIndex%2) {
  122. // col.style.background = '#f3f3f3';
  123. // }
  124. // else {
  125. col.style.background = '#ffffff';
  126. // }
  127. }
  128. }
  129. }
  130. }
  131. }
  132. }
  133. // @fragID: The ID for the fragment that will get created
  134. // @divID: The ID of the div that will get updated by the fragment
  135. // @xtsTargetURL: parameters that will get added to the URL. Should NOT start
  136. // with &
  137. function createFragment(fragID, divID, xtsTargetURL) {
  138. var frag = new fragment("/xts"+encodeURI(xtsTargetURL), fragID, divID);
  139. if (frag.parent && !document.getElementById(divID)) {
  140. var div = document.createElement('div');
  141. div.id = divID;
  142. document.getElementById(frag.parent.div).appendChild(div);
  143. }
  144. return frag;
  145. }
  146. // @id; div id for the modal dialog content
  147. function showModalDialog(style, id, title, height, width,fragment) {
  148. if (id) {
  149. var div = document.getElementById(id);
  150. if (div) {
  151. div.style.display="";
  152. if (!width) {
  153. width=xWidth(div);
  154. }
  155. if (!height) {
  156. height=xHeight(div);
  157. }
  158. var left = ((document.body.clientWidth - width) / 2);
  159. if (left < 0) {
  160. left = document.body.scrollLeft;
  161. }
  162. var top = ((document.body.clientHeight - height) / 2);
  163. if (top < 0) {
  164. top = document.body.scrollTop;
  165. }
  166. var uiDialog = new ui_dialog(id, title, style, left, top, width,
  167. height);
  168. if (fragment) {
  169. uiDialog.fragment = fragment;
  170. }
  171. uiDialog.setContent(div.innerHTML);
  172. div.parentNode.removeChild(div);
  173. uiDialog.show();
  174. return uiDialog;
  175. }
  176. }
  177. }
  178. // @id; div id for the modal dialog
  179. // @iframeId: iframe id
  180. function showModalDialogWithIFrame(id, height, width) {
  181. showModalDialogWithIFrame.triggerElement = document.activeElement;
  182. var div = $(id);
  183. if (div) {
  184. div.style.display = "";
  185. var locker = ui_locker.get();
  186. locker.show();
  187. if (height) {
  188. div.style.height = height + 'px';
  189. }
  190. if (width) {
  191. div.style.width = width + 'px';
  192. }
  193. var left = ((document.body.clientWidth - div.clientWidth) / 2)
  194. + document.body.scrollLeft - 170;
  195. if (left < 0) {
  196. left = document.body.scrollLeft;
  197. }
  198. div.style.left = left + 'px';
  199. var top = ((document.body.clientHeight - div.clientHeight) / 2)
  200. + document.body.scrollTop - 45;
  201. if (top < 0) {
  202. top = document.body.scrollTop;
  203. }
  204. div.style.top = top + 'px';
  205. div.style.visibility = 'visible';
  206. ui_setFocus(div);
  207. }
  208. }
  209. function hideModalDialog(id) {
  210. div = document.getElementById(id);
  211. if (div) {
  212. div.style.display = 'none';
  213. }
  214. var locker = ui_locker.get();
  215. while (locker.count > 0){
  216. locker.hide();
  217. locker = ui_locker.get();
  218. }
  219. setTimeout(function(){var triggerEle=showModalDialogWithIFrame.triggerElement;if(triggerEle){triggerEle.focus()}},500);
  220. }
  221. // @event - the event that has taken place (mouseclick, mouseover, ...)
  222. function cancelBubble(event) {
  223. event.cancelBubble = true;
  224. if (event.stopPropagation) {
  225. event.stopPropagation();
  226. }
  227. }
  228. //highlight row
  229. function toggleHighlight(fragmentName, object, alternate){
  230. cleanWhitespace(fragmentName + "tbodyElement");
  231. var group = document.getElementById(fragmentName + "tbodyElement");
  232. if (group.hasChildNodes()) {
  233. var children = group.childNodes;
  234. for (var i = 0; children.length > i; i++) {
  235. if (children[i].id != fragmentName + "footer") {
  236. if (alternate == true) {
  237. if (i%2 == 0) {
  238. children[i].className = "cogstyle-table-row-alternate";
  239. } else {
  240. children[i].className = "cogstyle-table-row-default";
  241. }
  242. } else {
  243. children[i].className = "cogstyle-table-row-default";
  244. }
  245. }
  246. }
  247. object.className = "cogstyle-table-row-selected";
  248. }
  249. }
  250. function cleanWhitespace (element) {
  251. var element = document.getElementById(element);
  252. for (var i = 0; i < element.childNodes.length; i++) {
  253. var node = element.childNodes[i];
  254. if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) {
  255. node.parentNode.removeChild(node);
  256. }
  257. }
  258. }
  259. function toggleAllGroups(fragmentName) {
  260. var i=0;
  261. var toggle = null;
  262. var hasNext = true;
  263. while(hasNext) {
  264. var tg = new toggleGroup(fragmentName,i++,toggle);
  265. hasNext = tg.hasNext;
  266. toggle = tg.toggle;
  267. }
  268. }
  269. //expand/collapse group
  270. function toggleGroup(fragmentName, group_number, toggle){
  271. var element = null;
  272. var display = false;
  273. var image=null;
  274. // get the next available group
  275. var next_available_group=0;
  276. for (var i=group_number; i < group_number+20; i++){
  277. image = document.getElementById(fragmentName + "group_image_" + i);
  278. if (image) {
  279. break;
  280. }
  281. }
  282. next_available_group = i;
  283. if (image && group_number==next_available_group) {
  284. if ((toggle == 'expand')
  285. || (!toggle && image.src.indexOf("collapse.gif") >= 0)) {
  286. image.src = image.src.replace(/collapse/, "expand");
  287. display = false
  288. if (!toggle) {
  289. toggle = 'expand';
  290. }
  291. } else {
  292. image.src = image.src.replace(/expand/, "collapse");
  293. display = true;
  294. if (!toggle) {
  295. toggle = 'collapse';
  296. }
  297. }
  298. image.setAttribute("aria-expanded",toggle != 'expand')
  299. var summary = document.getElementById(fragmentName + "group_summary_"
  300. + group_number);
  301. if (summary != null) {
  302. summary.style.display=display ? 'none' : '';
  303. }
  304. var i = 1;
  305. while (i == 1 || element) {
  306. element = document.getElementById(fragmentName + "group_"
  307. + group_number + "_" + (i++));
  308. if (element) {
  309. element.style.display = display ? '' : 'none';
  310. }
  311. }
  312. }
  313. this.hasNext = image != null;
  314. this.toggle = toggle;
  315. }
  316. //selects all the input checkboxes from a form
  317. function toggleCheckboxes(source_checkbox, parent_id) {
  318. var arrayCheckbox = getChildInputs(parent_id, 'checkbox');
  319. for (var i=0; i<arrayCheckbox.length; i++){
  320. var checkbox = arrayCheckbox[i];
  321. if (checkbox.id != '') {
  322. if (source_checkbox.checked == true) {
  323. checkbox.checked = true;
  324. } else {
  325. checkbox.checked = false;
  326. }
  327. }
  328. }
  329. }
  330. function getChildInputs (parent, typeName) {
  331. var inputs = document.getElementById(parent).getElementsByTagName('input');
  332. var matchingInputs = new Array();
  333. for (var i = 0; i < inputs.length; i++) {
  334. var input = inputs[i];
  335. if (typeName && input.type != typeName) {
  336. continue;
  337. }
  338. matchingInputs.push(input);
  339. }
  340. return matchingInputs;
  341. }
  342. // given a rowID, will hide/show all the rows with the same ID.
  343. function toggleRows(rowID, visible) {
  344. var row = document.getElementById(rowID);
  345. if (row) {
  346. row.style.display = visible ? '' : 'none';
  347. while(row.nextSibling) {
  348. row = row.nextSibling;
  349. if (row.id == rowID) {
  350. row.style.display = visible ? '' : 'none';
  351. }
  352. }
  353. }
  354. }
  355. // Creates a transient object to be added to an array and passed to the CPS
  356. // function transientUpdateList
  357. // Used when you have multiple transient updates to do and you don't want the
  358. // fragment to refresh multiple times
  359. function createTransient(name, value, scope, channel) {
  360. return {
  361. "name": name,
  362. "scope": scope,
  363. "channel": channel,
  364. "value": value
  365. }
  366. }
  367. function ParamsObject (params) {
  368. this.value = params;
  369. this.valueOf = function() {
  370. return this.value;
  371. }
  372. this.indexOf = function(value) {
  373. return this.value.indexOf(value);
  374. }
  375. }
  376. //from-to navigate the table
  377. function navGo(frag, pagerName , sortParams, interactionParams) {
  378. var from = document.getElementById(pagerName + "_from");
  379. var to = document.getElementById(pagerName + "_to");
  380. var fromloc = trim(from.value);
  381. var toloc = trim(to.value);
  382. if (fromloc != "") {
  383. checkPositiveIntegerDefault(from,"");
  384. fromloc = from.value;
  385. if ( fromloc == "" ) {
  386. alert(pager_validation_msg_array['IDS_PAGER_FROM_INVALID']);
  387. // alert( "The number in the first entry box is not valid; it must
  388. // be a number greater than 0.");
  389. return;
  390. }
  391. if (toloc !="") {
  392. checkPositiveIntegerDefault(to,"");
  393. toloc = to.value;
  394. if ( toloc == "" ) {
  395. alert(pager_validation_msg_array['IDS_PAGER_TO_INVALID']);
  396. // alert( "The number in the second entry box is not valid; it
  397. // must be a number greater than 0.");
  398. return;
  399. }
  400. if ( Number(toloc) < Number(fromloc)) {
  401. alert(pager_validation_msg_array['IDS_PAGER_ENTRIES_INVALID']);
  402. // alert( "The number in the first entry box cannot be greater
  403. // than the number in the second entry box.");
  404. return;
  405. }
  406. }
  407. } else {
  408. if (toloc == "") {
  409. alert(pager_validation_msg_array['IDS_PAGER_ENTRIES_EMPTY']);
  410. // alert ("Specify the entry numbers to show and then click the Go
  411. // to button.");
  412. return;
  413. } else {
  414. checkPositiveIntegerDefault(to,"");
  415. toloc = to.value;
  416. if ( toloc == "" ) {
  417. alert(pager_validation_msg_array['IDS_PAGER_TO_INVALID']);
  418. // alert( "The number in the second entry box is not valid; it
  419. // must be a number greater than 0.");
  420. return;
  421. }
  422. }
  423. }
  424. var skipnum = Number(fromloc) -1;
  425. if (Number(skipnum) < 0) {
  426. skipnum=0;
  427. }
  428. var addtionParams = sortParams;
  429. if (interactionParams != '') {
  430. addtionParams = addtionParams + "&" + interactionParams;
  431. }
  432. var paramsObj = new ParamsObject(pagerName + "_skip=" + skipnum + "&"
  433. + pagerName + "_from=" + fromloc + "&" + pagerName + "_to=" + toloc
  434. + "&" + addtionParams);
  435. frag.retrieve(paramsObj);
  436. }
  437. function navOthers (frag,defaultOnClickParams,interactionParams){
  438. var params = defaultOnClickParams + "&" + interactionParams;
  439. var paramsObj = new ParamsObject(params);
  440. frag.retrieve(paramsObj);
  441. }
  442. // sort the table
  443. function sortGo(frag, columnTitle, sortColumn, sortOrder, pageParams,
  444. interactionParams) {
  445. var isSortedOn = false;
  446. if (sortColumn != '' && sortColumn == columnTitle) {
  447. isSortedOn = true;
  448. }
  449. var order = "ascending";
  450. if (isSortedOn == true) {
  451. if (sortOrder == "descending") {
  452. order = '';
  453. } else {
  454. if (sortOrder == "ascending") {
  455. order = "descending";
  456. }
  457. }
  458. }
  459. var addtionParams = pageParams;
  460. if (interactionParams != '') {
  461. addtionParams = addtionParams + "&" + interactionParams;
  462. }
  463. var paramsObj = new ParamsObject("sort_column=" + columnTitle
  464. + "&sort_order=" + order + "&" + addtionParams);
  465. frag.retrieve(paramsObj);
  466. }
  467. //return multi-dimensional array where each child element in the array
  468. //is an array containing the checkbox number, id and value
  469. function getCheckboxArray(table_name) {
  470. var checkboxes = new Array();
  471. var elements = document.getElementsByTagName("INPUT");
  472. var checkboxNumber = 0;
  473. for (var i=0; i<elements.length; i++) {
  474. if (elements[i].id != null){
  475. if (elements[i].id.indexOf(table_name + "_checkbox_") >= 0){
  476. if (elements[i].checked == true) {
  477. var checkboxArray = new Array();
  478. checkboxArray[0] = checkboxNumber;
  479. checkboxArray[1] = elements[i].id;
  480. checkboxArray[2] = elements[i].value;
  481. checkboxes[checkboxes.length++] = checkboxArray;
  482. }
  483. checkboxNumber++;
  484. }
  485. }
  486. }
  487. return checkboxes;
  488. }
  489. // returns a string with a key/value pair where the key is the id of the
  490. // checkbox
  491. function getCheckboxUrlParams(table_name) {
  492. return getCheckboxParams(table_name, false, null, true);
  493. }
  494. // returns a string with a key/value pair where the key name is checkbox_1,
  495. // checkbox_2...
  496. function getCheckboxCheckParams(table_name, valueFunc) {
  497. return getCheckboxParams(table_name, true, "checkbox", true, valueFunc);
  498. }
  499. //returns a string with a key/value pair (key=value)
  500. function getCheckboxParams(table_name, use_parameter_name, parameter_name, use_parameter_index, valueFunc) {
  501. var array = getCheckboxArray(table_name);
  502. var params = "";
  503. var last = array.length - 1;
  504. for (var i=0; i<array.length; i++) {
  505. var checkboxArray = array[i];
  506. var checkboxName = checkboxArray[1];
  507. var checkboxValue = checkboxArray[2];
  508. var param;
  509. if (use_parameter_name) {
  510. param = parameter_name;
  511. if (use_parameter_index) {
  512. param += "_" + (i + 1);
  513. }
  514. } else {
  515. param = checkboxName;
  516. }
  517. // This line is to avoid double encode issue, in case of the value of
  518. // the checkbox has been urlencoded before.
  519. checkboxValue = decodeURIComponent(checkboxValue);
  520. params += param + "=" + encodeURIComponent(valueFunc ? valueFunc(checkboxValue) : checkboxValue);
  521. if (i < last) {
  522. params += "&"
  523. }
  524. }
  525. return params;
  526. }
  527. function doAction(fragment, table_name, ifrmAction, confirm_msg){
  528. var checkboxes = getCheckboxCheckParams(table_name);
  529. actionImpl(fragment, checkboxes, ifrmAction, confirm_msg);
  530. }
  531. function actionImpl(fragment, checkboxes, ifrmAction, confirm_msg) {
  532. if (checkboxes.length == 0) {
  533. alert(action_no_selection_msg);
  534. return;
  535. }
  536. if (!confirm_msg) {
  537. if (ifrmAction == 'enable') {
  538. confirm_msg = enable_schecule_confirm_msg;
  539. } else if (ifrmAction == 'disable') {
  540. confirm_msg = disable_schecule_confirm_msg;
  541. } else if (ifrmAction == 'delete') {
  542. confirm_msg = delete_confirm_msg;
  543. } else if (ifrmAction == 'deleteDataset') {
  544. confirm_msg = delete_confirm_msg;
  545. }
  546. }
  547. var params = checkboxes;
  548. if (ifrmAction != '') {
  549. params += "&ifrmcmd=" + ifrmAction;
  550. }
  551. if (confirm_msg) {
  552. if (confirm(confirm_msg)) {
  553. fragment.retrieve(params);
  554. }
  555. } else {
  556. fragment.retrieve(params);
  557. }
  558. }
  559. function doDeleteCapability(fragment, table_name) {
  560. var checkboxes = getCheckboxCheckParams(table_name);
  561. deleteCapabilityImpl(fragment, checkboxes);
  562. }
  563. function deleteCapabilityImpl(fragment, checkboxes) {
  564. if (checkboxes.length == 0) {
  565. alert(action_no_selection_msg);
  566. return;
  567. }
  568. var confirm_msg = delete_capability_confirm_msg;
  569. var params = checkboxes;
  570. params += "&ifrmcmd=delete";
  571. if (confirm_msg != '') {
  572. if (confirm(confirm_msg)) {
  573. fragment.retrieve(params);
  574. }
  575. } else {
  576. fragment.retrieve(params);
  577. }
  578. }
  579. function doDeleteTenants(fragment, table_name) {
  580. var checkboxes = getCheckboxCheckParams(table_name);
  581. deleteTenantsImpl(fragment, checkboxes);
  582. }
  583. function deleteTenantsImpl(fragment, checkboxes) {
  584. if (checkboxes.length == 0) {
  585. alert(action_no_selection_msg);
  586. return;
  587. }
  588. var confirm_msg = delete_tenants_confirm_msg;
  589. var params = checkboxes;
  590. params += "&ifrmcmd=deleteTenants";
  591. if (confirm_msg != '') {
  592. if (confirm(confirm_msg)) {
  593. fragment.retrieve(params);
  594. }
  595. } else {
  596. fragment.retrieve(params);
  597. }
  598. }
  599. function getTenantProfileSearchPath(tenantID) {
  600. return "/configuration/account[@tenantID='" + encodeURIComponent(tenantID.replace(/'/g,"''")) + "']";
  601. }
  602. function doDeleteTenantUserProfile(fragment, table_name) {
  603. var checkboxes = getCheckboxCheckParams(table_name, getTenantProfileSearchPath);
  604. if (checkboxes.length == 0) {
  605. alert(action_no_selection_msg);
  606. return;
  607. }
  608. deleteTenantUserProfileImpl(fragment, checkboxes);
  609. }
  610. function deleteTenantUserProfileImpl(fragment, checkboxes) {
  611. var confirm_msg = delete_tenantuserprofile_confirm_msg;
  612. if (confirm_msg != '') {
  613. if (confirm(confirm_msg)) {
  614. var params = checkboxes;
  615. params+="&ifrmcmd=delete";
  616. fragment.retrieve(params);
  617. }
  618. } else {
  619. fragment.retrieve();
  620. }
  621. }
  622. function doEditDefaultUserProfile(tenantId, tenantName, backURL) {
  623. var urlParams = "?b_action=xts.run";
  624. urlParams += "&m=portal/properties_general.xts";
  625. urlParams += "&m_class=account";
  626. urlParams += "&m_obj="+getTenantProfileSearchPath(tenantId);
  627. urlParams += "&m_tenantId="+encodeURIComponent(tenantId);
  628. urlParams += "&m_tenantName="+encodeURIComponent(tenantName);
  629. urlParams += "&backURL=";
  630. urlParams += backURL;
  631. ui_modal_dialog.open(urlParams, false, true, true);
  632. }
  633. function doExportTenants(table_name, mPath, backURL) {
  634. var checkboxes = getCheckboxParams(table_name, true, "selectedTenants", false);
  635. exportTenantsImpl(checkboxes, mPath, backURL);
  636. }
  637. function exportTenantsImpl(checkboxes, mPath, backURL) {
  638. var urlParams = "?b_action=xts.run";
  639. urlParams += "&m_path=";
  640. urlParams += mPath;
  641. urlParams += "&m=portal/new_general.xts";
  642. urlParams += "&from_tool=true";
  643. urlParams += "&m_class=exportDeployment";
  644. urlParams += "&m_setArchiveChanged=true";
  645. urlParams += "&m_archive";
  646. urlParams += "&m_setArchiveChanged=true";
  647. urlParams += "&m_new_class=exportDeployment";
  648. urlParams += "&m_deploymentWizardPage=tenants";
  649. urlParams += "&backURL=";
  650. urlParams += backURL;
  651. urlParams += "&m_entireContentStoreSelect=true";
  652. urlParams += "&m_last_value_entireContentStoreSelect=true";
  653. urlParams += "&m_last_value_personalDataSelect=true";
  654. urlParams += "&m_personalDataSelect";
  655. urlParams += "&m_exportMethod=selectTenants";
  656. urlParams += "&m_wizardOp=update-method";
  657. if (checkboxes) {
  658. urlParams += "&" + checkboxes;
  659. }
  660. else
  661. {
  662. urlParams += "&tenants";
  663. }
  664. ui_modal_dialog.open(urlParams, false, true, true);
  665. }
  666. function doTerminateSessions(fragment, table_name) {
  667. var checkboxes = getCheckboxCheckParams(table_name);
  668. terminateSessionsImpl(fragment, checkboxes);
  669. }
  670. function terminateSessionsImpl(fragment, checkboxes) {
  671. if (checkboxes.length == 0) {
  672. alert(action_no_selection_msg);
  673. return;
  674. }
  675. var confirm_msg = terminate_sessions_confirm_msg;
  676. var params = checkboxes;
  677. params += "&ifrmcmd=terminateSessions";
  678. if (confirm_msg != '') {
  679. if (confirm(confirm_msg)) {
  680. fragment.retrieve(params);
  681. }
  682. } else {
  683. fragment.retrieve(params);
  684. }
  685. }
  686. function doEnableDisableObj(fragment, table_name, isDisable) {
  687. var checkboxes = getCheckboxArray(table_name);
  688. var tenantIds = new Array();
  689. for (var i = 0; i < checkboxes.length; i++) {
  690. tenantIds[tenantIds.length]=checkboxes[i][2];
  691. }
  692. enableDisableObjImpl(fragment, tenantIds, isDisable);
  693. }
  694. function enableDisableObjImpl(fragment, tenantIds, isDisable) {
  695. if (tenantIds.length == 0) {
  696. alert(action_no_selection_msg);
  697. return;
  698. }
  699. var params = "&ifrmcmd=save&m_p_disabled=" + isDisable + "&m_class=tenant&m_obj=/directory//tenant[";
  700. for (var i = 0; i < tenantIds.length; i++) {
  701. if (i > 0) {
  702. params+=" or ";
  703. }
  704. var tenantId = decodeURIComponent(tenantIds[i]);
  705. params+="@tenantID='" + encodeURIComponent(tenantId.replace(/'/g,"''")) + "'";
  706. }
  707. params+="]";
  708. fragment.retrieve(params);
  709. }
  710. function doCreateContentUtilizationInfo(table_name, mPath, backURL) {
  711. var checkboxes = getCheckboxParams(table_name, true, "selectedTenants", false);
  712. createContentUtilizationInfoImpl(checkboxes, mPath, backURL);
  713. }
  714. function createContentUtilizationInfoImpl(checkboxes, mPath, backURL) {
  715. var urlParams = "?b_action=xts.run";
  716. urlParams += "&m_path=";
  717. urlParams += mPath;
  718. urlParams += "&m=portal/new_general.xts";
  719. urlParams += "&from_tool=true";
  720. urlParams += "&m_class=contentTask";
  721. urlParams += "&m_new_class=contentTask";
  722. urlParams += "&backURL=";
  723. urlParams += backURL;
  724. urlParams += "&contentTaskType=createContentUtilizationInfo";
  725. if (checkboxes) {
  726. urlParams += "&" + checkboxes;
  727. }
  728. ui_modal_dialog.open(urlParams, false, true, true);
  729. }
  730. function doActionCancelInteractive(fragment, tableName, arguments,
  731. isGroupAction) {
  732. var params = '';
  733. if (arguments) {
  734. params = arguments;
  735. }
  736. if (isGroupAction) {
  737. var checkedPramsArray = getCheckboxArray(tableName);
  738. if (checkedPramsArray.length == 0) {
  739. alert(action_no_selection_msg);
  740. return;
  741. }
  742. for (var i=0; i<checkedPramsArray.length; i++) {
  743. var checkboxArray = checkedPramsArray[i];
  744. var checkboxIdx = checkboxArray[0];
  745. var entriesInfo = entriesArray[checkboxIdx];
  746. if (params != '') {
  747. params += '&';
  748. }
  749. params += 'requestID_' + i + '=' + entriesInfo[0]
  750. + '&dispatcherName_' + i + '='
  751. + encodeURIComponent(entriesInfo[1]) + '&reportName_' + i
  752. + '=' + encodeURIComponent(entriesInfo[2]);
  753. }
  754. }
  755. fragment.retrieve(params);
  756. }
  757. /*******************************************************************************
  758. * COGADMIN SYSMGMT WRAPPER FOR FRAGMENT EVENTS
  759. ******************************************************************************/
  760. var EVTKEY_COGADMIN_PREFIX = "com.cognos.cogadmin.";
  761. var EVTKEY_RELOAD = "reload";
  762. var PAGELET_TOP_HEIGHT = 60;
  763. var FRAGMENT_TOP_HEIGHT = 34;
  764. var FRAGMENT_MIN_HEIGHT = 500;
  765. function setContentTableHeight (frgId,windowState,number){
  766. var defaultPageletHeight = (xClientHeight() < FRAGMENT_MIN_HEIGHT) ? FRAGMENT_MIN_HEIGHT
  767. : xClientHeight() - PAGELET_TOP_HEIGHT;
  768. var frgFrameId = frgId + "frame";
  769. var frgContentTableId = frgId + "contentTable";
  770. var fragmentOtherHeight = xHeight(frgContentTableId) ? (xHeight(frgFrameId)
  771. - xHeight(frgContentTableId) + 2) : 85;
  772. var num = number || 1;
  773. switch (windowState){
  774. case "maximized":
  775. xHeight(frgContentTableId,defaultPageletHeight - fragmentOtherHeight);
  776. break;
  777. case "extended":
  778. xHeight(frgContentTableId, defaultPageletHeight - FRAGMENT_TOP_HEIGHT
  779. - fragmentOtherHeight);
  780. break;
  781. case "normal":
  782. default:
  783. xHeight(frgContentTableId, (defaultPageletHeight / num)
  784. - fragmentOtherHeight);
  785. }
  786. }
  787. var appOnLeaveHandlers = {};
  788. function regAppOnLeaveEvent (id, handler, context){
  789. appOnLeaveHandlers[id] = {};
  790. appOnLeaveHandlers[id]["conext"] = context;
  791. appOnLeaveHandlers[id]["handler"] = handler;
  792. window.onbeforeunload = function(evt){
  793. for (o in appOnLeaveHandlers){
  794. appOnLeaveHandlers[o]["handler"].apply(
  795. appOnLeaveHandlers[o]["conext"], [ evt ]);
  796. }
  797. };
  798. }
  799. /*
  800. * This function is introduced to unload the regestered event when fragment is
  801. * unloaded.
  802. */
  803. function regFragEvent (frag,evt,handler,capture){
  804. var cap = capture || false;
  805. if (typeof frag == "string")
  806. frag = $(frag);
  807. if (frag) {
  808. frag.addEventListener(evt,handler,cap);
  809. frag.addEventListener("fragment.unload", function() {
  810. frag.removeEventListener(evt,handler,cap);
  811. }, cap);
  812. return true;
  813. } else
  814. return false;
  815. }
  816. function proxyCogadminEvent (frag,evtName,type,payload){
  817. var evt = new _F_Event.Event();
  818. evt.initEvent(evtName, type, payload, false, true);
  819. evt.eventPhase = evt.AT_TARGET;
  820. frag.proxyEvent(evt);
  821. }
  822. function addCogadminEventListener(fragment, key, listener) {
  823. fragment.addEventListener(EVTKEY_COGADMIN_PREFIX + key, listener);
  824. }
  825. function removeCogadminEventListener(fragment, key, listener) {
  826. fragment.removeEventListener(EVTKEY_COGADMIN_PREFIX + key, listener);
  827. }
  828. function raiseCogadminEvent(fragment, key, payload) {
  829. fragment.raiseEvent(EVTKEY_COGADMIN_PREFIX + key, payload);
  830. }
  831. function addReloadEventListener(fragment, listener) {
  832. addCogadminEventListener(fragment,EVTKEY_RELOAD, listener);
  833. }
  834. function removeReloadEventListener(fragment, listener) {
  835. removeCogadminEventListener(fragment,EVTKEY_RELOAD, listener);
  836. }
  837. function raiseReloadEvent(fragment, payload, skipFocus) {
  838. if (!skipFocus) {
  839. fragment.afterRetrieve = function(evt) {
  840. fragment.removeEventListener("fragment.retrieve.after", fragment.afterRetrieve);
  841. ui_setFocus(fragment.div);
  842. }
  843. fragment.addEventListener("fragment.retrieve.after", fragment.afterRetrieve);
  844. }
  845. raiseCogadminEvent(fragment, EVTKEY_RELOAD, payload);
  846. }
  847. /*
  848. * This function is used for those popup sub fragment only, to prevent the
  849. * following events (title_change/mode_change/windowstate_change/refresh) from
  850. * propergation. (This kind of propergation is something we don't want to see.)
  851. *
  852. */
  853. //TODO: It's better to use popup dialog instead of popup fragment.
  854. function stopDefaultPropagation (fragment) {
  855. var frag = $(fragment);
  856. frag.addEventListener("fragment.title.change", stopPropagation);
  857. frag.addEventListener("fragment.mode.change", stopPropagation);
  858. frag.addEventListener("fragment.windowstate.change", stopPropagation);
  859. frag.addEventListener("fragment.refresh.change", stopPropagation);
  860. function stopPropagation (evt) {
  861. evt.stopPropagation();
  862. }
  863. }
  864. /*******************************************************************************
  865. * END COGADMIN-SYSMGMT WRAPPER FOR FRAGMENT EVENTS
  866. ******************************************************************************/
  867. function includeClass(elt,cName) {
  868. var elt = xGetElementById(elt);
  869. if (elt && elt.className){
  870. var reg = new RegExp("(^|\\s)"+cName+"(\\s|$)");
  871. return reg.test(elt.className);
  872. } else {
  873. return false;
  874. }
  875. }
  876. // change the styles for a button during a mouseover
  877. function mouseoverImage(item) {
  878. if (includeClass(item,'cogstyle-toolbar-imageNormal')) {
  879. item.className = 'cogstyle-toolbar-imageOver';
  880. }
  881. if (includeClass(item,'cogstyle-toolbar-imagePressed')) {
  882. item.className = 'cogstyle-toolbar-imageOverPressed';
  883. }
  884. }
  885. // change the styles for a button during a mouseout
  886. function mouseoutImage(item) {
  887. if (includeClass(item,'cogstyle-toolbar-imageOver')) {
  888. item.className = 'cogstyle-toolbar-imageNormal';
  889. }
  890. if (includeClass(item,'cogstyle-toolbar-imageOverPressed')) {
  891. item.className = 'cogstyle-toolbar-imagePressed';
  892. }
  893. }
  894. function switchImageState(itemID_Release, item_Press) {
  895. var item_Release = document.getElementById(itemID_Release);
  896. if (item_Release != null) {
  897. item_Release.className = 'cogstyle-toolbar-imageNormal';
  898. }
  899. if (item_Press != null) {
  900. item_Press.className = 'cogstyle-toolbar-imagePressed';
  901. }
  902. }
  903. // Walk the tree to see if we can find style.display == 'none'
  904. function isHidden(obj) {
  905. if (obj.style && obj.style.display == 'none') {
  906. return true;
  907. } else if (obj.parentNode) {
  908. return isHidden(obj.parentNode);
  909. }
  910. return false;
  911. }
  912. // set the target height relative to the first parent that has height defined >
  913. // minHeight. Otherwise, use minHeight
  914. function setRelativeHeight(targetId, fragment, minHeight, offset) {
  915. var parent = fragment.parent;
  916. var iHeight = minHeight;
  917. while (parent) {
  918. if (parent.div) {
  919. var _height = parseInt($(parent.div).style.height);
  920. if (_height) {
  921. if (offset) {
  922. _height = (_height * offset.percentage) + offset.pixels;
  923. }
  924. if (_height > minHeight) {
  925. iHeight = _height;
  926. }
  927. break;
  928. }
  929. }
  930. parent = parent.parent;
  931. }
  932. var target = $(targetId);
  933. if (target) {
  934. $(targetId).style.height = iHeight + "px";
  935. }
  936. }
  937. function floatMath (operand1,operand2,operator) {
  938. var f1 = getFixedDecimal(operand1);
  939. var f2 = getFixedDecimal(operand2);
  940. var fixedDecimal = ((f1 - f2)>0) ? f1 : f2;
  941. var result;
  942. switch (operator) {
  943. case '-':
  944. result = operand1 - operand2;
  945. break;
  946. case '*':
  947. result = operand1 * operand2;
  948. fixedDecimal = f1 + f2;
  949. break;
  950. default:
  951. result = operand1 + operand2;
  952. }
  953. return result.toFixed(fixedDecimal);
  954. function getFixedDecimal (number) {
  955. var pre = number.toString().indexOf(".");
  956. if (pre == -1)
  957. return 0;
  958. else
  959. return fixedDecimal = number.toString().length - 1 - pre;
  960. }
  961. }
  962. function getExpandedTableGroups(table) {
  963. var expandedGroupKeys = new Array();
  964. var trs = table.getElementsByTagName('tr');
  965. for (var tr in trs) {
  966. var row = trs[tr];
  967. if (includeClass(row,"cogstyle-table-group")) {
  968. var img = row.getElementsByTagName("img")[0]; // the
  969. // expand/collapse
  970. // icon
  971. if (img.src.indexOf("collapse") >=0) { //the group is expanded
  972. expandedGroupKeys[expandedGroupKeys.length] = row
  973. .getAttribute("key");
  974. }
  975. }
  976. }
  977. return expandedGroupKeys;
  978. }
  979. function generateQueryString(currentString, newName, newValue, ignoreEmptyValues) {
  980. if (!currentString) {
  981. currentString="";
  982. }
  983. if (newName) {
  984. if (ignoreEmptyValues && (!newValue || newValue.length == 0)) {
  985. return currentString;
  986. }
  987. if (currentString.length > 0) {
  988. currentString+="&";
  989. }
  990. return currentString+newName+"="+newValue;
  991. }
  992. return currentString;
  993. }
  994. function importUserInterfaceProfiles(parentFrag, msg) {
  995. if (confirm(msg)) {
  996. var fragUrl='/cogadmin/controls/importUserInterfaceProfiles.xts';
  997. var frag = createFragment(parentFrag.id+'importUIProfiles', parentFrag.id+'importUIProfiles_div', fragUrl);
  998. frag.retrieve();
  999. }
  1000. }