-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b72f5cd
commit 08a2ff0
Showing
8 changed files
with
286 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
.dashboard-container { | ||
grid-template-areas: | ||
'map reports' | ||
'map charts'; | ||
grid-template-columns: 2fr 1fr; | ||
grid-template-rows: | ||
2fr | ||
3fr; | ||
} | ||
|
||
/* Mobile */ | ||
@media only screen and (max-width: 768px) and (orientation: portrait) { | ||
.dashboard-container { | ||
grid-template-areas: | ||
'map' | ||
'reports' | ||
'charts'; | ||
grid-template-columns: 1fr; | ||
grid-template-rows: | ||
2fr | ||
1fr | ||
3fr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.dashboard-container { | ||
grid-template-areas: | ||
'ssd' | ||
'charts'; | ||
grid-template-rows: | ||
2fr | ||
1fr; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.dashboard-container { | ||
grid-template-areas: | ||
'reports map map' | ||
'reports widget-rain widget-snow' | ||
'reports widget-temp widget-wind'; | ||
grid-template-columns: 2fr 1fr 1fr; | ||
grid-template-rows: | ||
1fr | ||
1fr | ||
1fr; | ||
} | ||
|
||
/* Mobile */ | ||
@media only screen and (max-width: 768px) and (orientation: portrait) { | ||
.dashboard-container { | ||
grid-template-areas: | ||
'reports reports' | ||
'widget-rain widget-snow' | ||
'widget-temp widget-wind' | ||
'map map'; | ||
grid-template-columns: 1fr 1fr; | ||
grid-template-rows: | ||
1fr | ||
1fr | ||
1fr | ||
1fr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
[ | ||
{ | ||
"id": "widgets-and-reports", | ||
"title": "Widgets and reports", | ||
"css": "widgets-and-reports.css", | ||
"panels": [ | ||
{ | ||
"id": "widget-rain" | ||
}, | ||
{ | ||
"id": "widget-snow" | ||
}, | ||
{ | ||
"id": "widget-temp" | ||
}, | ||
{ | ||
"id": "widget-wind" | ||
}, | ||
{ | ||
"id": "reports", | ||
"reportDisplay": { | ||
"reports": [ | ||
{ | ||
"moduleInstanceId": "ReportHazardMapRainfallSAWS" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"id": "map" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "map-and-reports", | ||
"title": "Map and reports", | ||
"css": "map-and-reports.css", | ||
"panels": [ | ||
{ | ||
"id": "map", | ||
"gridDisplaySelection": { | ||
"plotId": "hazard_map_saws" | ||
} | ||
}, | ||
{ | ||
"id": "reports", | ||
"reportDisplay": { | ||
"reports": [ | ||
{ | ||
"moduleInstanceId": "ReportHazardMapRainfallSAWS" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"id": "charts" | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "ssd-and-charts", | ||
"title": "SSD and charts", | ||
"css": "ssd-and-charts.css", | ||
"panels": [ | ||
{ | ||
"id": "ssd" | ||
}, | ||
{ | ||
"id": "charts", | ||
"chartDisplay": { | ||
"charts": [ | ||
{ | ||
"moduleInstanceId": "ChartHazardMapRainfallSAWS" | ||
} | ||
] | ||
} | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<template> | ||
<div class="dashboard-container"> | ||
<template v-for="(panel, i) in dashboard.panels"> | ||
<section | ||
:style="{ | ||
backgroundColor: distinctColorFromIndex(i), | ||
gridArea: panel.id, | ||
}" | ||
> | ||
<h2 class="pa-5">{{ panel.id }}</h2> | ||
</section> | ||
</template> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { watch } from 'vue' | ||
interface Panel { | ||
id: string | ||
} | ||
interface Dashboard { | ||
id: string | ||
title: string | ||
css: string | ||
panels: Panel[] | ||
} | ||
interface Props { | ||
dashboard: Dashboard | ||
} | ||
const props = defineProps<Props>() | ||
function distinctColorFromIndex(index: number) { | ||
return `hsl(${(index * 137) % 360}, 50%, 50%)` | ||
} | ||
function loadCss(url: string) { | ||
if (!document.querySelector(`link[href="${url}"]`)) { | ||
const link = document.createElement('link') | ||
link.rel = 'stylesheet' | ||
link.href = url | ||
document.head.appendChild(link) | ||
} | ||
} | ||
function removeCss(url: string) { | ||
const link = document.querySelector(`link[href="${url}"]`) | ||
if (link) { | ||
link.remove() | ||
} | ||
} | ||
watch( | ||
() => props.dashboard.css, | ||
(newCss, oldCss) => { | ||
if (oldCss) removeCss(`/css/${oldCss}`) | ||
loadCss(`/css/${newCss}`) | ||
}, | ||
{ immediate: true }, | ||
) | ||
</script> | ||
|
||
<style scoped> | ||
.dashboard-container { | ||
display: grid; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<template> | ||
<div class="dashboard-wrapper"> | ||
<v-toolbar> | ||
<v-select | ||
v-model="selectedDashboard" | ||
:items="dashboards" | ||
return-object | ||
hide-details | ||
item-text="title" | ||
item-value="id" | ||
label="Dashboard" | ||
class="px-2" | ||
menu-icon="mdi-chevron-down" | ||
variant="solo-filled" | ||
dense | ||
/> | ||
<v-spacer /> | ||
</v-toolbar> | ||
<DashboardDisplay v-if="selectedDashboard" :dashboard="selectedDashboard" /> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { onMounted, ref } from 'vue' | ||
import DashboardDisplay from '@/components/general/DashboardDisplay.vue' | ||
async function getDashboards() { | ||
const data = await fetch('/dashboards.json') | ||
return data.json() | ||
} | ||
const selectedDashboard = ref() | ||
const dashboards = ref() | ||
onMounted(async () => { | ||
dashboards.value = await getDashboards() | ||
selectedDashboard.value = dashboards.value[0] | ||
}) | ||
</script> | ||
|
||
<style scoped> | ||
.dashboard-wrapper { | ||
display: grid; | ||
grid-template-rows: auto 1fr; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
.dashboard-body { | ||
height: 100%; | ||
width: 100%; | ||
} | ||
</style> |