From f973eca8189fd4b7e187fa6a83119143d0de6a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bjo=CC=88rn=20Dahlgren?= Date: Sat, 30 May 2015 01:30:53 +0200 Subject: [PATCH] Manual refresh mods button Fixes #9 --- app.js | 1 + public/js/app/views/mods/list.js | 17 ++++++++++++++++- public/js/tpl/mods/list.html | 17 +++++++++++------ routes/mods.js | 5 +++++ 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/app.js b/app.js index dbd3f64..858f8dd 100644 --- a/app.js +++ b/app.js @@ -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); diff --git a/public/js/app/views/mods/list.js b/public/js/app/views/mods/list.js index 963cfde..e8befc2 100644 --- a/public/js/app/views/mods/list.js +++ b/public/js/app/views/mods/list.js @@ -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) { + + }, + }); + }, }); }); diff --git a/public/js/tpl/mods/list.html b/public/js/tpl/mods/list.html index be4bad5..369e682 100644 --- a/public/js/tpl/mods/list.html +++ b/public/js/tpl/mods/list.html @@ -1,13 +1,18 @@ + + + Refresh + + + + + Search & Download + + - + diff --git a/routes/mods.js b/routes/mods.js index de7f583..8492fc5 100644 --- a/routes/mods.js +++ b/routes/mods.js @@ -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) {
Mod - - - Search & Download - -