mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Sort logs by creation date in descending order
This commit is contained in:
parent
a33c866644
commit
0d9b6134b7
@ -97,13 +97,15 @@ Logs.prototype.logFiles = function (callback) {
|
|||||||
|
|
||||||
async.filter(files, function (file, cb) {
|
async.filter(files, function (file, cb) {
|
||||||
fs.stat(file.path, function (err, stat) {
|
fs.stat(file.path, function (err, stat) {
|
||||||
|
file.created = stat.birthtime.toISOString()
|
||||||
|
file.modified = stat.mtime.toISOString()
|
||||||
file.formattedSize = filesize(stat.size)
|
file.formattedSize = filesize(stat.size)
|
||||||
file.size = stat.size
|
file.size = stat.size
|
||||||
cb(!err && stat.isFile())
|
cb(!err && stat.isFile())
|
||||||
})
|
})
|
||||||
}, function (files) {
|
}, function (files) {
|
||||||
files.sort(function (a, b) {
|
files.sort(function (a, b) {
|
||||||
return a.name.toLowerCase().localeCompare(b.name.toLowerCase())
|
return b.created.localeCompare(a.created) // Descending order
|
||||||
})
|
})
|
||||||
|
|
||||||
callback(null, files)
|
callback(null, files)
|
||||||
|
@ -3,7 +3,9 @@ var Backbone = require('backbone')
|
|||||||
var Log = require('app/models/log')
|
var Log = require('app/models/log')
|
||||||
|
|
||||||
module.exports = Backbone.Collection.extend({
|
module.exports = Backbone.Collection.extend({
|
||||||
comparator: 'name',
|
comparator: function (a, b) {
|
||||||
|
return b.get('created').localeCompare(a.get('created')) // Descending order
|
||||||
|
},
|
||||||
model: Log,
|
model: Log,
|
||||||
url: '/api/logs/'
|
url: '/api/logs/'
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user