Abbiamo già trattato l’argomento, ci torno sopra perché –dopo gli ultimi aggiornamenti del software di Manage Engine– l’aspetto di ServiceDesk Plus è decisamente cambiato (in meglio) e mi ha fatto nascere una nuova esigenza, in realtà nell’aria già da tempo. Si tratta della possibilità di fare un refresh manuale della pagina.
Nulla di particolare sotto al sole, sia chiaro, giusto un’aggiunta che può tornare utile avere a portata di clic oltre che di tastiera (in quel caso basta un F5
). Ho scelto di inserire il nuovo pulsante subito prima del “Close“.
Per lanciare un aggiornamento della pagina ho utilizzato un semplice window.location.reload()
, che si integra quindi nel codice di un nuovo pulsante. Per poter far stare tutto su una sola riga, ho aumentato le dimensioni (larghezza) della toolbar, portando il valore a 310 pixel. Nello specifico, questo è il codice del nuovo pulsante:
// REFRESH '<input type="button" title="Refresh" class="formStylebutton" style="width:auto;height:18" onclick="window.location.reload()" value="Refresh" name="refreshButton"> ' +
Ho rilasciato perciò una nuova versione del CustomScripts.js
, disponibile come sempre su Gist, te la propongo qui di seguito per comodità:
jQuery(document).ready(function() { | |
/* | |
Custom "Shortcuts" toolbar for ManageEngine SDP | |
From an ideas of MKR @ SDPAdmins.pl | |
SDP Community: https://forums.manageengine.com/topic/show-bottom-toolbar#49000008012652 | |
Master HEX To RGBA Color Chart: http://www.websitecodetutorials.com/code/css/master-hex-to-rgba-color-chart.php | |
GSolone, first release 7/7/16 ( CustomScripts.js @ https://gist.github.com/gioxx ) | |
last mod. 10/11/16 | |
10/11/16- I have added a new button to refresh the page. | |
8/7/16- I have included an array of possible words that you can "catch" in the URL (var checkURL) and a "for" cycle to check and show the custom toolbar (credits: http://stackoverflow.com/questions/15344413/how-to-check-if-one-of-the-strings-from-an-array-are-in-the-url-window-location). | |
*/ | |
//Original idea | |
//var userLoc = location.pathname; | |
//if(userLoc == "/WOListView.do" && sdp_user["USERTYPE"] =="Technician"){ | |
//My idea: intercept an array of possible URLs. | |
var checkURL = ['WOListView.do', 'CompleteRequest.do', 'SearchN.do']; | |
for (var i = 0; i < checkURL.length; i++) { | |
if( (document.URL.indexOf(checkURL[i]) != -1) && sdp_user["USERTYPE"] =="Technician"){ | |
// Style | |
var toolbarStyle = '<style type="text/css">' + | |
' #rapidtools{' + | |
' bottom: 0;' + | |
' right: 0;' + | |
' margin-bottom: 10px;' + | |
' position: fixed;' + | |
' background-color: rgba(208,208,208,0.6);' + | |
' width: 310px;' + | |
' height: 50px;' + | |
' margin: 0 auto;' + | |
' }' + | |
' #rapidtoolscontent{' + | |
' text-align: center;' + | |
' margin-top: 8px;' + | |
' }' + | |
'</style>' | |
// Append Style | |
jQuery('head').append(toolbarStyle); | |
// Shortcuts | |
var buttons = '<div id="rapidtools">' + | |
'<strong style="padding-left: 10px; padding-right: 10px; background-color:#fff486;">Shortcuts</strong> <br />' + | |
'<div id="rapidtoolscontent">' + | |
// PICK UP | |
'<input type="button" title="Pickup" class="formStylebutton" style="width:auto;height:18" onclick="return checkWOSelection(document.getElementById(\'ReqListForm\'),\'checkbox\',\'pickUpRequest=Pick up&\')" value="Pick up" name="pickUpRequest"> ' + | |
// MERGE | |
'<input type="button" title="Merge" class="formStylebutton" style="width:auto;height:18" onclick="return checkMergeSelection(document.getElementById(\'ReqListForm\'),\'checkbox\',\'mergeRequest=merge&\',serReqId)" value="Merge" name="mergeRequest"> ' + | |
// DELETE | |
'<input type="button" title="Delete" class="formStylebutton" style="width:auto;height:18" onclick="return confirmRequestDeleteFromList(document.getElementById(\'ReqListForm\'),\'checkbox\',document.getElementById(\'confirmrequestdelete\'),document.getElementById(\'chooserequest\'),\'deleteRequest=Delete\',true)" value="Delete" name="deleteRequest"> ' + | |
// REFRESH | |
'<input type="button" title="Refresh" class="formStylebutton" style="width:auto;height:18" onclick="window.location.reload()" value="Refresh" name="refreshButton"> ' + | |
// CLOSE | |
'<input type="button" title="Close" class="formStylebutton" style="width:auto;height:18" onclick="return checkWOSelection(document.getElementById(\'ReqListForm\'),\'checkbox\',\'closeRequest=Close&\')" value="Close" name="closeRequest"> ' + | |
// END OF TOOLBAR | |
'</div></div>'; | |
// Show Toolbar | |
jQuery('body').append(buttons); | |
} | |
} | |
}); |
Ne approfitto per ricordarti che lo script dovrà essere inserito in [TUOSERVERSDP]\ServiceDesk\custom\scripts, e che forzando un aggiornamento della pagina (del tuo HelpDesk) dovresti notare subito la novità, senza la necessità di riavviare il software.
Per commenti, nuove idee o suggerimenti riguardo possibili miglioramenti del codice attualmente proposto, l’area commenti è a tua totale disposizione!
G
L'articolo potrebbe non essere aggiornato
Questo post è stato scritto più di 5 mesi fa, potrebbe non essere aggiornato. Per qualsiasi dubbio ti invito a lasciare un commento per chiedere ulteriori informazioni! :-)