configguide.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Password Management Servlets (PWM)
  3. * http://code.google.com/p/pwm/
  4. *
  5. * Copyright (c) 2006-2009 Novell, Inc.
  6. * Copyright (c) 2009-2014 The PWM Project
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  21. */
  22. "use strict";
  23. var PWM_GUIDE = PWM_GUIDE || {};
  24. var PWM_MAIN = PWM_MAIN || {};
  25. var PWM_GLOBAL = PWM_GLOBAL || {};
  26. PWM_GUIDE.selectTemplate = function(template) {
  27. PWM_MAIN.showWaitDialog({title:'Loading...',loadFunction:function() {
  28. var url = "config-guide?processAction=selectTemplate&template=" + template;
  29. PWM_MAIN.showDialog(url,function(result){
  30. if (!result['error']) {
  31. PWM_MAIN.getObject('button_next').disabled = template == "NOTSELECTED";
  32. PWM_MAIN.closeWaitDialog();
  33. } else {
  34. PWM_MAIN.showError(result['errorDetail']);
  35. }
  36. },{method:'GET'});
  37. }});
  38. };
  39. PWM_GUIDE.updateForm = function() {
  40. require(["dojo","dijit/registry","dojo/dom-form"],function(dojo,registry,domForm){
  41. var formJson = dojo.formToJson('configForm');
  42. dojo.xhrPost({
  43. url: "config-guide?processAction=updateForm&pwmFormID=" + PWM_GLOBAL['pwmFormID'],
  44. postData: formJson,
  45. headers: {"Accept":"application/json"},
  46. contentType: "application/json;charset=utf-8",
  47. encoding: "utf-8",
  48. handleAs: "json",
  49. dataType: "json",
  50. preventCache: true,
  51. error: function(errorObj) {
  52. PWM_MAIN.showError("error reaching server: " + errorObj);
  53. },
  54. load: function(result) {
  55. console.log("sent form params to server: " + formJson);
  56. }
  57. });
  58. });
  59. };
  60. PWM_GUIDE.gotoStep = function(step) {
  61. PWM_MAIN.showWaitDialog({loadFunction:function(){
  62. //preload in case of server restart
  63. PWM_MAIN.preloadAll(function(){
  64. var url = "config-guide?processAction=gotoStep&step=" + step;
  65. var loadFunction = function(result) {
  66. if (result['error']) {
  67. PWM_MAIN.showErrorDialog(result);
  68. return;
  69. } else if (result['data']) {
  70. if (result['data']['serverRestart']) {
  71. PWM_CONFIG.waitForRestart();
  72. return;
  73. }
  74. }
  75. PWM_MAIN.goto('config-guide');
  76. };
  77. PWM_MAIN.ajaxRequest(url,loadFunction);
  78. });
  79. }});
  80. };
  81. PWM_GUIDE.setUseConfiguredCerts = function(value) {
  82. PWM_MAIN.showWaitDialog({title:'Loading...',loadFunction:function() {
  83. var url = "config-guide?processAction=useConfiguredCerts&value=" + value;
  84. var loadFunction = function(result) {
  85. if (!result['error']) {
  86. PWM_MAIN.goto("config-guide");
  87. } else {
  88. PWM_MAIN.showError(result['errorDetail']);
  89. }
  90. };
  91. PWM_MAIN.ajaxRequest(url,loadFunction);
  92. }});
  93. };
  94. PWM_GUIDE.extendSchema = function() {
  95. PWM_MAIN.showConfirmDialog({text:"Are you sure you want to extend the LDAP schema?",okAction:function(){
  96. PWM_MAIN.showWaitDialog({loadFunction:function() {
  97. var url = "config-guide?processAction=extendSchema";
  98. var loadFunction = function(result) {
  99. if (result['error']) {
  100. PWM_MAIN.showError(result['errorDetail']);
  101. } else {
  102. var output = '<pre>' + result['data'] + '</pre>';
  103. PWM_MAIN.showDialog({title:"Results",text:output,okAction:function(){
  104. window.location.reload();
  105. }});
  106. }
  107. };
  108. PWM_MAIN.ajaxRequest(url,loadFunction);
  109. }});
  110. }});
  111. };