Manual refresh mods button

Fixes #9
This commit is contained in:
Björn Dahlgren 2015-05-30 01:30:53 +02:00
parent 1f3f2d605a
commit f973eca818
4 changed files with 33 additions and 7 deletions

1
app.js
View File

@ -29,6 +29,7 @@ app.resource('api/mods', modsRoutes);
var serversResource = app.resource('api/servers', serversRoutes);
app.resource('api/settings', require('./routes/settings'));
app.post('/api/mods/refresh', modsRoutes.refresh);
app.post('/api/mods/search', modsRoutes.search);
app.get('/api/servers/:server/start', serversRoutes.start);
app.get('/api/servers/:server/stop', serversRoutes.stop);

View File

@ -18,7 +18,8 @@ define(function (require) {
template: template,
events: {
"click #download": "download"
"click #download": "download",
"click #refresh": "refresh",
},
initialize: function (options) {
@ -37,5 +38,19 @@ define(function (require) {
view.modal = modal;
modal.open();
},
refresh: function (event) {
event.preventDefault();
$.ajax({
url: "/api/mods/refresh",
type: 'POST',
success: function (resp) {
},
error: function (resp) {
},
});
},
});
});

View File

@ -1,13 +1,18 @@
<a class="btn btn-primary" id="refresh" href="#">
<span class="glyphicon glyphicon-refresh"></span>
Refresh
</a>
<a class="btn btn-primary" id="download" href="#">
<span class="glyphicon glyphicon-search"></span>
Search &amp; Download
</a>
<table class="table table-striped">
<thead>
<tr>
<th>Mod</th>
<th>
<a class="btn btn-primary btn-xs pull-right" id="download" href="#">
<span class="glyphicon glyphicon-search"></span>
Search &amp; Download
</a>
</th>
<th></th>
</tr>
</thead>

View File

@ -39,6 +39,11 @@ module.exports = function (modsManager) {
res.send('destroy mod ' + req.params.mod);
},
refresh: function(req, res){
modsManager.updateMods();
res.send(200, {});
},
search: function(req, res){
var query = req.body.query || "";
modsManager.search(query, function (err, mods) {