mirror of
https://github.com/Dahlgren/arma-server-web-admin.git
synced 2024-08-30 17:22:10 +00:00
Merge pull request #115 from Dahlgren/feature/socket-settings
Push settings with socket connection
This commit is contained in:
commit
e16b558df6
6
app.js
6
app.js
@ -13,6 +13,7 @@ var Manager = require('./lib/manager')
|
|||||||
var Missions = require('./lib/missions')
|
var Missions = require('./lib/missions')
|
||||||
var Mods = require('./lib/mods')
|
var Mods = require('./lib/mods')
|
||||||
var Logs = require('./lib/logs')
|
var Logs = require('./lib/logs')
|
||||||
|
var Settings = require('./lib/settings')
|
||||||
|
|
||||||
var app = express()
|
var app = express()
|
||||||
var server = require('http').Server(app)
|
var server = require('http').Server(app)
|
||||||
@ -43,15 +44,18 @@ var missions = new Missions(config)
|
|||||||
var mods = new Mods(config)
|
var mods = new Mods(config)
|
||||||
mods.updateMods()
|
mods.updateMods()
|
||||||
|
|
||||||
|
var settings = new Settings(config)
|
||||||
|
|
||||||
app.use('/api/logs', require('./routes/logs')(logs))
|
app.use('/api/logs', require('./routes/logs')(logs))
|
||||||
app.use('/api/missions', require('./routes/missions')(missions))
|
app.use('/api/missions', require('./routes/missions')(missions))
|
||||||
app.use('/api/mods', require('./routes/mods')(mods))
|
app.use('/api/mods', require('./routes/mods')(mods))
|
||||||
app.use('/api/servers', require('./routes/servers')(manager, mods))
|
app.use('/api/servers', require('./routes/servers')(manager, mods))
|
||||||
app.use('/api/settings', require('./routes/settings')(config))
|
app.use('/api/settings', require('./routes/settings')(settings))
|
||||||
|
|
||||||
io.on('connection', function (socket) {
|
io.on('connection', function (socket) {
|
||||||
socket.emit('mods', mods.mods)
|
socket.emit('mods', mods.mods)
|
||||||
socket.emit('servers', manager.getServers())
|
socket.emit('servers', manager.getServers())
|
||||||
|
socket.emit('settings', settings.getPublicSettings())
|
||||||
})
|
})
|
||||||
|
|
||||||
mods.on('mods', function (mods) {
|
mods.on('mods', function (mods) {
|
||||||
|
11
lib/settings.js
Normal file
11
lib/settings.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
var _ = require('lodash')
|
||||||
|
|
||||||
|
var Settings = function (config) {
|
||||||
|
this.config = config
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings.prototype.getPublicSettings = function () {
|
||||||
|
return _.pick(this.config, ['game', 'path', 'type'])
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = Settings
|
@ -37,7 +37,6 @@ define(function (require) {
|
|||||||
initialize: function () {
|
initialize: function () {
|
||||||
layoutView.navigation.show(new NavigationView({settings: settings, servers: servers}));
|
layoutView.navigation.show(new NavigationView({settings: settings, servers: servers}));
|
||||||
missions.fetch();
|
missions.fetch();
|
||||||
settings.fetch();
|
|
||||||
|
|
||||||
var initialized = false;
|
var initialized = false;
|
||||||
|
|
||||||
@ -53,6 +52,9 @@ define(function (require) {
|
|||||||
Backbone.history.start();
|
Backbone.history.start();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
socket.on('settings', function (_settings) {
|
||||||
|
settings.set(_settings);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
home: function () {
|
home: function () {
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
var express = require('express')
|
var express = require('express')
|
||||||
var _ = require('lodash')
|
|
||||||
|
|
||||||
module.exports = function (config) {
|
module.exports = function (settings) {
|
||||||
var router = express.Router()
|
var router = express.Router()
|
||||||
|
|
||||||
router.get('/', function (req, res) {
|
router.get('/', function (req, res) {
|
||||||
res.json(_.pick(config, ['game', 'path', 'type']))
|
res.json(settings.getPublicSettings())
|
||||||
})
|
})
|
||||||
|
|
||||||
return router
|
return router
|
||||||
|
Loading…
Reference in New Issue
Block a user