Merge pull request #11 from hcvcastro/master

Add WOPI client settings
pull/1/head
Andras Timar 8 years ago
commit 0f01c190ef

@ -58,12 +58,12 @@ class DocumentController extends Controller{
'uploadMaxFilesize' => $maxUploadFilesize,
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'),
'wopi_url' => $this->settings->getAppValue('richdocuments', 'wopi_url'),
]);
$policy = new ContentSecurityPolicy();
//$policy->addAllowedChildSrcDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\'');
$policy->addAllowedScriptDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\'');
$policy->addAllowedFrameDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\'');
+ $policy->addAllowedScriptDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $this->settings->getAppValue('richdocuments', 'wopi_url'));
+ $policy->addAllowedFrameDomain('\'self\' http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js http://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js \'unsafe-eval\' ' . $this->settings->getAppValue('richdocuments', 'wopi_url'));
$policy->addAllowedConnectDomain('ws://' . $_SERVER['SERVER_NAME'] . ':9980');
$policy->addAllowedImageDomain('*');
$policy->allowInlineScript(true);

@ -78,6 +78,7 @@ class SettingsController extends Controller{
'admin',
[
'converter' => $this->appConfig->getAppValue('converter'),
'wopi_url' => $this->appConfig->getAppValue('wopi_url'),
'converter_url' => $this->appConfig->getAppValue('converter_url'),
],
'blank'
@ -120,11 +121,15 @@ class SettingsController extends Controller{
return array('status' => 'success');
}
public function setConverter($converter, $url){
public function setConverter($converter, $wopi_url, $url){
if (!is_null($converter)){
$this->appConfig->setAppValue('converter', $converter);
}
if (!is_null($wopi_url)){
$this->appConfig->setAppValue('wopi_url', $wopi_url);
}
if (!is_null($url)){
$this->appConfig->setAppValue('converter_url', $url);
}

@ -6,7 +6,8 @@ $(document).ready(function(){
save : function() {
$('#docs_apply').attr('disabled', true);
var data = {
converter : $('[name="docs_converter"]:checked').val()
converter : $('[name="docs_converter"]:checked').val(),
wopi_url : $('#wopi_url').val()
};
if (data.converter === 'external'){

@ -179,22 +179,28 @@ var documentsMain = {
$(document.body).prepend(documentsMain.UI.container);
$('title').text(title + ' - ' + documentsMain.UI.mainTitle);
var viewer = window.location.protocol + '//' + window.location.host + '/loleaflet/dist/loleaflet.html?' +
'file_path=' + documentsMain.url +
'&host=' + 'ws://' + window.location.hostname + ':9980' +
'&permission=' + 'view' +
'&timestamp=' + '';
var frame = '<iframe id="loleafletframe" allowfullscreen style="width:100%;height:100%;position:absolute;" src="' + viewer + '" sandbox="allow-scripts allow-same-origin allow-popups allow-modals"/>';
// TODO. wopiurl = get from discovery xml
var wopiurl = $('#wopi-url').val() + '/loleaflet/dist/loleaflet.html';
var wopisrc = documentsMain.url;
var action = wopiurl + '?' + wopisrc;
var token = oc_requesttoken;
var form = '<form id="loleafletform" name="loleafletform" target="loleafletframe" action="' + action + '" method="post">' +
'<input name="access_token" value="' + token + '" type="hidden"/></form>';
var frame = '<iframe id="loleafletframe" name= "loleafletframe" allowfullscreen style="width:100%;height:100%;position:absolute;"/>';
$('#mainContainer').append(form);
$('#mainContainer').append(frame);
documentsMain.overlay.documentOverlay('hide');
$('#loleafletframe').load(function(){
var iframe = $('#loleafletframe').contents();
// avoid Blocked a frame with origin different domains
/*var iframe = $('#loleafletframe').contents();
iframe.find('#tb_toolbar-up_item_close').click(function() {
documentsMain.onClose();
});
var frameWindow = $('#loleafletframe')[0].contentWindow;
});*/
/*var frameWindow = $('#loleafletframe')[0].contentWindow;
(function() {
cloudSuiteOnClick = frameWindow.onClick;
frameWindow.onClick = function() {
@ -203,8 +209,9 @@ var documentsMain = {
cloudSuiteOnClick.apply(this, arguments);
frameWindow.map.options.doc = documentsMain.url;
};
})();
})();*/
});
$('#loleafletform').submit();
},
hideEditor : function(){
@ -499,25 +506,12 @@ var documentsMain = {
},
loadDocument: function() {
var url = OC.generateUrl('apps/richdocuments/load/{file_id}', {file_id: documentsMain.fileId});
$.post(
url,
{},
function(result) {
if (result && result.status === 'error') {
if (result.message){
documentsMain.IU.notify(result.message);
}
documentsMain.onEditorShutdown(t('richdocuments', 'Failed to load this document. Please check if it can be opened with an external editor. This might also mean it has been unshared or deleted recently.'));
return;
}
documentsMain.url = 'file://' + result.filename;
documentsMain.baseName = result.basename;
documentsMain.UI.showEditor(documentsMain.fileName);
}
);
// Provides access to information about a file and allows
// for file-level operations.
// HTTP://server/<...>/wopi*/files/<id>
var url = window.location.protocol + '//' + window.location.host + OC.generateUrl('apps/documents/wopi/files/{file_id}', {file_id: documentsMain.fileId}, false);
documentsMain.url = 'WOPISrc=' + encodeURIComponent(url);
documentsMain.UI.showEditor(documentsMain.fileName);
},
saveDocumentBack: function() {

@ -18,7 +18,8 @@ use \OCP\IConfig;
private $defaults = [
'converter' => 'off',
'converter_url' => 'http://localhost:16080',
'unstable' => 'false'
'unstable' => 'false',
'wopi_url' => 'htpp://localhost'
];
private $config;

@ -33,6 +33,11 @@ script('richdocuments', 'admin');
/>
<br /><em><?php p($l->t('Server URL')) ?></em>
</div>
<br />
<div id="wopi_client">
<input type="text" name="wopi_url" id="wopi_url" value="<?php p($_['wopi_url'])?>" style="width:250px;">
<br /><em><?php p($l->t('WOPI Client')) ?></em>
</div>
<br /><button type="button" id="docs_apply"><?php p($l->t('Apply and test')) ?></button>
<span id="documents-admin-msg" class="msg"></span>
</div>

@ -50,6 +50,7 @@ script('files', 'jquery.fileupload');
</li>
</ul>
</div>
<input type="hidden" id="wopi-url" name="wopi-url" value="<?php p($_['wopi_url']) ?>" />
<input type="hidden" id="webodf-unstable" value="<?php p($_['useUnstable']) ?>" />
<?php if ($_['enable_previews']): ?>
<input type="hidden" id="previews_enabled" value="<?php p($_['enable_previews']) ?>" />

Loading…
Cancel
Save