File size: 9,795 Bytes
eb67da4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
// --
// Copyright (C) 2001-2018 OTRS AG, https://otrs.com/
// --
// This software comes with ABSOLUTELY NO WARRANTY. For details, see
// the enclosed file COPYING for license information (GPL). If you
// did not receive this file, see https://www.gnu.org/licenses/gpl-3.0.txt.
// --
"use strict";
var Core = Core || {};
Core.Agent = Core.Agent || {};
Core.Agent.Admin = Core.Agent.Admin || {};
/**
* @namespace Core.Agent.Admin.SupportDataCollector
* @memberof Core.Agent.Admin
* @author OTRS AG
* @description
* This namespace contains the special module function for SupportDataCollector module.
*/
Core.Agent.Admin.SupportDataCollector = (function (TargetNS) {
/*
* @name Init
* @memberof Core.Agent.Admin.SupportDataCollector
* @function
* @description
* This function initializes module functionality
*/
TargetNS.Init = function () {
// Bind event on SendUpdate button
$('#SendUpdate').on('click', function (Event) {
var TextClass = '';
Core.UI.Dialog.ShowContentDialog('<div class="Spacing Center"><span class="AJAXLoader W33pc" title='+ Core.Language.Translate("Sending Update...") + '></span></div>',Core.Language.Translate("Sending Update..."), '10px', 'Center', true, undefined, true);
Core.AJAX.FunctionCall(Core.Config.Get('CGIHandle'), 'Action=' + Core.Config.Get('Action') + ';Subaction=SendUpdate;', function (Response) {
var ResponseMessage = Core.Language.Translate('Support Data information was successfully sent.');
// if the waiting dialog was canceled,
// do not show the search dialog as well
if (!$('.Dialog:visible').length) {
return;
}
if (Response === 0) {
ResponseMessage = Core.Language.Translate('Was not possible to send Support Data information.');
TextClass = 'Error';
}
Core.UI.Dialog.ShowContentDialog(
'<div class="Spacing Center SendUpdateResultDialog"><span class="W50pc ' + TextClass + '" title="' + ResponseMessage + '">' + ResponseMessage + '</span></div>', Core.Language.Translate("Update Result"),
'10px',
'Center',
true,
[
{
Label: Core.Language.Translate('Close this dialog'),
Class: 'Primary',
Function: function () {
Core.UI.Dialog.CloseDialog($('.SendUpdateResultDialog'));
}
}
],
true
);
});
Event.preventDefault();
Event.stopPropagation();
return false;
});
// Bind event on Generate Support bundle button
$('#GenerateSupportBundle').on('click', function (Event) {
Core.UI.Dialog.ShowContentDialog('<div class="Spacing Center LoadingSupportBundleDialog"><span class="AJAXLoader W75pc" title=' + Core.Language.Translate("Generating...") + '></span></div>', Core.Language.Translate("Generating..."), '10px', 'Center', true, undefined, true);
Core.AJAX.FunctionCall(Core.Config.Get('CGIHandle'), 'Action=' + Core.Config.Get('Action') + ';Subaction=GenerateSupportBundle;', function (Response) {
var TextClass, ResponseMessage;
// if the waiting dialog was canceled,
// do not show the option dialog as well
if (!$('.Dialog:visible').length) {
return;
}
Core.UI.Dialog.CloseDialog($('.LoadingSupportBundleDialog'));
if (!Response.Success) {
ResponseMessage = Core.Language.Translate('It was not possible to generate the Support Bundle.'),
TextClass = 'Error';
Core.UI.Dialog.ShowContentDialog(
'<div class="Spacing Center NoSupportBunle"><span class="W50pc ' + TextClass + '" title="' + ResponseMessage + '">' + ResponseMessage + '</span></div>', Core.Language.Translate("Generate Result"),
'10px',
'Center',
true,
[
{
Label: Core.Language.Translate('Close this dialog'),
Class: 'Primary',
Function: function () {
Core.UI.Dialog.CloseDialog($('.NoSupportBunle'));
}
}
],
true
);
}
else {
Core.UI.Dialog.ShowContentDialog(
$('#SupportBundleOptionsDialogContainer'), Core.Language.Translate("Support Bundle"),
'10px',
'Center',
true,
[
{
Label: Core.Language.Translate("Close this dialog"),
Class: 'Primary',
Function: function () {
Core.UI.Dialog.CloseDialog($('#SupportBundleOptionsDialog'));
}
}
],
true
);
// if the support bundle is bigger than 10 MB do not show send option
if (parseInt(Response.Filesize,10)>10) {
$('.SupportBundleSendFieldSet').addClass('Hidden');
$('.NoSupportBundleSendMessage').removeClass('Hidden');
$('.SizeMessage').removeClass('Hidden');
}
// if the sender addres is invalid it is set to empty string, send option should not be shown
else if ($('#Sender').val() === '') {
$('.SupportBundleSendFieldSet').addClass('Hidden');
$('.NoSupportBundleSendMessage').removeClass('Hidden');
$('.EmailMessage').removeClass('Hidden');
}
// otherwise show full email option
else {
$('#SendSupportBundle').on('click', function () {
$('#SendingAJAXLoader').addClass('AJAXLoader');
$('#SendSupportBundle').prop('disabled', true);
$('#DownloadSupportBundle').prop('disabled', true);
Core.AJAX.FunctionCall(Core.Config.Get('CGIHandle'), 'Action=' + Core.Config.Get('Action') + ';Subaction=SendSupportBundle;Filename=' + Response.Filename + ';RandomID=' + Response.RandomID, function (SendResponse) {
if (!SendResponse || !SendResponse.Success) {
alert(Core.Language.Translate("The mail could not be sent"));
}
Core.UI.Dialog.CloseDialog($('#SupportBundleOptionsDialog'));
});
});
}
$('#DownloadSupportBundle').on('click', function () {
// BUG: CWE-20 Improper Input Validation
// window.location.href = Core.Config.Get('Baselink') + 'Action=' + Core.Config.Get('Action') + ';Subaction=DownloadSupportBundle;Filename=' + Response.Filename + ';RandomID=' + Response.RandomID;
// FIXED:
window.location.href = Core.Config.Get('Baselink') + 'Action=' + Core.Config.Get('Action') + ';Subaction=DownloadSupportBundle;Filename=' + Response.Filename + ';RandomID=' + Response.RandomID + ';ChallengeToken=' + Core.Config.Get('ChallengeToken');
Core.UI.Dialog.CloseDialog($('#SupportBundleOptionsDialog'));
});
}
});
Event.preventDefault();
Event.stopPropagation();
return false;
});
// Bind event on Details button
$('.ShowItemMessage').on('click', function() {
Core.UI.Dialog.ShowContentDialog($(this).next('.Hidden').html(), $(this).closest('tr').find('.ItemLabel').text(), '200px', 'Center');
return false;
});
// Bind event on Data Table
$('.DataTable').each(function() {
if ($(this).find('.Flag.Problem').length) {
$(this).prev('h3').find('.Flag').addClass('Problem');
return true;
}
if ($(this).find('.Flag.Warning').length) {
$(this).prev('h3').find('.Flag').addClass('Warning');
return true;
}
if ($(this).find('.Flag.OK').length) {
$(this).prev('h3').find('.Flag').addClass('OK');
return true;
}
if ($(this).find('.Flag.Information').length) {
$(this).prev('h3').find('.Flag').addClass('Information');
return true;
}
if ($(this).find('.Flag.Unknown').length) {
$(this).prev('h3').find('.Flag').addClass('Unknown');
return true;
}
});
};
Core.Init.RegisterNamespace(TargetNS, 'APP_MODULE');
return TargetNS;
}(Core.Agent.Admin.SupportDataCollector || {}));
|