[Rt-commit] rtir branch, 4.0/save-lookup-results, created. 4.0.0-38-gf369675
Aaron Kondziela
aaron at bestpractical.com
Thu Apr 13 21:07:36 EDT 2017
The branch, 4.0/save-lookup-results has been created
at f3696756d075f71e2ab172739962f16a7de760f7 (commit)
- Log -----------------------------------------------------------------
commit f3696756d075f71e2ab172739962f16a7de760f7
Author: Aaron Kondziela <aaron at bestpractical.com>
Date: Thu Apr 13 21:06:27 2017 -0400
Add button to save Whois and Traceroute results to a ticket
Fixes T#183237
diff --git a/html/RTIR/Tools/Elements/ToolResultsWhois b/html/RTIR/Tools/Elements/ToolResultsWhois
index b9d570f..5bc77fc 100644
--- a/html/RTIR/Tools/Elements/ToolResultsWhois
+++ b/html/RTIR/Tools/Elements/ToolResultsWhois
@@ -47,6 +47,11 @@
%# END BPS TAGGED BLOCK }}}
% if ( $q ) {
<h2>WHOIS Results</h2>
+
+% if ($TicketObj and $WhoisIterator) {
+ <button onClick="jQuery('#save-results-to-ticket').click()"><% loc('Save these results to the ticket') %></button>
+% }
+
% if ( $TicketObj && RT::IR::TicketType( Ticket => $TicketObj ) eq 'Incident' ) {
<form method="post" action="<% RT::IR->HREFTo("Tools/Lookup.html")|n%>">
<input type="hidden" name="incidentid" value="<% $TicketObj->id %>" />
@@ -58,8 +63,10 @@
% }
<%PERL>
my $DoInvestigate = 0;
+my $SavedContent = '';
if ($WhoisIterator) {
while (my $obj = $WhoisIterator->next) {
+ $SavedContent = $SavedContent . $obj->content . "\n";
my @lines_starting_with_space = grep /^(\s+)(\w+)/, $obj->content;
if ($handparse || $#lines_starting_with_space >= 4) { #we couldn't parse that. suck
my $content = join "", $obj->content;
@@ -72,7 +79,7 @@ if ($WhoisIterator) {
<pre><% $content |n %></pre><br />
% } else {
Structured RIPE whois data returned.
-lick <a href="Lookup.html?q=<% $q |u %>&server=<% $WhoisServer |u %>&handparse=1">here</a> to manually parse this data.
+Click <a href="Lookup.html?q=<% $q |u %>&server=<% $WhoisServer |u %>&handparse=1">here</a> to manually parse this data.
<br />Warnings <% $obj->warnings %>
<br />errors <% $obj->errors %>
<hr />
@@ -108,11 +115,28 @@ foreach my $attribute ( $obj->attributes ) {
&>
% }
</form>
+
+% if ($TicketObj and $WhoisIterator and $SavedContent) {
+% my $url = RT::IR->HREFTo(
+% "Tools/Lookup.html?"
+% . $m->comp(
+% '/Elements/QueryString',
+% ticket => $TicketObj->id,
+% q => $q,
+% )
+% );
+ <form method="post" action="<% $url %>">
+ <input type="hidden" name="LookupResults" value="<% $SavedContent %>" />
+ <input type="submit" value="<% loc('Save these results to the ticket') %>" id="save-results-to-ticket" />
+ </form>
+% }
+
<%args>
$q => undef
$handparse => 1
$TicketObj => undef
$WhoisServer => undef
+$results => undef
$server => undef
</%args>
<%init>
diff --git a/html/RTIR/Tools/Lookup.html b/html/RTIR/Tools/Lookup.html
index c0899ef..aad82e7 100644
--- a/html/RTIR/Tools/Lookup.html
+++ b/html/RTIR/Tools/Lookup.html
@@ -47,6 +47,7 @@
%# END BPS TAGGED BLOCK }}}
<& /RTIR/Elements/Header, Title => $title &>
<& /Elements/Tabs &>
+<& /Elements/ListActions, actions => \@results &>
% $m->callback(CallbackName => 'BeforeCurrent', %ARGS, ARGSRef => \%ARGS, Ticket => $TicketObj, LookupType => $type, q => $q);
@@ -80,7 +81,7 @@
% $m->callback(CallbackName => 'AfterTools', %ARGS, ARGSRef => \%ARGS, Ticket => $TicketObj, LookupType => $type, q => $q);
<%INIT>
-
+my @results;
# Redirect when necessary
if ( $ARGS{'InvestigateTo'} ) {
my $requestors = join ', ', map /^Requestorbox-(.*)/, keys %ARGS;
@@ -108,10 +109,18 @@ if ( $ticket ) {
$TicketType = RT::IR::TicketType( Ticket => $TicketObj );
}
+if ($TicketObj and $LookupResults) {
+ my ($val, $msg) = $TicketObj->Comment(
+ Content => $LookupResults,
+ );
+ push @results, loc("Lookup results for Ticket [_1]: [_2]", $TicketObj->id, $msg);
+}
+
</%INIT>
<%ARGS>
$q => ''
$type => undef
$ticket => undef
+$LookupResults => undef
$HideResults => 0
</%ARGS>
diff --git a/html/RTIR/Tools/Traceroute.html b/html/RTIR/Tools/Traceroute.html
index 8ea29e3..c9b07da 100644
--- a/html/RTIR/Tools/Traceroute.html
+++ b/html/RTIR/Tools/Traceroute.html
@@ -50,13 +50,19 @@
<div style="margin: 2em;">
+% my $SavedContent = '';
+
<&| /Widgets/TitleBox,
title => $title,
class => 'traceroute',
&>
+% if ($TicketObj) {
+ <button onClick="jQuery('#save-results-to-ticket').click()"><% loc('Save these results to the ticket') %></button>
+% }
<pre>
<%PERL>
while (my $content = <$tr>) {
+ $SavedContent = $SavedContent . $content . "\n";
$m->comp('/Elements/MakeClicky', content => \$content, ($TicketObj? (object => $TicketObj):()) );
$m->out( $content );
$m->out('<br />');
@@ -66,6 +72,21 @@ while (my $content = <$tr>) {
</pre>
</&>
+% if ($TicketObj and $SavedContent) {
+% my $url = RT::IR->HREFTo(
+% "Tools/Lookup.html?"
+% . $m->comp(
+% '/Elements/QueryString',
+% ticket => $ticket,
+% q => $q,
+% )
+% );
+ <form method="post" action="<% $url %>">
+ <input type="hidden" name="LookupResults" value="<% $SavedContent %>" />
+ <input type="submit" value="<% loc('Save these results to the ticket') %>" id="save-results-to-ticket" />
+ </form>
+% }
+
</div>
<%INIT>
unless ( $q =~ /^[A-Z0-9.:]+$/i ) {
-----------------------------------------------------------------------
More information about the rt-commit
mailing list