Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 6

// // // //

==UserScript== @name UWQ Tweaks @namespace Stephen Carter @description Tweaks the UWQ page

// // // // // // // // // // // // // // // // // // // // // // // // // // // // //

@include http://corpusclb2b1/uwq/* @include http://corpusclb2b1.corp.emc.com/uwq/* @include http://corpusapp49/uwq/* @include http://corpusapp49.corp.emc.com/uwq/* @include http://corpusclb2b1/uwq/UWQViewer.aspx @include http://qmt.corp.emc.com/UWQViewer.aspx @exclude @version 1.1 ==/UserScript== bugs/comments/suggestions: carter_stephen@emc.com Tweaks * "Time" field shows the number of minutes remaining before SLA is hit. S1 - 15 mins S2 - 2 hours s3 - 3 hours S4 - 4 hours S5 - 8 hours S6 - 8 hours s7x - treated as their equivalent severities * Highlighting: Yellow within 30mins of SLA. Orange within 10mins of SLA. Red when the SLA missed. "Status" field for "Open - Unassigned" SRs is highlighted green. * Reordered by the time to SLA. * Grouped hourly by time to SLA. * S7H,S7M,S7L SRs are treated S1,S2,S3

var oBody=document.getElementsByTagName("body")[0]; // Create Tweaked UWQ var uwqTable=document.createElement("table"); var uwqTbody=document.createElement("tbody"); uwqTbody.setAttribute("id", "uwqTweaked"); uwqTable.setAttribute("style", "width: 100%; font-family: Book Antiqua; font-siz e: 9pt;"); uwqTable.cellPadding="2"; uwqTable.cellSpacing="1"; var sr_header = document.getElementById("ctl00_ContentPlaceHolder1_gvSRS").lastC hild.firstChild.cloneNode(true); var sr_header_count = sr_header.childNodes.length-2; uwqTbody.appendChild(sr_header); var 3-4 var for sr_timeline_headers = ["Missed :-(", "0-1 hour", "1-2 hours", "2-3 hours", " hours", "4+ hours", "&nbsp"]; sr_timeline_section = 0; each (header in sr_timeline_headers) { var srMarkerRow=document.createElement("tr"); var srMarkerCol=document.createElement("td");

srMarkerRow.setAttribute("id", "section"+sr_timeline_section); srMarkerCol.innerHTML = header; srMarkerCol.colSpan = sr_header_count; srMarkerCol.setAttribute("style", "color: #FFFFFF; background-color: #00 6699; font-weight: 900; font-size: 7pt; padding: 4px;"); srMarkerRow.appendChild(srMarkerCol); uwqTbody.appendChild(srMarkerRow); sr_timeline_section++; } uwqTable.appendChild(uwqTbody); // Insert at beginning of page document.body.insertBefore(uwqTable, document.body.firstChild); // Create Tweaked UWQ var uwqStats=document.createElement("div"); uwqStats.setAttribute("id", "uwqStats"); uwqStats.setAttribute("style", "font-weight: 900; font-size: 10pt; color: #00669 9; font-family: Book Antiqua;"); // Insert at beginning of page document.body.insertBefore(uwqStats, document.body.firstChild); // Tweak it!!! tweakUWQ(); // Hide the original table //document.getElementById("ctl00_ContentPlaceHolder1_UpdatePanel1").setAttribute ("style", "visibility: hidden; display: none;") function tweakUWQ(event) { var sr_table=document.getElementById("ctl00_ContentPlaceHolder1_gvSRS"); /// SLA S1 S2 S3 S4 S5 /// mins 15m 2h 3h 4h 8h var mins_s = [0, 15, 120, 180, 240, 480, ]; var colors = new Array(); colors["red"] = "#FF3333"; colors["orange"] = "#FF9933"; colors["yellow"] = "#FFFF33"; colors["green"] = "#99FF33"; colors["blue"] = "#3399FF"; colors["white"] = "#EEEEFF"; // Red // Orange // Yellow // Green // Blue // White (almost)

// SR Colors var sr_colors = new Array(); sr_colors["past"] = colors["red"]; sr_colors["10mins"] = colors["orange"]; sr_colors["30mins"] = colors["yellow"]; sr_colors["default"] = colors["white"]; // SR Stats var sr_stats = new Array(); // Save column headers var sr_data_headers = sr_table.lastChild.firstChild.cloneNode(true); sr_data_headers.setAttribute("id", "section");

