Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
399 changes: 332 additions & 67 deletions src/GenericDashboard.ts

Large diffs are not rendered by default.

286 changes: 235 additions & 51 deletions src/MESQA-Config-RF.json

Large diffs are not rendered by default.

633 changes: 546 additions & 87 deletions src/MHCQA-Config-RF.json

Large diffs are not rendered by default.

37 changes: 30 additions & 7 deletions src/api/Matrix.Labels.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,52 @@
/// <reference path="../../lib/core.d.ts" />
/// <reference path="../../lib/admin.d.ts" />
/// <reference path="./Matrix.d.ts" />
/// <reference path="./Matrix.REST.ts" />

namespace Matrix {
export namespace Labels {
/**
* Get the label history for all items in a project
*/
export function projectLabelHistory(): Promise<XRLabelEntry[]> {
return new Promise<XRLabelEntry[]>((resolve, reject) => {
export function projectLabelHistory(resourceId: string, resourceType: string): Promise<resourcesData> {
return new Promise<resourcesData>((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Matrix.REST.projectGETRequest("/labelhistory")
.then((data: XRLabelHistory) => resolve(data.entries as XRLabelEntry[]))
Matrix.REST.projectGETRequest("/labelhistory")
.then((data: XRLabelHistory) => resolve({id:resourceId,type:resourceType,source:data.entries}))
.catch((error) => reject(error));
});
}

/**
* Get needles by category and field id for all items in a project
*/
export function getNeedlesByCategoryAndFiledId(category: string, fieldId: Number): Promise<XRTrimNeedleItem[]> {
return new Promise<XRTrimNeedleItem[]>((resolve, reject) => {
export function getNeedlesByCategoryAndFiledId(resourceId: string, resourceType: string, category: string, fieldId: Number): Promise<resourcesData> {
return new Promise<resourcesData>((resolve, reject) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
Matrix.REST.projectGETRequest("/needle?search=mrql:category="+category+"&fieldsOut="+fieldId)
.then((data: XRTrimNeedle) => resolve(data.needles as XRTrimNeedleItem[]))
.then((data: XRTrimNeedle) => resolve({id:resourceId,type:resourceType,source:data.needles}))
.catch((error) => reject(error));
});
}

/**
* Get needles by category and field id for all items in a project
*/
// export function getNeedlesBySearch(resourceId: string, resourceType: string, searchParams: string): Promise<resourcesData> {
// return new Promise<resourcesData>((resolve, reject) => {
// Matrix.REST.projectGETRequest("/needle?search=mrql:"+searchParams)
// .then((data: XRTrimNeedle) => resolve({id:resourceId,type:resourceType,source:data.needles}))
// .catch((error) => reject(error));
// });
// }

/**
* Get needles by category and field id for all items in a project
*/
export function getNeedlesBySearch(resourceId: string, resourceType: string, category: string, fieldId: Number): Promise<resourcesData> {
return new Promise<resourcesData>((resolve, reject) => {
Matrix.REST.projectGETRequest("/needle?search=mrql:category="+category+"&fieldsOut="+fieldId+"&labels=1")
.then((data: XRTrimNeedle) => resolve({id:resourceId,type:resourceType,source:data.needles}))
.catch((error) => reject(error));
});
}
Expand Down
8 changes: 8 additions & 0 deletions src/api/Matrix.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/// <reference path="../../lib/core.d.ts" />
/// <reference path="../../lib/admin.d.ts" />

interface resourcesData {
id: string;
type: string;
source: XRLabelEntry[] | XRTrimNeedleItem[];
}
196 changes: 195 additions & 1 deletion src/commons/Commons.GenericFunctionalities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,17 @@ namespace Commons {
let avgData: avgObject[] = [];
let closureData: closureObject[] = [];
let trackerData: trackerObject[] = [];
let groupByNcrDeptData: groupByNcrDeptObject[] = [];
let groupByNcrAuditorData: groupByNcrAuditorObject[] = [];
let dateRangeCompareData: dateRangeCompareObject[] = [];
let groupByStackCurrentLabelData: groupByStackCurrentData[] = [];
let groupByObjectCurrentLabelData: groupByObjectCurrentData[] = [];
let closureLabelCurrentData: closureObjectCurrentData[] = [];
let dateRangeCompareCurrentLabelData: groupByObjectCurrentData[] = [];
let trackerLabelCurrentData: Map<string, trackerObjectCurrentData> = new Map<string, trackerObjectCurrentData>();
let groupByNcrDeptCurrentLabelData: groupByNcrDeptCurrentData[] = [];
let currentAuditorInfoData: auditorInfoCurrentData[] = [];
let currentAuditFindingsData: auditFindingsCurrentData[] = [];
let operandsData: Map<string, operandObjectData> = new Map<string, operandObjectData>();

category.functionalities.forEach(functionality => {
Expand Down Expand Up @@ -325,7 +330,6 @@ namespace Commons {
}
break;
case 'dateRangeComapre':

let dateRangeComapreObject: dateRangeCompareObject = {
id: functionality.id,
dataSourceType: functionality.dataSourceType,
Expand All @@ -341,6 +345,70 @@ namespace Commons {
};
dateRangeCompareData.push(dateRangeComapreObject);
break;
case 'groupByNcrDept':
let ncOptions = [];
let groupByNcrDeptWiseData = [];
let groupByNcrDeptInitials = Array(functionality.labels.length).fill(0);
let fieldAuditFindings = IC.getFieldByName(category.id,functionality.sourceTableName);
let ncCatColumn = fieldAuditFindings.parameterJson.columns.find(col=>col.name == functionality.sourceTableColumnName);
let ncDropDownOptions = IC.getDropDowns(ncCatColumn.options.setting).pop();
if( ncDropDownOptions && ncDropDownOptions.value && ncDropDownOptions.value.options){
ncOptions = ncDropDownOptions.value.options;
for( let option of ncDropDownOptions.value.options){
groupByNcrDeptWiseData.push([option.label, ...groupByNcrDeptInitials]);
}
}
let groupByNcrDeptObject: groupByNcrDeptObject = {
id: functionality.id,
dataSourceType: functionality.dataSourceType,
renderChart: functionality.renderChart,
sourceTableName: functionality.sourceTableName,
sourceTableColumnName: functionality.sourceTableColumnName,
labels: functionality.labels,
labelsDesc: functionality.labelsDesc,
ncOptions: ncOptions,
ncCatColumnField: ncCatColumn.field,
groupByNcrDeptWiseData: groupByNcrDeptWiseData,
currentLabelData: groupByNcrDeptCurrentLabelData
};
groupByNcrDeptData.push(groupByNcrDeptObject);
break;
case 'groupByNcrAuditor':
let groupByNcrAuditorWiseData = [
['x'],
['No of audits performed'],
['No of NC given'],
['NC ratio']
];
let fieldAuditorInfo = IC.getFieldByName(category.id,functionality.auditorSourceTableName);
let auditorTypeColumn = fieldAuditorInfo.parameterJson.columns.find(col=>col.name == functionality.auditorTypeColumnName);
let auditorNameColumn = fieldAuditorInfo.parameterJson.columns.find(col=>col.name == functionality.auditorNameColumnName);
let auditorDropDownOptions = IC.getDropDowns(auditorTypeColumn.options.setting).pop();
let auditorOptionId = "";
if( auditorDropDownOptions && auditorDropDownOptions.value && auditorDropDownOptions.value.options){
for( let option of auditorDropDownOptions.value.options){
if(option.label == functionality.auditorOptionLabel){
auditorOptionId = option.id;
}
}
}
let groupByNcrAuditorObject: groupByNcrAuditorObject = {
id: functionality.id,
dataSources: functionality.dataSources,
renderChart: functionality.renderChart,
auditorSourceTableName: functionality.auditorSourceTableName,
auditorTypeColumnName: functionality.auditorTypeColumnName,
auditorNameColumnName: functionality.auditorNameColumnName,
auditorOptionLabel: functionality.auditorOptionLabel,
auditorOptionId: auditorOptionId,
auditorTypeColumnField: auditorTypeColumn.field,
auditorNameColumnField: auditorNameColumn.field,
groupByNcrAuditorWiseData: groupByNcrAuditorWiseData,
currentAuditorInfoData: currentAuditorInfoData,
currentAuditFindingsData: currentAuditFindingsData
};
groupByNcrAuditorData.push(groupByNcrAuditorObject);
break;
};

});
Expand All @@ -352,6 +420,8 @@ namespace Commons {
groupByStateData: groupByStateData,
groupByStateOverdueData: groupByStateOverdueData,
groupByStackData: groupByStackData,
groupByNcrDeptData: groupByNcrDeptData,
groupByNcrAuditorData: groupByNcrAuditorData,
avgData: avgData,
closureData: closureData,
trackerData: trackerData,
Expand Down Expand Up @@ -1097,5 +1167,129 @@ namespace Commons {

}

export function processGroupByNcrDeptObjectData(groupByNcrDeptObject: groupByNcrDeptObject,
groupByNcrDeptObjectDataSource: XRTrimNeedleItem[]) {

for (const item of groupByNcrDeptObjectDataSource) {
if(item.labels){
let itemDeptIndex = -1;
for(const label of groupByNcrDeptObject.labels){
if(item.labels.includes(label)){
let labelIndex = groupByNcrDeptObject.labels.findIndex(labelCode => labelCode === label);
itemDeptIndex = labelIndex;
break;
}
}

if(itemDeptIndex > 0){
if(item.fieldVal.length == 1){
let auditFindingTable = JSON.parse(item.fieldVal[0].value);
for( let auditFindingLine of auditFindingTable){
let ncId = auditFindingLine[groupByNcrDeptObject.ncCatColumnField];
let ncOption = groupByNcrDeptObject.ncOptions.find(ncOption => ncOption.id === ncId);
groupByNcrDeptObject.groupByNcrDeptWiseData.forEach(ncDeptWiseData => {
if(ncDeptWiseData[0] == ncOption.label){
ncDeptWiseData[itemDeptIndex+1] += 1;
}
});

let groupByNcrDeptCurrentData: groupByNcrDeptCurrentData = {
id: item.itemOrFolderRef,
creationDate: new Date(item.creationDate),
labels: item.labels,
ncLabel: ncOption.label
};

groupByNcrDeptObject.currentLabelData.push(groupByNcrDeptCurrentData);

}
}
}
}
}
}

export function processGroupByNcrAuditorObjectData(groupByNcrAuditorObject: groupByNcrAuditorObject,
auditFindingsDataSource: XRTrimNeedleItem[],
auditorinfoDataSource: XRTrimNeedleItem[],
) {

let auditorsData = [];
let auditCountData = [];
let auditItemsData = [];
let auditNcCountData = [];
let auditNcRatio = [];

for (const auditInfoItem of auditorinfoDataSource) {
if(auditInfoItem.fieldVal.length == 1){
let auditInfoTable = JSON.parse(auditInfoItem.fieldVal[0].value);
for( let auditInfoLine of auditInfoTable){
let auditorOptionId = auditInfoLine[groupByNcrAuditorObject.auditorTypeColumnField];
if(auditorOptionId == groupByNcrAuditorObject.auditorOptionId){
let auditorName = auditInfoLine[groupByNcrAuditorObject.auditorNameColumnField];

let auditorInfoCurrentData: auditorInfoCurrentData = {
id: auditInfoItem.itemOrFolderRef,
creationDate: new Date(auditInfoItem.creationDate),
auditorName: auditorName,
auditorOptionId: auditorOptionId
};

groupByNcrAuditorObject.currentAuditorInfoData.push(auditorInfoCurrentData);

let auditorIndex = auditorsData.findIndex(auditor => auditor === auditorName);
if(auditorIndex > -1){
auditCountData[auditorIndex] += 1;
auditItemsData[auditorIndex].push(auditInfoItem.itemOrFolderRef);
}else{
auditorsData.push(auditorName);
auditCountData.push(1);
auditItemsData.push([auditInfoItem.itemOrFolderRef])
auditNcCountData.push(0);
auditNcRatio.push(0);
}
}
}
}
}

for (const auditFindingItem of auditFindingsDataSource) {
if(auditFindingItem.fieldVal.length == 1){
let auditFindingTable = JSON.parse(auditFindingItem.fieldVal[0].value);
let itemIndex = -1;
for( let auditItems of auditItemsData){
itemIndex += 1;
let auditorItemIndex = auditItems.findIndex(itemRefId => itemRefId === auditFindingItem.itemOrFolderRef);
if(auditorItemIndex > 0){
let auditNcCount = auditFindingTable.length;
auditNcCountData[itemIndex] += auditNcCount;

let auditFindingsCurrentData: auditFindingsCurrentData = {
id: auditFindingItem.itemOrFolderRef,
creationDate: new Date(auditFindingItem.creationDate),
auditNcCount: auditNcCount
};

groupByNcrAuditorObject.currentAuditFindingsData.push(auditFindingsCurrentData);
break;
}
}
}
}

auditorsData.forEach((auditor, index) => {
if(auditNcCountData[index] !== 0){
auditNcRatio[index] = Math.round(((auditNcCountData[index]/auditCountData[index]) + Number.EPSILON) * 100) / 100;
}
});

groupByNcrAuditorObject.groupByNcrAuditorWiseData = [
['x', ...auditorsData],
['No of audits performed',...auditCountData],
['No of NC given', ...auditNcCountData],
['NC ratio', ...auditNcRatio]
];
}

}
}
52 changes: 52 additions & 0 deletions src/interfaces/generic-dashboard.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ interface trackerObjectCurrentData {
itemStateDays: Map<string, Number>;
}

interface groupByNcrDeptCurrentData {
id: string;
creationDate: Date;
labels: string;
ncLabel: string;
}

interface auditorInfoCurrentData {
id: string;
creationDate: Date;
auditorName: string;
auditorOptionId: string;
}

interface auditFindingsCurrentData {
id: string;
creationDate: Date;
auditNcCount: Number;
}

interface operandObjectData {
operand: string;
labelsState: Map<string, Boolean>;
Expand Down Expand Up @@ -79,6 +99,36 @@ interface groupByStateObject {
currentLabelData: groupByObjectCurrentData[];
}

interface groupByNcrDeptObject {
id: string;
dataSourceType: string;
renderChart: string;
sourceTableName: string;
sourceTableColumnName: string;
labels: any[];
labelsDesc: any[];
ncOptions: any[];
ncCatColumnField: string;
groupByNcrDeptWiseData: any[];
currentLabelData: groupByNcrDeptCurrentData[];
}

interface groupByNcrAuditorObject {
id: string;
dataSources: string[];
renderChart: string;
auditorSourceTableName: string;
auditorTypeColumnName: string;
auditorNameColumnName: string;
auditorOptionLabel: string;
auditorOptionId: string;
auditorTypeColumnField: string;
auditorNameColumnField: string;
groupByNcrAuditorWiseData: any[];
currentAuditorInfoData: auditorInfoCurrentData[];
currentAuditFindingsData: auditFindingsCurrentData[];
}

interface groupByStateOverDueObject extends groupByStateObject {
dataSources: any[];
OpenItemsDueDateMap: Map;
Expand Down Expand Up @@ -178,6 +228,8 @@ interface ByCategoryLabelData {
groupByStateData: groupByStateObject[];
groupByStackData: groupByStackObject[];
groupByStateOverdueData: groupByStateOverDueObject[];
groupByNcrDeptData: groupByNcrDeptObject[];
groupByNcrAuditorData: groupByNcrAuditorObject[];
avgData: avgObject[];
closureData: closureObject[];
trackerData: trackerObject[];
Expand Down