-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatasetItem.vue
More file actions
116 lines (111 loc) · 3.12 KB
/
DatasetItem.vue
File metadata and controls
116 lines (111 loc) · 3.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<script lang="ts">
import {
PropType, defineComponent,
onMounted,
onUnmounted,
ref,
} from 'vue';
import {
FMVLayer, NetCDFData, RasterMapLayer, VectorMapLayer,
} from '../../types';
import { toggleLayerSelection } from '../../map/mapLayers';
import MapStore from '../../MapStore';
import NetCDFDataConfigurator from './NetCDFDataConfigurator.vue';
export default defineComponent({
components: {
NetCDFDataConfigurator,
},
props: {
layer: {
type: Object as PropType<RasterMapLayer | VectorMapLayer | NetCDFData | FMVLayer>,
required: true,
},
},
emits: ['netcdf-deleted'],
setup(props) {
let timeOutId: NodeJS.Timeout | null = null;
const processing = ref(false);
const checkProcessingTasks = async () => {
const id = props.layer.dataset_id;
if (id !== undefined) {
processing.value = true;
await MapStore.loadLayers(id, true);
const layersByDataset = MapStore.mapLayersByDataset;
const layers = layersByDataset[id];
if (layers) {
const currentLayer = layers.find((item) => item.id === props.layer.id && item.type === props.layer.type);
if (currentLayer && currentLayer.processing_tasks) {
timeOutId = setTimeout(checkProcessingTasks, 5000);
return;
}
}
}
processing.value = false;
if (timeOutId !== null) {
clearTimeout(timeOutId);
timeOutId = null;
}
};
onMounted(async () => {
if (props.layer.processing_tasks?.length) {
// Processing is occuring so we need to refresh every few seconds
processing.value = true;
timeOutId = setTimeout(checkProcessingTasks, 5000);
}
});
onUnmounted(() => {
if (timeOutId !== null) {
clearTimeout(timeOutId);
timeOutId = null;
processing.value = false;
}
});
return {
toggleLayerSelection,
selectedLayers: MapStore.selectedMapLayers,
processing,
checkProcessingTasks,
};
},
});
</script>
<template>
<v-checkbox
v-if="layer.type === 'raster' || layer.type === 'vector' || layer.type === 'fmv'"
:model-value="!!selectedLayers.find((item) => (item.id === layer.id))"
class="layer-checkbox"
density="compact"
hide-details
@change="toggleLayerSelection(layer)"
>
<template #label>
<v-icon v-tooltip="layer.type === 'raster' ? 'Raster Layer' : 'Vector Layer'">
{{ layer.type === 'raster' ? 'mdi-image-outline' : 'mdi-map-marker-outline' }}
</v-icon>
<span class="layer-checkbox-label">
{{ layer.name }}
<v-tooltip
:text="layer.name"
activator="parent"
location="bottom"
open-delay="1000"
/>
</span>
</template>
</v-checkbox>
<div v-else-if="layer.type === 'netcdf'">
<NetCDFDataConfigurator
:data="layer"
:processing="processing"
@deleted="$emit('netcdf-deleted', $event)"
@generate-layer="checkProcessingTasks"
/>
</div>
</template>
<style scoped>
.layer-checkbox-label {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>