From 5dbd493364e3f9c309364e464af82624d6334df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Roso=C5=82owski?= <87621210+rr-adam@users.noreply.github.com> Date: Fri, 22 Nov 2024 11:42:15 +0100 Subject: [PATCH 1/2] Handle unauthorized error and refresh data --- .../components/Ontology/UnauthorizedError.vue | 7 ++- general/pages/ontology/[...resource].vue | 61 ++++++++++++------- 2 files changed, 44 insertions(+), 24 deletions(-) diff --git a/general/components/Ontology/UnauthorizedError.vue b/general/components/Ontology/UnauthorizedError.vue index f2897a0a..d05a5358 100644 --- a/general/components/Ontology/UnauthorizedError.vue +++ b/general/components/Ontology/UnauthorizedError.vue @@ -3,13 +3,16 @@

403

-

You don't have access to this resource

+

You don't have access to this page

Please login and try again.

Tips

-

Try using search box or modules tree to find ontology resources.

+

+ Try changing version or head to the + home page. +

diff --git a/general/pages/ontology/[...resource].vue b/general/pages/ontology/[...resource].vue index 70ae4076..e2299511 100644 --- a/general/pages/ontology/[...resource].vue +++ b/general/pages/ontology/[...resource].vue @@ -746,9 +746,13 @@ class="container" >
+ + - - @@ -1001,6 +1001,14 @@ export default { watch: { jwt() { this.fetchData(); + }, + async version() { + this.clearUnauthorizedError(); + await Promise.all([ + this.fetchModules(), + this.fetchSearchProperties(), + this.fetchEntity(this.query, { noScroll: true }) + ]); } }, async mounted() { @@ -1066,15 +1074,25 @@ export default { 'clearUnauthorizedError' ]), async fetchData() { + this.clearUnauthorizedError(); + this.data = null; + this.mergedData = null; + this.modulesList = null; + this.searchBox.findPropertiesAll = []; + this.searchBox.findProperties = []; + this.updateServers(this.$route); this.updateCompareServers(null); - this.fetchModules(); - this.fetchSearchProperties(); + await this.fetchVersions(); - this.fetchEntity(this.query, { noScroll: true }); + + await Promise.all([ + this.fetchModules(), + this.fetchSearchProperties(), + this.fetchEntity(this.query, { noScroll: true }) + ]); }, async fetchEntity(iri, options) { - this.clearUnauthorizedError(); const noScroll = options?.noScroll; if (iri) { if (!noScroll) this.scrollToOntologyViewerTopOfContainer(); @@ -1135,12 +1153,9 @@ export default { ontologyVersions.unshift(this.ontologyVersions.defaultData); // add default at the beginning if (this.version != null) { - this.ontologyVersions.selectedData = ontologyVersions.find((val) => { - if (val['@id'] === this.version) { - return true; - } - return false; - }); + this.ontologyVersions.selectedData = ontologyVersions.find( + (val) => val['@id'] === this.version + ); } else { this.ontologyVersions.selectedData = this.ontologyVersions.defaultData; @@ -1179,21 +1194,23 @@ export default { const tagsJson = await getJenkinsJobs( `${jenkinsJobUrl}/view/tags/api/json` ); - const tags = tagsJson.jobs.map((item) => item.name.toLowerCase()); + const tags = tagsJson.jobs.map((item) => { + return item.name.toLowerCase(); + }); const pullRequestsJson = await getJenkinsJobs( `${jenkinsJobUrl}/view/change-requests/api/json` ); - const pullRequests = pullRequestsJson.jobs.map((item) => - item.name.toLowerCase() - ); + const pullRequests = pullRequestsJson.jobs.map((item) => { + return item.name.toLowerCase(); + }); const defaultViewJson = await getJenkinsJobs( `${jenkinsJobUrl}/view/default/api/json` ); - const defaultView = defaultViewJson.jobs.map((item) => - item.name.toLowerCase() - ); + const defaultView = defaultViewJson.jobs.map((item) => { + return item.name.toLowerCase(); + }); // group versions const branchesGroup = []; From 8d047bea8e928db2047dabf56b15708a03ebea02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Roso=C5=82owski?= <87621210+rr-adam@users.noreply.github.com> Date: Fri, 22 Nov 2024 13:04:35 +0100 Subject: [PATCH 2/2] Hide stats and errors when unauthorized --- general/pages/ontology/[...resource].vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/general/pages/ontology/[...resource].vue b/general/pages/ontology/[...resource].vue index e2299511..9a1226d3 100644 --- a/general/pages/ontology/[...resource].vue +++ b/general/pages/ontology/[...resource].vue @@ -243,7 +243,7 @@ @@ -722,7 +722,7 @@
- +
@@ -987,7 +987,7 @@ export default { ); }, hasVersions() { - return this.ontologyVersions.data.length > 1; + return this.ontologyVersions.data.length >= 1; }, isComparing() { return ( @@ -1003,6 +1003,10 @@ export default { this.fetchData(); }, async version() { + this.error.entityNotFound = false; + this.error.entityData = false; + this.error.modules = false; + this.error.properties = false; this.clearUnauthorizedError(); await Promise.all([ this.fetchModules(),