Commit 71ba624a authored by Nicola Fulvio Calabria's avatar Nicola Fulvio Calabria
Browse files

added delete collection

parent 71d2497f
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -160,7 +160,7 @@ public class VOSpaceClient {


    public void deleteCollection(Long id, Optional<String> token) {
    public void deleteCollection(Long id, Optional<String> token) {


        HttpRequest request = getRequest("/collections?id="+id, token)
        HttpRequest request = getRequest("/collections/"+id, token)
                .header("Accept", useJson ? "application/json" : "text/xml")
                .header("Accept", useJson ? "application/json" : "text/xml")
                .header("Content-Type", useJson ? "application/json" : "text/xml")
                .header("Content-Type", useJson ? "application/json" : "text/xml")
                .DELETE()
                .DELETE()
+17 −0
Original line number Original line Diff line number Diff line
@@ -17,7 +17,9 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RestController;
@@ -61,4 +63,19 @@ public class NodeCollectionsController extends BaseController {
        return ResponseEntity.noContent().build();
        return ResponseEntity.noContent().build();
    }
    }
    
    
    @DeleteMapping(value = "/collections/{collectionId}", produces = MediaType.APPLICATION_JSON_VALUE)
    public ResponseEntity<?> deleteNodeCollection(User principal, 
            @PathVariable Long collectionId) 
            throws Exception
    {                
        
        LOG.debug("delete collection {} for user {}", 
                collectionId, principal.getName());

        // Call creation logic        
        client.deleteCollection(collectionId, tokenProvider.getToken());
                
        return ResponseEntity.noContent().build();
    }
    
}
}
+1 −1
Original line number Original line Diff line number Diff line
@@ -128,7 +128,7 @@ export default {
    });
    });
  },
  },
  deleteCollection(collectionId) {
  deleteCollection(collectionId) {
    let url = BASE_API_URL + 'collections?id='+collectionId;
    let url = BASE_API_URL + 'collections/'+collectionId;
    return apiRequest({
    return apiRequest({
      method: 'DELETE',
      method: 'DELETE',
      url: url,
      url: url,
+8 −2
Original line number Original line Diff line number Diff line
@@ -13,16 +13,17 @@
  <div v-if="collections.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>
          <th>Id</th>
          <th>Id</th>
          <th>Title</th>
          <th>Title</th>
          <th></th>
          <th>Actions</th>
        </tr>
        </tr>
      </thead>
      </thead>
      <tbody>
      <tbody>
        <tr v-for="collection in collections" :key="collection.id">
        <tr v-for="collection in collections" :key="collection.id">
          <td>{{collection.id}}</td>
          <td>{{collection.id}}</td>
          <td>{{collection.title}}</td>
          <td>{{collection.title}}</td>
          <td></td>
          <td><b-icon-trash color="red" @click="deleteCollection(collection.id)"/></td>
        </tr>
        </tr>
      </tbody>
      </tbody>
    </table>
    </table>
@@ -41,11 +42,13 @@
</template>
</template>


<script>
<script>
import { BIconTrash } from 'bootstrap-vue'
import FAQModal from './modal/FAQModal.vue'
import FAQModal from './modal/FAQModal.vue'
import CreateCollectionModal from './modal/CreateCollectionModal.vue'
import CreateCollectionModal from './modal/CreateCollectionModal.vue'


export default {
export default {
  components: {
  components: {
    BIconTrash,
    FAQModal,
    FAQModal,
    CreateCollectionModal
    CreateCollectionModal
  },
  },
@@ -60,6 +63,9 @@ export default {
  methods: {
  methods: {
    loadCollections() {
    loadCollections() {
      this.$store.dispatch('loadCollections');
      this.$store.dispatch('loadCollections');
    },
    deleteCollection(id) {
        this.$store.dispatch('deleteCollection', id);
    }
    }
  }
  }
}
}