var sr_cols = new Array(); for (var col=1; col < sr_table.lastChild.firstChild.childNodes.length-1; col++) { this_html = sr_table.lastChild.firstChild.childNodes[col].innerH TML; if (this_html == "Sev") { sr_cols["sev"] = col; } else if (this_html == "Time\n(d:h:m)") { sr_cols["time"] = col; } else if (this_html == "Group") { sr_cols["group"] = col; } else if (this_html == "Number") { sr_cols["number"] = col; } else if (this_html == "Status") { sr_cols["status"] = col; } } // Read all the SR rows in to an array var sr_data = new Array(); for (var row=1; row < sr_table.lastChild.childNodes.length-1; row++) { sr_data[row-1] = sr_table.lastChild.childNodes[row].cloneNode(tr ue); // save the row } var sr_data_unsorted = new Array(); // Start parsing the SR for (var row=0; row < sr_data.length; row++) { this_sr = sr_data[row]; // Default color/bold for cells this_color = sr_colors["default"]; this_font_weight = 400; //-------------------------------------------------------------------------// Get the details // Severity this_html_sev = this_sr.childNodes[sr_cols["sev"]].innerHTML.sub str(1,1); // Status this_html_status = this_sr.childNodes[sr_cols["status"]].innerHT ML; // Group this_html_group = this_sr.childNodes[sr_cols["group"]].innerHTML ; // Number this_html_number = this_sr.childNodes[sr_cols["number"]].innerHT ML; // Fix for S7x dialhomes if (this_html_sev == "7") { this_s7_sev = this_sr.childNodes[sr_cols["sev"]].innerHT ML.substr(2,2); if (this_s7_sev == "H") { this_html_sev = "1";

} else if (this_s7_sev == "M") { this_html_sev = "2"; } else if (this_s7_sev == "L") { this_html_sev = "3"; } } // Time this_html_time = this_sr.childNodes[sr_cols["time"]].innerHTML.s plit("<")[0]; // Get the number of mins the SR has been in the queue this_time = this_html_time.split(":"); this_mins_inqueue = (this_time[0]*24*60) + (this_time[1]*60) + ( this_time[2]*1); // Days + Hours + Mins // Get the mins remaining based on SLA this_mins_remain = mins_s[this_html_sev] - this_mins_inqueue; if (this_mins_remain <= 0) { this_html_remain = ""; } else if (this_mins_remain <= 30) { this_html_remain = "<br /><strong><font style='font-size : 10pt;'>" + this_mins_remain + "</font> " + (message = (this_mins_remain == 1) ? "min" : "mins") + "</strong>"; } else { this_html_remain = "<br />" + this_mins_remain + " mins" ; } this_sr.childNodes[sr_cols["time"]].innerHTML = this_html_time + this_html_remain; // Count the number of SRs in each Queue if (sr_stats[this_html_group] == undefined) { sr_stats[this_html_group] = 1; } else { sr_stats[this_html_group] += 1; } //-------------------------------------------------------------------------// Change the SR color based on the SLA if (this_mins_remain <= 0) { // Missed SLA :-( this_color = sr_colors["past"]; } else if (this_mins_remain <= 10) { // Approaching SLA :-o this_color = sr_colors["10mins"]; } else if (this_mins_remain <= 30) { // Approaching SLA :-o this_color = sr_colors["30mins"]; } //-------------------------------------------------------------------------// Severity 1 & 7H if (this_html_sev == "1") { this_font_weight = 1000; // Make all S1/S7 bold this_sr.childNodes[sr_cols["sev"]].style.fontSize = "16p t"; // Make font larger // Severity 2 }else if (this_html_sev == "2") { // Severity 3

}else if (this_html_sev == "3") { // Severity 4 }else if (this_html_sev == "4") { } // Change the color/boldness for (var col=1; col < this_sr.childNodes.length-1; col++) { this_sr.childNodes[col].style.fontWeight = this_font_wei ght; this_sr.childNodes[col].bgColor = this_color; } // If "Open - Unassigned" Mark green if (this_html_status == "Open - Unassigned") { this_sr.childNodes[sr_cols["status"]].bgColor = colors[" green"]; } else { this_sr.childNodes[sr_cols["status"]].bgColor = colors[" blue"]; } // Need to tweak this to add mins_remain at start of row var timeCell=document.createElement("td"); timeCell.setAttribute("style", "visibility: hidden; display: non e;"); timeCell.innerHTML = this_mins_remain; this_sr.appendChild(timeCell); } //-------------------------------------------------------------------------// Create the stats for the top of the page var sr_html_stats=document.getElementById("uwqStats"); sr_html_stats.innerHTML = "Total: " + sr_data.length + " ~"; for ( var i in sr_stats ) { sr_html_stats.innerHTML = sr_html_stats.innerHTML + "&nbsp;" + i + "&nbsp;(" + sr_stats[i] + ")&nbsp;"; } // Sort by mins remaining var sr_sort; do { sr_sort=0; for (var row=0; row < sr_data.length-1; row++) { if (parseInt(sr_data[row].lastChild.innerHTML) > parseIn t(sr_data[row+1].lastChild.innerHTML)) { var sr_temp = sr_data[row]; sr_data[row] = sr_data[row+1]; sr_data[row+1] = sr_temp; sr_sort=1; } } } while (sr_sort!=0); // Remove existing elements var uwq_tweaked=document.getElementById("uwqTweaked"); for (var uwq_count=1; uwq_count<uwq_tweaked.childNodes.length; uwq_count ++) {

if (uwq_tweaked.childNodes[uwq_count].id.substr(0,7) != "section ") { uwq_tweaked.removeChild(uwq_tweaked.childNodes[uwq_count ]); // Remove uwq_count--; // Decrement count as row has just been del eted } } // Create Tweaked UWQ for (var sr_row = 0; sr_row < sr_data.length; sr_row++) { var this_sec; this_sr_time = sr_data[sr_row].childNodes[sr_data[sr_row].childN odes.length-1].innerHTML if (this_sr_time <= 0) { this_sec = 0; } else if (this_sr_time <= 60) { this_sec = 1; } else if (this_sr_time <= 120) { this_sec = 2; } else if (this_sr_time <= 180) { this_sec = 3; } else if (this_sr_time <= 240) { this_sec = 4; } else if (this_sr_time <= 480) { this_sec = 5; } uwq_tweaked.insertBefore(sr_data[sr_row],document.getElementById ("section"+(this_sec+1))); } // Refresh after 3secs. Until I figure out how to update when the page a uto refreshes window.setTimeout(tweakUWQ, 5000); }

You might also like