Migration of /tags and /settings views

This commit is contained in:
jendib 2014-01-11 20:39:00 +01:00
parent 6963fd9770
commit 9802beaf7b
11 changed files with 180 additions and 147 deletions

View File

@ -5,7 +5,5 @@
*/
App.controller('Settings', function($scope, Restangular) {
// Flag if the user is admin
$scope.userInfo.then(function (data) {
$scope.isAdmin = data.base_functions.indexOf('ADMIN') != -1;
});
$scope.isAdmin = $scope.userInfo.base_functions.indexOf('ADMIN') != -1;
});

View File

@ -11,7 +11,7 @@ App.directive('inlineEdit', function() {
value: '=',
editCallback: '&onEdit'
},
template: '<span ng-click="edit()" ng-bind="value"></span><input type="text" ng-model="value" />',
template: '<span ng-click="edit()" ng-bind="value"></span><input type="text" class="form-control" ng-model="value" />',
link: function (scope, element, attrs) {
// Let's get a reference to the input element, as we'll want to reference it.
var inputElement = angular.element(element.children()[1]);

View File

@ -59,12 +59,22 @@
<body>
<nav class="navbar navbar-default" role="navigation" ng-controller="Navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle"
ng-init="isCollapsed = true"
ng-click="isCollapsed = !isCollapsed">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="navbar-brand loader" ng-class="{'loader-hide': !isLoading() }">
<img src="img/loader.gif" />
</div>
<a class="navbar-brand" href="#">Sismics Docs</a>
</div>
<div class="collapse navbar-collapse" collapse="isCollapsed">
<ul class="nav navbar-nav" ng-show="!userInfo.anonymous">
<li ng-class="{active: $uiRoute}" ui-route="/document.*">
<a href="#/document"><span class="glyphicon glyphicon-book"></span> Documents</a>
@ -91,6 +101,7 @@
</a>
</li>
</ul>
</div>
</nav>
<div ui-view="page">

View File

@ -2,7 +2,7 @@
<div ng-show="document || !isEdit()">
<form name="documentForm" class="form-horizontal">
<div class="form-group" ng-class="{ error: !documentForm.title.$valid }">
<div class="form-group" ng-class="{ 'has-error': !documentForm.title.$valid }">
<label class="col-sm-2 control-label" for="inputTitle">Title</label>
<div class="col-sm-10">
<input required ng-maxlength="100" class="form-control" type="text" id="inputTitle"
@ -11,7 +11,7 @@
typeahead-wait-ms="200" ng-disabled="fileIsUploading" />
</div>
</div>
<div class="form-group" ng-class="{ error: !documentForm.description.$valid }">
<div class="form-group" ng-class="{ 'has-error': !documentForm.description.$valid }">
<label class="col-sm-2 control-label" for="inputDescription">Description</label>
<div class="col-sm-10">
<textarea ng-maxlength="4000" class="form-control" rows="5" id="inputDescription"

View File

@ -28,7 +28,7 @@
<p ng-bind-html="document.description | newline"></p>
<div class="row" ui-sortable="fileSortableOptions" ng-model="files" ng-show="files.length > 0">
<div class="col-md-2 text-center" ng-repeat="file in files">
<div class="col-xs-6 col-sm-4 col-md-3 col-lg-2 text-center" ng-repeat="file in files">
<div class="thumbnail">
<a ng-click="openFile(file)">
<img class="thumbnail-file" ng-src="api/file/{{ file.id }}/data?size=thumb" tooltip="{{ file.mimetype }}" tooltip-placement="top" />

View File

@ -1,28 +1,36 @@
<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
<div class="form-group" ng-class="{ 'has-error': !editUserForm.password.$valid, success: editUserForm.password.$valid }">
<label class="col-sm-2 control-label" for="inputPassword">Password</label>
<div class="col-sm-7">
<input name="password" type="password" id="inputPassword" required class="form-control"
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 class="col-sm-3">
<span class="help-block" ng-show="editUserForm.password.$error.required">Required</span>
<span class="help-block" ng-show="editUserForm.password.$error.minlength">Too short</span>
<span class="help-block" 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
<div class="form-group" ng-class="{ 'has-error': !editUserForm.passwordconfirm.$valid, success: editUserForm.passwordconfirm.$valid }">
<label class="col-sm-2 control-label" for="inputPasswordConfirm">Password (confirm)</label>
<div class="col-sm-7">
<input name="passwordconfirm" type="password" id="inputPasswordConfirm" required class="form-control"
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 class="col-sm-3">
<span class="help-block" ng-show="editUserForm.passwordconfirm.$error.validator">Password and password confirmation must match</span>
</div>
</div>
<div class="form-actions">
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary" ng-click="editUser()" ng-disabled="!editUserForm.$valid">
<span class="icon-pencil icon-white"></span> Edit
<span class="glyphicon glyphicon-pencil"></span> Edit
</button>
</div>
</div>
</form>
<alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)">{{ alert.msg }}</alert>

View File

@ -1,19 +1,23 @@
<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 ng-class="{active: $uiRoute}" ui-route="/settings/account"><a href="#/settings/account">User account</a></li>
<li ng-class="{active: $uiRoute}" ui-route="/settings/session"><a href="#/settings/session">Opened sessions</a></li>
<li class="nav-header" ng-show="isAdmin">General settings</li>
<li ng-show="isAdmin" ng-class="{active: $uiRoute}" ui-route="/settings/user.*"><a href="#/settings/user">Users</a></li>
<li ng-show="isAdmin" ng-class="{active: $uiRoute}" ui-route="/settings/log"><a href="#/settings/log">Server logs</a></li>
<div class="row">
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading"><strong>Personal settings</strong></div>
<ul class="list-group">
<a class="list-group-item" ng-class="{active: $uiRoute}" ui-route="/settings/account" href="#/settings/account">User account</a>
<a class="list-group-item" ng-class="{active: $uiRoute}" ui-route="/settings/session" href="#/settings/session">Opened sessions</a>
</ul>
</div>
<div class="span8 well">
<div ui-view="settings"></div>
<div class="panel panel-default">
<div class="panel-heading" ng-show="isAdmin"><strong>General settings</strong></div>
<ul class="list-group">
<a class="list-group-item" ng-show="isAdmin" ng-class="{active: $uiRoute}" ui-route="/settings/user.*" href="#/settings/user">Users</a>
<a class="list-group-item" ng-show="isAdmin" ng-class="{active: $uiRoute}" ui-route="/settings/log" href="#/settings/log">Server logs</a>
</ul>
</div>
</div>
<div class="col-md-8">
<div class="well" ui-view="settings"></div>
</div>
</div>

View File

@ -11,7 +11,7 @@
<tr ng-repeat="session in sessions | orderBy: '-current'" ng-class="{ 'info': session.current, 'warning': !session.current }">
<td>{{ session.create_date | date: 'yyyy-MM-dd HH:mm' }}</td>
<td>{{ session.last_connection_date | date: 'yyyy-MM-dd HH:mm' }}</td>
<td><span ng-show="session.current" class="icon-ok"></span></td>
<td><span ng-show="session.current" class="glyphicon glyphicon-ok"></span></td>
</tr>
</tbody>
</table>

View File

@ -8,59 +8,72 @@
<small>user</small>
</h2>
<form class="form-horizontal" name="editUserForm" novalidate>
<div class="control-group" ng-class="{ error: !editUserForm.username.$valid, success: editUserForm.username.$valid }">
<label class="control-label" for="inputUsername">Username</label>
<div class="form-group" ng-class="{ 'has-error': !editUserForm.username.$valid, success: editUserForm.username.$valid }">
<label class="col-sm-2 control-label" for="inputUsername">Username</label>
<div class="controls">
<input name="username" type="text" id="inputUsername" required ng-disabled="isEdit()"
<div class="col-sm-7">
<input name="username" type="text" id="inputUsername" required ng-disabled="isEdit()" class="form-control"
ng-minlength="3" ng-maxlength="50" placeholder="Username" ng-model="user.username"/>
<span class="help-inline" ng-show="editUserForm.username.$error.required">Required</span>
<span class="help-inline" ng-show="editUserForm.username.$error.minlength">Too short</span>
<span class="help-inline" ng-show="editUserForm.username.$error.maxlength">Too long</span>
</div>
</div>
<div class="control-group" ng-class="{ error: !editUserForm.email.$valid, success: editUserForm.email.$valid }">
<label class="control-label" for="inputEmail">E-mail</label>
<div class="controls">
<input name="email" type="email" id="inputEmail" required
<div class="col-sm-3">
<span class="help-block" ng-show="editUserForm.username.$error.required">Required</span>
<span class="help-block" ng-show="editUserForm.username.$error.minlength">Too short</span>
<span class="help-block" ng-show="editUserForm.username.$error.maxlength">Too long</span>
</div>
</div>
<div class="form-group" ng-class="{ 'has-error': !editUserForm.email.$valid, success: editUserForm.email.$valid }">
<label class="col-sm-2 control-label" for="inputEmail">E-mail</label>
<div class="col-sm-7">
<input name="email" type="email" id="inputEmail" required class="form-control"
ng-minlength="3" ng-maxlength="50" placeholder="E-mail" ng-model="user.email"/>
<span class="help-inline" ng-show="editUserForm.email.$error.required">Required</span>
<span class="help-inline" ng-show="editUserForm.email.$error.email">Must be a valid e-mail</span>
<span class="help-inline" ng-show="editUserForm.email.$error.minlength">Too short</span>
<span class="help-inline" ng-show="editUserForm.email.$error.maxlength">Too long</span>
</div>
</div>
<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" ng-required="!isEdit()"
<div class="col-sm-3">
<span class="help-block" ng-show="editUserForm.email.$error.required">Required</span>
<span class="help-block" ng-show="editUserForm.email.$error.email">Must be a valid e-mail</span>
<span class="help-block" ng-show="editUserForm.email.$error.minlength">Too short</span>
<span class="help-block" ng-show="editUserForm.email.$error.maxlength">Too long</span>
</div>
</div>
<div class="form-group" ng-class="{ 'has-error': !editUserForm.password.$valid, success: editUserForm.password.$valid }">
<label class="col-sm-2 control-label" for="inputPassword">Password</label>
<div class="col-sm-7">
<input name="password" type="password" id="inputPassword" ng-required="!isEdit()" class="form-control"
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" ng-required="!isEdit()"
<div class="col-sm-3">
<span class="help-block" ng-show="editUserForm.password.$error.required">Required</span>
<span class="help-block" ng-show="editUserForm.password.$error.minlength">Too short</span>
<span class="help-block" ng-show="editUserForm.password.$error.maxlength">Too long</span>
</div>
</div>
<div class="form-group" ng-class="{ 'has-error': !editUserForm.passwordconfirm.$valid, success: editUserForm.passwordconfirm.$valid }">
<label class="col-sm-2 -label" for="inputPasswordConfirm">Password (confirm)</label>
<div class="col-sm-7">
<input name="passwordconfirm" type="password" id="inputPasswordConfirm" ng-required="!isEdit()" class="form-control"
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 class="col-sm-3">
<span class="help-block" ng-show="editUserForm.passwordconfirm.$error.validator">Password and password confirmation must match</span>
</div>
</div>
<div class="form-actions">
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary" ng-click="edit()" ng-disabled="!editUserForm.$valid">
<span class="icon-pencil icon-white"></span> {{ isEdit() ? 'Edit' : 'Add' }}
<span class="glyphicon glyphicon-pencil"></span> {{ isEdit() ? 'Edit' : 'Add' }}
</button>
<button type="button" class="btn btn-danger" ng-click="remove()" ng-show="isEdit()">
<span class="icon-trash icon-white"></span> Delete
<span class="glyphicon glyphicon-trash"></span> Delete
</button>
</div>
</div>
</form>
<alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)">{{ alert.msg }}</alert>
</div>

View File

@ -1,8 +1,7 @@
<h1>Users <small>management</small> <a class="btn btn-primary" href="#/settings/user/add">Add</a></h1>
<div class="container-fluid">
<div class="row-fluid">
<div class="span4 well">
<div class="row">
<div class="col-md-4 well">
<table class="table table-striped table-hover table-users">
<thead>
<tr>
@ -19,8 +18,7 @@
</table>
</div>
<div class="span8">
<div class="col-md-8">
<div ui-view="user"></div>
</div>
</div>
</div>

View File

@ -1,45 +1,46 @@
<div class="container-fluid">
<div class="row-fluid">
<div class="span4 well text-center">
<div class="row">
<div class="col-md-4">
<div class="well">
<form name="tagForm" novalidate>
<div class="control-group" ng-class="{ error: !tagForm.name.$valid }">
<div class="input-prepend input-append input-block-level">
<span colorpicker class="btn" data-color="#3a87ad" ng-model="tag.color" ng-style="{ 'background': tag.color }">&nbsp;</span>
<input type="text" name="name" placeholder="New tag"
<p class="input-group" ng-class="{ 'has-error': !tagForm.name.$valid }">
<span colorpicker class="input-group-addon btn btn-default" data-color="#3a87ad" ng-model="tag.color" ng-style="{ 'background': tag.color }">&nbsp;</span>
<input type="text" name="name" placeholder="New tag" class="form-control"
ng-maxlength="36" required ng-model="tag.name" ui-validate="{duplicate: 'validateDuplicate($value)', space: '!$value || $value.indexOf(\' \') == -1' }">
<button type="submit" class="btn btn-primary" ng-disabled="!tagForm.$valid" ng-click="addTag()">Add</button>
</div>
<span class="help-inline" ng-show="tagForm.name.$error.duplicate">This tag already exists</span>
<span class="help-inline" ng-show="tagForm.name.$error.space">Space are not allowed</span>
</div>
<span class="input-group-addon btn btn-primary" ng-disabled="!tagForm.$valid" ng-click="addTag()">Add</span>
</p>
<span class="help-block" ng-show="tagForm.name.$error.duplicate">This tag already exists</span>
<span class="help-block" ng-show="tagForm.name.$error.space">Space are not allowed</span>
</form>
<div class="input-prepend input-block-level">
<span class="add-on"><span class="icon-search"></span></span>
<input type="text" placeholder="Search" ng-model="search.name">
</div>
<p class="input-group">
<span class="input-group-addon"><span class="glyphicon glyphicon-search"></span></span>
<input type="search" class="form-control" placeholder="Search" ng-model="search.name">
</p>
<table class="table table-striped table-hover table-tags">
<table class="row table table-striped table-hover table-tags">
<tbody>
<tr ng-repeat="tag in tags | filter:search">
<td><inline-edit value="tag.name" on-edit="updateTag(tag)" /></td>
<td class="span1"><span colorpicker class="btn" on-hide="updateTag(tag)" data-color="" ng-model="tag.color" ng-style="{ 'background': tag.color }">&nbsp;</span></td>
<td class="span1"><button class="btn btn-danger pull-right" ng-click="deleteTag(tag)"><span class="icon-trash icon-white"></span></button></td>
<td class="col-xs-1"><span colorpicker class="btn" on-hide="updateTag(tag)" data-color="" ng-model="tag.color" ng-style="{ 'background': tag.color }">&nbsp;</span></td>
<td class="col-xs-1"><button class="btn btn-danger pull-right" ng-click="deleteTag(tag)"><span class="glyphicon glyphicon-trash"></span></button></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="span8 well" ng-if="stats.length >= 0">
<div class="col-md-8" ng-if="stats.length >= 0">
<div class="well">
<h1>{{ tags.length }} <small>tag{{ tags.length > 1 ? 's' : '' }}</small></h1>
<dl class="dl-horizontal" ng-repeat="stat in stats | orderBy: '-count'">
<dt>{{ stat.name }} <span class="badge badge-info" ng-style="{ 'background': stat.color }">{{ stat.count }}</span></dt>
<dd><progress percent="stat.count / getStatCount() * 100" class="progress-info"></progress></dd>
<dd><progressbar value="stat.count / getStatCount() * 100" class="progress-info"></progressbar></dd>
</dl>
</div>
</div>
<div class="span8 well" ng-if="!stats">
<div class="col-md-8" ng-if="!stats">
<div class="well">
<img src="img/loader.gif" />
</div>
</div>