diff --git a/app/src/Admin.vue b/app/src/Admin.vue index bf3f3952..d08b2cac 100644 --- a/app/src/Admin.vue +++ b/app/src/Admin.vue @@ -25,6 +25,7 @@ th SID th Created th Downloaded + th Download Count th Expire th Size template(v-for="(bucket, sid) in db") @@ -37,6 +38,7 @@ td template(v-if="sum[sid].lastDownload") {{ sum[sid].lastDownload | date}} template(v-else="") - + td {{ sum[sid].downloadCountPre }} {{ sum[sid].downloadCount }} td template(v-if="typeof sum[sid].firstExpire === 'number'") {{ sum[sid].firstExpire | date }} template(v-else) {{ sum[sid].firstExpire }} @@ -49,13 +51,14 @@ td template(v-if="file.metadata.lastDownload") {{ +file.metadata.lastDownload | date}} template(v-else="") - + td {{ file.metadata.downloadCount }} td template(v-if="typeof file.expireDate === 'number'") {{ file.expireDate | date }} template(v-else) {{ file.expireDate }} td.text-right {{ humanFileSize(file.size) }} tfoot tr - td(colspan="3") + td(colspan="4") td.text-right(colspan="2") Sum: {{ humanFileSize(sizeSum) }} @@ -123,10 +126,19 @@ lastDownload: 0, created: Number.MAX_SAFE_INTEGER, password: false, - size: 0 + size: 0, + downloadCount:0, + downloadCountPre: "", }; this.db[sid].forEach(file => { bucketSum.size += file.size; + + if(bucketSum.downloadCount == undefined) { + bucketSum.downloadCount = isNaN(file.metadata.downloadCount) ? "-" : file.metadata.downloadCount; + } else if(bucketSum.downloadCount != file.metadata.downloadCount ) { + bucketSum.downloadCountPre = bucketSum.downloadCount != 0 ? "~" : ""; + bucketSum.downloadCount = bucketSum.downloadCount < file.metadata.downloadCount ? file.metadata.downloadCount : bucketSum.downloadCount; + } if(file.metadata._password) { bucketSum.password = true; } diff --git a/app/src/Download.vue b/app/src/Download.vue index 2a12be5e..5f77147c 100644 --- a/app/src/Download.vue +++ b/app/src/Download.vue @@ -43,7 +43,10 @@ i.pull-right.fa.fa-check.text-success.downloaded(v-show='file.downloaded') p strong {{ file.metadata.name }} - small.file-size(v-if="isFinite(file.size)") ({{ humanFileSize(file.size) }}) + small.file-size(v-if="isFinite(file.size)") ({{ humanFileSize(file.size) }}) + small(v-if="!isNaN(file.metadata.downloadCount)" style="padding-left:10px;") + icon.fa-fw(name="download") + strong(style="padding-left:5px;") {{file.metadata.downloadCount}} p {{ file.metadata.comment }} preview-modal(:preview="preview", :files="previewFiles", :max-size="config.maxPreviewSize", @close="preview=false") @@ -124,6 +127,7 @@ aEl.click(); document.body.removeChild(aEl); file.downloaded = true; + file.metadata.downloadCount = isNaN(file.metadata.downloadCount) ? 1 : ++file.metadata.downloadCount; }, downloadAll(format) { @@ -137,6 +141,7 @@ this.files.forEach(f => { f.downloaded = true; + f.metadata.downloadCount = isNaN(f.metadata.downloadCount) ? 1 : ++f.metadata.downloadCount; }); }, diff --git a/lib/db.js b/lib/db.js index 3d334037..7e664b90 100644 --- a/lib/db.js +++ b/lib/db.js @@ -120,6 +120,7 @@ module.exports = class DB { const data = this.get(sid).find(item => item.key === key); if(!data) return; data.metadata.lastDownload = Date.now(); + data.metadata.downloadCount = isNaN(data.metadata.downloadCount) ? 1 : ++data.metadata.downloadCount await this.store.update(`${sid}++${key}`, data); }