settings page and custom css for users

This commit is contained in:
Athou
2013-04-04 11:36:24 +02:00
parent 19ab1810ce
commit 2f13891f81
17 changed files with 1744 additions and 14 deletions

View File

@@ -342,4 +342,22 @@ module.controller('ManageUserCtrl', function($scope, $state, $stateParams,
}
});
};
});
module.controller('SettingsCtrl', function($scope, $location, SettingsService) {
$scope.settingsService = SettingsService;
$scope.codeMirrorConfig = {
mode : 'css',
lineNumbers : true
};
$scope.cancel = function() {
SettingsService.init(function() {
$location.path('/');
});
};
$scope.save = function() {
SettingsService.save(function() {
$location.path('/');
});
};
});

View File

@@ -232,6 +232,9 @@ module.directive('toolbar', function($state, $stateParams, $route, $location,
$scope.toAdmin = function() {
$location.path('admin');
};
$scope.toSettings = function() {
$location.path('settings');
};
},
link : function($scope, element) {
element.find('.read-mode button').bind('click', function() {

View File

@@ -39,6 +39,12 @@ app.config(function($routeProvider, $stateProvider, $urlRouterProvider) {
templateUrl : 'templates/admin.useredit.html',
controller : 'ManageUserCtrl'
});
$stateProvider.state('settings', {
url : '/settings',
templateUrl : 'templates/settings.html',
controller : 'SettingsCtrl'
});
$urlRouterProvider.when('/', '/feeds/view/category/all');
$urlRouterProvider.when('/admin', '/admin/user/list');

View File

@@ -162,12 +162,22 @@ module.factory('EntryService', function($resource, $http) {
module.factory('SettingsService', function($resource) {
var s = {};
s.settings = {};
$resource('rest/settings/get').get(function(data) {
s.settings = data;
});
s.save = function() {
$resource('rest/settings/save').save(s.settings);
s.save = function(callback) {
$resource('rest/settings/save').save(s.settings, function(data) {
if (callback) {
callback(data);
}
});
};
s.init = function(callback) {
$resource('rest/settings/get').get(function(data) {
s.settings = data;
if (callback) {
callback(data);
}
});
};
s.init();
return s;
});