mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Check for outdated mods from PlayWithSix and button in listview to update
This commit is contained in:
parent
77026aa4bc
commit
6efdf0d34a
@ -9,6 +9,7 @@
|
|||||||
"express-resource": "~1.0.0",
|
"express-resource": "~1.0.0",
|
||||||
"when": "~3.1.0",
|
"when": "~3.1.0",
|
||||||
"gamedig": "^0.2.4",
|
"gamedig": "^0.2.4",
|
||||||
"ip": "^0.3.0"
|
"ip": "^0.3.0",
|
||||||
|
"playwithsix": "0.0.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,5 +15,13 @@ define(function (require) {
|
|||||||
itemView: ListItemView,
|
itemView: ListItemView,
|
||||||
itemViewContainer: "tbody",
|
itemViewContainer: "tbody",
|
||||||
template: template,
|
template: template,
|
||||||
|
|
||||||
|
initialize: function (options) {
|
||||||
|
this.on("itemview:mods:update", this.update, this);
|
||||||
|
},
|
||||||
|
|
||||||
|
update: function() {
|
||||||
|
this.collection.fetch();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -12,6 +12,23 @@ define(function (require) {
|
|||||||
|
|
||||||
return Marionette.ItemView.extend({
|
return Marionette.ItemView.extend({
|
||||||
tagName: "tr",
|
tagName: "tr",
|
||||||
template: template
|
template: template,
|
||||||
|
|
||||||
|
events: {
|
||||||
|
"click .update": "update"
|
||||||
|
},
|
||||||
|
|
||||||
|
update: function (event) {
|
||||||
|
var self = this;
|
||||||
|
event.preventDefault();
|
||||||
|
$.ajax({
|
||||||
|
url: "/api/mods/" + this.model.get('name'),
|
||||||
|
type: 'PUT',
|
||||||
|
success: function (resp) {
|
||||||
|
self.trigger("mods:update", mods);
|
||||||
|
},
|
||||||
|
error: $.noop
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -1,3 +1,9 @@
|
|||||||
<td>
|
<td>
|
||||||
<a href='#mods/<%-name%>'><%-name%></a>
|
<a href='#mods/<%-name%>'><%-name%></a>
|
||||||
|
<% if (outdated) { %>
|
||||||
|
<a class="btn btn-primary btn-xs update pull-right">
|
||||||
|
<span class="glyphicon glyphicon-save"></span>
|
||||||
|
Update
|
||||||
|
</a>
|
||||||
|
<% } %>
|
||||||
</td>
|
</td>
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
var fs = require('fs')
|
var fs = require('fs')
|
||||||
, path = require('path')
|
, path = require('path')
|
||||||
|
, playwithsix = require('playwithsix')
|
||||||
, when = require('when')
|
, when = require('when')
|
||||||
, nodefn = require('when/node/function');
|
, nodefn = require('when/node/function');
|
||||||
|
|
||||||
var config = require('./../config');
|
var config = require('./../config');
|
||||||
|
|
||||||
|
function downloadMod(mod, cb) {
|
||||||
|
playwithsix.downloadMod(config.path, mod, cb);
|
||||||
|
}
|
||||||
|
|
||||||
function walk (directory) {
|
function walk (directory) {
|
||||||
createFile = function (file, stat) {
|
createFile = function (file, stat) {
|
||||||
return {
|
return {
|
||||||
@ -49,10 +54,13 @@ exports.index = function(req, res){
|
|||||||
} else {
|
} else {
|
||||||
var mods = files.filter(function (file) {
|
var mods = files.filter(function (file) {
|
||||||
return file.charAt(0) == "@";
|
return file.charAt(0) == "@";
|
||||||
}).map(function (mod) {
|
|
||||||
return { name: mod }
|
|
||||||
});
|
});
|
||||||
res.send(mods);
|
|
||||||
|
playwithsix.checkOutdated(config.path, function (outdatedMods, err) {
|
||||||
|
res.send(mods.map(function (mod) {
|
||||||
|
return { name: mod, outdated: outdatedMods.indexOf(mod) >= 0 };
|
||||||
|
}));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -70,6 +78,16 @@ exports.show = function(req, res){
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.update = function(req, res){
|
||||||
|
downloadMod(req.params.mod, function (mods, err) {
|
||||||
|
if (mods && !err) {
|
||||||
|
res.send(mods);
|
||||||
|
} else {
|
||||||
|
res.send(500, err);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
exports.destroy = function(req, res){
|
exports.destroy = function(req, res){
|
||||||
res.send('destroy mod ' + req.params.mod);
|
res.send('destroy mod ' + req.params.mod);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user