// ==SPICEWORKS-PLUGIN==
// @name Help Desk Customizations Clone
// @description Adds minor enhancements to your Help Desk, including ticket status in the toolbar, colors for past due tickets and private messages, and information on devices in the Related To field.
// @version 0.6
// ==/SPICEWORKS-PLUGIN==
plugin.configure({
settingDefinitions: [
{name:'past_due_color', label:'Past Due Highlight Color', type:'string', defaultValue:'#ffdede', example:'Default: #ffdede'},
{name:'private_note_color', label:'Private Note Color', type:'string', defaultValue:'#cccccc', example:'Default: #cccccc'},
{name:'tickets_open_display', label:'Display Open Tickets', type:'checkbox', defaultValue:true },
{name:'tickets_due_display', label:'Display Past Due Tickets', type:'checkbox', defaultValue:true },
{name:'tickets_unassigned_display', label:'Display Unassigned Tickets', type:'checkbox', defaultValue:true }
]
});
function refreshToolbarTicketInfo(){
// display ticket stats
if (plugin.settings.tickets_open_display || plugin.settings.tickets_due_display || plugin.settings.ticket_unassigned_display){
var displayString = '';
if (plugin.settings.tickets_open_display){
displayString += '<span><strong>Open:</strong> ' + SPICEWORKS.data.Ticket.find('all', {filter:'open'}).length + '</span>';
}
if (plugin.settings.tickets_due_display){
displayString += '<span><strong>Past Due:</strong> ' + SPICEWORKS.data.Ticket.find('all', {filter:'past_due'}).length + '</span>';
}
if (plugin.settings.tickets_unassigned_display){
displayString += '<span><strong>Unassigned:</strong> ' + SPICEWORKS.data.Ticket.find( 'all', {filter:'unassigned'}).length + '</span>';
}
var toolbarTicketInfo = $('main-toolbar').down('span.right span.toolbar_ticket_info');
if (toolbarTicketInfo){
toolbarTicketInfo.remove();
}
$('main-toolbar').down('span.right').insert({top:'<span class="toolbar_ticket_info">' + displayString + '</span>'});
}
}
SPICEWORKS.app.helpdesk.ready(function(){
// set styling
SPICEWORKS.utils.addStyle("\
span.toolbar_ticket_info{margin-right:20px;padding:0 5px;border:1px solid #999;}\
span.toolbar_ticket_info span{margin-right:5px;}\
#related_to_summary{display:none;clear:both;border:1px solid #ccc;padding:10px;margin:5px 0;overflow:hidden;}\
#related_to_summary ul{margin:0;padding:0;text-align:left;}\
#related_to_summary p{float:right;}\
");
// mark past due ticket rows
$('td.past_due').each(function(item){
item.up().setStyle({backgroundColor: plugin.settings.past_due_color});
});
refreshToolbarTicketInfo();
});
SPICEWORKS.app.helpdesk.ticket.closed(function(){
refreshToolbarTicketInfo();
});
SPICEWORKS.app.helpdesk.ticket.ready(function(){
// color private messages
$('li.private').each(function(item){
item.setStyle({backgroundColor: plugin.settings.private_note_color})
});
// add device summary
var deviceLink = $('related_to_property').down('.value a');
if(deviceLink) {
var deviceURL = deviceLink.readAttribute('href');
var startIndex = deviceURL.indexOf('devices/');
if(startIndex != -1) {
var substring = deviceURL.substring(startIndex);
var deviceID = substring.gsub(/[^\d]/, '');
var device = SPICEWORKS.data.Device.find(deviceID);
if(device) {
var displayInfo = '<div id="related_to_summary"><ul>'
var listStyle = '<li>'
if(device.ip_address && !device.ip_address.empty()) {
displayInfo += listStyle + '<strong>IP:</strong> ' + device.ip_address + '</li>';
}
if(device.mac_address && !device.mac_address.empty()) {
displayInfo += listStyle + '<strong>MAC:</strong> ' + device.mac_address + '</li>';
}
if(device.manufacturer && !device.manufacturer.empty()) {
displayInfo += listStyle + '<strong>Vendor:</strong> ' + device.manufacturer + '</li>';
}
if(device.current_user && !device.current_user.empty()) {
displayInfo += listStyle + '<strong>Last Login:</strong> ' + device.current_user + '</li>';
}
if(device.primary_owner_name && !device.primary_owner_name.empty()) {
displayInfo += listStyle + '<strong>Owner:</strong> ' + device.primary_owner_name + '</li>';
}
if(device.asset_tag && !device.asset_tag.empty()) {
displayInfo += listStyle + '<strong>Asset Tag:</strong> ' + device.asset_tag + '</li>';
}
if(device.operating_system && !device.operating_system.empty()) {
displayInfo += listStyle + '<strong>OS:</strong> ' + device.operating_system + '</li>';
}
if(device.serial_number && !device.serial_number.empty()) {
displayInfo += listStyle + '<strong>Serial No:</strong> ' + device.serial_number + '</li>';
}
displayInfo += '</ul><p><a href="#" onclick="new Effect.BlindUp(\'related_to_summary\', {duration:0.20}); return false;">hide</a></p></div>';
$('related_to_section').insert({after: displayInfo});
deviceLink.insert({after: ' (<a href="#" onclick="new Effect.BlindDown(\'related_to_summary\', {duration:0.20}); return false;">info</a>)'})
}
}
}
});
Tuesday, June 30, 2009
Updated the spiceworks helpdesk customization plugin
Just a quick update with the source code. I added a field to the toolbar thanks to Paul_Maxim and now all of those fields are optional. Oh yeah, I separated the css out from the inline styling.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment