321 lines
12 KiB
JavaScript
321 lines
12 KiB
JavaScript
var _apiUrl = null;
|
|
|
|
function compareFunction(a, b) {
|
|
return b.WeightedShortestJobFirst - a.WeightedShortestJobFirst || b.CoDRank - b.CoDRank || b.ParentId - a.ParentId || a.Id - b.Id;
|
|
}
|
|
|
|
function compareEffortFunction(a, b) {
|
|
return a.Effort - b.Effort || b.ParentId - a.ParentId || a.Id - b.Id;
|
|
}
|
|
|
|
function compareBusinessValueFunction(a, b) {
|
|
return a.BusinessValue - b.BusinessValue || b.ParentId - a.ParentId || a.Id - b.Id;
|
|
}
|
|
|
|
function compareTimeCriticalityFunction(a, b) {
|
|
return a.TimeCriticality - b.TimeCriticality || b.ParentId - a.ParentId || a.Id - b.Id;
|
|
}
|
|
|
|
function compareRiskReductionMinusOpportunityEnablementFunction(a, b) {
|
|
return b.RiskReductionMinusOpportunityEnablement - b.RiskReductionMinusOpportunityEnablement || b.ParentId - a.ParentId || a.Id - b.Id;
|
|
}
|
|
|
|
function compareCostOfDelay(a, b) {
|
|
return b.CoD - b.CoD || b.ParentId - a.ParentId || a.Id - b.Id;
|
|
}
|
|
|
|
function showOne(rowData) {
|
|
if (rowData == undefined)
|
|
return;
|
|
var data = [];
|
|
data.push({ name: "Edit in ADO", value: '<a target="_blank" href="https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/' + rowData["Id"] + '">Edit in ADO ' + rowData["Id"] + '</a>' });
|
|
for (const property in rowData) {
|
|
if (rowData[property] == undefined)
|
|
continue;
|
|
data.push({ name: property, value: rowData[property].toString() });
|
|
}
|
|
$("#AllGrid").igGrid({
|
|
autoGenerateColumns: true,
|
|
dataSource: data,
|
|
width: "100%",
|
|
showHeader: false,
|
|
});
|
|
}
|
|
|
|
function loadOne() {
|
|
var selectedRow = $("#HeaderGrid").data("igGridSelection").selectedRow();
|
|
if (selectedRow == undefined)
|
|
return;
|
|
var rowData = $("#HeaderGrid").data("igGrid").dataSource.dataView()[selectedRow.index];
|
|
showOne(rowData);
|
|
}
|
|
|
|
function detailSelectionChangedRunInfo(evt, ui) {
|
|
if (ui.row.index === 0)
|
|
return;
|
|
var rowData = ui.owner.grid.dataSource.dataView()[ui.row.index];
|
|
showOne(rowData);
|
|
}
|
|
|
|
function getState(state) {
|
|
var result;
|
|
if (state == undefined)
|
|
result = "9-Null";
|
|
else if (state === "New")
|
|
result = `1-${state}`;
|
|
else if (state === "Active")
|
|
result = `2-${state}`;
|
|
else if (state === "Resolved")
|
|
result = `3-${state}`;
|
|
else if (state === "Closed")
|
|
result = `4-${state}`;
|
|
else if (state === "Removed")
|
|
result = `5-${state}`;
|
|
else
|
|
result = `8-${state}`;
|
|
return result;
|
|
}
|
|
|
|
function getPriority(workItemType, priority) {
|
|
var result;
|
|
if (workItemType === "Bug")
|
|
result = "0-Bug";
|
|
else if (priority == undefined || priority === 0)
|
|
result = "9-Null";
|
|
else if (priority === 1)
|
|
result = `${priority}-High`;
|
|
else if (priority === 2)
|
|
result = `${priority}-Med`;
|
|
else if (priority === 3)
|
|
result = `${priority}-Low`;
|
|
else if (priority === 4)
|
|
result = `${priority}-TBD`;
|
|
else
|
|
result = "8-Not";
|
|
return result;
|
|
}
|
|
|
|
function updateRecordCoD(workItem) {
|
|
if (workItem != undefined) {
|
|
if (workItem["Effort"] == undefined)
|
|
workItem["Effort"] = 1;
|
|
if (workItem["BusinessValue"] == undefined)
|
|
workItem["BusinessValue"] = 99999;
|
|
if (workItem["TimeCriticality"] == undefined)
|
|
workItem["TimeCriticality"] = 99999;
|
|
if (workItem["RiskReductionMinusOpportunityEnablement"] == undefined)
|
|
workItem["RiskReductionMinusOpportunityEnablement"] = 99999;
|
|
}
|
|
}
|
|
|
|
function getFibonacci(length) {
|
|
var results = [];
|
|
for (var i = 0; i < length; i++) {
|
|
results.push(21);
|
|
}
|
|
var index = 0;
|
|
var fibonacci = [3, 5, 8, 13, 20];
|
|
var factor = (length / fibonacci.length).toFixed();
|
|
for (var j = 0; j < fibonacci.length; j++) {
|
|
for (var i = 0; i < factor; i++) {
|
|
results[index] = fibonacci[j];
|
|
index += 1;
|
|
}
|
|
}
|
|
// for (var i = 0; i < results.length; i++) {
|
|
// console.log(results[i]);
|
|
// }
|
|
return results;
|
|
}
|
|
|
|
function updateCoD(records) {
|
|
var workItem;
|
|
var collection = [];
|
|
for (var i = 0; i < records.length; i++) {
|
|
workItem = records[i];
|
|
if (workItem.Priority[0] === '2') {
|
|
workItem.EffortFibonacci = 2;
|
|
workItem.BusinessValueFibonacci = 2;
|
|
workItem.TimeCriticalityFibonacci = 2;
|
|
workItem.RiskReductionMinusOpportunityEnablementFibonacci = 2;
|
|
continue;
|
|
}
|
|
else if (workItem.Priority[0] === '3') {
|
|
workItem.EffortFibonacci = 1;
|
|
workItem.BusinessValueFibonacci = 1;
|
|
workItem.TimeCriticalityFibonacci = 1;
|
|
workItem.RiskReductionMinusOpportunityEnablementFibonacci = 1;
|
|
continue;
|
|
}
|
|
collection.push(workItem);
|
|
}
|
|
var fibonacci = getFibonacci(collection.length);
|
|
collection.sort(compareEffortFunction);
|
|
for (var i = 0; i < collection.length; i++) {
|
|
workItem = collection[i];
|
|
workItem.EffortFibonacci = fibonacci[i];
|
|
}
|
|
records.sort(compareEffortFunction);
|
|
for (var i = 0; i < records.length; i++) {
|
|
workItem = records[i];
|
|
workItem.EffortRank = (((i + 1) / records.length) * 100).toFixed();
|
|
}
|
|
collection.sort(compareBusinessValueFunction);
|
|
for (var i = 0; i < collection.length; i++) {
|
|
workItem = collection[i];
|
|
workItem.BusinessValueFibonacci = fibonacci[i];
|
|
}
|
|
records.sort(compareBusinessValueFunction);
|
|
for (var i = 0; i < records.length; i++) {
|
|
workItem = records[i];
|
|
workItem.BusinessValueRank = (((i + 1) / records.length) * 100).toFixed();
|
|
}
|
|
collection.sort(compareTimeCriticalityFunction);
|
|
for (var i = 0; i < collection.length; i++) {
|
|
workItem = collection[i];
|
|
workItem.TimeCriticalityFibonacci = fibonacci[i];
|
|
}
|
|
records.sort(compareTimeCriticalityFunction);
|
|
for (var i = 0; i < records.length; i++) {
|
|
workItem = records[i];
|
|
workItem.TimeCriticalityRank = (((i + 1) / records.length) * 100).toFixed();
|
|
}
|
|
collection.sort(compareRiskReductionMinusOpportunityEnablementFunction);
|
|
for (var i = 0; i < collection.length; i++) {
|
|
workItem = collection[i];
|
|
workItem.RiskReductionMinusOpportunityEnablementFibonacci = fibonacci[i];
|
|
}
|
|
records.sort(compareRiskReductionMinusOpportunityEnablementFunction);
|
|
for (var i = 0; i < records.length; i++) {
|
|
workItem = records[i];
|
|
workItem.RiskReductionMinusOpportunityEnablementRank = (((i + 1) / records.length) * 100).toFixed();
|
|
}
|
|
for (var i = 0; i < records.length; i++) {
|
|
workItem = records[i];
|
|
workItem.CoD = workItem.RiskReductionMinusOpportunityEnablementFibonacci + workItem.TimeCriticalityFibonacci + workItem.BusinessValueFibonacci;
|
|
}
|
|
records.sort(compareCostOfDelay);
|
|
for (var i = 0; i < records.length; i++) {
|
|
workItem = records[i];
|
|
workItem.CoDRank = (((i + 1) / records.length) * 100).toFixed();
|
|
}
|
|
for (var i = 0; i < records.length; i++) {
|
|
workItem = records[i];
|
|
if (workItem.Priority[0] !== '1' && workItem.Priority[0] !== '4') {
|
|
workItem.WeightedShortestJobFirst = 0.000001;
|
|
workItem.WeightedShortestJobFirstRank = 0;
|
|
}
|
|
else {
|
|
workItem.WeightedShortestJobFirstRank = (((i + 1) / records.length) * 100).toFixed();
|
|
workItem.WeightedShortestJobFirst = (workItem.CoD / workItem.EffortFibonacci).toFixed(3);
|
|
}
|
|
}
|
|
}
|
|
|
|
function updateRecordOther(workItem) {
|
|
workItem["State"] = getState(workItem["State"]);
|
|
workItem["Priority"] = getPriority(workItem["WorkItemType"], workItem["Priority"]);
|
|
}
|
|
|
|
function updateRecordParent(parent, workItem) {
|
|
if (parent == undefined) {
|
|
workItem["ParentId"] = 9999999;
|
|
workItem["ParentTitle"] = null;
|
|
workItem["ParentState"] = null;
|
|
workItem["ParentCoD"] = 9999999;
|
|
}
|
|
else {
|
|
workItem["ParentId"] = parent["Id"];
|
|
workItem["ParentCoD"] = parent["CoD"];
|
|
workItem["ParentTitle"] = parent["Title"];
|
|
workItem["ParentState"] = getState(parent["State"]);
|
|
}
|
|
}
|
|
|
|
function getRecords(data) {
|
|
var parent;
|
|
var workItem;
|
|
var records = [];
|
|
for (var i = 0; i < data.length; i++) {
|
|
parent = data[i].Parent;
|
|
workItem = data[i].WorkItem;
|
|
if (workItem.WorkItemType !== 'Feature')
|
|
continue;
|
|
if (workItem.State !== 'Active' && workItem.State !== 'New')
|
|
continue;
|
|
if (workItem.Tags != null && workItem.Tags.includes("Ignore"))
|
|
continue;
|
|
if ((window.location.href.indexOf('=LEO') > -1 && workItem.AreaPath !== 'ART SPS\\LEO') || (window.location.href.indexOf('=MES') > -1 && workItem.AreaPath !== 'ART SPS\\MES'))
|
|
continue;
|
|
updateRecordCoD(parent);
|
|
updateRecordCoD(workItem);
|
|
updateRecordOther(workItem);
|
|
updateRecordParent(parent, workItem);
|
|
records.push(workItem);
|
|
}
|
|
updateCoD(records);
|
|
records.sort(compareFunction);
|
|
return records;
|
|
}
|
|
|
|
function setRecords(workItems) {
|
|
var record;
|
|
var html = "<tr><th>Parent Id</th><th>Parent Title</th><th>Id</th><th>Requester</th><th>Title</th><th>Assigned To</th><th>System(s)</th><th>State</th><th>Priority</th><th>Risk Reduction and/or Opportunity Enablement</th><th>Time Criticality</th><th>Business Value</th><th>CoD</th><th>Effort</th><th>WSJF</th><th>Up</th><th>Down</th></tr>";
|
|
const element = document.getElementById("HeaderGrid");
|
|
for (var i = 0; i < workItems.length; i++) {
|
|
record = workItems[i];
|
|
html += "<tr><td>" + '<a target="_blank" href="https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/' + record.ParentId + '">' + record.ParentId + "</a>" +
|
|
"</td><td>" + record.ParentTitle +
|
|
"</td><td>" + '<a target="_blank" href="https://tfs.intra.infineon.com/tfs/FactoryIntegration/ART%20SPS/_workitems/edit/' + record.Id + '">' + record.Id + "</a>" +
|
|
"</td><td>" + record.Requester +
|
|
"</td><td>" + record.Title +
|
|
"</td><td>" + record.AssignedTo +
|
|
"</td><td>" + record.Tags +
|
|
"</td><td>" + record.State +
|
|
"</td><td>" + record.Priority +
|
|
"</td><td>" + record.RiskReductionMinusOpportunityEnablementRank + '% - ' + record.RiskReductionMinusOpportunityEnablement + ' - ' + record.RiskReductionMinusOpportunityEnablementFibonacci +
|
|
"</td><td>" + record.TimeCriticalityRank + '% - ' +record.TimeCriticality + ' - ' + record.TimeCriticalityFibonacci +
|
|
"</td><td>" + record.BusinessValueRank + '% - ' +record.BusinessValue + ' - ' + record.BusinessValueFibonacci +
|
|
"</td><td>" + record.CoDRank + '% - ' + record.CoD +
|
|
"</td><td>" + record.EffortRank + '% - ' +record.Effort + ' - ' + record.EffortFibonacci +
|
|
"</td><td>" + record.WeightedShortestJobFirst +
|
|
"</td><td><a href='#' class='up'>Up</a></td><td><a href='#' class='down'>Down</a></td></tr>";
|
|
}
|
|
element.innerHTML = html.replaceAll(">null<", "> <");
|
|
}
|
|
|
|
function updateSite() {
|
|
if (window.location.href.indexOf('=LEO') > -1) {
|
|
document.title = document.title.replace("Infineon", "HiRel (Leominster)");
|
|
document.getElementById("siteHeader").innerText = "HiRel (Leominster)";
|
|
}
|
|
else if (window.location.href.indexOf('=MES') > -1) {
|
|
document.title = document.title.replace("Infineon", "Mesa");
|
|
document.getElementById("siteHeader").innerText = "Mesa";
|
|
}
|
|
else {
|
|
document.title = document.title.replace("Infineon", "Infineon");
|
|
document.getElementById("siteHeader").innerText = "Infineon";
|
|
}
|
|
}
|
|
|
|
function initIndex(url, apiUrl) {
|
|
_apiUrl = apiUrl;
|
|
updateSite();
|
|
$.getJSON(url, { _: new Date().getTime() }, function (data) {
|
|
var records = getRecords(data);
|
|
console.log(data.length);
|
|
if (data.length > 0)
|
|
console.log(data[0]);
|
|
setRecords(records);
|
|
$(".up,.down").click(function () {
|
|
var row = $(this).parents("tr:first");
|
|
if ($(this).is(".up")) {
|
|
row.insertBefore(row.prev());
|
|
} else {
|
|
row.insertAfter(row.next());
|
|
}
|
|
});
|
|
});
|
|
$("#HeaderGrid").on("dblclick", "tr", loadOne);
|
|
} |