mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-06 04:09:01 +02:00
ACP integration for Sounds
This commit is contained in:
@@ -5,12 +5,6 @@ define(['uploader', 'sounds'], function(uploader, sounds) {
|
||||
var Settings = {};
|
||||
|
||||
Settings.init = function() {
|
||||
// Sounds tab
|
||||
$('#sounds').find('button[data-action="play"]').on('click', function() {
|
||||
var fileName = $(this).parent().siblings('select').val();
|
||||
sounds.playFile(fileName);
|
||||
});
|
||||
|
||||
Settings.prepare();
|
||||
};
|
||||
|
||||
|
||||
27
public/src/forum/admin/sounds.js
Normal file
27
public/src/forum/admin/sounds.js
Normal file
@@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
/* global define */
|
||||
|
||||
define(['sounds', 'settings'], function(Sounds, Settings) {
|
||||
var SoundsAdmin = {};
|
||||
|
||||
SoundsAdmin.init = function() {
|
||||
// Sounds tab
|
||||
$('.sounds').find('button[data-action="play"]').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var fileName = $(this).parent().parent().find('select').val();
|
||||
Sounds.playFile(fileName);
|
||||
});
|
||||
|
||||
// Load Form Values
|
||||
Settings.load('sounds', $('.sounds form'));
|
||||
|
||||
// Saving of Form Values
|
||||
var saveEl = $('#save');
|
||||
saveEl.on('click', function() {
|
||||
Settings.save('sounds', $('.sounds form'));
|
||||
});
|
||||
};
|
||||
|
||||
return SoundsAdmin;
|
||||
});
|
||||
@@ -43,6 +43,8 @@ define(function() {
|
||||
type: 'success',
|
||||
timeout: 2500
|
||||
});
|
||||
|
||||
socket.emit('admin.restart');
|
||||
});
|
||||
} else {
|
||||
console.log('[settings] Form not found.');
|
||||
|
||||
@@ -28,6 +28,7 @@ var adminController = {
|
||||
languages: {},
|
||||
settings: {},
|
||||
logger: {},
|
||||
sounds: {},
|
||||
users: require('./admin/users'),
|
||||
uploads: require('./admin/uploads')
|
||||
};
|
||||
@@ -112,18 +113,7 @@ adminController.languages.get = function(req, res, next) {
|
||||
};
|
||||
|
||||
adminController.settings.get = function(req, res, next) {
|
||||
meta.sounds.getLocal(function(err, sounds) {
|
||||
// There has GOT to be a better way!
|
||||
sounds = Object.keys(sounds).map(function(name) {
|
||||
return {
|
||||
name: name
|
||||
};
|
||||
});
|
||||
|
||||
res.render('admin/settings', {
|
||||
sounds: sounds
|
||||
});
|
||||
});
|
||||
res.render('admin/settings', {});
|
||||
};
|
||||
|
||||
adminController.logger.get = function(req, res, next) {
|
||||
@@ -181,4 +171,18 @@ adminController.groups.get = function(req, res, next) {
|
||||
});
|
||||
};
|
||||
|
||||
adminController.sounds.get = function(req, res, next) {
|
||||
meta.sounds.getLocal(function(err, sounds) {
|
||||
sounds = Object.keys(sounds).map(function(name) {
|
||||
return {
|
||||
name: name
|
||||
};
|
||||
});
|
||||
|
||||
res.render('admin/sounds', {
|
||||
sounds: sounds
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = adminController;
|
||||
11
src/meta.js
11
src/meta.js
@@ -367,8 +367,15 @@ var fs = require('fs'),
|
||||
|
||||
/* Settings */
|
||||
Meta.settings = {};
|
||||
Meta.settings.get = db.getObject;
|
||||
Meta.settings.set = db.setObject;
|
||||
Meta.settings.get = function(hash, callback) {
|
||||
hash = 'settings:' + hash;
|
||||
db.getObject(hash, callback);
|
||||
};
|
||||
|
||||
Meta.settings.set = function(hash, values, callback) {
|
||||
hash = 'settings:' + hash;
|
||||
db.setObject(hash, values, callback);
|
||||
};
|
||||
|
||||
/* Assorted */
|
||||
Meta.css = {
|
||||
|
||||
@@ -20,6 +20,9 @@ function mainRoutes(app, middleware, controllers) {
|
||||
|
||||
app.get('/admin/groups', middleware.admin.buildHeader, controllers.admin.groups.get);
|
||||
app.get('/api/admin/groups', controllers.admin.groups.get);
|
||||
|
||||
app.get('/admin/sounds', middleware.admin.buildHeader, controllers.admin.sounds.get);
|
||||
app.get('/api/admin/sounds', controllers.admin.sounds.get);
|
||||
}
|
||||
|
||||
function userRoutes(app, middleware, controllers) {
|
||||
|
||||
Reference in New Issue
Block a user