Migration of /document views

This commit is contained in:
jendib 2014-01-11 16:38:58 +01:00
parent 85aa16afba
commit 6963fd9770
16 changed files with 5559 additions and 172 deletions

View File

@ -113,7 +113,7 @@ App.controller('DocumentEdit', function($rootScope, $scope, $q, $http, $state, $
// Send the file
var promiseFile = $http.put('api/file',
formData, {
headers: { 'Content-Type': false },
headers: { 'Content-Type': undefined },
transformRequest: function(data) { return data; }
});

View File

@ -7,7 +7,7 @@ App.controller('FileView', function($modal, $state, $stateParams) {
var modal = $modal.open({
windowClass: 'modal modal-fileview',
templateUrl: 'partial/docs/file.view.html',
controller: function($scope, $state, $stateParams, Restangular, dialog) {
controller: function($rootScope, $scope, $state, $stateParams, Restangular) {
// Load files
Restangular.one('file').getList('list', { id: $stateParams.id }).then(function(data) {
$scope.files = data.files;
@ -28,7 +28,6 @@ App.controller('FileView', function($modal, $state, $stateParams) {
if (value.id == $stateParams.fileId) {
var next = $scope.files[key + 1];
if (next) {
dialog.close({});
$state.transitionTo('document.view.file', { id: $stateParams.id, fileId: next.id });
}
}
@ -43,7 +42,6 @@ App.controller('FileView', function($modal, $state, $stateParams) {
if (value.id == $stateParams.fileId) {
var previous = $scope.files[key - 1];
if (previous) {
dialog.close({});
$state.transitionTo('document.view.file', { id: $stateParams.id, fileId: previous.id });
}
}
@ -61,13 +59,17 @@ App.controller('FileView', function($modal, $state, $stateParams) {
* Close the file preview.
*/
$scope.closeFile = function () {
dialog.close();
modal.dismiss();
};
// Close the modal when the user exits this state
var off = $scope.$on('$stateChangeStart', function(event, toState){
if (dialog.isOpen()) {
dialog.close(toState.name == 'document.view.file' ? {} : null);
var off = $rootScope.$on('$stateChangeStart', function(event, toState) {
if (!modal.closed) {
if (toState.name == 'document.view.file') {
modal.close();
} else {
modal.dismiss();
}
}
off();
});
@ -75,9 +77,11 @@ App.controller('FileView', function($modal, $state, $stateParams) {
});
// Returns to document view on file close
modal.result.then(function(result) {
if (result == null) {
modal.closed = false;
modal.result.then(function() {
modal.closed = true;
}, function() {
modal.closed = true;
$state.transitionTo('document.view', { id: $stateParams.id });
}
});
});

View File

@ -4,7 +4,9 @@
* Navigation controller.
*/
App.controller('Navigation', function($scope, $http, $state, $rootScope, User, Restangular) {
$rootScope.userInfo = User.userInfo();
User.userInfo().then(function(data) {
$rootScope.userInfo = data;
});
// Last time when the errors logs was checked
$scope.lastLogCheck = new Date().getTime();
@ -47,7 +49,9 @@ App.controller('Navigation', function($scope, $http, $state, $rootScope, User, R
*/
$scope.logout = function($event) {
User.logout().then(function() {
$rootScope.userInfo = User.userInfo(true);
User.userInfo(true).then(function(data) {
$rootScope.userInfo = data;
});
$state.transitionTo('main');
});
$event.preventDefault();

View File

@ -57,34 +57,43 @@
<script src="app/docs/directive/InlineEdit.js" type="text/javascript"></script>
</head>
<body>
<div class="navbar" ng-controller="Navigation">
<div class="navbar-inner">
<div class="container">
<div class="brand loader hidden-phone" ng-class="{hide: !isLoading() }">
<nav class="navbar navbar-default" role="navigation" ng-controller="Navigation">
<div class="navbar-header">
<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>
<a class="brand hidden-phone" href="#">Sismics Docs</a>
<ul class="nav" ng-show="!userInfo.anonymous">
<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"><span class="icon-tag"></span> Tags</a></li>
<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>
</li>
<li ng-class="{active: $uiRoute}" ui-route="/tag.*">
<a href="#/tag"><span class="glyphicon glyphicon-tags"></span> Tags</a>
</li>
</ul>
<ul class="nav pull-right" ng-show="!userInfo.anonymous">
<ul class="nav navbar-nav navbar-right" ng-show="!userInfo.anonymous">
<li ng-show="errorNumber > 0">
<a href="#/settings/log" ng-click="openLogs()" class="nav-text-error">
<span class="icon-warning-sign"></span> {{ errorNumber }} new error{{ errorNumber > 1 ? 's' : '' }}
<span class="glyphicon glyphicon-warning-sign"></span> {{ errorNumber }} new error{{ errorNumber > 1 ? 's' : '' }}
</a>
</li>
<li ng-class="{active: $uiRoute}" ui-route="/settings.*">
<a href="#/settings/account">
<span class="glyphicon glyphicon-cog"></span> Settings
</a>
</li>
<li>
<a href="#" ng-click="logout($event)">
<span class="glyphicon glyphicon-off"></span> Logout
</a>
</li>
<li ng-class="{active: $uiRoute}" ui-route="/settings.*"><a href="#/settings/account"><span class="icon-cog"></span><span class="hidden-phone"> Settings</span></a></li>
<li><a href="#" ng-click="logout($event)"><span class="icon-off"></span><span class="hidden-phone"> Logout</span></a></li>
</ul>
</div>
</div>
</div>
</nav>
<main ui-view="page">
</main>
<div ui-view="page">
</div>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,11 @@
<div>
<ul class="inline">
<li ng-repeat="tag in tags"><span class="label label-info" ng-style="{ 'background': tag.color }">{{ tag.name }} <span class="icon-remove icon-white" ng-click="deleteTag(tag)" ng-show="!ngDisabled"></span></span></li>
<ul class="list-inline">
<li ng-repeat="tag in tags">
<span class="label label-info" ng-style="{ 'background': tag.color }">{{ tag.name }}
<span class="glyphicon glyphicon-remove" ng-click="deleteTag(tag)" ng-show="!ngDisabled"></span>
</span>
</li>
</ul>
<input class="span12" type="text" id="{{ ref }}" placeholder="Type a tag" ng-model="input" ng-disabled="ngDisabled"
<input class="form-control" type="text" id="{{ ref }}" placeholder="Type a tag" ng-model="input" ng-disabled="ngDisabled"
autocomplete="off" typeahead="tag.name for tag in allTags | filter: $viewValue" typeahead-on-select="addTag()" />
</div>

View File

@ -12,8 +12,8 @@
<div class="clearfix"></div>
<div class="muted">
<ul class="inline">
<div class="text-muted">
<ul class="list-inline">
<li><strong>Version:</strong> {{ app.current_version }}</li>
<li><strong>Memory:</strong> {{ app.free_memory / 1000000 | number: 0 }}/{{ app.total_memory / 1000000 | number: 0 }} MB</li>
</ul>

View File

@ -1,62 +1,64 @@
<img src="img/loader.gif" ng-show="!document && isEdit()" />
<div ng-show="document || !isEdit()">
<form class="form-horizontal" name="documentForm">
<div class="control-group" ng-class="{ error: !documentForm.title.$valid }">
<label class="control-label" for="inputTitle">Title</label>
<div class="controls">
<input required ng-maxlength="100" class="input-block-level" type="text" id="inputTitle"
<form name="documentForm" class="form-horizontal">
<div class="form-group" ng-class="{ 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"
placeholder="Title" name="title" ng-model="document.title" autocomplete="off"
typeahead="document for document in getTitleTypeahead($viewValue) | filter: $viewValue"
typeahead-wait-ms="200" ng-disabled="fileIsUploading" />
</div>
</div>
<div class="control-group" ng-class="{ error: !documentForm.description.$valid }">
<label class="control-label" for="inputDescription">Description</label>
<div class="controls">
<textarea ng-maxlength="4000" class="input-block-level" rows="5" id="inputDescription"
<div class="form-group" ng-class="{ 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"
name="description" ng-model="document.description" ng-disabled="fileIsUploading"></textarea>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputCreateDate">Creation date</label>
<div class="controls">
<input type="text" id="inputCreateDate" ng-readonly="true" datepicker-popup="yyyy-MM-dd"
<div class="form-group">
<label class="col-sm-2 control-label" for="inputCreateDate">Creation date</label>
<div class="col-sm-10">
<input type="text" id="inputCreateDate" ng-readonly="true" datepicker-popup="yyyy-MM-dd" class="form-control"
ng-model="document.create_date" starting-day="1" show-weeks="false" ng-disabled="fileIsUploading" />
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputCreateDate">Language</label>
<div class="controls">
<select id="inputLanguage" ng-model="document.language" ng-disabled="fileIsUploading">
<div class="form-group">
<label class="col-sm-2 control-label" for="inputLanguage">Language</label>
<div class="col-sm-10">
<select class="form-control" id="inputLanguage" ng-model="document.language" ng-disabled="fileIsUploading">
<option value="fra">French</option>
<option value="eng">English</option>
<option value="jpn">Japanese</option>
</select>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputFiles">New files</label>
<div class="controls">
<file class="input-block-level" id="inputFiles" multiple="multiple" ng-model="newFiles"
accept="image/png,image/jpg,image/jpeg,image/gif,application/pdf" ng-disabled="fileIsUploading" />
<div class="form-group">
<label class="col-sm-2 control-label" for="inputFiles">New files</label>
<div class="col-sm-10">
<file class="form-control" id="inputFiles" multiple="multiple" ng-model="newFiles"
accept="image/png,image/jpg,image/jpeg,image/gif,application/pdf" ng-disabled="fileIsUploading"></file>
</div>
</div>
<div class="control-group">
<label class="control-label" for="inputTags">Tags</label>
<div class="controls">
<select-tag tags="document.tags" class="input-block-level" ref="inputTags" ng-disabled="fileIsUploading" />
<div class="form-group">
<label class="col-sm-2 control-label" for="inputTags">Tags</label>
<div class="col-sm-10">
<select-tag tags="document.tags" ref="inputTags" ng-disabled="fileIsUploading"></select-tag>
</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-disabled="!documentForm.$valid || fileIsUploading" ng-click="edit()">{{ isEdit() ? 'Edit' : 'Add' }}</button>
<button type="submit" class="btn" ng-click="cancel()" ng-disabled="fileIsUploading">Cancel</button>
<button type="submit" class="btn btn-default" ng-click="cancel()" ng-disabled="fileIsUploading">Cancel</button>
</div>
</div>
</form>
<div class="row-fluid" ng-show="fileIsUploading">
<div class="row" ng-show="fileIsUploading">
<h4>Uploading files...</h4>
<div class="span6"><progress percent="fileProgress" class="progress-info active"></progress></div>
<div class="col-md-6"><progressbar value="fileProgress" class="progress-info active"></progressbar></div>
</div>
<alert ng-repeat="alert in alerts" type="alert.type" close="closeAlert($index)">{{ alert.msg }}</alert>

View File

@ -1,13 +1,13 @@
<div class="container-fluid">
<div class="row-fluid">
<div class="span4 well">
<div class="row">
<div class="col-md-4">
<div class="well">
<p class="text-center">
<button class="btn btn-primary" type="button" ng-click="addDocument()"><span class="icon-plus icon-white"></span> Add a document</button>
<button class="btn btn-primary" type="button" ng-click="addDocument()"><span class="glyphicon glyphicon-plus"></span> Add a document</button>
</p>
<p class="input-prepend text-center input-block-level">
<span class="add-on"><span class="icon-search"
<div class="input-group">
<span class="input-group-addon">
<span class="glyphicon glyphicon-search"
tooltip-placement="bottom"
tooltip-html-unsafe="before:2012-05<br/>
after:2012-05<br/>
@ -15,26 +15,28 @@
tag:car<br/>
full:led<br/>
shared:yes<br/>
lang:fra"
></span></span>
<input type="text" placeholder="Search" ng-model="search" class="span10" />
</p>
lang:fra"></span>
</span>
<input type="search" class="form-control" placeholder="Search" ng-model="search" />
</div>
<table class="table table-striped table-hover table-documents">
<table class="row table table-striped table-hover table-documents">
<thead>
<tr>
<th class="span6" ng-click="sortDocuments(1)"><span class="icon-chevron-{{ sortColumn == 1 ? (asc ? 'down' : 'up') : '' }}"></span> Title</th>
<th class="span3" ng-click="sortDocuments(3)"><span class="icon-chevron-{{ sortColumn == 3 ? (asc ? 'down' : 'up') : '' }}"></span> Creation date</th>
<th class="span3 hidden-phone">Tags</th>
<th class="col-xs-6" ng-click="sortDocuments(1)"><span class="glyphicon glyphicon-chevron-{{ sortColumn == 1 ? (asc ? 'down' : 'up') : '' }}"></span> Title</th>
<th class="col-xs-3" ng-click="sortDocuments(3)"><span class="glyphicon glyphicon-chevron-{{ sortColumn == 3 ? (asc ? 'down' : 'up') : '' }}"></span> Creation date</th>
<th class="col-xs-3 hidden-xs">Tags</th>
</tr>
</thead>
<tbody>
<tr ng-click="viewDocument(document.id)" ng-repeat="document in documents">
<td>{{ document.title }} ({{ document.file_count }})<span class="icon-share" ng-if="document.shared" tooltip="Shared"></span></td>
<td>{{ document.title }} ({{ document.file_count }}) <span class="glyphicon glyphicon-share" ng-if="document.shared" tooltip="Shared"></span></td>
<td>{{ document.create_date | date: 'yyyy-MM-dd' }}</td>
<td class="hidden-phone cell-tags">
<td class="hidden-xs cell-tags">
<div class="tags">
<span class="label label-info" ng-repeat="tag in document.tags" ng-style="{ 'background': tag.color }"><span class="shorten">{{ tag.name | shorten }}</span><span class="full">{{ tag.name }}</span></span>
<span class="label label-info" ng-repeat="tag in document.tags" ng-style="{ 'background': tag.color }">
<span class="shorten">{{ tag.name | shorten }}</span><span class="full">{{ tag.name }}</span>
</span>
</div>
</td>
</tr>
@ -48,10 +50,10 @@
<div class="text-right">
{{ totalDocuments }} document{{ totalDocuments > 1 ? 's' : '' }} found
</div>
</div>
</div>
</div>
<div class="span8 well">
<div ui-view="document"></div>
</div>
<div class="col-md-8">
<div class="well" ui-view="document"></div>
</div>
</div>

View File

@ -8,6 +8,8 @@
</p>
</div>
<div class="modal-footer">
<button ng-click="close(name)" class="btn btn-primary"><span class="icon-share icon-white"></span> Share</button>
<button ng-click="close(null)" class="btn">Cancel</button>
<button ng-click="close(name)" class="btn btn-primary">
<span class="glyphicon glyphicon-share"></span> Share
</button>
<button ng-click="close(null)" class="btn btn-default">Cancel</button>
</div>

View File

@ -3,42 +3,48 @@
<div ng-show="document">
<div class="text-right">
<div class="btn-group">
<button class="btn btn-danger" ng-click="deleteDocument(document)"><span class="icon-trash icon-white"></span> Delete</button>
<button class="btn btn-primary" ng-click="editDocument(document.id)"><span class="icon-pencil icon-white"></span> Edit</button>
<button class="btn btn-danger" ng-click="deleteDocument(document)"><span class="glyphicon glyphicon-trash"></span> Delete</button>
<button class="btn btn-primary" ng-click="editDocument(document.id)"><span class="glyphicon glyphicon-pencil"></span> Edit</button>
</div>
</div>
<div class="page-header">
<h1>{{ document.title }} <small>{{ document.create_date | date: 'yyyy-MM-dd' }}</small> <img ng-if="document" ng-src="img/flag/{{ document.language }}.png" title="{{ document.language }}" /></h1>
<p>
<button class="btn btn-small btn-inverse" ng-click="share()"><span class="icon-share icon-white"></span> Share</button>
<button class="btn btn-small" ng-repeat="share in document.shares" ng-click="showShare(share)"><span class="icon-ok"></span> {{ share.name ? share.name : 'shared' }}</button>
<button class="btn btn-sm btn-info" ng-click="share()">
<span class="glyphicon glyphicon-share"></span> Share
</button>
<button class="btn btn-default btn-sm" ng-repeat="share in document.shares" ng-click="showShare(share)">
<span class="glyphicon glyphicon-ok"></span> {{ share.name ? share.name : 'shared' }}
</button>
</p>
<ul class="inline">
<li ng-repeat="tag in document.tags"><span class="label label-info" ng-style="{ 'background': tag.color }">{{ tag.name }}</span></li>
<ul class="list-inline">
<li ng-repeat="tag in document.tags">
<span class="label label-info" ng-style="{ 'background': tag.color }">{{ tag.name }}</span>
</li>
</ul>
</div>
<p ng-bind-html="document.description | newline"></p>
<ul class="thumbnails thumbnails-file" ui-sortable="fileSortableOptions" ng-model="files" ng-show="files.length > 0">
<li class="span2 text-center thumbnail-container" ng-repeat="file in files">
<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="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" />
</a>
<div class="caption">
<div class="pull-left">
<div class="btn handle"><span class="icon-resize-horizontal"></span></div>
<div class="btn btn-default handle"><span class="glyphicon glyphicon-resize-horizontal"></span></div>
</div>
<div class="pull-right">
<button class="btn btn-danger" ng-click="deleteFile(file)"><span class="glyphicon glyphicon-trash"></span></button>
</div>
<p class="pull-right">
<button class="btn btn-danger" ng-click="deleteFile(file)"><span class="icon-trash icon-white"></span></button>
</p>
<div class="clearfix"></div>
</div>
</div>
</li>
</ul>
</div>
</div>
<div ui-view="file"></div>
</div>

View File

@ -1,21 +1,23 @@
<div class="text-center">
<div class="btn-group pull-left">
<button type="button" class="btn" ng-click="closeFile()"><span class="icon-remove"></span></button>
<button type="button" class="btn btn-default" ng-click="closeFile()">
<span class="glyphicon glyphicon-remove"></span>
</button>
</div>
<div class="btn-group">
<button type="button" class="btn" ng-click="previousFile()">Previous</button>
<button type="button" class="btn" ng-click="nextFile()">Next</button>
<button type="button" class="btn btn-default" ng-click="previousFile()">Previous</button>
<button type="button" class="btn btn-default" ng-click="nextFile()">Next</button>
</div>
<div class="btn-group pull-right">
<button type="button" class="btn" ng-click="openFile()"><span class="icon-download-alt"></span></button>
<button type="button" class="btn btn-default" ng-click="openFile()">
<span class="glyphicon glyphicon-download-alt"></span>
</button>
</div>
</div>
<img ng-if="$stateParams.fileId && (file.mimetype == 'image/png' || file.mimetype == 'image/jpeg' || file.mimetype == 'image/gif')" ng-src="api/file/{{ $stateParams.fileId }}/data?size=web" />
<div class="text-center" ng-if="$stateParams.fileId && file.mimetype == 'application/pdf'">
<div class="text-center" ng-if="$stateParams.fileId">
<img ng-src="api/file/{{ $stateParams.fileId }}/data?size=web" />
</div>

View File

@ -1,26 +1,25 @@
<div class="row-fluid">
<div class="span4 offset4">
<form class="form-horizontal">
<div class="control-group">
<label class="control-label" for="inputUsername">Username</label>
<div class="controls">
<input type="text" id="inputUsername" placeholder="Username" ng-model="user.username" />
<div class="row">
<div class="col-sm-offset-5 col-sm-3">
<form>
<div class="form-group">
<label class="sr-only" for="inputUsername">Username</label>
<input class="form-control" type="text" id="inputUsername" placeholder="Username" ng-model="user.username" />
</div>
<div class="form-group">
<label class="sr-only" for="inputPassword">Password</label>
<input class="form-control" type="password" id="inputPassword" placeholder="Password" ng-model="user.password" />
</div>
<div class="control-group">
<label class="control-label" for="inputPassword">Password</label>
<div class="controls">
<input type="password" id="inputPassword" placeholder="Password" ng-model="user.password" />
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="user.remember" /> Remember me
</label>
<button type="submit" class="btn btn-primary" ng-click="login()"><span class="icon-ok icon-white"></span> Sign in</button>
</div>
</div>
<button type="submit" class="btn btn-primary btn-block" ng-click="login()">
<span class="glyphicon glyphicon-ok"></span> Sign in
</button>
</form>
</div>
</div>

View File

@ -1,5 +1,3 @@
<div class="row-fluid">
<div class="span12">
<div class="container">
<h4 class="text-center">Loading...</h4>
</div>
</div>

View File

@ -2,17 +2,12 @@
.table-documents {
thead th {
cursor: pointer;
width: 50%;
}
tbody tr {
cursor: pointer;
}
tbody td {
vertical-align: middle;
}
.cell-tags {
padding: 2px;
@ -27,7 +22,6 @@
&:hover {
.tags {
position: absolute;
margin-top: -10px;
.label {
.full {
@ -48,18 +42,11 @@
position: relative;
top: -2px;
&.hide {
&.loader-hide {
visibility: hidden;
}
}
// Tags list
.table-tags {
tbody td {
vertical-align: middle;
}
}
// Users list
.table-users {
tbody tr {
@ -85,6 +72,10 @@
top: 2%;
max-height: 96%;
overflow-y: scroll;
img {
width: 100%;
}
}
// File thumbnails
@ -145,3 +136,9 @@ input[readonly].share-link {
.nav-text-error {
color: #b94a48 !important;
}
// Dirty Bootstrap 3 fix, see https://github.com/twbs/bootstrap/issues/6686
.row { margin: 0; padding: 0 }
.navbar-nav.navbar-right:last-child {
margin-right: auto;
}