var _apiUrl = null; function compareFunction(a, b) { return b.PollValue.split('-')[0] - a.PollValue.split('-')[0] || a.Priority[0] - b.Priority[0] || b.ParentId - a.ParentId || a.Id - b.Id; } function showOne(rowData) { if (rowData == null) return; var data = []; data.push({ name: "Edit in ADO", value: 'Edit in ADO ' + rowData["Id"] + '' }); 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 getPollValue(priority, pollValue) { var result; if (pollValue === undefined || pollValue.Records.length === undefined || pollValue.Records.length === 0) result = priority; else { if (pollValue.Average !== null) result = priority; if (pollValue.Average > 2) result = `${pollValue.Average}-1-${pollValue.Count}-High (Most Critical)`; else if (pollValue.Average > 1) result = `${pollValue.Average}-2-${pollValue.Count}-Medium`; else if (pollValue.Average > 0) result = `${pollValue.Average}-3-${pollValue.Count}-Low`; else result = priority; } return result; } function getWorkItems(data, dataB) { 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 ((window.location.href.indexOf('=LEO') > -1 && workItem.AreaPath !== 'ART SPS\\LEO') || (window.location.href.indexOf('=MES') > -1 && workItem.AreaPath !== 'ART SPS\\MES')) continue; if (parent === null) { workItem["ParentId"] = 9999999; 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"]) var priority = getPriority(workItem["WorkItemType"], workItem["Priority"]) workItem["Priority"] = priority; workItem["PollValue"] = getPollValue(priority, dataB[workItem.Id]); workItems.push(workItem); } workItems.sort(compareFunction); return workItems; } function sendValue(element, page, id) { var body = { time: new Date().getTime(), id: id, page: page, value: element.value }; $.post(_apiUrl + "save", body) .done(function (msg) { console.log("Posted value of " + element.value + " for " + id + " on page " + page + " " + msg); }) .fail(function (xhr, textStatus, errorThrown) { alert(textStatus); }); } function setWorkItems(workItems, page, description) { var record; var html = "