diff --git a/UI5_Quality_Checks_App/webapp/controller/startpage.controller.js b/UI5_Quality_Checks_App/webapp/controller/startpage.controller.js index 8f361b8..56ba8b9 100644 --- a/UI5_Quality_Checks_App/webapp/controller/startpage.controller.js +++ b/UI5_Quality_Checks_App/webapp/controller/startpage.controller.js @@ -77,8 +77,8 @@ sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) { resultsList.setVisible(true); loginBox.setVisible(false); - var linter = await SRBGitHub.getLatestLintWorkflowRun(); - this.fetchData(linter); + var allResponses = await SRBGitHub.getLatestLintWorkflowRun(); + this.fetchData(allResponses); }, fetchData: async function (linter) { @@ -100,17 +100,25 @@ sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) { repoUrl: "https://github.com/" + repoResult.repository.owner.login + "/" + repoResult.repository.name, filename: repoResult.path, fileUrl: repoResult.html_url, - owner: repoResult.repository.owner.login + owner: repoResult.repository.owner.login, + repository: repoResult.repository }; var file = await SRBGitHub.getFileOfRepo(repoResult.repository.name, repoResult.path, repoResult.repository.owner.login); var version = await SRBGitHub.detectUI5VersionInFileV2(file); - linter.forEach((lint) => { + for (const lint of linter) { if (lint) { - if (repoResult.repository.name === lint.head_repository.name) version.linter = lint; + if (repoResult.repository.name === lint.head_repository.name) { + version.linter = lint; + var latestJobs = await SRBGitHub.getLatestLintWorkflowJob(repoResult.repository.name, lint.id); + for (const job of latestJobs) { + if (job.name.includes("linter")) version.allLintJobs.push(job); + else if (job.name.includes("build")) version.allBuildJobs.push(job); + } + } } - }); + } if (version.isMinVersion === true) { noVersionFound.push(repoResult.repository.name); } else { @@ -118,28 +126,38 @@ sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) { that.addRow(resultRecord); } } + return noVersionFound; }, fetchManifestData: async function (manifestFiles, linter) { var that = this; + for (const manifestResult of manifestFiles) { var resultRecord = { repo: manifestResult.repository.name, repoUrl: "https://github.com/" + manifestResult.repository.owner.login + "/" + manifestResult.repository.name, filename: manifestResult.path, fileUrl: manifestResult.html_url, - owner: manifestResult.repository.owner.login + owner: manifestResult.repository.owner.login, + repository: manifestResult.repository }; var file = await SRBGitHub.getFileOfRepo(manifestResult.repository.name, manifestResult.path, manifestResult.repository.owner.login); var version = await SRBGitHub.detectUI5VersionInManifestFile(file); - linter.forEach((lint) => { + for (const lint of linter) { if (lint) { - if (manifestResult.repository.name === lint.head_repository.name) version.linter = lint; + if (manifestResult.repository.name === lint.head_repository.name) { + version.linter = lint; + var latestJobs = await SRBGitHub.getLatestLintWorkflowJob(manifestResult.repository.name, lint.id); + for (const job of latestJobs) { + if (job.name.includes("linter")) version.allLintJobs.push(job); + else if (job.name.includes("build")) version.allBuildJobs.push(job); + } + } } - }); + } that.setResultData(resultRecord, version, file, true); that.addRow(resultRecord); @@ -157,6 +175,10 @@ sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) { resultRecord["eocp"] = versionInfo.eocp; resultRecord["eom"] = versionInfo.eom; resultRecord["linter"] = versionInfo.linter; + resultRecord["allBuildJobs"] = versionInfo.allBuildJobs; + resultRecord["allLintJobs"] = versionInfo.allLintJobs; + + // console.log(resultRecord); if (versionInfo.eocp === true) { problematic = true; @@ -216,14 +238,9 @@ sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) { }); }, - tableFilterButtonPressed: function (oEvent) { - var resultsTable = this.getView().byId("resultsTable"); - TableUtils.filter.openFilterDialog(resultsTable); - }, - tableSortButtonPressed: function (oEvent) { - var resultsTable = this.getView().byId("resultsTable"); - TableUtils.sort.openSortDialog(resultsTable, oEvent.getSource()); + var resultsList = this.getView().byId("list"); + TableUtils.sort.openSortDialog(this.resultsModel, oEvent.getSource()); }, getRepoDialogContent: function (listRecord) { @@ -302,6 +319,18 @@ sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) { ); } } + }, + + onSearch: function (oEvent) { + var aFilters = []; + var query = oEvent.getSource().getValue(); + if (query && query.length > 0) { + var filter = new sap.ui.model.Filter("repo", sap.ui.model.FilterOperator.Contains, query); + aFilters.push(filter); + } + + var list = this.getView().byId("list"); + list.getBinding("items").filter(aFilters, "Application"); } }); }); diff --git a/UI5_Quality_Checks_App/webapp/css/style.css b/UI5_Quality_Checks_App/webapp/css/style.css index e120eed..8107f24 100644 --- a/UI5_Quality_Checks_App/webapp/css/style.css +++ b/UI5_Quality_Checks_App/webapp/css/style.css @@ -8,3 +8,7 @@ font-size: 90%; font-weight: bold; } + +.boldText { + font-weight: bold; +} diff --git a/UI5_Quality_Checks_App/webapp/libs/SRBGitHub.js b/UI5_Quality_Checks_App/webapp/libs/SRBGitHub.js index c6e21ca..3c1487f 100644 --- a/UI5_Quality_Checks_App/webapp/libs/SRBGitHub.js +++ b/UI5_Quality_Checks_App/webapp/libs/SRBGitHub.js @@ -41,6 +41,8 @@ var SRBGitHub = (function () { per_page: 100 }); + console.log(response); + return { results: response.data.items, headers: response.headers }; }, @@ -137,7 +139,11 @@ var SRBGitHub = (function () { isEvergreenBootstrap: evergreen, eocp: eocp, // <-- If true, it has already been removed eom: eom, - linter: undefined + linter: undefined, + allBuildJobs: [], + buildSuccess: undefined, + lintSuccess: undefined, + allLintJobs: [] }; }, @@ -186,7 +192,9 @@ var SRBGitHub = (function () { isEvergreenBootstrap: false, eocp: eocp, // <-- If true, it has already been removed eom: eom, - linter: undefined + linter: undefined, + allBuildJobs: [], + allLintJobs: [] }; }, @@ -215,9 +223,22 @@ var SRBGitHub = (function () { allResponses.push(response.data.workflow_runs[0]); } + // console.log(allResponses); + return allResponses; }, + getLatestLintWorkflowJob: async function (repoName, runId) { + var that = this; + var job = await that.octokit.rest.actions.listJobsForWorkflowRun({ + owner: "SRBConsultingTeam", + repo: repoName, + run_id: runId + }); + + return job.data.jobs; + }, + getAvailableRepos: function () { var that = this; diff --git a/UI5_Quality_Checks_App/webapp/libs/TableUtils.js b/UI5_Quality_Checks_App/webapp/libs/TableUtils.js index 10adc4c..9c48f00 100644 --- a/UI5_Quality_Checks_App/webapp/libs/TableUtils.js +++ b/UI5_Quality_Checks_App/webapp/libs/TableUtils.js @@ -3,299 +3,296 @@ * @module TableUtils */ var TableUtils = (function () { - return { - sort: { - openSortDialog: function (table, button) { - var that = this; - var existingCols = table.getColumns(); - - if (!table.sortSettingsDialog) { - table.sortSettingsDialog = new sap.m.ViewSettingsDialog({ - filterSearchOperator: sap.m.StringFilterOperator.Contains - }); - - table.sortSettingsDialog.addStyleClass("sapUiNoContentPadding"); - - existingCols.forEach(function (col) { - var colLabel = col.getHeader().getText(); - var dataField; - - col.getCustomData().forEach(function (customDataObject) { - if (customDataObject.getKey() === "dataField") { - dataField = customDataObject.getValue(); - } - }); - - table.sortSettingsDialog.addSortItem(new sap.m.ViewSettingsItem({ key: dataField, text: colLabel })); - }); - } - - this.sortSettingsDialog = table.sortSettingsDialog; - - this.sortSettingsDialog.attachConfirm({}, function (oEvent) { - var parameters = oEvent.getParameters(); - var sortItem = parameters.sortItem; - - if (!sortItem) { - return; - } - - button.setType(sap.m.ButtonType.Emphasized); - - var sortConfig = { - sortKey: sortItem.getKey(), - sortDescending: parameters.sortDescending - }; - - TableUtils.sort.performSort(table, sortConfig); - }); - - this.sortSettingsDialog.open(); - - }, - - /** - * For performing sorting logic on a existing table, with predefined sort config - * @public - * @memberOf module:TableUtils - * @param {Object} table - The sapui5 table - * @param {Object} sortConfig - Sort configuration with the following format: - * { - * sortKey: "LGNUM", // <-- The json property for sorting - * sortDescending: true // <-- Sorting direction true/false - * } - * @example - * TableUtils.sort.performSort(table, { sortConfig } ); - * - * @author Michael Henninger - SRB Consulting Team - */ - performSort: function (table, sortConfig) { - var sortKey = sortConfig.sortKey; - var sortDescending = sortConfig.sortDescending; - var tableItemsBinding = table.getBinding("items"); - var bindingPropertyPath = tableItemsBinding.getPath(); - var tableModel = tableItemsBinding.getModel(); - - var tableItems = tableModel.getProperty(bindingPropertyPath); - - function compare(a, b) { - if (a[sortKey] < b[sortKey]) { - return sortDescending === true ? 1 : -1; - } - if (a[sortKey] > b[sortKey]) { - return sortDescending === true ? -1 : 1; - } - return 0; - } - - if (tableItems) { - var sortedItems = tableItems.sort(compare); - tableModel.setProperty(bindingPropertyPath, sortedItems); - } else { - return; - } - } - }, - - filter: { - openFilterDialog: function (table) { - var that = this; - - var existingCols = table.getColumns(); - - var tableItemsBinding = table.getBinding("items"); - var bindingPropertyPath = tableItemsBinding.getPath(); - var tableModel = tableItemsBinding.getModel(); - - var tableItems = tableModel.getProperty(bindingPropertyPath); - - if (!table.filterSettingsDialog) { - table.filterSettingsDialog = new sap.m.ViewSettingsDialog({ - filterSearchOperator: sap.m.StringFilterOperator.Contains - }); - - table.filterSettingsDialog.addStyleClass("sapUiNoContentPadding"); - - if (!table.initialRecords) { - table.initialRecords = tableItems; - } + return { + sort: { + openSortDialog: function (table, button) { + var that = this; + console.log(table); + var existingCols = [table.oData.results[0]]; + + if (!table.sortSettingsDialog) { + table.sortSettingsDialog = new sap.m.ViewSettingsDialog({ + filterSearchOperator: sap.m.StringFilterOperator.Contains + }); + + table.sortSettingsDialog.addStyleClass("sapUiNoContentPadding"); + + existingCols.forEach(function (col) { + var colLabel = col; + var dataField; + + col.getCustomData().forEach(function (customDataObject) { + if (customDataObject.getKey() === "dataField") { + dataField = customDataObject.getValue(); + } + }); + + table.sortSettingsDialog.addSortItem(new sap.m.ViewSettingsItem({ key: dataField, text: colLabel })); + }); + } - var removeDuplicates = function (arr) { - return arr.filter((item, index) => arr.indexOf(item) === index); - }; + this.sortSettingsDialog = table.sortSettingsDialog; + + this.sortSettingsDialog.attachConfirm({}, function (oEvent) { + var parameters = oEvent.getParameters(); + var sortItem = parameters.sortItem; + + if (!sortItem) { + return; + } + + button.setType(sap.m.ButtonType.Emphasized); + + var sortConfig = { + sortKey: sortItem.getKey(), + sortDescending: parameters.sortDescending + }; + + TableUtils.sort.performSort(table, sortConfig); + }); + + this.sortSettingsDialog.open(); + }, + + /** + * For performing sorting logic on a existing table, with predefined sort config + * @public + * @memberOf module:TableUtils + * @param {Object} table - The sapui5 table + * @param {Object} sortConfig - Sort configuration with the following format: + * { + * sortKey: "LGNUM", // <-- The json property for sorting + * sortDescending: true // <-- Sorting direction true/false + * } + * @example + * TableUtils.sort.performSort(table, { sortConfig } ); + * + * @author Michael Henninger - SRB Consulting Team + */ + performSort: function (table, sortConfig) { + var sortKey = sortConfig.sortKey; + var sortDescending = sortConfig.sortDescending; + var tableItemsBinding = table.getBinding("items"); + var bindingPropertyPath = tableItemsBinding.getPath(); + var tableModel = tableItemsBinding.getModel(); + + var tableItems = tableModel.getProperty(bindingPropertyPath); + + function compare(a, b) { + if (a[sortKey] < b[sortKey]) { + return sortDescending === true ? 1 : -1; + } + if (a[sortKey] > b[sortKey]) { + return sortDescending === true ? -1 : 1; + } + return 0; + } - var savedFilterSettings = []; + if (tableItems) { + var sortedItems = tableItems.sort(compare); + tableModel.setProperty(bindingPropertyPath, sortedItems); + } else { + return; + } + } + }, - existingCols.forEach(function (col) { - var colLabel = col.getHeader().getText(); - var dataField; + filter: { + openFilterDialog: function (table) { + var that = this; - var filterItem = new sap.m.ViewSettingsFilterItem({ key: dataField, text: colLabel }); + var existingCols = table.getColumns(); - var valuesByDataField = []; - var uniqueValues = []; + var tableItemsBinding = table.getBinding("items"); + var bindingPropertyPath = tableItemsBinding.getPath(); + var tableModel = tableItemsBinding.getModel(); - col.getCustomData().forEach(function (customDataObject) { - if (customDataObject.getKey() === "dataField") { - dataField = customDataObject.getValue(); + var tableItems = tableModel.getProperty(bindingPropertyPath); - var valueSet = table.initialRecords || tableItems; + if (!table.filterSettingsDialog) { + table.filterSettingsDialog = new sap.m.ViewSettingsDialog({ + filterSearchOperator: sap.m.StringFilterOperator.Contains + }); - valueSet.forEach(function (tableItemRecord) { - var property = tableItemRecord[dataField]; - valuesByDataField.push(property); - }); - } - }); + table.filterSettingsDialog.addStyleClass("sapUiNoContentPadding"); - uniqueValues = removeDuplicates(valuesByDataField); + if (!table.initialRecords) { + table.initialRecords = tableItems; + } - uniqueValues.forEach(function (uniqueValue) { - var selected = false; + var removeDuplicates = function (arr) { + return arr.filter((item, index) => arr.indexOf(item) === index); + }; - // Check if the cunstructed item exists in the saved filter settings, if yes, mark it as checked - if (savedFilterSettings.filter((e) => e.filterField === dataField && e.filterValue === uniqueValue).length > 0) { - selected = true; - } + var savedFilterSettings = []; - filterItem.addItem( - new sap.m.ViewSettingsItem({ text: uniqueValue, key: uniqueValue, selected: selected }).addCustomData( - new sap.ui.core.CustomData({ - key: "dataField", - value: dataField - }) - ) - ); - }); + existingCols.forEach(function (col) { + var colLabel = col.getHeader().getText(); + var dataField; - table.filterSettingsDialog.addFilterItem(filterItem); - }); - } + var filterItem = new sap.m.ViewSettingsFilterItem({ key: dataField, text: colLabel }); - this.filterSettingsDialog = table.filterSettingsDialog; + var valuesByDataField = []; + var uniqueValues = []; - this.filterSettingsDialog.attachConfirm({}, function (oEvent) { - var parameters = oEvent.getParameters(); - var filterItems = parameters.filterItems; - var filterString = parameters.filterString; + col.getCustomData().forEach(function (customDataObject) { + if (customDataObject.getKey() === "dataField") { + dataField = customDataObject.getValue(); - var filterConfig = { - filterSettings: TableUtils.filter.convertFilterItemsToSettings(filterItems), - filterString: filterString - }; + var valueSet = table.initialRecords || tableItems; + valueSet.forEach(function (tableItemRecord) { + var property = tableItemRecord[dataField]; + valuesByDataField.push(property); + }); + } + }); + + uniqueValues = removeDuplicates(valuesByDataField); + + uniqueValues.forEach(function (uniqueValue) { + var selected = false; + + // Check if the cunstructed item exists in the saved filter settings, if yes, mark it as checked + if (savedFilterSettings.filter((e) => e.filterField === dataField && e.filterValue === uniqueValue).length > 0) { + selected = true; + } + + filterItem.addItem( + new sap.m.ViewSettingsItem({ text: uniqueValue, key: uniqueValue, selected: selected }).addCustomData( + new sap.ui.core.CustomData({ + key: "dataField", + value: dataField + }) + ) + ); + }); + + table.filterSettingsDialog.addFilterItem(filterItem); + }); + } - TableUtils.filter.performFilter(table, { - filterItems: filterItems, - filterString: filterString - }); + this.filterSettingsDialog = table.filterSettingsDialog; + + this.filterSettingsDialog.attachConfirm({}, function (oEvent) { + var parameters = oEvent.getParameters(); + var filterItems = parameters.filterItems; + var filterString = parameters.filterString; + + var filterConfig = { + filterSettings: TableUtils.filter.convertFilterItemsToSettings(filterItems), + filterString: filterString + }; + + TableUtils.filter.performFilter(table, { + filterItems: filterItems, + filterString: filterString + }); + }); + + this.filterSettingsDialog.open(); + }, + + convertFilterItemsToSettings: function (filterItems) { + var settings = []; + filterItems.forEach(function (item) { + var filterValue = item.getKey(); + filterItems[0].getCustomData().forEach(function (customData) { + if (customData.getKey() === "dataField") { + settings.push({ + filterValue: filterValue, + filterField: customData.getValue() + }); + } + }); + }); + + return settings; + }, + + /** + * For performing filtering logic on a existing table, with predefined filter config + * @public + * @memberOf module:TableUtils + * @param {Object} table - The sapui5 table + * @param {Object} filterConfig - Sort configuration with the following format: + * { + * filterString: "Filtered by Obi Wan Kenobi", // <-- The filter string to be displayed + * filterItems: [ { sap.m.ViewSettingsItem }] // <-- The filter items + * } + * @example + * TableUtils.filter.performFilter(table, { filterConfig } ); + * + * @author Michael Henninger - SRB Consulting Team + */ + performFilter: function (table, filterConfig) { + var tableItemsBinding = table.getBinding("items"); + var bindingPropertyPath = tableItemsBinding.getPath(); + var tableModel = tableItemsBinding.getModel(); + + var tableItems = tableModel.getProperty(bindingPropertyPath); + if (!table.initialRecords) { + table.initialRecords = tableItems; + } - }); + var filterItems = + filterConfig.filterItems || // Take the filter items aggregation which are real sap.m.ViewSettingsItem + (function () { + // Or cunstruct real sap.m.ViewSettingsItem from a array of objects in format of [{filterField:"A",filterValue:"4"},...] + var items = []; + filterConfig.filterSettings.forEach(function (setting) { + items.push( + new sap.m.ViewSettingsItem({ text: setting.filterValue, key: setting.filterValue }).addCustomData( + new sap.ui.core.CustomData({ + key: "dataField", + value: setting.filterField + }) + ) + ); + }); + + return items; + })(); + var filtersKeyValue = {}; + + if (filterItems.length === 0) { + tableModel.setProperty(bindingPropertyPath, table.initialRecords); + return; + } - this.filterSettingsDialog.open(); - }, - - convertFilterItemsToSettings: function (filterItems) { - var settings = []; - filterItems.forEach(function (item) { - var filterValue = item.getKey(); - filterItems[0].getCustomData().forEach(function (customData) { - if (customData.getKey() === "dataField") { - settings.push({ - filterValue: filterValue, - filterField: customData.getValue() - }); - } - }); - }); + filterItems.forEach(function (filterItem) { + var filterValue = filterItem.getKey(); - return settings; - }, - - /** - * For performing filtering logic on a existing table, with predefined filter config - * @public - * @memberOf module:TableUtils - * @param {Object} table - The sapui5 table - * @param {Object} filterConfig - Sort configuration with the following format: - * { - * filterString: "Filtered by Obi Wan Kenobi", // <-- The filter string to be displayed - * filterItems: [ { sap.m.ViewSettingsItem }] // <-- The filter items - * } - * @example - * TableUtils.filter.performFilter(table, { filterConfig } ); - * - * @author Michael Henninger - SRB Consulting Team - */ - performFilter: function (table, filterConfig) { - var tableItemsBinding = table.getBinding("items"); - var bindingPropertyPath = tableItemsBinding.getPath(); - var tableModel = tableItemsBinding.getModel(); - - var tableItems = tableModel.getProperty(bindingPropertyPath); - if (!table.initialRecords) { - table.initialRecords = tableItems; - } - - var filterItems = - filterConfig.filterItems || // Take the filter items aggregation which are real sap.m.ViewSettingsItem - (function () { - // Or cunstruct real sap.m.ViewSettingsItem from a array of objects in format of [{filterField:"A",filterValue:"4"},...] - var items = []; - filterConfig.filterSettings.forEach(function (setting) { - items.push( - new sap.m.ViewSettingsItem({ text: setting.filterValue, key: setting.filterValue }).addCustomData( - new sap.ui.core.CustomData({ - key: "dataField", - value: setting.filterField - }) - ) - ); - }); - - return items; - })(); - var filtersKeyValue = {}; - - if (filterItems.length === 0) { - tableModel.setProperty(bindingPropertyPath, table.initialRecords); - return; - } - - filterItems.forEach(function (filterItem) { - var filterValue = filterItem.getKey(); - - filterItem.getCustomData().forEach(function (customDataObject) { - if (customDataObject.getKey() === "dataField") { - var dataField = customDataObject.getValue(); - - if (!filtersKeyValue[dataField]) { - filtersKeyValue[dataField] = []; - } - - filtersKeyValue[dataField].push(filterValue); - } - }); - }); + filterItem.getCustomData().forEach(function (customDataObject) { + if (customDataObject.getKey() === "dataField") { + var dataField = customDataObject.getValue(); - var filteredTableRecords = table.initialRecords; + if (!filtersKeyValue[dataField]) { + filtersKeyValue[dataField] = []; + } - if (!filteredTableRecords) { - // <-- If there are no records for filtering, return - return; - } + filtersKeyValue[dataField].push(filterValue); + } + }); + }); - Object.keys(filtersKeyValue).forEach(function (key) { - filteredTableRecords = filteredTableRecords.filter(function (el) { - if (el.detected === true && el[key]) { - return filtersKeyValue[key].includes(el[key].toString()); - } + var filteredTableRecords = table.initialRecords; - }); - }); + if (!filteredTableRecords) { + // <-- If there are no records for filtering, return + return; + } - tableModel.setProperty(bindingPropertyPath, filteredTableRecords); + Object.keys(filtersKeyValue).forEach(function (key) { + filteredTableRecords = filteredTableRecords.filter(function (el) { + if (el.detected === true && el[key]) { + return filtersKeyValue[key].includes(el[key].toString()); } - } - }; + }); + }); + + tableModel.setProperty(bindingPropertyPath, filteredTableRecords); + } + } + }; })(); diff --git a/UI5_Quality_Checks_App/webapp/view/startpage.view.xml b/UI5_Quality_Checks_App/webapp/view/startpage.view.xml index d13784c..135e202 100644 --- a/UI5_Quality_Checks_App/webapp/view/startpage.view.xml +++ b/UI5_Quality_Checks_App/webapp/view/startpage.view.xml @@ -53,54 +53,72 @@ + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + highlight="{= ${problematic} === true ? 'Indication02' : 'Indication04' }" width="100%"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +