Mike Phares 141f9c084a AzureDevOpsRepository
Switch to DataGrid
Markdown links
Add css for files, leo and mes
copySelectedB
Logic for other collections
monospace
Ticks bug fix, default to *.wc files and formatting
2024-10-14 12:24:43 -07:00

170 lines
5.9 KiB
JavaScript

var _apiUrl = null;
function compareFunction(a, b) {
return a.Priority[0] - b.Priority[0] || a.Id - b.Id;
}
function showOne(rowData) {
if (rowData == null)
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] == null)
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 == null)
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 == null)
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 == null || 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 getTimeCriticality(workItemType, timeCriticality) {
var result;
if (workItemType === "Bug")
result = "0-Bug";
else if (timeCriticality == null || timeCriticality === 0)
result = "9-Null";
else if (timeCriticality === 1)
result = `${timeCriticality}-QSM`;
else if (timeCriticality === 2)
result = `${timeCriticality}-Qual`;
else if (timeCriticality === 3)
result = `${timeCriticality}-Eff`;
else
result = "8-Not";
return result;
}
function getWorkItems(data) {
var parent;
var workItem;
var workItems = [];
for (var i = data.length - 1; i > -1; i--) {
parent = data[i].Parent;
workItem = data[i].WorkItem;
if (workItem.WorkItemType !== 'Feature')
continue;
if (workItem.IterationPath !== 'ART SPS')
continue;
if (workItem.Tags != null && workItem.Tags.includes("Ignore"))
continue;
if ((document.title.indexOf('HiRel') > -1 && workItem.AreaPath !== 'ART SPS\\LEO') || (document.title.indexOf('Mesa') > -1 && workItem.AreaPath !== 'ART SPS\\MES'))
continue;
if (parent === null) {
workItem["ParentId"] = null;
workItem["ParentTitle"] = null;
workItem["ParentState"] = null;
}
else {
workItem["ParentId"] = parent["Id"];
workItem["ParentTitle"] = parent["Title"];
workItem["ParentState"] = getState(parent["State"]);
}
workItem["State"] = getState(workItem["State"])
workItem["Priority"] = getPriority(workItem["WorkItemType"], workItem["Priority"])
workItem["TimeCriticality"] = getTimeCriticality(workItem["WorkItemType"], workItem["TimeCriticality"])
workItems.push(workItem);
}
workItems.sort(compareFunction);
return workItems;
}
function sendValue(element, page, id) {
$.post(_apiUrl + "save", { time: new Date().getTime(), id: id, page: page, value: element.value }, function (data) {
console.log("Posted value of " + element.value + " for " + id + " on page " + page);
});
}
function setWorkItems(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>Value</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>" +
'<select onchange="sendValue(this, \'risk\', ' + record.Id + ')">' +
'<option value="9">Unknown</option>' +
'<option value="1">High (Most Risk)</option>' +
'<option value="2">Medium</option>' +
'<option value="3">Low</option>' +
'</select>' +
"</td></tr>";
}
element.innerHTML = html.replaceAll(">null<", ">&nbsp;<");
}
function initIndex(url, apiUrl) {
_apiUrl = apiUrl;
$.getJSON(url, { _: new Date().getTime() }, function (data) {
var workItems = getWorkItems(data);
console.log(data.length);
if (data.length > 0)
console.log(data[0]);
setWorkItems(workItems);
});
$("#HeaderGrid").on("dblclick", "tr", loadOne);
}