mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 05:57:57 +01:00
User settings, alerts on document added
This commit is contained in:
parent
2e95803424
commit
0f75faeccc
@ -1,2 +1 @@
|
|||||||
- Reordering files (server)
|
- Reordering files (server)
|
||||||
- User settings
|
|
@ -35,6 +35,7 @@
|
|||||||
<script src="js/controller/Login.js" type="text/javascript"></script>
|
<script src="js/controller/Login.js" type="text/javascript"></script>
|
||||||
<script src="js/controller/Tag.js" type="text/javascript"></script>
|
<script src="js/controller/Tag.js" type="text/javascript"></script>
|
||||||
<script src="js/controller/Navigation.js" type="text/javascript"></script>
|
<script src="js/controller/Navigation.js" type="text/javascript"></script>
|
||||||
|
<script src="js/controller/Settings.js" type="text/javascript"></script>
|
||||||
<script src="js/service/User.js" type="text/javascript"></script>
|
<script src="js/service/User.js" type="text/javascript"></script>
|
||||||
<script src="js/service/Tag.js" type="text/javascript"></script>
|
<script src="js/service/Tag.js" type="text/javascript"></script>
|
||||||
<script src="js/filter/Newline.js" type="text/javascript"></script>
|
<script src="js/filter/Newline.js" type="text/javascript"></script>
|
||||||
@ -45,11 +46,19 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="navbar" ng-controller="Navigation">
|
<div class="navbar" ng-controller="Navigation">
|
||||||
<div class="navbar-inner">
|
<div class="navbar-inner">
|
||||||
|
<div class="container">
|
||||||
<a class="brand" href="#">Sismics Docs</a>
|
<a class="brand" href="#">Sismics Docs</a>
|
||||||
|
|
||||||
<ul class="nav" ng-show="!userInfo.anonymous">
|
<ul class="nav" ng-show="!userInfo.anonymous">
|
||||||
<li ng-class="{active: $uiRoute}" ui-route="/document.*"><a href="#/document">Documents</a></li>
|
<li ng-class="{active: $uiRoute}" ui-route="/document.*"><a href="#/document"><span class="icon-book"></span> Documents</a></li>
|
||||||
<li ng-class="{active: $uiRoute}" ui-route="/tag.*"><a href="#/tag">Tags</a></li>
|
<li ng-class="{active: $uiRoute}" ui-route="/tag.*"><a href="#/tag"><span class="icon-tag"></span> Tags</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
<ul class="nav pull-right" ng-show="!userInfo.anonymous">
|
||||||
|
<li ng-class="{active: $uiRoute}" ui-route="/settings.*"><a href="#/settings"><span class="icon-cog"></span> Settings</a></li>
|
||||||
|
<li><a href="#" ng-click="logout($event)"><span class="icon-off"></span> Logout</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/**
|
/**
|
||||||
* Trackino application.
|
* Trackino application.
|
||||||
*/
|
*/
|
||||||
var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.route', 'ui.keypress', 'ui.sortable', 'restangular', 'ngSanitize'])
|
var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.route', 'ui.keypress', 'ui.validate', 'ui.sortable', 'restangular', 'ngSanitize'])
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuring modules.
|
* Configuring modules.
|
||||||
@ -29,6 +29,15 @@ var App = angular.module('docs', ['ui.state', 'ui.bootstrap', 'ui.route', 'ui.ke
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.state('settings', {
|
||||||
|
url: '/settings',
|
||||||
|
views: {
|
||||||
|
'page': {
|
||||||
|
templateUrl: 'partial/settings.html',
|
||||||
|
controller: 'Settings'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
.state('document', {
|
.state('document', {
|
||||||
url: '/document',
|
url: '/document',
|
||||||
abstract: true,
|
abstract: true,
|
||||||
|
@ -4,6 +4,16 @@
|
|||||||
* Document edition controller.
|
* Document edition controller.
|
||||||
*/
|
*/
|
||||||
App.controller('DocumentEdit', function($scope, $q, $http, $state, $stateParams, Restangular, Tag) {
|
App.controller('DocumentEdit', function($scope, $q, $http, $state, $stateParams, Restangular, Tag) {
|
||||||
|
// Alerts
|
||||||
|
$scope.alerts = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close an alert.
|
||||||
|
*/
|
||||||
|
$scope.closeAlert = function(index) {
|
||||||
|
$scope.alerts.splice(index, 1);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if in edit mode (false in add mode).
|
* Returns true if in edit mode (false in add mode).
|
||||||
*/
|
*/
|
||||||
@ -61,6 +71,7 @@ App.controller('DocumentEdit', function($scope, $q, $http, $state, $stateParams,
|
|||||||
$scope.document = {};
|
$scope.document = {};
|
||||||
$scope.newFiles = [];
|
$scope.newFiles = [];
|
||||||
$scope.loadDocuments();
|
$scope.loadDocuments();
|
||||||
|
$scope.alerts.push({ type: 'success', msg: 'Document successfully added' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
/**
|
/**
|
||||||
* Main controller.
|
* Main controller.
|
||||||
*/
|
*/
|
||||||
App.controller('Main', function($scope, $state, User) {
|
App.controller('Main', function($scope, $rootScope, $state, User) {
|
||||||
User.userInfo(true).then(function(data) {
|
User.userInfo().then(function(data) {
|
||||||
if (data.anonymous) {
|
if (data.anonymous) {
|
||||||
$state.transitionTo('login');
|
$state.transitionTo('login');
|
||||||
} else {
|
} else {
|
||||||
|
@ -3,6 +3,17 @@
|
|||||||
/**
|
/**
|
||||||
* Navigation controller.
|
* Navigation controller.
|
||||||
*/
|
*/
|
||||||
App.controller('Navigation', function($scope, $rootScope, User) {
|
App.controller('Navigation', function($scope, $state, $rootScope, User, Restangular) {
|
||||||
$rootScope.userInfo = User.userInfo();
|
$rootScope.userInfo = User.userInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User logout.
|
||||||
|
*/
|
||||||
|
$scope.logout = function($event) {
|
||||||
|
User.logout().then(function() {
|
||||||
|
$rootScope.userInfo = User.userInfo(true);
|
||||||
|
$state.transitionTo('main');
|
||||||
|
});
|
||||||
|
$event.preventDefault();
|
||||||
|
};
|
||||||
});
|
});
|
28
docs-web/src/main/webapp/js/controller/Settings.js
Normal file
28
docs-web/src/main/webapp/js/controller/Settings.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Settings controller.
|
||||||
|
*/
|
||||||
|
App.controller('Settings', function($scope, Restangular) {
|
||||||
|
$scope.editUserAlert = false;
|
||||||
|
|
||||||
|
// Alerts
|
||||||
|
$scope.alerts = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Close an alert.
|
||||||
|
*/
|
||||||
|
$scope.closeAlert = function(index) {
|
||||||
|
$scope.alerts.splice(index, 1);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Edit user.
|
||||||
|
*/
|
||||||
|
$scope.editUser = function() {
|
||||||
|
Restangular.one('user').post('', $scope.user).then(function() {
|
||||||
|
$scope.user = {};
|
||||||
|
$scope.alerts.push({ type: 'success', msg: 'Account successfully updated' });
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
@ -23,6 +23,13 @@ App.factory('User', function(Restangular) {
|
|||||||
*/
|
*/
|
||||||
login: function(user) {
|
login: function(user) {
|
||||||
return Restangular.one('user').post('login', user);
|
return Restangular.one('user').post('login', user);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logout the current user.
|
||||||
|
*/
|
||||||
|
logout: function() {
|
||||||
|
return Restangular.one('user').post('logout', {});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -39,3 +39,5 @@
|
|||||||
<h4>Uploading files...</h4>
|
<h4>Uploading files...</h4>
|
||||||
<div class="span6"><progress percent="fileProgress" class="progress-info active"></progress></div>
|
<div class="span6"><progress percent="fileProgress" class="progress-info active"></progress></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)">{{ alert.msg }}</alert>
|
@ -18,7 +18,7 @@
|
|||||||
<label class="checkbox">
|
<label class="checkbox">
|
||||||
<input type="checkbox" ng-model="user.remember" /> Remember me
|
<input type="checkbox" ng-model="user.remember" /> Remember me
|
||||||
</label>
|
</label>
|
||||||
<button type="submit" class="btn" ng-click="login()">Sign in</button>
|
<button type="submit" class="btn btn-primary" ng-click="login()"><span class="icon-ok icon-white"></span> Sign in</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
41
docs-web/src/main/webapp/partial/settings.html
Normal file
41
docs-web/src/main/webapp/partial/settings.html
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row-fluid">
|
||||||
|
<div class="span4 well">
|
||||||
|
<ul class="nav nav-list">
|
||||||
|
<li class="nav-header">Personal settings</li>
|
||||||
|
<li class="active"><a href="#/settings">User account</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="span8 well">
|
||||||
|
<h1>User <small>account</small></h1>
|
||||||
|
<form class="form-horizontal" name="editUserForm" novalidate>
|
||||||
|
<div class="control-group" ng-class="{ error: !editUserForm.password.$valid, success: editUserForm.password.$valid }">
|
||||||
|
<label class="control-label" for="inputPassword">Password</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input name="password" type="password" id="inputPassword" required
|
||||||
|
ng-minlength="8" ng-maxlength="50" placeholder="Password" ng-model="user.password" />
|
||||||
|
<span class="help-inline" ng-show="editUserForm.password.$error.required">Required</span>
|
||||||
|
<span class="help-inline" ng-show="editUserForm.password.$error.minlength">Too short</span>
|
||||||
|
<span class="help-inline" ng-show="editUserForm.password.$error.maxlength">Too long</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="control-group" ng-class="{ error: !editUserForm.passwordconfirm.$valid, success: editUserForm.passwordconfirm.$valid }">
|
||||||
|
<label class="control-label" for="inputPasswordConfirm">Password (confirm)</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input name="passwordconfirm" type="password" id="inputPasswordConfirm" required
|
||||||
|
ui-validate="'$value == user.password'" ui-validate-watch="'user.password'"
|
||||||
|
placeholder="Password (confirm)" ng-model="user.passwordconfirm" />
|
||||||
|
<span class="help-inline" ng-show="editUserForm.passwordconfirm.$error.validator">Password and password confirmation must match</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="form-actions">
|
||||||
|
<button type="submit" class="btn btn-primary" ng-click="editUser()" ng-disabled="!editUserForm.$valid">
|
||||||
|
<span class="icon-pencil icon-white"></span> Edit
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)">{{ alert.msg }}</alert>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
Loading…
Reference in New Issue
Block a user