move documents.php functionality to controller, add route
This commit is contained in:
Родитель
d62e723304
Коммит
e62bae00b4
|
@ -96,7 +96,7 @@ class Controller {
|
||||||
exit();
|
exit();
|
||||||
} catch (\Exception $e){
|
} catch (\Exception $e){
|
||||||
Helper::warnLog('Joining a session failed. Reason:' . $e->getMessage());
|
Helper::warnLog('Joining a session failed. Reason:' . $e->getMessage());
|
||||||
\OCP\JSON::error();
|
\OCP\JSON::error(array('message'=>$e->getMessage()));
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,30 @@ class Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* lists the documents the user has access to (including shared files, once the code in core has been fixed)
|
||||||
|
* also adds session and member info for these files
|
||||||
|
*/
|
||||||
|
public static function listDocuments(){
|
||||||
|
self::preDispatch();
|
||||||
|
|
||||||
|
$documents = Storage::getDocuments();
|
||||||
|
|
||||||
|
$fileIds = array();
|
||||||
|
foreach ($documents as $document) {
|
||||||
|
$fileIds[] = $document['fileid'];
|
||||||
|
}
|
||||||
|
|
||||||
|
$sessions = Session::getSessionsByFileIds($fileIds);
|
||||||
|
|
||||||
|
$members = array();
|
||||||
|
foreach ($sessions as $session) {
|
||||||
|
$members[$session['es_id']] = Member::getMembersByEsId($session['es_id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
\OCP\JSON::success(array('documents' => $documents,'sessions' => $sessions,'members' => $members));
|
||||||
|
}
|
||||||
|
|
||||||
public static function listSessions(){
|
public static function listSessions(){
|
||||||
self::preDispatch();
|
self::preDispatch();
|
||||||
$sessions = Session::getAll();
|
$sessions = Session::getAll();
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* returns the list of documents the user has access to
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Init owncloud
|
|
||||||
|
|
||||||
namespace OCA\Documents;
|
|
||||||
|
|
||||||
\OCP\User::checkLoggedIn();
|
|
||||||
\OCP\JSON::checkAppEnabled('documents');
|
|
||||||
|
|
||||||
$documents = Storage::getDocuments();
|
|
||||||
|
|
||||||
$fileIds = array();
|
|
||||||
foreach ($documents as $document) {
|
|
||||||
$fileIds[] = $document['fileid'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$sessions = Session::getSessionsByFileIds($fileIds);
|
|
||||||
|
|
||||||
$members = array();
|
|
||||||
foreach ($sessions as $session) {
|
|
||||||
$members[$session['es_id']] = Member::getMembersByEsId($session['es_id']);
|
|
||||||
}
|
|
||||||
|
|
||||||
\OCP\JSON::success(array('documents' => $documents,'sessions' => $sessions,'members' => $members));
|
|
|
@ -27,6 +27,11 @@ $this->create('documents_session_start', 'ajax/session/start')
|
||||||
->action('\OCA\Documents\Controller', 'startSession')
|
->action('\OCA\Documents\Controller', 'startSession')
|
||||||
;
|
;
|
||||||
|
|
||||||
|
$this->create('documents_documents_list', 'ajax/documents/list')
|
||||||
|
->get()
|
||||||
|
->action('\OCA\Documents\Controller', 'listDocuments')
|
||||||
|
;
|
||||||
|
|
||||||
$this->create('documents_session_list', 'ajax/session/list')
|
$this->create('documents_session_list', 'ajax/session/list')
|
||||||
->get()
|
->get()
|
||||||
->action('\OCA\Documents\Controller', 'listSessions')
|
->action('\OCA\Documents\Controller', 'listSessions')
|
||||||
|
|
|
@ -155,6 +155,11 @@ var documentsMain = {
|
||||||
onClose: function() {
|
onClose: function() {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var saveSessionRoute = OC.Router.generate('documents_session_save');
|
||||||
|
//auto save document
|
||||||
|
documentsMain.webodfEditorInstance.saveDocument(saveSessionRoute, function(){});
|
||||||
|
|
||||||
|
//close editor
|
||||||
documentsMain.webodfEditorInstance.shutdown(function() {
|
documentsMain.webodfEditorInstance.shutdown(function() {
|
||||||
// successfull shutdown - all is good.
|
// successfull shutdown - all is good.
|
||||||
|
|
||||||
|
@ -173,16 +178,18 @@ var documentsMain = {
|
||||||
loadDocuments: function () {
|
loadDocuments: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var def = new $.Deferred();
|
var def = new $.Deferred();
|
||||||
jQuery.getJSON(OC.filePath('documents', 'ajax', 'documents.php'))
|
OC.Router.registerLoadedCallback(function () {
|
||||||
.done(function (data) {
|
jQuery.getJSON(OC.Router.generate('documents_documents_list'))
|
||||||
self._documents = data.documents;
|
.done(function (data) {
|
||||||
self._sessions = data.sessions;
|
self._documents = data.documents;
|
||||||
self._members = data.members;
|
self._sessions = data.sessions;
|
||||||
def.resolve();
|
self._members = data.members;
|
||||||
})
|
def.resolve();
|
||||||
.fail(function(data){
|
})
|
||||||
console.log(t('documents','Failed to load documents.'));
|
.fail(function(data){
|
||||||
});
|
console.log(t('documents','Failed to load documents.'));
|
||||||
|
});
|
||||||
|
});
|
||||||
return def;
|
return def;
|
||||||
},
|
},
|
||||||
renderDocuments: function () {
|
renderDocuments: function () {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче