Skip to content

Commit 278aeb0

Browse files
committed
Sync/Refresh button for user workspaces #231 #286
1 parent a2b6e9c commit 278aeb0

File tree

6 files changed

+91
-6
lines changed

6 files changed

+91
-6
lines changed

src/components/CustomProcessPanel.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<DataTable ref="table" :data="data" :columns="columns" class="CustomProcessPanel">
33
<template slot="toolbar">
44
<button title="Add new custom process" @click="addProcessFromScript" v-show="supportsCreate" :disabled="!this.hasProcess"><i class="fas fa-plus"></i> Add</button>
5+
<SyncButton name="custom processes" :sync="() => updateData(true)" />
56
</template>
67
<template #actions="p">
78
<button title="Details" @click="processInfo(p.row)" v-show="supportsRead"><i class="fas fa-info"></i></button>
@@ -12,14 +13,18 @@
1213
</template>
1314

1415
<script>
15-
import EventBusMixin from './EventBusMixin.js';
16+
import EventBusMixin from './EventBusMixin';
1617
import WorkPanelMixin from './WorkPanelMixin';
18+
import SyncButton from './SyncButton.vue';
1719
import Utils from '../utils.js';
1820
import { UserProcess } from '@openeo/js-client';
1921
2022
export default {
2123
name: 'CustomProcessPanel',
2224
mixins: [WorkPanelMixin('userProcesses', 'custom process', 'custom processes', false), EventBusMixin],
25+
components: {
26+
SyncButton
27+
},
2328
data() {
2429
return {
2530
columns: {

src/components/FilePanel.vue

+17
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<input type="file" name="uploadUserFile" class="uploadUserFile" ref="uploadUserFile" @change="uploadFiles" multiple>
1010
</div>
1111
</div>
12+
<SyncButton name="files" :sync="() => updateData(true)" />
1213
</template>
1314
<template #actions="p">
1415
<button title="Download" @click="downloadFile(p.row)" v-show="supportsRead"><i class="fas fa-download"></i></button>
@@ -20,11 +21,15 @@
2021

2122
<script>
2223
import WorkPanelMixin from './WorkPanelMixin';
24+
import SyncButton from './SyncButton.vue';
2325
import Utils from '../utils.js';
2426
2527
export default {
2628
name: 'FilePanel',
2729
mixins: [WorkPanelMixin('files', 'file', 'files')],
30+
components: {
31+
SyncButton
32+
},
2833
data() {
2934
return {
3035
columns: {
@@ -153,6 +158,18 @@ export default {
153158
height: 100%;
154159
width: 100%;
155160
161+
.toolbar {
162+
display: flex;
163+
164+
.upload {
165+
flex-grow: 1;
166+
}
167+
.data-sync {
168+
flex-grow: 0;
169+
height: 100%;
170+
}
171+
}
172+
156173
.dropZone {
157174
width: 100%;
158175
height: 100%;

src/components/JobPanel.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<template slot="toolbar">
44
<button title="Add new job for batch processing" @click="createJobFromScript()" v-show="supportsCreate" :disabled="!this.hasProcess"><i class="fas fa-plus"></i> Create Batch Job</button>
55
<button title="Run the process directly and view the results without storing them permanently" @click="executeProcess" v-show="supports('computeResult')" :disabled="!this.hasProcess"><i class="fas fa-play"></i> Run now</button>
6+
<SyncButton name="batch jobs" :sync="() => updateData(true)" />
67
</template>
78
<template #actions="p">
89
<button title="Details" @click="showJobInfo(p.row)" v-show="supportsRead"><i class="fas fa-info"></i></button>
@@ -21,8 +22,9 @@
2122
</template>
2223

2324
<script>
24-
import EventBusMixin from './EventBusMixin.js';
25+
import EventBusMixin from './EventBusMixin';
2526
import WorkPanelMixin from './WorkPanelMixin';
27+
import SyncButton from './SyncButton.vue';
2628
import Utils from '../utils.js';
2729
import { AbortController, Job } from '@openeo/js-client';
2830
@@ -31,6 +33,9 @@ const WorkPanelMixinInstance = WorkPanelMixin('jobs', 'batch job', 'batch jobs')
3133
export default {
3234
name: 'JobPanel',
3335
mixins: [WorkPanelMixinInstance, EventBusMixin],
36+
components: {
37+
SyncButton
38+
},
3439
data() {
3540
return {
3641
columns: {

src/components/ServicePanel.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<template slot="toolbar">
44
<button title="Add new permanently stored web service" @click="createServiceFromScript()" v-show="supportsCreate" :disabled="!this.hasProcess"><i class="fas fa-plus"></i> Create</button>
55
<button title="Quickly show the process on map without storing it permanently" @click="quickViewServiceFromScript()" v-show="supportsQuickView" :disabled="!this.hasProcess"><i class="fas fa-map"></i> Show on Map</button>
6+
<SyncButton name="web services" :sync="() => updateData(true)" />
67
</template>
78
<template #actions="p">
89
<button title="Details" @click="serviceInfo(p.row)" v-show="supportsRead"><i class="fas fa-info"></i></button>
@@ -17,15 +18,19 @@
1718
</template>
1819

1920
<script>
20-
import EventBusMixin from './EventBusMixin.js';
21+
import EventBusMixin from './EventBusMixin';
2122
import WorkPanelMixin from './WorkPanelMixin';
23+
import SyncButton from './SyncButton.vue';
2224
import Utils from '../utils';
2325
import { Service } from '@openeo/js-client';
2426
import { mapMutations } from 'vuex';
2527
2628
export default {
2729
name: 'ServicePanel',
2830
mixins: [WorkPanelMixin('services', 'web service', 'web services'), EventBusMixin],
31+
components: {
32+
SyncButton
33+
},
2934
data() {
3035
return {
3136
columns: {

src/components/SyncButton.vue

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<template>
2+
<button :title="title" class="data-sync" @click="update">
3+
<i v-if="syncState === true" class="fas fa-check"></i>
4+
<i v-else-if="syncState === false" class="fas fa-times"></i>
5+
<i v-else class="fas fa-sync"></i>
6+
</button>
7+
</template>
8+
9+
<script>
10+
export default {
11+
name: "SyncButton",
12+
props: {
13+
name: {
14+
type: String,
15+
required: true
16+
},
17+
sync: {
18+
type: Function,
19+
required: true
20+
}
21+
},
22+
data() {
23+
return {
24+
syncState: null
25+
};
26+
},
27+
computed: {
28+
title() {
29+
return "Refresh list of " + this.name
30+
}
31+
},
32+
methods: {
33+
async update(event) {
34+
if (this.syncState !== null) {
35+
return;
36+
}
37+
this.syncState = await this.sync(event);
38+
setTimeout(() => this.syncState = null, 3000);
39+
}
40+
}
41+
}
42+
</script>
43+
44+
<style scoped lang="scss">
45+
.fa-check {
46+
color: green;
47+
}
48+
.fa-times {
49+
color: maroon;
50+
}
51+
</style>

src/components/WorkPanelMixin.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ export default (namespace, singular, plural, loadInitially = true) => {
6262
Utils.exception(this, error, "Load " + singular + " error");
6363
}
6464
},
65-
async updateData() {
65+
async updateData(force = false) {
6666
var table = this.getTable();
6767
var nextSyncTime = Date.now() - this.getSyncInterval();
68-
if (!table || this.lastSyncTime > nextSyncTime) {
69-
return;
68+
if (!table || (!force && this.lastSyncTime > nextSyncTime)) {
69+
return false;
7070
}
7171
else if (!this.supportsList) {
7272
table.setNoData("Sorry, listing stored " + plural + " is not supported by the server.");
@@ -85,6 +85,7 @@ export default (namespace, singular, plural, loadInitially = true) => {
8585
if(data.length == 0) {
8686
table.setNoData("Add your first " + singular + " here...");
8787
}
88+
return true;
8889
} catch(error) {
8990
if (!isUpdate) {
9091
Utils.exception(this, error);
@@ -95,6 +96,7 @@ export default (namespace, singular, plural, loadInitially = true) => {
9596
}
9697
}
9798
}
99+
return false;
98100
}
99101
}
100102
};

0 commit comments

Comments
 (0)