Skip to content

Commit

Permalink
Merge pull request #33 from opencdms/clean-up
Browse files Browse the repository at this point in the history
Addition of catalogue and station import
  • Loading branch information
isedwards authored May 16, 2023
2 parents b35c4f4 + e4072d8 commit 397e04c
Show file tree
Hide file tree
Showing 13 changed files with 2,005 additions and 58 deletions.
1,443 changes: 1,443 additions & 0 deletions public/data/cdms-specs/specs.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/_nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ var pages = [
{
/*
component: 'VListItem',
name: 'home',
name: 'dashboard',
to: '/dashboard',
routeName: "home",
routeName: "dashboard",
icon: 'mdi-view-dashboard',
*/
},
Expand Down
13 changes: 10 additions & 3 deletions src/components/AppSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<v-list-item router :to="{name: 'station-list'}" prepend-icon="mdi-table" title="Table view"/>
<v-list-item router :to="{name: 'station-viewer'}" prepend-icon="mdi-pencil" title="View/edit"/>
<v-list-item router :to="{name: 'host-form'}" prepend-icon="mdi-pencil" title="Create new"/>
<v-list-item router :to="{name: 'sensor-list'}" prepend-icon="mdi-upload" title="Import"/>
<v-list-item router :to="{name: 'station-import'}" prepend-icon="mdi-upload" title="Import"/>
</v-list-group>
<v-divider/>

Expand Down Expand Up @@ -103,11 +103,18 @@
</v-list-group>
<v-divider/>
-->

<v-list-group value="WIS2">
<template v-slot:activator="{ props }">
<v-list-item v-bind="props" prepend-icon="mdi-web" title="WIS2"/>
</template>
<v-list-item router :to="{name: 'wis2-catalogue'}" prepend-icon="mdi-cloud-search" title="Catalogue"/>
</v-list-group>
<v-divider/>
<v-list-item router :to="{name: 'roadmap'}" prepend-icon="mdi-map-marker-distance" title="Roadmap"/>
<!--
<v-list-group value="WIS2">
<template v-slot:activator="{ props }">
<v-list-item v-bind="props" prepend-icon="mdi-spirit-level" title="WIS2"/>
<v-list-item v-bind="props" prepend-icon="mdi-web" title="WIS2"/>
</template>
<v-list-item router :to="{name: 'wis2-publication'}" prepend-icon="mdi-publish" title="Manage publications"/>
<v-list-item router :to="{name: 'wis2-subscription'}" prepend-icon="mdi-spirit-level" title="Manage subscriptions"/>
Expand Down
15 changes: 15 additions & 0 deletions src/models/MQTTSubscription.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Model } from 'pinia-orm'

export default class MQTTSubscription extends Model {
static entity = 'mqtt_subscription' ;
static fields(){
return{
id: this.string(''),
topic: this.string(''), // topic we are subscribing to
bucket: this.string(''), // where to put the data
process: this.string(''), // process to use to process the data
collection: this.string(''), // which collection to associate with this subscription
subscribed: this.boolean(false) // current status of the process
}
}
}
10 changes: 10 additions & 0 deletions src/router/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ const routes = [
name: 'station-viewer',
component: () => import(/* webpackChunkName: "dashboard" */ '@/views/station.vue'),
},
{
path: 'import',
name: 'station-import',
component: () => import(/* webpackChunkName: "dashboard" */ '@/views/station-import.vue'),
}
]
},
{
Expand Down Expand Up @@ -444,6 +449,11 @@ const routes = [
name: 'data-table',
component: () => import(/* webpackChunkName: "dashboard" */ '@/views/data-table.vue')
},
{
path: '/roadmap',
name: 'roadmap',
component: () => import(/* webpackChunkName: "dashboard" */ '@/views/roadmap.vue')
},
...generateOtherRoutes(navs)
],
},
Expand Down
20 changes: 20 additions & 0 deletions src/views/roadmap.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div>
<roadmap/>
</div>
</template>

<script>
import Roadmap from './../web-components/roadmap.vue';
export default {
name: 'MyView',
components: {
Roadmap,
},
};
</script>

<style>
</style>
20 changes: 20 additions & 0 deletions src/views/station-import.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div>
<station-import/>
</div>
</template>

<script>
import StationImport from './../web-components/station-import.vue';
export default {
name: 'MyView',
components: {
StationImport,
},
};
</script>

<style>
</style>
20 changes: 20 additions & 0 deletions src/views/wis2-subscribe.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<template>
<div>
<wis2-subscription/>
</div>
</template>

<script>
import Wis2Subscription from './../web-components/wis2-subscription.vue';
export default {
name: 'MyView',
components: {
Wis2Subscription,
},
};
</script>

<style>
</style>
79 changes: 79 additions & 0 deletions src/web-components/roadmap.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<template>
<v-card>
<v-card-title>Specification and roadmap</v-card-title>
<v-card-text>The core functionality and requirements for a climate data management
are defined in the <a href="https://library.wmo.int/index.php?lvl=notice_display&id=16300">
WMO Climate Data Management Systems specifications (WMO-No. 1131)</a>. The specifications
detailed in WMO-No. 1131 cover a range of topics, including policy and core IT infrastructure.
Within the OpenCDMS project only the data management functions are considered, notably those covered
by Section 4 to 8 of WMO-No. 1131. The cards below summarises these functions and progress
towards their implementation. The full list of specifications can be found at
<a href="https://spec.opencdms.org">https://spec.opencdms.org</a>.
</v-card-text>
</v-card>
<v-expansion-panels v-if="requirements">
<v-expansion-panel v-for="requirement in requirements" :title="requirement.title">
<v-expansion-panel-text class="v-card-text">{{requirement.text}}
<v-expansion-panels v-if="requirement.requirements" multiple>
<v-expansion-panel v-for="r2 in requirement.requirements" :title="r2.title">
<v-expansion-panel-text class="v-card-text">{{r2.text}}</v-expansion-panel-text>
<v-expansion-panel-text>
<v-card v-for="r3 in r2.requirements">
<v-card-title>{{r3.title}} ({{r3.classification}})</v-card-title>
<v-card-text>{{r3.text}}</v-card-text>
<v-card :color="r3.color" :title="r3.status"/>
</v-card>
</v-expansion-panel-text>
</v-expansion-panel>
</v-expansion-panels>
</v-expansion-panel-text>
</v-expansion-panel>
</v-expansion-panels>
</template>

<script>
import { ref, defineComponent } from 'vue';
import { VCard, VCardTitle, VCardText } from 'vuetify/lib/components';
import { VExpansionPanels, VExpansionPanel, VExpansionPanelText } from 'vuetify/lib/components';
import { onBeforeMount, onMounted, onBeforeUpdate, onUpdated, onBeforeUnmount, onUnmounted, onErrorCaptured} from 'vue';
import axios from 'axios';
export default defineComponent({
name: 'roadmap',
props: {
},
components: {
VCard,
VCardTitle,
VCardText,
VExpansionPanel,
VExpansionPanels,
VExpansionPanelText
},
methods: {},
setup() {
const requirements=ref(null)
const renderRequirement = (requirement) => {
}
// lifecycle hooks
onBeforeMount( async () => {
});
onMounted( async() => {
const response = await axios.get("/data/cdms-specs/specs.json")
requirements.value = response.data
console.log(requirements)
// This hook is called after the component is mounted to the DOM.
// This is a good place to perform any necessary DOM manipulations, initialize
// third-party libraries, or set up event listeners.
});
return {requirements};
}
});
</script>
80 changes: 80 additions & 0 deletions src/web-components/station-import.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<template>
<v-container>
<v-card>
<v-card-title>Import station from OSCAR/Surface</v-card-title>
<v-card-text>
<v-form>
<v-text-field clearable :rules="[rules.validWSI]" label="WIGOS Identifier" v-model="wigos_identifier"/>
<v-btn @click="search">Search</v-btn>
</v-form>
</v-card-text>
</v-card>
</v-container>
</template>

<script>
import { defineComponent, ref, watchEffect, computed, watch } from 'vue';
import { VCard, VCardTitle, VCardText, VCardItem, VTabs, VTab, VBtn, VAutocomplete, VCardSubtitle, VTextField } from 'vuetify/lib/components';
import { VContainer, VForm } from 'vuetify/lib/components';
// opencdms imports
import Host from '@/models/Host';
import {flatten_geojson} from '@/utils/geojson.js';
import {loadData} from '@/utils/load-data.js';
import { useRoute, useRouter } from 'vue-router';
import {useRepo} from 'pinia-orm';
export default defineComponent({
name: 'import-wmdr-host',
components: {
VContainer, VBtn, VForm, VTextField,
VCard, VCardTitle, VCardText
},
setup(props, {context}){
const router = useRouter();
const wigos_identifier = ref("");
const rules = ref({
validWSI: value => /^0-[0-9]{1,5}-[0-9]{0,5}-[0-9a-zA-Z]{1,16}$/.test(value) || 'Invalid WSI',
});
const search = async () => {
//var oscar_url = "https://oscar.wmo.int/surface/rest/api/search/station?wigosId=";
//var query = oscar_url + wigos_identifier.value;
//console.log(query);
//var stations = await fetch(query).then(response => response.json());
//console.log(stations);
var payload = {
"inputs": {
WIGOS_identifier: wigos_identifier.value
},
"outputs": {
"status": null
}
}
payload = JSON.stringify(payload);
var url_ = process.env.API + "/processes/ingestHost/execution"
var response = await fetch( url_, {
method: 'POST',
body: payload,
headers: {
encode: 'json'
}
});
if(response.ok){
// reload host
await loadData(process.env.API + '/collections/stations/items?limit=1000&f=json', true)
.then( (result) => flatten_geojson(result.features) ).then( (result) => { useRepo(Host).save(result) });
var station_url = '#/station/' + wigos_identifier.value;
router.push('/station/'+wigos_identifier.value);
}else{
console.log(response);
}
};
return {rules, search, wigos_identifier};
}
});
</script>
15 changes: 10 additions & 5 deletions src/web-components/station.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
<v-card>
<v-card-title>Select station</v-card-title>
<v-card-text><select-host v-model="selectedHost"/></v-card-text>
<!-- <v-card-item><v-autocomplete :items="hostOptions" v-model="selectedHost" item-title="name" item-value="id" label="host" return-object persistent-hint></v-autocomplete></v-card-item> -->
</v-card>
</v-col>
</v-row>
<v-row>
</v-row>
<v-row>
<v-row v-if="host != null">
<v-col :cols="6">
<v-card>
<v-card-title>Station: {{ $route.params.id }}</v-card-title>
<v-card-item><v-card-text><pre>{{host}}</pre></v-card-text></v-card-item>
<v-card-title>
Station: {{ $route.params.id }}
</v-card-title>
<v-card-item><v-card-text><pre>{{host}}</pre></v-card-text></v-card-item>
</v-card>
</v-col>
<v-col :cols="6" align-self="center">
Expand Down Expand Up @@ -78,7 +79,11 @@ export default defineComponent({
const fetchRecord = async(identifier) => {
// load selected host
host.value = useRepo(Host).where('id',route.params.id).first();
var host_tmp = useRepo(Host).where('id',route.params.id).first();
if ( host_tmp != null ){
host.value = host_tmp;
}
console.log(host.value);
}
// add watch to update the geom
Expand Down
Loading

0 comments on commit 397e04c

Please sign in to comment.