Skip to content
Snippets Groups Projects
Commit 7dcb4740 authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Added Collection list mock

parent 56ab5075
No related branches found
No related tags found
No related merge requests found
[{
"id": "1",
"title": "My collection 1"
},
{
"id": "2",
"title": "My collection 2"
}
]
...@@ -8,6 +8,7 @@ import folder1 from './data/nodes/folder1'; ...@@ -8,6 +8,7 @@ import folder1 from './data/nodes/folder1';
import folder2 from './data/nodes/folder2'; import folder2 from './data/nodes/folder2';
import job from './data/job'; import job from './data/job';
import jobs from './data/jobs'; import jobs from './data/jobs';
import collections from './data/collections';
import user from './data/user'; import user from './data/user';
import sharing from './data/sharing'; import sharing from './data/sharing';
...@@ -49,6 +50,9 @@ export default { ...@@ -49,6 +50,9 @@ export default {
loadJobs() { loadJobs() {
return fetch(jobs, false); return fetch(jobs, false);
}, },
loadCollections() {
return fetch(collections, false);
},
getUserInfo() { getUserInfo() {
return fetch(user, false); return fetch(user, false);
}, },
......
...@@ -79,7 +79,7 @@ export default { ...@@ -79,7 +79,7 @@ export default {
} }
}, false, true); }, false, true);
}, },
loadNodeCollections() { loadCollections() {
let url = BASE_API_URL + 'collections'; let url = BASE_API_URL + 'collections';
return apiRequest({ return apiRequest({
method: 'GET', method: 'GET',
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<div class="mb-3"> <div class="mb-3">
<b-button variant="success" class="mr-2" v-b-modal.create-collection-modal>New collection</b-button> <b-button variant="success" class="mr-2" v-b-modal.create-collection-modal>New collection</b-button>
</div> </div>
<div v-if="jobs.length > 0" class="mb-3"> <div v-if="collections.length > 0" class="mb-3">
<table class="table b-table table-striped table-hover"> <table class="table b-table table-striped table-hover">
<thead> <thead>
<tr> <tr>
...@@ -19,20 +19,17 @@ ...@@ -19,20 +19,17 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="job in jobs" :key="job.id"> <tr v-for="collection in collections" :key="collection.id">
<td>{{job.type}}</td> <td>{{collection.id}}</td>
<td>{{job.creationTime}}</td> <td>{{collection.title}}</td>
<td>{{job.id}}</td>
<td><a :href="'download?jobId=' + job.id" v-if="job.phase === 'COMPLETED' && job.type === 'ARCHIVE'">Download archive</a></td>
<td>{{job.phase}}</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<div v-if="jobs.length === 0"> <div v-if="collections.length === 0">
No jobs No collections
</div> </div>
<div id="jobs-loading" v-if="jobsLoading" class="loading"> <div id="collections-loading" v-if="collectionsLoading" class="loading">
<div class="spinner-wrapper"> <div class="spinner-wrapper">
<b-spinner variant="primary" style="width: 3rem; height: 3rem;" label="Loading"></b-spinner> <b-spinner variant="primary" style="width: 3rem; height: 3rem;" label="Loading"></b-spinner>
</div> </div>
...@@ -52,16 +49,16 @@ export default { ...@@ -52,16 +49,16 @@ export default {
CreateCollectionModal CreateCollectionModal
}, },
computed: { computed: {
jobs() { return this.$store.state.jobs }, collections() { return this.$store.state.collections },
jobsLoading() { return this.$store.state.jobsLoading } collectionsLoading() { return this.$store.state.collectionsLoading }
}, },
mounted() { mounted() {
this.loadJobs(); this.loadCollections();
this.$store.commit('setLoading', false); this.$store.commit('setLoading', false);
}, },
methods: { methods: {
loadJobs() { loadCollections() {
this.$store.dispatch('loadJobs'); this.$store.dispatch('loadCollections');
} }
} }
} }
......
...@@ -35,6 +35,8 @@ export default new Vuex.Store({ ...@@ -35,6 +35,8 @@ export default new Vuex.Store({
jobs: [], jobs: [],
jobsLoading: true, jobsLoading: true,
lastJobsCheckTime: null, lastJobsCheckTime: null,
collections: [],
collectionsLoading: true,
user: 'anonymous', user: 'anonymous',
nodesToDelete: [], nodesToDelete: [],
selectedUndeletableNodes: [], selectedUndeletableNodes: [],
...@@ -95,6 +97,15 @@ export default new Vuex.Store({ ...@@ -95,6 +97,15 @@ export default new Vuex.Store({
setJobsLoading(state, loading) { setJobsLoading(state, loading) {
state.jobsLoading = loading; state.jobsLoading = loading;
}, },
setCollections(state, collections) {
updateArray(state.collections, collections);
},
addCollections(state, collection) {
state.collections.push(collection);
},
setCollectionsLoading(state, loading) {
state.collectionsLoading = loading;
},
setUsername(state, username) { setUsername(state, username) {
state.user = username; state.user = username;
}, },
...@@ -229,6 +240,14 @@ export default new Vuex.Store({ ...@@ -229,6 +240,14 @@ export default new Vuex.Store({
state.lastJobsCheckTime = new Date().getTime(); state.lastJobsCheckTime = new Date().getTime();
}); });
}, },
loadCollections({ commit }) {
commit('setCollectionsLoading', true);
client.loadCollections()
.then(collections => {
commit('setCollections', collections);
});
commit('setCollectionsLoading', false);
},
loadUserInfo({ commit }) { loadUserInfo({ commit }) {
client.getUserInfo() client.getUserInfo()
.then(res => commit('setUsername', res.username)); .then(res => commit('setUsername', res.username));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment