Skip to content

Commit a3adbe9

Browse files
authored
Merge pull request #248 from OpenTechStrategies/247-demonstrate-referring-to-external-data-source
247 demonstrate referring to external data source
2 parents 92ca0d2 + 49a4027 commit a3adbe9

File tree

12 files changed

+100
-22
lines changed

12 files changed

+100
-22
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ it is used only to serve the front-end component as bundeled javascript.
1313

1414
The ```front-end``` folder contains a Vue Application, built with Vite and Typescript. The ultimate goal of this application is to provide an alternative UI to the current Arches platform, using a modern web framework like Vue. Currently, the Vue code is bundled by vite into the static directory of the Django Application, which is then served on the user's Arches server.
1515

16+
The application also supports fetching data from external api sources, as seen in the `src/components/ArtistNote.vue` component. This component is designed around a simple API endpoint that is foreign-keyed to the Arches database, linking the arches dataset to an external custom set. The repository for the external API is [here](https://github.com/hminsky2002/archesAppRemoteServer).
1617

1718
# Installation Instructions
1819
*Credits to users @apeters and @chiatt*
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"index.html": {
3-
"file": "assets/index-DIt9QbVy.js",
3+
"file": "assets/index-CVuN95tD.js",
44
"name": "index",
55
"src": "index.html",
66
"isEntry": true,
77
"css": [
8-
"assets/index-BfOOURI1.css"
8+
"assets/index-Byc3Ge_L.css"
99
]
1010
}
1111
}

archesdataviewer/static/vite_build/assets/index-BfOOURI1.css

Lines changed: 0 additions & 1 deletion
This file was deleted.

archesdataviewer/static/vite_build/assets/index-Byc3Ge_L.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

archesdataviewer/static/vite_build/assets/index-DIt9QbVy.js renamed to archesdataviewer/static/vite_build/assets/index-CVuN95tD.js

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

archesdataviewer/static/vite_build/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Arches Data Viewer</title>
7-
<script type="module" crossorigin src="/assets/index-DIt9QbVy.js"></script>
8-
<link rel="stylesheet" crossorigin href="/assets/index-BfOOURI1.css">
7+
<script type="module" crossorigin src="/assets/index-CVuN95tD.js"></script>
8+
<link rel="stylesheet" crossorigin href="/assets/index-Byc3Ge_L.css">
99
</head>
1010
<body>
1111
<div id="app"></div>

front-end/.env.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
VITE_ARCHES_API_URL="http://localhost:8002"
22
VITE_ARTIST_GRAPH_ID=""
3-
VITE_ARTWORK_GRAPH_ID=""
3+
VITE_ARTWORK_GRAPH_ID=""
4+
VITE_REMOTE_SERVER_URL=""
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<template>
2+
<div v-if="validateRemoteServerResponseSchema(remoteServerResponse)" class="artist-note">
3+
<p>
4+
{{ remoteServerResponse.note }}
5+
<a :href="remoteServerResponse.url" target="_blank" rel="noopener noreferrer">{{
6+
remoteServerResponse.url
7+
}}</a>
8+
</p>
9+
</div>
10+
</template>
11+
12+
<script setup lang="ts">
13+
import type { Artist, RemoteServerResponse } from '@/types';
14+
import { ref, onMounted } from 'vue';
15+
import { validateRemoteServerResponseSchema } from '@/types';
16+
17+
const props = defineProps<{
18+
artist: Artist;
19+
}>();
20+
21+
const remoteServerResponse = ref<RemoteServerResponse | undefined>();
22+
23+
async function fetchRemoteServerResponse() {
24+
const url = new URL(
25+
`${import.meta.env.VITE_REMOTE_SERVER_URL}/artist/${props.artist.remoteServerId}`
26+
);
27+
const response = await fetch(url.toString()).then((res) => res.json());
28+
remoteServerResponse.value = response;
29+
}
30+
31+
onMounted(async () => {
32+
await fetchRemoteServerResponse();
33+
});
34+
</script>
35+
<style scoped>
36+
.artist-note {
37+
color: var(--wac--color--gray);
38+
padding-top: var(--wac--accessible-spacing--1x);
39+
padding-bottom: var(--wac--accessible-spacing--1x);
40+
}
41+
</style>

front-end/src/components/ResourcePanel.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,17 @@
1212
/>
1313
<h1>{{ props.resource.displayname ?? '' }}</h1>
1414
</div>
15-
1615
<RouterLink :to="'/'" class="resource-detail-back-button">
1716
<button type="button" class="back-button">
1817
<ArrowLeftIcon class="back-button-icon" />
1918
BACK
2019
</button>
2120
</RouterLink>
2221
</div>
23-
22+
<ArtistNote
23+
v-if="validateArtistSchema(props.resource.resource)"
24+
:artist="props.resource.resource"
25+
/>
2426
<ResourceDetail>
2527
<template #items>
2628
<ArtworkDetailItem
@@ -89,14 +91,15 @@ import type {
8991
ImageTileData,
9092
Resource
9193
} from '@/types';
92-
import { validateArtworkSchema, PanelResourceEnum } from '@/types';
94+
import { validateArtworkSchema, PanelResourceEnum, validateArtistSchema } from '@/types';
9395
import { ArrowLeftIcon } from '@heroicons/vue/24/outline';
9496
import ResourceDetail from './ResourceDetail.vue';
9597
import ArtworkDetailItem from './ArtworkDetailItem.vue';
9698
import RelatedArtworkDetailItem from './RelatedArtworkDetailItem.vue';
9799
import MoreArtworksByArtist from './MoreArtworksByArtist.vue';
98100
import ArtworksIcon from './Icons/ArtworksIcon.vue';
99101
import ArtistsIcon from './Icons/ArtistsIcon.vue';
102+
import ArtistNote from './ArtistNote.vue';
100103
101104
const props = defineProps<{
102105
resource: ApiResource;

front-end/src/types/Artist.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import ajv from '@/ajv';
33

44
export interface Artist {
55
Name: string;
6+
remoteServerId?: string;
67
}
78

89
const ArtistSchema: JSONSchemaType<Artist> = {
910
type: 'object',
1011
properties: {
11-
Name: { type: 'string' }
12+
Name: { type: 'string' },
13+
remoteServerId: { type: 'string', nullable: true }
1214
},
1315
required: ['Name'],
1416
additionalProperties: true

0 commit comments

Comments
 (0)