Skip to content

Commit

Permalink
Merge branch 'main' into issue-182_oc-php-lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ferishili committed Nov 23, 2023
2 parents 058c399 + b67a7c6 commit 2aca5ec
Show file tree
Hide file tree
Showing 23 changed files with 229 additions and 218 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Change Log

## [5.3.2]
- Fix #220: Upload of large files lead to a memory limit error.
- Fixed the Overlay when creating a new Event.

## [5.3.1]
- Fix #11 and #113: Introducing new Paella 7 Player

## [5.3.0]
- Implemented #193: The Chunk Size for Uploads is now configurable. The default value is 20MB, this can be changes in the plugin configuration.
- Fix #176: Fixed a static timeout in fileuploads, this now uses max_execution_time of the server.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ public function __construct(xoctPermissionTemplateGUI $a_parent_obj, $a_parent_c
$b->setUrl($this->ctrl->getLinkTarget($a_parent_obj, xoctPermissionTemplateGUI::CMD_ADD));
$this->addCommandButtonInstance($b);

xoctWaiterGUI::initJS();
new WaitOverlay($this->main_tpl); // TODO check if needed

$this->main_tpl->addJavaScript($this->plugin->getDirectory() . '/templates/default/sortable.js');
$base_link = $this->ctrl->getLinkTarget($this->parent_obj, 'reorder', '', true);
$this->main_tpl->addOnLoadCode("xoctSortable.init('" . $base_link . "');");
Expand Down
26 changes: 13 additions & 13 deletions classes/Event/class.xoctEventGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ class xoctEventGUI extends xoctGUI
* @var ilObjOpenCastGUI
*/
private $parent_gui;
/**
* @var WaitOverlay
*/
private $wait_overlay;
/**
* @var \ILIAS\UI\Implementation\DefaultRenderer
*/
Expand Down Expand Up @@ -192,6 +196,7 @@ public function __construct(
$this->ui_renderer = new \ILIAS\UI\Implementation\DefaultRenderer(
new Loader($DIC, ilOpenCastPlugin::getInstance())
);
$this->wait_overlay = new WaitOverlay($this->main_tpl);
}

/**
Expand Down Expand Up @@ -274,8 +279,7 @@ protected function performCommand($cmd)
*/
protected function prepareContent()
{
xoctWaiterGUI::initJS();
xoctWaiterGUI::addLinkOverlay('#rep_robj_xoct_event_clear_cache');
$this->wait_overlay->onLinkClick('#rep_robj_xoct_event_clear_cache');
$this->main_tpl->addJavascript("./src/UI/templates/js/Modal/modal.js");
$this->main_tpl->addOnLoadCode(
'xoctEvent.init(\'' . json_encode([
Expand Down Expand Up @@ -504,11 +508,11 @@ protected function loadAjaxCodeForList()
url: '{$ajax_link}',
dataType: 'html',
success: function(data){
xoctWaiter.hide();
il.Opencast.UI.waitOverlay.hide();
$('div#xoct_table_placeholder').replaceWith($(data));
}
});";
$this->main_tpl->addOnLoadCode('xoctWaiter.show();');
$this->main_tpl->addOnLoadCode('il.Opencast.UI.waitOverlay.show();');
$this->main_tpl->addOnLoadCode($ajax);
}

Expand All @@ -524,11 +528,11 @@ protected function loadAjaxCodeForTiles()
url: '{$ajax_link}',
dataType: 'html',
success: function(data){
xoctWaiter.hide();
il.Opencast.UI.waitOverlay.hide();
$('div#xoct_tiles_placeholder').replaceWith($(data));
}
});";
$this->main_tpl->addOnLoadCode('xoctWaiter.show();');
$this->main_tpl->addOnLoadCode('il.Opencast.UI.waitOverlay.show();');
$this->main_tpl->addOnLoadCode($ajax);
}

Expand Down Expand Up @@ -615,12 +619,8 @@ protected function add()
$this->objectSettings->getObjId(),
ilObjOpenCastAccess::hasPermission('edit_videos')
);
xoctWaiterGUI::initJS();
$this->main_tpl->addOnLoadCode(
'window.onbeforeunload = function(){
xoctWaiter.show();
};'
);
$this->wait_overlay->onUnload();

$this->main_tpl->setContent($this->ui_renderer->render($form));
}

Expand Down Expand Up @@ -664,7 +664,7 @@ protected function create()
$this->ACLUtils->getBaseACLForUser(xoctUser::getInstance($this->user)),
new Processing(
PluginConfig::getConfig(PluginConfig::F_WORKFLOW),
$this->getDefaultWorkflowParameters($data['workflow_configuration']['object'])
$this->getDefaultWorkflowParameters($data['workflow_configuration']['object'] ?? null)
),
xoctUploadFile::getInstanceFromFileArray($data['file']['file'])
)
Expand Down
5 changes: 3 additions & 2 deletions classes/IVTGroup/class.xoctPermissionGroupGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ public function __construct(?ObjectSettings $objectSettings = null)
$this->objectSettings = new ObjectSettings();
}
$tabs->setTabActive(ilObjOpenCastGUI::TAB_GROUPS);
// xoctGroup::installDB();
xoctWaiterGUI::loadLib();

new WaitOverlay($this->main_tpl); // TODO check if needed

$main_tpl->addCss($this->plugin->getStyleSheetLocation('default/groups.css'));
$main_tpl->addJavaScript($this->plugin->getStyleSheetLocation('default/groups.js'));
}
Expand Down
4 changes: 3 additions & 1 deletion classes/IVTGroup/class.xoctPermissionGroupParticipantGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ public function __construct(?ObjectSettings $objectSettings = null)
$this->objectSettings = new ObjectSettings();
}
$tabs->setTabActive(ilObjOpenCastGUI::TAB_GROUPS);
xoctWaiterGUI::loadLib();

