Commit 7dcb4740 authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

Added Collection list mock

parent 56ab5075
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
[{
    "id": "1",
    "title": "My collection 1"
  },
  {
    "id": "2",
    "title": "My collection 2"
  }
]
+4 −0
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@ import folder1 from './data/nodes/folder1';
import folder2 from './data/nodes/folder2';
import job from './data/job';
import jobs from './data/jobs';
import collections from './data/collections';
import user from './data/user';
import sharing from './data/sharing';

@@ -49,6 +50,9 @@ export default {
  loadJobs() {
    return fetch(jobs, false);
  },
  loadCollections() {
    return fetch(collections, false);
  },
  getUserInfo() {
    return fetch(user, false);
  },
+1 −1
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ export default {
      }
    }, false, true);
  },
  loadNodeCollections() {
  loadCollections() {
    let url = BASE_API_URL + 'collections';
    return apiRequest({
      method: 'GET',
+12 −15
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
  <div class="mb-3">
      <b-button variant="success" class="mr-2" v-b-modal.create-collection-modal>New collection</b-button>
  </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">
      <thead>
        <tr>
@@ -19,20 +19,17 @@
        </tr>
      </thead>
      <tbody>
        <tr v-for="job in jobs" :key="job.id">
          <td>{{job.type}}</td>
          <td>{{job.creationTime}}</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 v-for="collection in collections" :key="collection.id">
          <td>{{collection.id}}</td>
          <td>{{collection.title}}</td>          
        </tr>
      </tbody>
    </table>
  </div>
  <div v-if="jobs.length === 0">
    No jobs
  <div v-if="collections.length === 0">
    No collections
  </div>
  <div id="jobs-loading" v-if="jobsLoading" class="loading">
  <div id="collections-loading" v-if="collectionsLoading" class="loading">
    <div class="spinner-wrapper">
      <b-spinner variant="primary" style="width: 3rem; height: 3rem;" label="Loading"></b-spinner>
    </div>
@@ -52,16 +49,16 @@ export default {
    CreateCollectionModal
  },
  computed: {
    jobs() { return this.$store.state.jobs },
    jobsLoading() { return this.$store.state.jobsLoading }
    collections() { return this.$store.state.collections },
    collectionsLoading() { return this.$store.state.collectionsLoading }
  },
  mounted() {
    this.loadJobs();
    this.loadCollections();
    this.$store.commit('setLoading', false);
  },
  methods: {
    loadJobs() {
      this.$store.dispatch('loadJobs');
    loadCollections() {
      this.$store.dispatch('loadCollections');
    }
  }
}
+19 −0
Original line number Diff line number Diff line
@@ -35,6 +35,8 @@ export default new Vuex.Store({
    jobs: [],
    jobsLoading: true,
    lastJobsCheckTime: null,
    collections: [],
    collectionsLoading: true,
    user: 'anonymous',
    nodesToDelete: [],
    selectedUndeletableNodes: [],
@@ -95,6 +97,15 @@ export default new Vuex.Store({
    setJobsLoading(state, 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) {
      state.user = username;
    },
@@ -229,6 +240,14 @@ export default new Vuex.Store({
          state.lastJobsCheckTime = new Date().getTime();
        });
    },
    loadCollections({ commit }) {
      commit('setCollectionsLoading', true);
      client.loadCollections()
              .then(collections => {
                  commit('setCollections', collections);                  
      });
      commit('setCollectionsLoading', false);
    },
    loadUserInfo({ commit }) {
      client.getUserInfo()
        .then(res => commit('setUsername', res.username));