OTRS API Reference JavaScript

Source: Core.Agent.Admin.GenericInterfaceWebserviceHistory.js

  1. // --
  2. // Copyright (C) 2001-2018 OTRS AG, https://otrs.com/
  3. // --
  4. // This software comes with ABSOLUTELY NO WARRANTY. For details, see
  5. // the enclosed file COPYING for license information (GPL). If you
  6. // did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
  7. // --
  8. "use strict";
  9. var Core = Core || {};
  10. Core.Agent = Core.Agent || {};
  11. Core.Agent.Admin = Core.Agent.Admin || {};
  12. /**
  13. * @namespace Core.Agent.Admin.GenericInterfaceWebserviceHistory
  14. * @memberof Core.Agent.Admin
  15. * @author OTRS AG
  16. * @description
  17. * This namespace contains the special module functions for the GenericInterface WebserviceHistory module.
  18. */
  19. Core.Agent.Admin.GenericInterfaceWebserviceHistory = (function (TargetNS) {
  20. /**
  21. * @name Init
  22. * @memberof Core.Agent.Admin.GenericInterfaceWebserviceHistory
  23. * @function
  24. * @param {Object} Params - Initialization and internationalization parameters.
  25. * @description
  26. * This function initialize the module.
  27. */
  28. TargetNS.Init = function (Params) {
  29. TargetNS.WebserviceID = parseInt(Params.WebserviceID, 10);
  30. TargetNS.Localization = Params.Localization;
  31. };
  32. /**
  33. * @name GetWebserviceList
  34. * @memberof Core.Agent.Admin.GenericInterfaceWebserviceHistory
  35. * @function
  36. * @description
  37. * Get list of webservices via AJAX..
  38. */
  39. TargetNS.GetWebserviceList = function() {
  40. var Data = {
  41. Action: 'AdminGenericInterfaceWebserviceHistory',
  42. Subaction: 'GetWebserviceList',
  43. WebserviceID: TargetNS.WebserviceID,
  44. FilterRemoteIP: $('#FilterRemoteIP').val() || '',
  45. FilterType: $('#FilterType').val() || ''
  46. };
  47. $('#WebserviceDetails').css('visibility', 'hidden');
  48. $('.WebserviceListWidget').addClass('Loading');
  49. Core.AJAX.FunctionCall(Core.Config.Get('CGIHandle'), Data, function (Response) {
  50. var HTML = '',
  51. Counter;
  52. if (!Response || !Response.LogData) {
  53. alert(TargetNS.Localization.WebserviceHistoryErrorMsg);
  54. return;
  55. }
  56. $('.WebserviceListWidget').removeClass('Loading');
  57. if (!Response.LogData.length) {
  58. $('#WebserviceList tbody').empty().append('<tr><td colspan="3">' + TargetNS.Localization.NoDataFoundMsg + '</td></tr>');
  59. }
  60. else {
  61. $('#WebserviceList tbody').empty();
  62. Counter = Response.LogData.length;
  63. $.each(Response.LogData, function(){
  64. HTML += '<tr>';
  65. HTML += '<td><a href="#" class="AsBlock">' + Counter +
  66. '<input type="hidden" class="WebserviceHistoryID" value="' + this.ID + '" />' +
  67. '<input type="hidden" class="WebserviceHistoryVersion" value="' + Counter + '" />' +
  68. '</a></td>';
  69. HTML += '<td><a href="#" class="AsBlock">' + this.CreateTime + '</a></td>';
  70. HTML += '</tr>';
  71. Counter--;
  72. });
  73. $('#WebserviceList tbody').html(HTML);
  74. $('#WebserviceList a').bind('click', function() {
  75. var WebserviceHistoryID = $(this).blur().parents('tr').find('input.WebserviceHistoryID').val(),
  76. WebserviceHistoryVersion = $(this).blur().parents('tr').find('input.WebserviceHistoryVersion').val();
  77. TargetNS.LoadWebserviceHistoryDetails(WebserviceHistoryID, WebserviceHistoryVersion);
  78. return false;
  79. });
  80. }
  81. }, 'json');
  82. };
  83. /**
  84. * @name LoadWebserviceHistoryDetails
  85. * @memberof Core.Agent.Admin.GenericInterfaceWebserviceHistory
  86. * @function
  87. * @param {String} WebserviceHistoryID
  88. * @param {String} WebserviceHistoryVersion
  89. * @description
  90. * This function initialize the module.
  91. */
  92. TargetNS.LoadWebserviceHistoryDetails = function(WebserviceHistoryID, WebserviceHistoryVersion) {
  93. var Data = {
  94. Action: 'AdminGenericInterfaceWebserviceHistory',
  95. Subaction: 'GetWebserviceHistoryDetails',
  96. WebserviceID: TargetNS.WebserviceID,
  97. WebserviceHistoryID: WebserviceHistoryID
  98. };
  99. $('#WebserviceHistoryDetails').css('visibility', 'hidden');
  100. $('.WebserviceListWidget').addClass('Loading');
  101. Core.AJAX.FunctionCall(Core.Config.Get('CGIHandle'), Data, function (Response) {
  102. if (!Response || !Response.LogData) {
  103. alert(TargetNS.Localization.WebserviceHistoryErrorMsg);
  104. return;
  105. }
  106. $('.WebserviceListWidget').removeClass('Loading');
  107. if (!Response.LogData.Config) {
  108. $('#WebserviceHistoryDetails .ControlRow').empty();
  109. $('#WebserviceHistoryDetails .ControlRow').append(
  110. '<h2>History Details</h2>'
  111. );
  112. $('#WebserviceHistoryDetails .ConfigCode pre').empty();
  113. $('#WebserviceHistoryDetails .ConfigCode pre').append(
  114. '<span class="ErrorMessage">' + TargetNS.Localization.NoDataFoundMsg + '</span>'
  115. );
  116. $('#WebserviceHistoryDetails').css('visibility', 'visible').show();
  117. $('#WebserviceHistoryDetails .LightRow').hide();
  118. }
  119. else {
  120. $('#WebserviceHistoryID').attr('value', WebserviceHistoryID);
  121. $('#WebserviceHistoryDetails .ControlRow').empty();
  122. $('#WebserviceHistoryDetails .ControlRow').append(
  123. '<h2>History Details: Version ' + WebserviceHistoryVersion + ', ' + Response.LogData.CreateTime + '</h2>'
  124. );
  125. $('#WebserviceHistoryDetails .ConfigCode pre').empty();
  126. $('#WebserviceHistoryDetails .ConfigCode pre').append(
  127. '<code>' + Response.LogData.Config + '</code>'
  128. );
  129. $('#WebserviceHistoryDetails').css('visibility', 'visible').show();
  130. $('#WebserviceHistoryDetails .LightRow').show();
  131. }
  132. }, 'json');
  133. };
  134. /**
  135. * @name ShowRollbackDialog
  136. * @memberof Core.Agent.Admin.GenericInterfaceWebserviceHistory
  137. * @function
  138. * @returns {Boolean} Returns false.
  139. * @param {Object} Event - The browser event object, e.g. of the clicked DOM element.
  140. * @description
  141. * Shows a dialog to rollback log.
  142. */
  143. TargetNS.ShowRollbackDialog = function(Event){
  144. Core.UI.Dialog.ShowContentDialog(
  145. $('#RollbackDialogContainer'),
  146. TargetNS.Localization.RollbackLogMsg,
  147. '240px',
  148. 'Center',
  149. true,
  150. [
  151. {
  152. Label: TargetNS.Localization.CancelMsg,
  153. Class: 'Primary',
  154. Function: function () {
  155. Core.UI.Dialog.CloseDialog($('#RollbackDialog'));
  156. }
  157. },
  158. {
  159. Label: TargetNS.Localization.RollbackLogMsg,
  160. Function: function () {
  161. $('#Subaction').attr('value', 'Rollback');
  162. $('#ActionForm').submit();
  163. }
  164. }
  165. ]
  166. );
  167. Event.stopPropagation();
  168. return false;
  169. };
  170. return TargetNS;
  171. }(Core.Agent.Admin.GenericInterfaceWebserviceHistory || {}));

^ Use Elevator