Skip to content
Permalink
Browse files
Merge pull request #16 from akhil-8607/master
Added sort by Last Modified for storage units
  • Loading branch information
DImuthuUpe committed Aug 5, 2020
2 parents 5c51ebd + bde3e88 commit 7b5b60d20a5b8dd13c3656a0b657fc50e71e81d5
Showing 3 changed files with 18 additions and 10 deletions.
@@ -11,6 +11,7 @@
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#" @click="sortBy('name')">Name</a>
<a class="dropdown-item" href="#" @click="sortBy('size')">Size</a>
<a class="dropdown-item" href="#" @click="sortDateBy('lastModified')">Last Modified</a>
</div>
</div>
</div>
@@ -120,6 +121,9 @@ export default {
showDescription(unit) {
this.selectedStorage = unit
this.$bvModal.show("description-dialog")
},
sortDateBy(prop){
this.storageList.sort((a,b)=>a[prop] > b[prop] ? -1 : 1)
},
sortBy(prop){
this.storageList.sort((a,b)=>a[prop] < b[prop] ? -1 : 1)
@@ -1,7 +1,7 @@
<template>
<div class="row">
<div class="col-7">
<h1 class="h4 mb-4">{{heading}}</h1>
<h1 class="h4 mb-4">Storage Unit >{{heading}}</h1>
</div>
<div class="col-4">
<div class="btn-toolbar">
@@ -11,6 +11,7 @@
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#" @click="sortBy('name')">Name</a>
<a class="dropdown-item" href="#" @click="sortBy('size')">Size</a>
<a class="dropdown-item" href="#" @click="sortDateBy('lastModified')">Last Modified</a>
</div>
</div>
</div>
@@ -61,6 +62,9 @@
}
},
methods:{
sortDateBy(prop){
this.resourcesList.sort((a,b)=>a[prop] > b[prop] ? -1 : 1)
},
sortBy(prop){
this.resources.sort((a,b)=>a[prop] < b[prop] ? -1 : 1)
}
@@ -5,22 +5,22 @@

def storage(request):
# TODO: grpc calls to backend
storage_json = [{"storageId": "ssh-storage1", "name": "One Drive", "size": "20GB", "occupied": "10GB", "lastModified":"26, March 2020", "host": "localhost", "port": 22, "user": "root"},
{"storageId": "ssh-storage1", "name": "Google Drive", "size": "10GB", "occupied": "10GB", "lastModified":"26, March 2020", "host": "scp1", "port": 22, "user": "root"},
{"storageId": "ssh-storage1", "name": "Box", "size": "30GB", "occupied": "10GB", "lastModified":"26, March 2020", "host": "scp2", "port": 22, "user": "root"},
{"storageId": "ssh-storage1", "name": "Drop Box", "size": "40GB", "occupied": "10GB", "lastModified":"26, March 2020"}]
storage_json = [{"storageId": "ssh-storage1", "name": "One Drive", "size": "20GB", "occupied": "10GB", "lastModified":"01/15/2020", "host": "localhost", "port": 22, "user": "root"},
{"storageId": "ssh-storage1", "name": "Google Drive", "size": "10GB", "occupied": "10GB", "lastModified":"01/16/2020", "host": "scp1", "port": 22, "user": "root"},
{"storageId": "ssh-storage1", "name": "Box", "size": "30GB", "occupied": "10GB", "lastModified":"02/15/2020", "host": "scp2", "port": 22, "user": "root"},
{"storageId": "ssh-storage1", "name": "Drop Box", "size": "40GB", "occupied": "10GB", "lastModified":"01/15/2019"}]

return render(request, 'storage.html', {'bundle_name': 'storage',
'data': json.dumps(storage_json),
'title': 'Storage Unit'})


def resources(request, storage_id):
resource_json = [{"resourceId": "Spring project", "name": "Spring project", "size": "11 GB", "lastModified": "Jan 15, 2020"},
{"resourceId": "Trial", "name": "Trial", "size": "12 GB", "lastModified": "Jan 15, 2020"},
{"resourceId": "New", "name": "New", "size": "13 GB", "lastModified": "Jan 15, 2020"},
{"resourceId": "Random testing", "name": "Random testing", "size": "14 GB", "lastModified": "Jan 15, 2020"}]
resource_json = [{"resourceId": "Spring project", "name": "Spring project", "size": "11 GB", "lastModified": "01/15/2020"},
{"resourceId": "Trial", "name": "Trial", "size": "12 GB", "lastModified": "02/15/2020"},
{"resourceId": "New", "name": "New", "size": "13 GB", "lastModified": "03/15/2020"},
{"resourceId": "Random testing", "name": "Random testing", "size": "14 GB", "lastModified": "01/16/2020"}]
return render(request, 'resources.html', {'bundle_name': 'resources',
'data': json.dumps(resource_json),
'title': 'Storage Unit > ' + storage_id})
'title': storage_id})

0 comments on commit 7b5b60d

Please sign in to comment.