diff --git a/UI5_Quality_Checks_App/webapp/controller/startpage.controller.js b/UI5_Quality_Checks_App/webapp/controller/startpage.controller.js index 7c4bef2..496416f 100644 --- a/UI5_Quality_Checks_App/webapp/controller/startpage.controller.js +++ b/UI5_Quality_Checks_App/webapp/controller/startpage.controller.js @@ -22,7 +22,9 @@ sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) { SRBInfoAndSupport.init(this.getOwnerComponent()); - this.currentPage = 1; + this.resultsModel = new sap.ui.model.json.JSONModel({ + results: [] + }); }, /** @@ -49,45 +51,50 @@ sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) { }); }, - setResultData: function (resultRecord, versionInfo, fileContent, isMin) { - var problematic = false; + startPressed: async function () { + var that = this; + var userNameLabel = this.getView().byId("usernameLabel"); + var userAvatar = this.getView().byId("myAvatar"); + var loginBox = this.getView().byId("loginBox"); - resultRecord["fileContent"] = fileContent; - resultRecord["version"] = versionInfo.version; - resultRecord["isMinVersion"] = isMin; + var filterPanel = this.getView().byId("filterPanel"); + var resultsTable = this.getView().byId("resultsTable"); - // else resultRecord["version"] = `mind. ${versionInfo.version}`; - resultRecord["isEvergreenBootstrap"] = versionInfo.isEvergreenBootstrap; - resultRecord["eocp"] = versionInfo.eocp; - resultRecord["eom"] = versionInfo.eom; - resultRecord["detected"] = versionInfo.detected; + sap.ui.core.BusyIndicator.show(0); - // console.log(resultRecord); - if (versionInfo.eocp === "removed") { - //<-- This version is out of maintainance - problematic = true; - } + resultsTable.setModel(that.resultsModel); - if (versionInfo.isEvergreenBootstrap !== true) { - //<-- This version is out of maintainance - problematic = true; - } + var tokenInput = this.getView().byId("tokenInput"); + var tokenValue = tokenInput.getValue().trim(); - resultRecord["problematic"] = problematic; + await SRBGitHub.setup(tokenValue); + var userData = await SRBGitHub.getLoginData(); - return resultRecord; + userNameLabel.setText(userData.login); + userAvatar.setSrc(userData.avatar_url); + + filterPanel.setVisible(true); + resultsTable.setVisible(true); + loginBox.setVisible(false); + + this.fetchData(); }, fetchLinterStatus: async function () {}, - fetchData: async function (resultsModel) { + fetchData: async function () { var that = this; - var { results, headers } = await SRBGitHub.getUI5BootstrappingFiles(that.currentPage); - var noVersionFound = []; - var minVersions = []; - console.log(headers); + var { results, headers } = await SRBGitHub.getUI5BootstrappingFiles(); + var noVersionsFound = await that.fetchIndexData(results); + var { result: manifestFiles } = await SRBGitHub.getUI5ManifestFile(noVersionsFound); + await that.fetchManifestData(manifestFiles); + }, + + fetchIndexData: async function (results) { + var that = this; + var noVersionFound = []; for (const repoResult of results) { var resultRecord = { repo: repoResult.repository.name, @@ -102,14 +109,16 @@ sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) { if (version.isMinVersion === true) { noVersionFound.push(repoResult.repository.name); - minVersions.push(version); } else { that.setResultData(resultRecord, version, file, false); - that.addRow(resultsModel, resultRecord); + that.addRow(resultRecord); } } + return noVersionFound; + }, - var { result: manifestFiles } = await SRBGitHub.getUI5ManifestFile(noVersionFound); + fetchManifestData: async function (manifestFiles) { + var that = this; for (const manifestResult of manifestFiles) { var resultRecord = { repo: manifestResult.repository.name, @@ -126,63 +135,53 @@ sap.ui.define(["sap/ui/core/mvc/Controller"], function (Controller) { version.version = minVersion; if (version.isEvergreenBootstrap === true) { - var versionCheck = SRBGitHub.checkForVersionSupport(undefined, minVersion); - version.eocp = versionCheck.eocp; - version.eom = versionCheck.eom; + var { eocp, eom } = SRBGitHub.checkForVersionSupport(undefined, minVersion); + version.eocp = eocp; + version.eom = eom; } else { - var patchCheck = SRBGitHub.checkForPatchSupport(undefined, minVersion); - if (patchCheck) { - version.eocp = patchCheck.eocp; - version.eom = patchCheck.eom; - } + var { eocp, eom } = SRBGitHub.checkForPatchSupport(undefined, minVersion); + version.eocp = eocp; + version.eom = eom; } that.setResultData(resultRecord, version, file, true); - that.addRow(resultsModel, resultRecord); + that.addRow(resultRecord); } - that.currentPage++; }, - addRow: function (resultsModel, resultRecord) { - var tableData = resultsModel.getProperty("/results"); - if (tableData.map(({ fileUrl }) => fileUrl).includes(resultRecord["fileUrl"]) === false) { - tableData.push(resultRecord); - resultsModel.setProperty("/results", tableData); - sap.ui.core.BusyIndicator.hide(); - } - }, - - startPressed: async function () { - var that = this; - var userNameLabel = this.getView().byId("usernameLabel"); - var userAvatar = this.getView().byId("myAvatar"); - var loginBox = this.getView().byId("loginBox"); - - var filterPanel = this.getView().byId("filterPanel"); - var resultsTable = this.getView().byId("resultsTable"); - - var resultsModel = new sap.ui.model.json.JSONModel({ - results: [] - }); + setResultData: function (resultRecord, versionInfo, fileContent, isMin) { + var problematic = false; - sap.ui.core.BusyIndicator.show(0); + resultRecord["fileContent"] = fileContent; + resultRecord["version"] = versionInfo.version; + resultRecord["isMinVersion"] = isMin; - resultsTable.setModel(resultsModel); + resultRecord["isEvergreenBootstrap"] = versionInfo.isEvergreenBootstrap; + resultRecord["eocp"] = versionInfo.eocp; + resultRecord["eom"] = versionInfo.eom; + resultRecord["detected"] = versionInfo.detected; - var tokenInput = this.getView().byId("tokenInput"); - var tokenValue = tokenInput.getValue().trim(); + if (versionInfo.eocp === "removed") { + problematic = true; + } - await SRBGitHub.setup(tokenValue); - var userData = await SRBGitHub.getLoginData(); + if (versionInfo.isEvergreenBootstrap !== true) { + problematic = true; + } - userNameLabel.setText(userData.login); - userAvatar.setSrc(userData.avatar_url); + resultRecord["problematic"] = problematic; - filterPanel.setVisible(true); - resultsTable.setVisible(true); - loginBox.setVisible(false); + return resultRecord; + }, - this.fetchData(resultsModel); + addRow: function (resultRecord) { + var that = this; + var tableData = that.resultsModel.getProperty("/results"); + if (tableData.map(({ fileUrl }) => fileUrl).includes(resultRecord["fileUrl"]) === false) { + tableData.push(resultRecord); + that.resultsModel.setProperty("/results", tableData); + sap.ui.core.BusyIndicator.hide(); + } }, showSupportDialogPressed: function () { diff --git a/UI5_Quality_Checks_App/webapp/libs/SRBGitHub.js b/UI5_Quality_Checks_App/webapp/libs/SRBGitHub.js index c9f0a1e..b23d0bc 100644 --- a/UI5_Quality_Checks_App/webapp/libs/SRBGitHub.js +++ b/UI5_Quality_Checks_App/webapp/libs/SRBGitHub.js @@ -27,7 +27,7 @@ var SRBGitHub = (function () { return response.data; }, - getUI5BootstrappingFiles: async function (page) { + getUI5BootstrappingFiles: async function () { var that = this; checkSetup(); @@ -38,14 +38,13 @@ var SRBGitHub = (function () { q: cdnAQuery, type: "code", // eslint-disable-next-line camelcase - per_page: 100, - page: page + per_page: 100 }); return { results: response.data.items, headers: response.headers }; }, - getUI5ManifestFile: async function (repos, page) { + getUI5ManifestFile: async function (repos) { var that = this; checkSetup(); @@ -77,77 +76,6 @@ var SRBGitHub = (function () { return atob(response.data.content); }, - detectUI5VersionInFile: function (fileContentText, repo) { - var that = this; - - checkSetup(); - - return new Promise(function (resolve, reject) { - var overviewData = availableVersionsModel.getData(); - var patches = overviewData.patches; - var versions = overviewData.versions; - - var detected = false; - var evergreen = false; - var eocp; - var eom; - - var groups = []; - var versionString; - - groups = fileContentText.match("https://sapui5.hana.ondemand.com/(.*)(/resources)"); - - if (groups) { - versionString = groups[1]; - detected = true; - } else { - groups = fileContentText.match("https://ui5.sap.com/(.*)(/resources)"); - - if (groups) { - versionString = groups[1]; - detected = true; - } else { - console.log("Hello"); - } - } - - if (versionString) { - evergreen = versionString.split(".").length <= 2; - } - - if (evergreen === true) { - versions.forEach(function (versionEntry) { - var major = versionEntry.version.split(".")[0]; - var minor = versionEntry.version.split(".")[1]; - var compareVersion = major + "." + minor; - - if (versionString === compareVersion) { - eocp = versionEntry.eocp; - eom = versionEntry.eom; - } - }); - } else { - patches.forEach(function (patch) { - if (patch.version === versionString) { - if (patch.removed === true) { - eocp = "reached"; // <-- Write true because it has beed removed - } else { - eocp = patch.eocp === true ? "reached" : patch.eocp; // <-- Write the provided eocp date - } - } - }); - } - - resolve({ - detected: detected, - version: versionString, - isEvergreenBootstrap: evergreen, - eocp: eocp, // <-- If true, it has already been removed - eom: eom - }); - }); - }, - detectUI5VersionInFileV2: async function (fileContentText, repo) { var that = this; // console.log(fileContentText); @@ -201,12 +129,9 @@ var SRBGitHub = (function () { eocp = eocp; eom = eom; } else { - var checks = that.checkForPatchSupport(patches, versionString); - if (checks) { - var { eocp, eom } = checks; - eocp = eocp; - eom = eom; - } + var { eocp, eom } = that.checkForPatchSupport(patches, versionString); + eocp = eocp; + eom = eom; } } } @@ -235,13 +160,14 @@ var SRBGitHub = (function () { checkForPatchSupport: function (patches, currentVersion) { if (!patches) patches = availableVersionsModel.getData().patches; - var returnValues; + var returnValues = undefined; patches.forEach((patch) => { if (patch.version === currentVersion) { if (patch.removed === true) returnValues = { eocp: "Reached", eom: "Reached" }; - else returnValues = { eocp: patch.eocp, eom: "" }; + else returnValues = { eocp: patch.eocp, eom: "No Information found" }; } }); + if (returnValues === undefined) returnValues = { eocp: true, eom: true }; return returnValues; }, diff --git a/UI5_Quality_Checks_App/webapp/view/startpage.view.xml b/UI5_Quality_Checks_App/webapp/view/startpage.view.xml index 1120cbd..dbe7cfb 100644 --- a/UI5_Quality_Checks_App/webapp/view/startpage.view.xml +++ b/UI5_Quality_Checks_App/webapp/view/startpage.view.xml @@ -64,25 +64,22 @@ - - - - + - + - + - + - + @@ -90,33 +87,58 @@ - - + - + + - - - + + + + + + + + + + - +