Skip to content

Commit

Permalink
Remove slack integration settings from public config pantsel#144
Browse files Browse the repository at this point in the history
  • Loading branch information
pantsel committed Jun 10, 2018
1 parent c56999f commit 417c0fc
Show file tree
Hide file tree
Showing 5 changed files with 209 additions and 163 deletions.
42 changes: 33 additions & 9 deletions api/controllers/SettingsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,39 @@ var _ = require('lodash');
*/
module.exports = _.merge(_.cloneDeep(require('../base/Controller')), {

find : function(req,res) {
find: function (req, res) {

sails.models.settings.find().limit(1)
.exec(function(err,settings){
sails.models.settings.find().limit(1)
.exec(function (err, settings) {

if(err) return res.negotiate(err)
// Store settings in memory
sails.KONGA_CONFIG = settings[0].data || {}
return res.json(settings[0] ? settings[0] : {})
})
}
if (err) return res.negotiate(err)

var _settings = settings[0];
if(!_settings) {
sails.KONGA_CONFIG = {}
return res.json({})
}

// Remove integrations from public json
delete _settings.data.integrations;

// Store settings in memory
sails.KONGA_CONFIG = settings[0].data || {}
return res.json(settings[0] ? settings[0] : {})
})
},

getIntegrations : function (req,res) {
sails.models.settings.find().limit(1)
.exec(function (err, settings) {

if (err) return res.negotiate(err)

if(!settings[0]) {
return res.json({})
}

return res.json(settings[0].data.integrations);
})
}
});
62 changes: 33 additions & 29 deletions assets/js/app/settings/01_settings.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
(function () {
'use strict';

(function() {
'use strict';
angular.module('frontend.settings', []);

angular.module('frontend.settings', [
]);

// Module configuration
angular.module('frontend.settings')
.config([
'$stateProvider',
function config($stateProvider) {
$stateProvider
.state('settings', {
url: '/settings',
parent: 'frontend',
data: {
access: 0,
pageName: "Settings",
displayName: "settings",
prefix: '<i class="mdi mdi-settings"></i>'
},
views: {
'content@': {
templateUrl: 'js/app/settings/index.html',
controller: 'SettingsController',
}
}
})
// Module configuration
angular.module('frontend.settings')
.config([
'$stateProvider',
function config($stateProvider) {
$stateProvider
.state('settings', {
url: '/settings',
parent: 'frontend',
data: {
access: 0,
pageName: "Settings",
displayName: "settings",
prefix: '<i class="mdi mdi-settings"></i>'
},
views: {
'content@': {
templateUrl: 'js/app/settings/index.html',
controller: 'SettingsController',
resolve: {
_integrations : ['$http', function ($http) {
return $http.get('/api/settings/integrations');
}]
}

}
}
])
;
})

}
])
;
}());
2 changes: 1 addition & 1 deletion assets/js/app/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ <h5>Transports</h5>
</p>
<hr>
<div class="row">
<div class="col-md-4" ng-repeat="item in KONGA_CONFIG.integrations">
<div class="col-md-4" ng-repeat="item in integrations">

<div
ng-class="{'panel-primary' : item.config.enabled}"
Expand Down
Loading

0 comments on commit 417c0fc

Please sign in to comment.