new WaitOverlay($main_tpl); // TODO check if needed

$main_tpl->addJavaScript(
$this->plugin->getStyleSheetLocation('default/group_participants.js')
);
Expand Down
2 changes: 1 addition & 1 deletion classes/Invitations/class.xoctGrantPermissionGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(ObjectSettings $objectSettings, EventRepository $eve
$tabs->clearTargets();

$tabs->setBackTarget($this->plugin->txt('tab_back'), $this->ctrl->getLinkTargetByClass(xoctEventGUI::class));
xoctWaiterGUI::loadLib();
new WaitOverlay($this->main_tpl); // TODO check if needed
$main_tpl->addCss($this->plugin->getStyleSheetLocation('default/invitations.css'));
$main_tpl->addJavaScript($this->plugin->getStyleSheetLocation('default/invitations.js'));
$this->ctrl->saveParameter($this, xoctEventGUI::IDENTIFIER);
Expand Down
4 changes: 3 additions & 1 deletion classes/Owner/class.xoctChangeOwnerGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ public function __construct(ObjectSettings $objectSettings, EventRepository $eve
$this->plugin->txt('tab_back'),
$ctrl->getLinkTargetByClass(xoctEventGUI::class)
);
xoctWaiterGUI::loadLib();

new WaitOverlay($this->main_tpl); // TODO check if needed

$main_tpl->addCss($this->plugin->getStyleSheetLocation('default/change_owner.css'));
$main_tpl->addJavaScript($this->plugin->getStyleSheetLocation('default/change_owner.js'));
$ctrl->saveParameter($this, xoctEventGUI::IDENTIFIER);
Expand Down
85 changes: 0 additions & 85 deletions classes/class.xoctWaiterGUI.php

This file was deleted.

81 changes: 81 additions & 0 deletions js/opencast/src/UI/WaitOverlay.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/**
* PasswordToggle
*
* PasswordToggle class
*
* @author Fabian Schmid <fs@studer-raimann.ch>
* @author Farbod Zamani Boroujeni <zamani@elan-ev.de>
*/
export default class WaitOverlay {
count;
timer;


constructor() {
this.count = 0;
this.timer = null;
}

init(type) {
$('body').append('<div id="xoct_waiter" class="xoct_waiter"></div>')
}


show() {
if (this.count === 0) {
this.timer = setTimeout(function () {
$('#xoct_waiter').show();
}, 10);

}
this.count = this.count + 1;
}


hide() {
this.count = this.count - 1;
if (this.count === 0) {
window.clearTimeout(this.timer);
$('#xoct_waiter').fadeOut(200);
}
}

addListener(dom_selector_string) {
const self = this;
$(document).ready(function () {
$(dom_selector_string).on("click", function () {
self.show();
});
});
}


addLinkOverlay(dom_selector_string) {
const self = this;
$(document).ready(function () {
$(dom_selector_string).on("click", function (e) {
e.preventDefault();
self.show();
let href = $(this).attr('href');
setTimeout(function () {
document.location.href = href;
}, 1000);
});
});
}

onFormSubmit(dom_selector_string) {
const self = this;
$(document).ready(function () {
// check if element is form, otherwise search for parent form
let form = $(dom_selector_string).is('form') ? $(dom_selector_string) : $(dom_selector_string).closest('form');
if (form.length === 0) {
console.warn('Unable to find form for selector: ' + dom_selector_string);
return;
}
form.on("submit", function () {
self.show();
});
});
}
}
4 changes: 4 additions & 0 deletions js/opencast/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import il from 'ilias';
import $ from 'jquery';
import PasswordToggle from './Form/PasswordToggle';
import PublicationUsage from './Form/PublicationUsage';
import WaitOverlay from './UI/WaitOverlay';
import PaellaPlayer from './Paella/paella-player.min.js'

il.Opencast = il.Opencast || {};
il.Opencast.Form = il.Opencast.Form || {};
il.Opencast.Form.passwordToggle = new PasswordToggle($);
il.Opencast.Form.publicationUsage = new PublicationUsage($);

il.Opencast.UI = il.Opencast.UI || {};
il.Opencast.UI.waitOverlay = new WaitOverlay($);

il.Opencast.Paella = il.Opencast.Paella || {};
il.Opencast.Paella.player = PaellaPlayer;
2 changes: 0 additions & 2 deletions src/API/Handlers.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ private static function requestDebug()
return function (callable $handler) {
return function (RequestInterface $request, array $options) use ($handler) {
$path = $request->getUri()->getPath();
$host = $request->getUri()->getHost();
$query = $request->getUri()->getQuery();
$method = $request->getMethod();
$requestBody = $request->getBody()->getContents();
$completeUri = $request->getUri()->__toString();

// Exclude requests.
Expand Down
7 changes: 7 additions & 0 deletions src/UI/EventFormBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ function ($file) use ($upload_storage_service): array {
)
);

// We must bind the WaitOverlay to an Input since the Form itself is not JS-bindable
$file_input = $file_input->withAdditionalOnLoadCode(
function ($id) {
return 'il.Opencast.UI.waitOverlay.onFormSubmit("#' . $id . '")';
}
);

$file_section_inputs = ['file' => $file_input];
if ($obj_id == 0) {
$file_section_inputs['isPartOf'] = $this->buildSeriesSelector();
Expand Down

0 comments on commit 2aca5ec

Please sign in to comment.