Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Did some shit
Browse files Browse the repository at this point in the history
  • Loading branch information
konnork committed Sep 22, 2017
1 parent 52f829c commit c46bf5f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
9 changes: 7 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ var http = require('http'),
apiRouter = require('./server/routes/api.js'),
indexRouter = require('./server/routes/index.js'),
shortenerRouter = require('./server/routes/shortener.js'),
sharedsession = require('express-socket.io-session');
sharedsession = require('express-socket.io-session'),
Configuration = require('./server/db/model/Configuration.js');

// Force https
app.use(function(req, res, next) {
Expand Down Expand Up @@ -167,7 +168,11 @@ if (config.service === 'shortener') {
require('./server/interactors/setup.js');
}

require('./server/socketio/index.js')(io);
Configuration.findOne().then(configuration => {
if (configuration.is_chat_enabled) {
require('./server/socketio/index.js')(io);
}
});

// Now we start the server
if (config.start_server) {
Expand Down
10 changes: 7 additions & 3 deletions app/pages/live/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ class LivePage extends React.Component {
<Row>
<Mentorship />
</Row>
<Row>
<Chat />
</Row>
{this.props.configurationState.data.is_chat_enabled ? (
<Row>
<Chat />
</Row>
) : (
undefined
)}
<Double>
<Hardware />
<Resources />
Expand Down
9 changes: 9 additions & 0 deletions server/db/model/Configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ var schema = new mongoose.Schema(
label: 'Application Open'
}
},
is_chat_enabled: {
type: Boolean,
default: false,
required: true,
form: {
user_editable: true,
label: 'Chat Enabled'
}
},
save_button: {
type: String,
form: {
Expand Down
4 changes: 4 additions & 0 deletions server/routes/api/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ router.post('/control', authMiddleware('admin', 'api'), function(req, res) {
req.body.is_live_page_enabled !== undefined
? req.body.is_live_page_enabled
: configuration.is_live_page_enabled;
configuration.is_chat_enabled =
req.body.is_chat_enabled !== undefined
? req.body.is_chat_enabled
: configuration.is_chat_enabled;
configuration.is_application_open =
req.body.is_application_open !== undefined
? req.body.is_application_open
Expand Down

0 comments on commit c46bf5f

Please sign in to comment.