Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 30 additions & 4 deletions src/static/riot/datasets/management.tag
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<data-management>
<!-------------------------------------
Search and filter bits
------------------------------------->
-------------------------------------->

<div class="ui icon input">
<input type="text" placeholder="Search..." ref="search" onkeyup="{ filter.bind(this, undefined) }">
<i class="search icon"></i>
Expand All @@ -26,13 +27,14 @@

<!-------------------------------------
Data Table
------------------------------------->
-------------------------------------->
<table class="ui {selectable: datasets.length > 0} celled compact table">
<thead>
<tr>
<th>Name</th>
<th width="175px">Type</th>
<th width="125px">Uploaded...</th>
<th width="175px">Size</th>
<th width="125px">Uploaded</th>
<th width="60px">In Use</th>
<th width="60px">Public</th>
<th width="50px">Delete?</th>
Expand All @@ -45,6 +47,7 @@
onclick="{show_info_modal.bind(this, dataset)}">
<td>{ dataset.name }</td>
<td>{ dataset.type }</td>
<td>{ format_file_size(dataset.file_size) }</td>
<td>{ timeSince(Date.parse(dataset.created_when)) } ago</td>
<td class="center aligned">
<i class="checkmark box icon green" show="{ dataset.in_use.length > 0 }"></i>
Expand Down Expand Up @@ -77,7 +80,7 @@
Pagination
-------------------------------------->
<tr>
<th colspan="7" if="{datasets.length > 0}">
<th colspan="8" if="{datasets.length > 0}">
<div class="ui right floated pagination menu" if="{datasets.length > 0}">
<a show="{!!_.get(pagination, 'previous')}" class="icon item" onclick="{previous_page}">
<i class="left chevron icon"></i>
Expand Down Expand Up @@ -443,6 +446,29 @@
}
}

// Function to format file size
self.format_file_size = function(file_size) {
// parse file size from string to float
try {
n = parseFloat(file_size)
}
catch(err) {
// return empty string if parsing fails
return ""
}
// constant units to show with files size
// file size is in KB, converting it to MB and GB
const units = ['KB', 'MB', 'GB']
// loop incrementer for selecting desired unit
let i = 0
// loop over n until it is greater than 1000
while(n >= 1000 && ++i){
n = n/1000;
}
// restrict file size to 1 decimal number concatinated with unit
return(n.toFixed(1) + ' ' + units[i]);
}

</script>

<style type="text/stylus">
Expand Down