Skip to content
Snippets Groups Projects
Commit 982965e9 authored by uhensler's avatar uhensler
Browse files

OO-4043: Live stream configurations in administration site

parent ee2ac773
No related branches found
No related tags found
No related merge requests found
Showing with 242 additions and 24 deletions
......@@ -76,7 +76,8 @@
</list>
</property>
</bean>
<bean class="org.olat.core.extensions.action.GenericActionExtension" init-method="initExtensionPoints">
<bean class="org.olat.core.extensions.action.GenericActionExtension" init-method="initExtensionPoints">
<property name="order" value="8210" />
<property name="actionController">
<bean class="org.olat.core.gui.control.creator.AutoCreator" scope="prototype">
......@@ -94,5 +95,24 @@
</list>
</property>
</bean>
<bean class="org.olat.core.extensions.action.GenericActionExtension" init-method="initExtensionPoints">
<property name="order" value="7210" />
<property name="actionController">
<bean class="org.olat.core.gui.control.creator.AutoCreator" scope="prototype">
<property name="className" value="org.olat.course.nodes.livestream.ui.LiveStreamAdminController"/>
</bean>
</property>
<property name="navigationKey" value="livestream" />
<property name="parentTreeNodeIdentifier" value="modulesParent" />
<property name="i18nActionKey" value="admin.menu.title"/>
<property name="i18nDescriptionKey" value="admin.menu.title.alt"/>
<property name="translationPackage" value="org.olat.course.nodes.livestream.ui"/>
<property name="extensionPoints">
<list>
<value>org.olat.admin.SystemAdminMainController</value>
</list>
</property>
</bean>
</beans>
\ No newline at end of file
......@@ -129,7 +129,7 @@ public class LiveStreamCourseNode extends AbstractAccessableCourseNode {
LiveStreamModule liveStreamModule = CoreSpringFactory.getImpl(LiveStreamModule.class);
config.setIntValue(CONFIG_BUFFER_BEFORE_MIN, liveStreamModule.getBufferBeforeMin());
config.setIntValue(CONFIG_BUFFER_AFTER_MIN, liveStreamModule.getBufferAfterMin());
config.setBooleanEntry(CONFIG_COACH_CAN_EDIT, false);
config.setBooleanEntry(CONFIG_COACH_CAN_EDIT, liveStreamModule.isEditCoach());
}
config.setConfigurationVersion(CURRENT_VERSION);
}
......
......@@ -39,6 +39,7 @@ public class LiveStreamModule extends AbstractSpringModule implements ConfigOnOf
public static final String LIVE_STREAM_ENABLED = "live.stream.enabled";
public static final String LIVE_STREAM_BUFFER_BEFORE_MIN = "live.stream.buffer.before.min";
public static final String LIVE_STREAM_BUFFER_AFTER_MIN = "live.stream.buffer.after.min";
public static final String LIVE_STREAM_EDIT_COACH = "live.stream.edit.coach";
@Value("${live.stream.enabled:false}")
private boolean enabled;
......@@ -46,7 +47,9 @@ public class LiveStreamModule extends AbstractSpringModule implements ConfigOnOf
private int bufferBeforeMin;
@Value("${live.stream.buffer.after.min:5}")
private int bufferAfterMin;
@Value("${live.stream.edit.coach:false}")
private boolean editCoach;
@Autowired
public LiveStreamModule(CoordinatorManager coordinatorManager) {
super(coordinatorManager);
......@@ -68,6 +71,11 @@ public class LiveStreamModule extends AbstractSpringModule implements ConfigOnOf
if(StringHelper.containsNonWhitespace(bufferAfterMinObj)) {
bufferAfterMin = Integer.parseInt(bufferAfterMinObj);
}
String editCoachObj = getStringPropertyValue(LIVE_STREAM_EDIT_COACH, true);
if(StringHelper.containsNonWhitespace(editCoachObj)) {
editCoach = "true".equals(editCoachObj);
}
}
@Override
......@@ -103,4 +111,13 @@ public class LiveStreamModule extends AbstractSpringModule implements ConfigOnOf
setStringProperty(LIVE_STREAM_BUFFER_BEFORE_MIN, Integer.toString(bufferAfterMin), true);
}
public boolean isEditCoach() {
return editCoach;
}
public void setEditCoach(boolean editCoach) {
this.editCoach = editCoach;
setStringProperty(LIVE_STREAM_EDIT_COACH, Boolean.toString(editCoach), true);
}
}
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.course.nodes.livestream.ui;
import static org.olat.core.gui.translator.TranslatorHelper.translateAll;
import static org.olat.course.nodes.livestream.ui.LiveStreamUIFactory.validateInteger;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
import org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement;
import org.olat.core.gui.components.form.flexible.elements.TextElement;
import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.course.nodes.livestream.LiveStreamModule;
import org.springframework.beans.factory.annotation.Autowired;
/**
*
* Initial date: 5 Jun 2019<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
public class LiveStreamAdminController extends FormBasicController {
private static final String[] ENABLED_KEYS = new String[]{"on"};
private MultipleSelectionElement enabledEl;
private TextElement bufferBeforeMinEl;
private TextElement bufferAfterMinEl;
private MultipleSelectionElement coachCanEditEl;
@Autowired
private LiveStreamModule liveStreamModule;
public LiveStreamAdminController(UserRequest ureq, WindowControl wControl) {
super(ureq, wControl, LAYOUT_BAREBONE);
initForm(ureq);
}
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FormLayoutContainer generalCont = FormLayoutContainer.createDefaultFormLayout("general", getTranslator());
generalCont.setFormTitle(translate("admin.general.title"));
generalCont.setRootForm(mainForm);
formLayout.add("genearl", generalCont);
enabledEl = uifactory.addCheckboxesHorizontal("admin.module.enabled", generalCont, ENABLED_KEYS,
translateAll(getTranslator(), ENABLED_KEYS));
enabledEl.select(ENABLED_KEYS[0], liveStreamModule.isEnabled());
FormLayoutContainer defaultValuesCont = FormLayoutContainer.createDefaultFormLayout("default_values", getTranslator());
defaultValuesCont.setFormTitle(translate("admin.default.values.title"));
defaultValuesCont.setFormDescription(translate("admin.default.values.desc"));
defaultValuesCont.setRootForm(mainForm);
formLayout.add("defaultValues", defaultValuesCont);
int bufferBeforeMin = liveStreamModule.getBufferBeforeMin();
bufferBeforeMinEl = uifactory.addTextElement("admin.buffer.before.min", 4, String.valueOf(bufferBeforeMin),
defaultValuesCont);
bufferBeforeMinEl.setMandatory(true);
int bufferAfterMin = liveStreamModule.getBufferAfterMin();
bufferAfterMinEl = uifactory.addTextElement("admin.buffer.after.min", 4, String.valueOf(bufferAfterMin),
defaultValuesCont);
bufferAfterMinEl.setMandatory(true);
coachCanEditEl = uifactory.addCheckboxesHorizontal("admin.coach.edit", defaultValuesCont, ENABLED_KEYS,
translateAll(getTranslator(), ENABLED_KEYS));
boolean coachCanEdit = liveStreamModule.isEditCoach();
coachCanEditEl.select(ENABLED_KEYS[0], coachCanEdit);
FormLayoutContainer buttonsCont = FormLayoutContainer.createDefaultFormLayout("buttons", getTranslator());
buttonsCont.setRootForm(mainForm);
formLayout.add("buttons", buttonsCont);
uifactory.addFormSubmitButton("save", buttonsCont);
}
@Override
protected boolean validateFormLogic(UserRequest ureq) {
boolean allOk = super.validateFormLogic(ureq);
allOk &= validateInteger(bufferBeforeMinEl, true);
allOk &= validateInteger(bufferAfterMinEl, true);
return allOk;
}
@Override
protected void formOK(UserRequest ureq) {
boolean enabled = enabledEl.isAtLeastSelected(1);
liveStreamModule.setEnabled(enabled);
int bufferBeforeMin = Integer.parseInt(bufferBeforeMinEl.getValue());
liveStreamModule.setBufferBeforeMin(bufferBeforeMin);
int bufferAfterMin = Integer.parseInt(bufferAfterMinEl.getValue());
liveStreamModule.setBufferAfterMin(bufferAfterMin);
boolean coachCanEdit = coachCanEditEl.isAtLeastSelected(1);
liveStreamModule.setEditCoach(coachCanEdit);
}
@Override
protected void doDispose() {
//
}
}
......@@ -20,6 +20,7 @@
package org.olat.course.nodes.livestream.ui;
import static org.olat.core.gui.translator.TranslatorHelper.translateAll;
import static org.olat.course.nodes.livestream.ui.LiveStreamUIFactory.validateInteger;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.components.form.flexible.FormItemContainer;
......@@ -29,7 +30,6 @@ import org.olat.core.gui.components.form.flexible.impl.FormBasicController;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.util.StringHelper;
import org.olat.course.nodes.LiveStreamCourseNode;
import org.olat.modules.ModuleConfiguration;
......@@ -85,26 +85,6 @@ public class LiveStreamConfigController extends FormBasicController {
return allOk;
}
private boolean validateInteger(TextElement el, boolean mandatory) {
boolean allOk = true;
el.clearError();
if(el.isEnabled() && el.isVisible()) {
String val = el.getValue();
if (StringHelper.containsNonWhitespace(val)) {
try {
Integer.parseInt(val);
} catch (NumberFormatException e) {
el.setErrorKey("form.error.wrong.int", null);
allOk = false;
}
} else if (mandatory) {
el.setErrorKey("form.mandatory.hover", null);
allOk = false;
}
}
return allOk;
}
@Override
protected void formOK(UserRequest ureq) {
......
/**
* <a href="http://www.openolat.org">
* OpenOLAT - Online Learning and Training</a><br>
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at the
* <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a>
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS, <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Initial code contributed and copyrighted by<br>
* frentix GmbH, http://www.frentix.com
* <p>
*/
package org.olat.course.nodes.livestream.ui;
import org.olat.core.gui.components.form.flexible.elements.TextElement;
import org.olat.core.util.StringHelper;
/**
*
* Initial date: 5 Jun 2019<br>
* @author uhensler, urs.hensler@frentix.com, http://www.frentix.com
*
*/
class LiveStreamUIFactory {
static boolean validateInteger(TextElement el, boolean mandatory) {
boolean allOk = true;
el.clearError();
if(el.isEnabled() && el.isVisible()) {
String val = el.getValue();
if (StringHelper.containsNonWhitespace(val)) {
try {
Integer.parseInt(val);
} catch (NumberFormatException e) {
el.setErrorKey("form.error.wrong.int", null);
allOk = false;
}
} else if (mandatory) {
el.setErrorKey("form.mandatory.hover", null);
allOk = false;
}
}
return allOk;
}
}
admin.buffer.before.min=$:\config.buffer.before.min
admin.buffer.after.min=$:\config.buffer.after.min
admin.default.values.title=Initialwerte
admin.default.values.desc=Hier k\u00F6nnen Sie die Initialwerte eines neuen Kursbausteines konfigurieren.
admin.coach.edit=$:\config.coach.edit
admin.general.title=$:\admin.menu.title
admin.menu.title=Livestream
admin.menu.title.alt=$:\admin.menu.title
admin.module.enabled=Kursbaustein
condition.accessibility.title=Zugang
config.buffer.before.min=Vorlaufzeit (in Minuten)
config.buffer.after.min=Nachlaufzeit (in Minuten)
......
admin.buffer.before.min=$:\config.buffer.before.min
admin.buffer.after.min=$:\config.buffer.after.min
admin.coach.edit=$:\config.coach.edit
admin.default.values.title=Default values
admin.default.values.desc=Modify the default values of a new course node.
admin.general.title=$:\admin.menu.title
admin.menu.title=Live stream
admin.menu.title.alt=$:\admin.menu.title
admin.module.enabled=Course element
condition.accessibility.title=Access
config.buffer.before.min=Buffer time before start (in minutes)
config.buffer.after.min=Buffer time after end (in minutes)
......
......@@ -1596,3 +1596,5 @@ live.stream.enabled=false
# and vice versa.
live.stream.buffer.before.min=5
live.stream.buffer.after.min=5
live.stream.edit.coach=false
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment