mirror of
https://github.com/sismics/docs.git
synced 2025-12-19 12:41:40 +00:00
Search on shared status (server)
This commit is contained in:
@@ -5,14 +5,14 @@
|
||||
*/
|
||||
var App = angular.module('docs',
|
||||
// Dependencies
|
||||
['ui.state', 'ui.bootstrap', 'ui.route', 'ui.keypress', 'ui.validate',
|
||||
['ui.state', 'ui.bootstrap', 'ui.keypress', 'ui.validate',
|
||||
'ui.sortable', 'restangular', 'ngSanitize', 'ngMobile', 'colorpicker.module']
|
||||
)
|
||||
|
||||
/**
|
||||
* Configuring modules.
|
||||
*/
|
||||
.config(function($stateProvider, $httpProvider, $routeProvider, RestangularProvider) {
|
||||
.config(function($stateProvider, $httpProvider, RestangularProvider) {
|
||||
// Configuring UI Router
|
||||
$stateProvider
|
||||
.state('main', {
|
||||
|
||||
@@ -5,13 +5,13 @@
|
||||
*/
|
||||
var App = angular.module('share',
|
||||
// Dependencies
|
||||
['ui.state', 'ui.bootstrap', 'ui.route', 'restangular', 'ngSanitize', 'ngMobile']
|
||||
['ui.state', 'ui.bootstrap', 'restangular', 'ngSanitize', 'ngMobile']
|
||||
)
|
||||
|
||||
/**
|
||||
* Configuring modules.
|
||||
*/
|
||||
.config(function($stateProvider, $httpProvider, $routeProvider, RestangularProvider) {
|
||||
.config(function($stateProvider, $httpProvider, RestangularProvider) {
|
||||
// Configuring UI Router
|
||||
$stateProvider
|
||||
.state('main', {
|
||||
|
||||
83
docs-web/src/main/webapp/app/share/controller/FileView.js
Normal file
83
docs-web/src/main/webapp/app/share/controller/FileView.js
Normal file
@@ -0,0 +1,83 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* File view controller.
|
||||
*/
|
||||
App.controller('FileView', function($dialog, $state, $stateParams) {
|
||||
var dialog = $dialog.dialog({
|
||||
keyboard: true,
|
||||
templateUrl: 'partial/share/file.view.html',
|
||||
controller: function($scope, $state, $stateParams, Restangular, dialog) {
|
||||
// Load files
|
||||
Restangular.one('file').getList('list', { id: $stateParams.documentId, share: $stateParams.shareId }).then(function(data) {
|
||||
$scope.files = data.files;
|
||||
|
||||
// Search current file
|
||||
_.each($scope.files, function(value) {
|
||||
if (value.id == $stateParams.fileId) {
|
||||
$scope.file = value;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Navigate to the next file.
|
||||
*/
|
||||
$scope.nextFile = function() {
|
||||
_.each($scope.files, function(value, key) {
|
||||
if (value.id == $stateParams.fileId) {
|
||||
var next = $scope.files[key + 1];
|
||||
if (next) {
|
||||
dialog.close({});
|
||||
$state.transitionTo('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: next.id });
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Navigate to the previous file.
|
||||
*/
|
||||
$scope.previousFile = function() {
|
||||
_.each($scope.files, function(value, key) {
|
||||
if (value.id == $stateParams.fileId) {
|
||||
var previous = $scope.files[key - 1];
|
||||
if (previous) {
|
||||
dialog.close({});
|
||||
$state.transitionTo('share.file', { documentId: $stateParams.documentId, shareId: $stateParams.shareId, fileId: previous.id });
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Open the file in a new window.
|
||||
*/
|
||||
$scope.openFile = function() {
|
||||
window.open('api/file/' + $stateParams.fileId + '/data?share=' + $stateParams.shareId);
|
||||
};
|
||||
|
||||
/**
|
||||
* Close the file preview.
|
||||
*/
|
||||
$scope.closeFile = function () {
|
||||
dialog.close();
|
||||
};
|
||||
|
||||
// Close the dialog when the user exits this state
|
||||
var off = $scope.$on('$stateChangeStart', function(event, toState){
|
||||
if (dialog.isOpen()) {
|
||||
dialog.close(toState.name == 'share.file' ? {} : null);
|
||||
}
|
||||
off();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Returns to share view on file close
|
||||
dialog.open().then(function(result) {
|
||||
if (result == null) {
|
||||
$state.transitionTo('share', { documentId: $stateParams.documentId, shareId: $stateParams.shareId });
|
||||
}
|
||||
});
|
||||
});
|
||||
21
docs-web/src/main/webapp/partial/share/file.view.html
Normal file
21
docs-web/src/main/webapp/partial/share/file.view.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<div class="text-center">
|
||||
<div class="btn-group pull-left">
|
||||
<button type="button" class="btn" ng-click="closeFile()"><span class="icon-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>
|
||||
</div>
|
||||
|
||||
<div class="btn-group pull-right">
|
||||
<button type="button" class="btn" ng-click="openFile()"><span class="icon-share"></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?share={{ $stateParams.shareId }}" />
|
||||
|
||||
<div class="text-center" ng-if="$stateParams.fileId && file.mimetype == 'application/pdf'">
|
||||
<img ng-src="api/file/{{ $stateParams.fileId }}/data?thumbnail=true&share={{ $stateParams.shareId }}" />
|
||||
</div>
|
||||
Reference in New Issue
Block a user