Skip to content

Commit

Permalink
Added notifications dashboard and notify button
Browse files Browse the repository at this point in the history
  • Loading branch information
RoryPTB committed Aug 24, 2023
1 parent 02017c6 commit c4544d4
Show file tree
Hide file tree
Showing 22 changed files with 1,157 additions and 621 deletions.
4 changes: 2 additions & 2 deletions webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<link rel="icon" href="/src/assets/logo-small.png" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FM-12 Form</title>
<title>wis2box</title>
</head>

<body>
Expand Down
107 changes: 107 additions & 0 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
"dependencies": {
"@mdi/font": "7.0.96",
"@vuepic/vue-datepicker": "^5.4.0",
"apexcharts": "^3.41.1",
"core-js": "^3.29.0",
"roboto-fontface": "*",
"vue": "^3.2.0",
"vue-router": "^4.0.0",
"vue3-apexcharts": "^1.4.4",
"vuetify": "^3.0.0",
"webfontloader": "^1.0.0"
},
Expand Down
Binary file removed webapp/public/favicon.ico
Binary file not shown.
Binary file added webapp/src/assets/banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/src/assets/foot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/src/assets/logo-large.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added webapp/src/assets/logo-small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed webapp/src/assets/logo.png
Binary file not shown.
6 changes: 0 additions & 6 deletions webapp/src/assets/logo.svg

This file was deleted.

95 changes: 95 additions & 0 deletions webapp/src/components/MonitoringPage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<template>
<v-card-title class="big-title">Monitoring Dashboard</v-card-title>

<!-- Drop down selection for the dataset the user wants to monitor -->
<v-select label="Choose dataset to monitor" v-model="selectedTitle" :items="titles" v-if="titles.length"></v-select>

<!-- Dashboard visualising the notifications of the dataset selected -->
<NotificationDashboard :topicHierarchy="datasets[selectedTitle]" v-if="selectedTitle"/>

</template>

<script>
import { defineComponent } from 'vue';
import { VCardTitle } from 'vuetify/lib/components/index.mjs';
import NotificationDashboard from '@/components/NotificationDashboard.vue';
export default defineComponent({
name: 'MonitoringPage',
components: {
VCardTitle,
NotificationDashboard
},
data() {
return {
// Options for user to filter the dashboard (surface, upper air, etc)
datasets: {},
// Title selected by the user, used to get the topic hierarchy
// from the datasets dictionary
selectedTitle: null
}
},
computed: {
// Get titles (the keys) from datasets dictionary by using Object.keys,
// used for the selection at the top of the page
titles() {
return Object.keys(this.datasets);
}
},
methods: {
// Method to get topic hierarchies and corresponding titles from the
// discovery metadata, in order to allow the user to select the dataset
// dsisplayed in the dashboard
async getDatasets() {
if (import.meta.env.VITE_TEST_MODE === "true" || import.meta.env.VITE_API_URL == undefined) {
console.log("Use test datasets");
this.datasets = {
"Synoptic weather observations from Romania": "rou/rnimh/data/core/weather/surface-based-observations/synop",
"Surface weather observations from Malawi": "mwi/mwi_met_centre/data/core/weather/surface-based-observations/synop"
};
}
else {
const apiUrl = `${import.meta.env.VITE_API_URL}/collections/discovery-metadata/items?f=json`;
console.log("Fetching topic hierarchy from:", apiUrl);
try {
const response = await fetch(apiUrl);
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
else {
const data = await response.json();
// If the features object is in the data
if (data.features) {
// Populate the datasets dictionary with the titles as keys
// and corresponding topic hierarchies as items
this.datasets = data.features.reduce((acc, feature) => {
acc[feature.properties.title] = feature.properties["wmo:topicHierarchy"];
// acc: accumulator object, used to iteratively build
// this datasets dictionary
return acc;
}, {});
console.log("Datasets:", this.datasets);
}
else {
console.error("API response does not have features property");
}
}
}
catch (error) {
console.error("Error fetching topic hierarchy:", error)
}
}
}
},
mounted() {
// Get topic hierarchies and titles for the user to select a dataset
this.getDatasets();
}
});
</script>
<style scoped>
.big-title {
font-size: 1.4rem;
font-weight: 700;
}
</style>
Loading

0 comments on commit c4544d4

Please sign in to comment.