mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Show size and last updated in missions list
This commit is contained in:
parent
a09651179c
commit
88c3a2067c
@ -1,3 +1,5 @@
|
||||
var async = require('async');
|
||||
var filesize = require('filesize');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
|
||||
@ -14,16 +16,30 @@ Missions.prototype.missionPath = function (name) {
|
||||
}
|
||||
|
||||
Missions.prototype.list = function (cb){
|
||||
var self = this;
|
||||
fs.readdir(this.missionsPath(), function (err, files) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
} else {
|
||||
var missions = files.map(function (filename) {
|
||||
return {
|
||||
name: filename,
|
||||
};
|
||||
async.map(files, function (filename, cb) {
|
||||
fs.stat(self.missionPath(filename), function (err, stat) {
|
||||
if (err) {
|
||||
cb(err);
|
||||
}
|
||||
|
||||
cb(null, {
|
||||
dateCreated: new Date(stat.ctime),
|
||||
dateModified: new Date(stat.mtime),
|
||||
name: filename,
|
||||
size: stat.size,
|
||||
sizeFormatted: filesize(stat.size),
|
||||
});
|
||||
});
|
||||
}, function (err, missions) {
|
||||
if (cb) {
|
||||
cb(err, missions);
|
||||
}
|
||||
});
|
||||
cb(null, missions);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
@ -20,3 +20,7 @@ body {
|
||||
#footer .container .text-muted {
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.text-nowrap {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Mission</th>
|
||||
<th>Size</th>
|
||||
<th>Updated</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
@ -1,6 +1,8 @@
|
||||
<td style="width: 100%;">
|
||||
<a href='/api/missions/<%-encodeURI(name)%>'><%-name%></a>
|
||||
</td>
|
||||
<td class="text-nowrap"><%-sizeFormatted%></td>
|
||||
<td class="text-nowrap"><%-dateModified.substring(0, 10)%></td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-danger btn-xs delete">
|
||||
<span class="glyphicon glyphicon-trash"></span> Delete
|
||||
|
Loading…
Reference in New Issue
Block a user