Friday, June 19, 2009

Spiceworks 4.0 released, helpdesk customization plugin updated

I got in to work today and found out that a final version of Spiceworks 4.0 had been released. That was very exciting as they have added a network map and carbon-copying people on helpdesk tickets. Those were the two features that I wanted to add the most. So I went ahead and upgraded my 3.5 installation and everything went as smooth as butter.

I then went and checked my helpdesk and aghhh, the helpdesk customization plugin I helped write was no longer working. That just wouldn't do, so I decided to fix all the things that were broken in it. I also removed the expanding height for the ticket responses box since the height is now liquid with the new version. I also went and shared the new version of the plugin.

It looks like it hasn't been updated with the new release yet and I'm not sure how long it will take, but there is a direct link to the plugin by going here. There is also the new source below. Enjoy.

// ==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.4
// ==/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'}
]
});

function refreshToolbarTicketInfo(){
// display ticket stats
var numOpenTickets = SPICEWORKS.data.Ticket.find('all', {filter:'open'}).length;
var numPastDue = SPICEWORKS.data.Ticket.find('all', {filter:'past_due'}).length;

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" style="margin-right: 40px; padding: 0 5px; border: 1px solid #999;"><strong>Open Tickets:</strong> ' + numOpenTickets + '&nbsp;&nbsp;&nbsp;<strong>Past Due:</strong> ' + numPastDue + '</span>'});
}

SPICEWORKS.app.helpdesk.ready(function(){


// 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" style="display: none; clear: both; border:1px solid #ccc; padding: 10px; margin: 5px 0; overflow: hidden;"><ul style="margin: 0; padding: 0; text-align: left;">'
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 style="float: right;"><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: '&nbsp;&nbsp;(<a href="#" onclick="new Effect.BlindDown(\'related_to_summary\', {duration:0.20}); return false;">info</a>)'})
}
}
}
});

1 comment: