Skip to content

Commit 715a0cb

Browse files
committed
init globalTime Component
1 parent e9c1857 commit 715a0cb

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

client/src/MapStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class MapStore {
3535

3636
public static proModeButtonEnabled = ref(true);
3737

38-
public static globalTime = ref(new Date());
38+
public static globalTime = ref(Math.floor(new Date().getTime() / 1000));
3939

4040
public static displayConfiguration: Ref<DisplayConfiguration> = ref(
4141
{ default_displayed_layers: [], enabled_ui: ['Collections', 'Datasets', 'Metadata'], default_tab: 'Scenarios' },
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<script lang="ts">
2+
import { computed, defineComponent } from 'vue';
3+
import MapStore from '../../MapStore';
4+
5+
export default defineComponent({
6+
name: 'GlobalTime',
7+
components: {
8+
},
9+
props: {
10+
},
11+
setup() {
12+
const minMax = computed(() => MapStore.graphChartsMinMax.value);
13+
14+
const updateGlobalTime = (time: number) => {
15+
let updateTime = time;
16+
if (time > minMax.value.max) {
17+
updateTime = minMax.value.max;
18+
} else if (time < minMax.value.min) {
19+
updateTime = minMax.value.min;
20+
}
21+
MapStore.globalTime.value = updateTime;
22+
};
23+
const dateString = computed(() => {
24+
const date = new Date(MapStore.globalTime.value * 1000);
25+
return date.toISOString().split('T')[0];
26+
});
27+
28+
return {
29+
minMax,
30+
globalTime: MapStore.globalTime,
31+
updateGlobalTime,
32+
dateString,
33+
};
34+
},
35+
});
36+
</script>
37+
38+
<template>
39+
<v-row>
40+
<v-col cols="1">
41+
<v-tooltip text="Global Time">
42+
<template #activator="{ props }">
43+
<v-icon
44+
class="pl-3"
45+
v-bind="props"
46+
color="primary"
47+
>
48+
mdi-timer-outline
49+
</v-icon>
50+
</template>
51+
</v-tooltip>
52+
</v-col>
53+
<v-col cols="6">
54+
<v-slider
55+
:model-value="globalTime"
56+
:min="minMax.min"
57+
:max="minMax.max"
58+
step="1"
59+
hide-details
60+
thumb-size="12"
61+
track-size="4"
62+
color="primary"
63+
track-color="grey lighten-3"
64+
density="compact"
65+
@update:model-value="updateGlobalTime($event)"
66+
/>
67+
</v-col>
68+
<v-col
69+
cols="5"
70+
class="text-right pr-1"
71+
>
72+
<span class="text-xs">{{ dateString }}</span>
73+
</v-col>
74+
</v-row>
75+
</template>

0 commit comments

Comments
 (0)