You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openmeetings.apache.org by so...@apache.org on 2016/08/19 17:29:57 UTC
svn commit: r1756948 [2/3] - in /openmeetings/application:
branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/
branches/3.1.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/
branches/3.1.x/openmeetings-web/...
Copied: openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationDialog.java (from r1756947, openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/InvitationDialog.java)
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationDialog.java?p2=openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationDialog.java&p1=openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/InvitationDialog.java&r1=1756947&r2=1756948&rev=1756948&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/InvitationDialog.java (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationDialog.java Fri Aug 19 17:29:56 2016
@@ -16,144 +16,29 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.openmeetings.web.room.menu;
+package org.apache.openmeetings.web.common;
-import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
-import static org.apache.openmeetings.web.app.Application.getBean;
-import static org.apache.openmeetings.web.app.Application.getInvitationLink;
-import static org.apache.openmeetings.web.app.WebSession.AVAILABLE_TIMEZONES;
-import static org.apache.openmeetings.web.app.WebSession.getRights;
-import static org.apache.openmeetings.web.app.WebSession.getUserId;
-
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
import java.util.List;
-import java.util.UUID;
-import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
-import org.apache.openmeetings.db.dao.room.InvitationDao;
-import org.apache.openmeetings.db.dao.room.RoomDao;
-import org.apache.openmeetings.db.dao.user.GroupDao;
-import org.apache.openmeetings.db.dao.user.GroupUserDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
import org.apache.openmeetings.db.entity.room.Invitation;
-import org.apache.openmeetings.db.entity.room.Invitation.MessageType;
-import org.apache.openmeetings.db.entity.room.Invitation.Valid;
-import org.apache.openmeetings.db.entity.user.Group;
-import org.apache.openmeetings.db.entity.user.GroupUser;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.db.entity.user.User.Type;
-import org.apache.openmeetings.db.util.AuthLevelUtil;
-import org.apache.openmeetings.service.room.InvitationManager;
-import org.apache.openmeetings.util.crypt.CryptProvider;
import org.apache.openmeetings.web.app.Application;
-import org.apache.openmeetings.web.app.WebSession;
-import org.apache.openmeetings.web.common.LanguageDropDown;
-import org.apache.openmeetings.web.util.UserMultiChoice;
import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.PasswordTextField;
-import org.apache.wicket.markup.html.form.Radio;
-import org.apache.wicket.markup.html.form.RadioGroup;
-import org.apache.wicket.markup.html.form.TextArea;
-import org.apache.wicket.markup.html.form.TextField;
-import org.apache.wicket.model.CompoundPropertyModel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.model.util.CollectionModel;
-import org.apache.wicket.util.string.Strings;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.wicketstuff.select2.ChoiceProvider;
-import org.wicketstuff.select2.Response;
-import org.wicketstuff.select2.Select2MultiChoice;
-import com.googlecode.wicket.jquery.core.Options;
import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractFormDialog;
import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton;
-import com.googlecode.wicket.kendo.ui.form.datetime.AjaxDateTimePicker;
-import com.googlecode.wicket.kendo.ui.form.datetime.DateTimePicker;
-import com.googlecode.wicket.kendo.ui.panel.KendoFeedbackPanel;
public class InvitationDialog extends AbstractFormDialog<Invitation> {
private static final long serialVersionUID = 1L;
- private static final Logger log = Red5LoggerFactory.getLogger(InvitationDialog.class, webAppRootKey);
- private final DialogButton generate = new DialogButton("generate", Application.getString(1526));
- private final DialogButton send = new DialogButton("send", Application.getString(218));
+ public final DialogButton generate = new DialogButton("generate", Application.getString(1526));
+ public final DialogButton send = new DialogButton("send", Application.getString(218));
private final DialogButton cancel = new DialogButton("cancel", Application.getString(219));
private final InvitationForm form;
- private final KendoFeedbackPanel feedback = new KendoFeedbackPanel("feedback", new Options("button", true));
- private final Long roomId;
- private final IModel<String> subject = Model.of((String)null);
- private final IModel<String> message = Model.of((String)null);
- private final IModel<String> tzId = Model.of((String)null);
- private final IModel<InviteeType> inviteeType = Model.of(InviteeType.user);
- private long lang;
- private final TextField<String> url = new TextField<String>("url", Model.of((String)null));
- enum InviteeType {
- user
- , group
- }
- private final UserMultiChoice recipients = new UserMultiChoice("recipients", new CollectionModel<User>(new ArrayList<User>()));
- private final Select2MultiChoice<Group> groups = new Select2MultiChoice<Group>("groups"
- , new CollectionModel<Group>(new ArrayList<Group>())
- , new ChoiceProvider<Group>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void query(String term, int page, Response<Group> response) {
- if (WebSession.getRights().contains(User.Right.Admin)) {
- List<Group> groups = getBean(GroupDao.class).get(0, Integer.MAX_VALUE);
- for (Group g : groups) {
- if (Strings.isEmpty(term) || g.getName().toLowerCase().contains(term.toLowerCase())) {
- response.add(g);
- }
- }
- } else {
- User u = getBean(UserDao.class).get(getUserId());
- for (GroupUser ou : u.getGroupUsers()) {
- if (Strings.isEmpty(term) || ou.getGroup().getName().toLowerCase().contains(term.toLowerCase())) {
- response.add(ou.getGroup());
- }
- }
- }
- }
-
- @Override
- public Collection<Group> toChoices(Collection<String> ids) {
- Collection<Group> c = new ArrayList<>();
- for (String id : ids) {
- c.add(getBean(GroupDao.class).get(Long.valueOf(id)));
- }
- return c;
- }
-
- @Override
- public String getDisplayValue(Group choice) {
- return choice.getName();
- }
-
- @Override
- public String getIdValue(Group choice) {
- Long id = choice.getId();
- return id == null ? null : "" + id;
- }
- });
- private final WebMarkupContainer sipContainer = new WebMarkupContainer("sip-container");
-
- public InvitationDialog(String id, Long roomId) {
- super(id, Application.getString(214), new CompoundPropertyModel<Invitation>(new Invitation()));
- this.roomId = roomId;
- add(form = new InvitationForm("form", getModel()));
+
+ public InvitationDialog(String id, final InvitationForm _form) {
+ super(id, Application.getString(214),_form.getModel());
+ add(form = _form);
}
@Override
@@ -162,33 +47,9 @@ public class InvitationDialog extends Ab
}
public void updateModel(AjaxRequestTarget target) {
- Invitation i = new Invitation();
- User u = getBean(UserDao.class).get(getUserId());
- i.setInvitedBy(u);
- i.setRoom(getBean(RoomDao.class).get(roomId));
- if (i.getRoom() != null) {
- target.add(sipContainer.replace(new Label("room.confno", i.getRoom().getConfno())).setVisible(i.getRoom().isSipEnabled()));
- }
- Calendar d = Calendar.getInstance();
- i.setValidFrom(d.getTime());
- d.add(Calendar.DATE, 1);
- i.setValidTo(d.getTime());
- i.setPassword(null);
- i.setHash(null);
- subject.setObject(null);
- message.setObject(null);
- recipients.setModelObject(new ArrayList<User>());
- recipients.setEnabled(true);
- groups.setModelObject(new ArrayList<Group>());
- groups.setEnabled(false);
- tzId.setObject(u.getTimeZoneId());
- lang = u.getLanguageId();
- url.setModelObject(null);
- inviteeType.setObject(InviteeType.user);
- form.setModelObject(i);
+ form.updateModel(target);
send.setEnabled(false, target);
generate.setEnabled(false, target);
- target.add(form);
}
@Override
@@ -216,203 +77,18 @@ public class InvitationDialog extends Ab
@Override
protected void onError(AjaxRequestTarget target) {
- target.add(feedback);
+ form.onError(target);
}
@Override
public void onClick(AjaxRequestTarget target, DialogButton button) {
- //TODO need to be reviewed
- if (button.equals(cancel)) {
- super.onClick(target, button);
- } else if (button.equals(generate)) {
- Invitation i = create(recipients.getModelObject().iterator().next());
- form.setModelObject(i);
- url.setModelObject(getInvitationLink(getBean(ConfigurationDao.class).getBaseUrl(), i));
- target.add(url);
- } else if (button.equals(send)) {
- if (Strings.isEmpty(url.getModelObject())) {
- if (inviteeType.getObject() == InviteeType.user) {
- for (User u : recipients.getModelObject()) {
- Invitation i = create(u);
- try {
- getBean(InvitationManager.class).sendInvitationLink(i, MessageType.Create, subject.getObject(), message.getObject(), false);
- } catch (Exception e) {
- log.error("error while sending invitation by User ", e);
- }
- }
- } else {
- for (Group g : groups.getModelObject()) {
- for (GroupUser ou : getBean(GroupUserDao.class).get(g.getId(), 0, Integer.MAX_VALUE)) {
- Invitation i = create(ou.getUser());
- try {
- getBean(InvitationManager.class).sendInvitationLink(i, MessageType.Create, subject.getObject(), message.getObject(), false);
- } catch (Exception e) {
- log.error("error while sending invitation by Group ", e);
- }
- }
- }
- }
- } else {
- Invitation i = form.getModelObject();
- try {
- getBean(InvitationManager.class).sendInvitationLink(i, MessageType.Create, subject.getObject(), message.getObject(), false);
- } catch (Exception e) {
- log.error("error while sending invitation by URL ", e);
- }
- }
+ if (!form.onSubmit(target, button.equals(generate), button.equals(send))) {
super.onClick(target, button);
}
}
- private Invitation create(User u) {
- Invitation i = new Invitation(form.getModelObject());
- i.setId(null);
- i.setUpdated(null);
- i.setUsed(false);
-
- i.setPassword(CryptProvider.get().hash(i.getPassword())); //FIXME should be hidden
- //FIXME another HACK
- Calendar d = Calendar.getInstance();
- d.setTime(i.getValidFrom());
- d.add(Calendar.MINUTE, -5);
- i.setValidFrom(d.getTime());
-
- i.setInvitee(u);
- i.setHash(UUID.randomUUID().toString());
- if (Type.contact == u.getType()) {
- //TODO not sure it is right
- u.setLanguageId(lang);
- }
- return getBean(InvitationDao.class).update(i);
- }
-
@Override
protected void onSubmit(AjaxRequestTarget target) {
//designed to be empty because of multiple submit buttons
}
-
- private class InvitationForm extends Form<Invitation> {
- private static final long serialVersionUID = 1L;
- private final PasswordTextField passwd;
- private final DateTimePicker from;
- private final DateTimePicker to;
- private final DropDownChoice<String> timeZoneId;
- private final WebMarkupContainer groupContainer = new WebMarkupContainer("groupContainer");
-
- public InvitationForm(String id, IModel<Invitation> model) {
- super(id, model);
- boolean showGroups = AuthLevelUtil.hasAdminLevel(getRights());
- RadioGroup<InviteeType> rdi = new RadioGroup<>("inviteeType", inviteeType);
- add(rdi.add(new AjaxFormChoiceComponentUpdatingBehavior() {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- boolean groupsEnabled = InviteeType.group == inviteeType.getObject();
- updateButtons(target);
- target.add(groups.setEnabled(groupsEnabled), recipients.setEnabled(!groupsEnabled));
- }
- }));
- //TODO list should be updated on open
- rdi.add(recipients.setLabel(Model.of(Application.getString(216))).setRequired(true).add(new AjaxFormComponentUpdatingBehavior("change") {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- url.setModelObject(null);
- updateButtons(target);
- }
- }).setOutputMarkupId(true));
- groupContainer.add(
- groups.setLabel(Model.of(Application.getString(126))).setRequired(true).add(new AjaxFormComponentUpdatingBehavior("change") {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- url.setModelObject(null);
- updateButtons(target);
- }
- }).setOutputMarkupId(true)
- , new Radio<InviteeType>("group", Model.of(InviteeType.group))
- );
- rdi.add(groupContainer.setVisible(showGroups));
- rdi.add(new Radio<InviteeType>("user", Model.of(InviteeType.user)));
-
- rdi.add(new TextField<String>("subject", subject));
- rdi.add(new TextArea<String>("message", message));
- rdi.add(new AjaxCheckBox("passwordProtected") {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- InvitationForm.this.getModelObject().setPasswordProtected(getConvertedInput());
- passwd.setEnabled(getConvertedInput());
- target.add(passwd);
- }
- });
- RadioGroup<Valid> valid = new RadioGroup<Valid>("valid");
- valid.add(new AjaxFormChoiceComponentUpdatingBehavior() {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- boolean dateEnabled = InvitationForm.this.getModelObject().getValid() == Valid.Period;
- target.add(from.setEnabled(dateEnabled), to.setEnabled(dateEnabled), timeZoneId.setEnabled(dateEnabled));
- }
- });
- rdi.add(valid.add(new Radio<Valid>("one", Model.of(Valid.OneTime))
- , new Radio<Valid>("period", Model.of(Valid.Period))
- , new Radio<Valid>("endless", Model.of(Valid.Endless))));
- rdi.add(passwd = new PasswordTextField("password"));
- Invitation i = getModelObject();
- passwd.setLabel(Model.of(Application.getString(525))).setOutputMarkupId(true).setEnabled(i.isPasswordProtected());
- rdi.add(from = new AjaxDateTimePicker("validFrom", "yyyy/MM/dd", "HH:mm:ss")); //FIXME use user locale
- rdi.add(to = new AjaxDateTimePicker("validTo", "yyyy/MM/dd", "HH:mm:ss")); //FIXME use user locale
- rdi.add(timeZoneId = new DropDownChoice<String>("timeZoneId", tzId, AVAILABLE_TIMEZONES));
- from.setEnabled(i.getValid() == Valid.Period).setOutputMarkupId(true);
- to.setEnabled(i.getValid() == Valid.Period).setOutputMarkupId(true);
- timeZoneId.setEnabled(i.getValid() == Valid.Period).setOutputMarkupId(true)
- .add(new AjaxFormComponentUpdatingBehavior("change") {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- //no-op added to preserve selection
- }
- });
- rdi.add(new LanguageDropDown("language", new PropertyModel<Long>(InvitationDialog.this, "lang")));
- rdi.add(url.setOutputMarkupId(true));
- rdi.add(sipContainer.setOutputMarkupPlaceholderTag(true).setOutputMarkupId(true));
- sipContainer.add(new Label("room.confno", "")).setVisible(false);
- add(feedback);
- }
-
- private void updateButtons(AjaxRequestTarget target) {
- if (inviteeType.getObject() == InviteeType.user) {
- Collection<User> to = recipients.getModelObject();
- send.setEnabled(to.size() > 0, target);
- generate.setEnabled(to.size() == 1, target);
- } else {
- Collection<Group> to = groups.getModelObject();
- send.setEnabled(to.size() > 0, target);
- generate.setEnabled(false, target);
- }
- }
-
- @Override
- protected void onValidate() {
- if (from.getConvertedInput() != null && to.getConvertedInput() != null && from.getConvertedInput().after(to.getConvertedInput())) {
- error(Application.getString(1592));
- }
- }
- }
-
- @Override
- protected void onDetach() {
- subject.detach();
- message.detach();
- tzId.detach();
- inviteeType.detach();
- super.onDetach();
- }
}
Added: openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.html
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.html?rev=1756948&view=auto
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.html (added)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.html Fri Aug 19 17:29:56 2016
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<html xmlns:wicket="http://wicket.apache.org">
+<wicket:panel>
+ <div class="invitation table">
+ <div>
+ <div class="column label"><label wicket:for="subject"><wicket:message key="215" /></label></div>
+ <div class="column data"><input type="text" wicket:id="subject" class="input"/></div>
+ </div>
+ <wicket:child/>
+ <div>
+ <div class="column label"><label wicket:for="message"><wicket:message key="217" /></label></div>
+ <div class="column data"><textarea wicket:id="message" style="width: 280px; height: 70px;"></textarea></div>
+ </div>
+ <div>
+ <input wicket:id="passwordProtected" type="checkbox"/> <label
+ wicket:for="passwordProtected"><wicket:message key="524" /></label>
+ </div>
+ <div>
+ <div class="column label"><label wicket:for="password"><wicket:message key="525" /></label></div>
+ <div class="column data"><input wicket:id="password" type="password"/></div>
+ </div>
+ <div>
+ <div class="column label"><wicket:message key="526" /></div>
+ <div class="column data">
+ <div wicket:id="valid">
+ <input type="radio" wicket:id="one"/><label wicket:for="one"><wicket:message key="529" /></label>
+ <input type="radio" wicket:id="period"/><label wicket:for="period"><wicket:message key="528" /></label>
+ <input type="radio" wicket:id="endless"/><label wicket:for="endless"><wicket:message key="527" /></label>
+ </div>
+ </div>
+ </div>
+ <div>
+ <div class="column label"><label wicket:for="from"><wicket:message key="530" /></label></div>
+ <div class="column data"><span class="date time picker" wicket:id="from"></span></div>
+ </div>
+ <div>
+ <div class="column label"><label wicket:for="to"><wicket:message key="531" /></label></div>
+ <div class="column data"><span class="date time picker" wicket:id="to"></span></div>
+ </div>
+ <div>
+ <div class="column label"><label wicket:for="timeZoneId"><wicket:message key="1143" /></label></div>
+ <div class="column data"><select wicket:id="timeZoneId"/></div>
+ </div>
+ <div>
+ <div class="column label"><label wicket:for="language"><wicket:message key="59" /></label></div>
+ <div class="column data"><select wicket:id="language"/></div>
+ </div>
+ <div>
+ <input wicket:id="url" type="text" readonly="readonly" style="width: 100%;"/>
+ </div>
+ </div>
+ <span wicket:id="feedback"></span>
+</wicket:panel>
+</html>
Added: openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.java?rev=1756948&view=auto
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.java (added)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.java Fri Aug 19 17:29:56 2016
@@ -0,0 +1,174 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") + you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.web.common;
+
+import static org.apache.openmeetings.util.CalendarHelper.getDate;
+import static org.apache.openmeetings.web.app.Application.getBean;
+import static org.apache.openmeetings.web.app.WebSession.AVAILABLE_TIMEZONES;
+import static org.apache.openmeetings.web.app.WebSession.getUserId;
+
+import java.util.UUID;
+
+import org.apache.openmeetings.db.dao.room.InvitationDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.room.Invitation;
+import org.apache.openmeetings.db.entity.room.Invitation.Valid;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.db.entity.user.User.Type;
+import org.apache.openmeetings.util.crypt.CryptProvider;
+import org.apache.openmeetings.web.app.Application;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;
+import org.apache.wicket.markup.html.form.DropDownChoice;
+import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.PasswordTextField;
+import org.apache.wicket.markup.html.form.Radio;
+import org.apache.wicket.markup.html.form.RadioGroup;
+import org.apache.wicket.markup.html.form.TextArea;
+import org.apache.wicket.markup.html.form.TextField;
+import org.apache.wicket.markup.html.panel.IMarkupSourcingStrategy;
+import org.apache.wicket.markup.html.panel.PanelMarkupSourcingStrategy;
+import org.apache.wicket.model.CompoundPropertyModel;
+import org.apache.wicket.model.Model;
+import org.threeten.bp.LocalDateTime;
+
+import com.googlecode.wicket.jquery.core.Options;
+import com.googlecode.wicket.kendo.ui.panel.KendoFeedbackPanel;
+
+public abstract class InvitationForm extends Form<Invitation> {
+ private static final long serialVersionUID = 1L;
+ private final KendoFeedbackPanel feedback = new KendoFeedbackPanel("feedback", new Options("button", true));
+ private final PasswordTextField passwd;
+ private final DropDownChoice<String> timeZoneId = new DropDownChoice<String>("timeZoneId", Model.of((String)null), AVAILABLE_TIMEZONES);
+ private final OmDateTimePicker from = new OmDateTimePicker("from", Model.of(LocalDateTime.now()));
+ private final OmDateTimePicker to = new OmDateTimePicker("to", Model.of(LocalDateTime.now()));
+ private final LanguageDropDown lang = new LanguageDropDown("language", Model.of((Long)null));
+ protected final TextField<String> subject = new TextField<String>("subject", Model.of((String)null));
+ protected final TextArea<String> message = new TextArea<String>("message", Model.of((String)null));
+ protected final TextField<String> url = new TextField<String>("url", Model.of((String)null));
+ protected InvitationDialog dialog;
+
+ public InvitationForm(String id) {
+ super(id, new CompoundPropertyModel<Invitation>(new Invitation()));
+ setOutputMarkupId(true);
+
+ add(subject, message);
+ add(new AjaxCheckBox("passwordProtected") {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ InvitationForm.this.getModelObject().setPasswordProtected(getConvertedInput());
+ passwd.setEnabled(getConvertedInput());
+ target.add(passwd);
+ }
+ });
+ RadioGroup<Valid> valid = new RadioGroup<Valid>("valid");
+ valid.add(new AjaxFormChoiceComponentUpdatingBehavior() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ boolean dateEnabled = InvitationForm.this.getModelObject().getValid() == Valid.Period;
+ target.add(from.setEnabled(dateEnabled), to.setEnabled(dateEnabled), timeZoneId.setEnabled(dateEnabled));
+ }
+ });
+ add(valid.add(new Radio<Valid>("one", Model.of(Valid.OneTime))
+ , new Radio<Valid>("period", Model.of(Valid.Period))
+ , new Radio<Valid>("endless", Model.of(Valid.Endless))));
+ add(passwd = new PasswordTextField("password"));
+ Invitation i = getModelObject();
+ passwd.setLabel(Model.of(Application.getString(525))).setOutputMarkupId(true).setEnabled(i.isPasswordProtected());
+ add(from, to, timeZoneId);
+ from.setEnabled(i.getValid() == Valid.Period).setOutputMarkupId(true);
+ to.setEnabled(i.getValid() == Valid.Period).setOutputMarkupId(true);
+ timeZoneId.setEnabled(i.getValid() == Valid.Period).setOutputMarkupId(true)
+ .add(new AjaxFormComponentUpdatingBehavior("change") {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ //no-op added to preserve selection
+ }
+ });
+ add(url.setOutputMarkupId(true));
+ add(lang, feedback);
+ }
+
+ @Override
+ protected void onValidate() {
+ if (from.getConvertedInput() != null && to.getConvertedInput() != null && from.getConvertedInput().isAfter(to.getConvertedInput())) {
+ error(Application.getString(1592));
+ }
+ }
+
+ protected Invitation create(User u) {
+ Invitation i = new Invitation(getModelObject());
+ i.setId(null);
+ i.setUpdated(null);
+ i.setUsed(false);
+
+ i.setPassword(CryptProvider.get().hash(i.getPassword())); //FIXME should be hidden
+ i.setValidFrom(getDate(from.getModelObject().minusMinutes(5), timeZoneId.getModelObject()));
+ i.setValidTo(getDate(to.getModelObject(), timeZoneId.getModelObject()));
+
+ i.setInvitee(u);
+ i.setHash(UUID.randomUUID().toString());
+ if (Type.contact == u.getType()) {
+ //TODO not sure it is right
+ u.setLanguageId(lang.getModelObject());
+ }
+ return getBean(InvitationDao.class).update(i);
+ }
+
+ @Override
+ protected IMarkupSourcingStrategy newMarkupSourcingStrategy() {
+ return new PanelMarkupSourcingStrategy(false);
+ }
+
+ public void onError(AjaxRequestTarget target) {
+ target.add(feedback);
+ }
+
+ public void updateModel(AjaxRequestTarget target) {
+ Invitation i = new Invitation();
+ User u = getBean(UserDao.class).get(getUserId());
+ i.setInvitedBy(u);
+ i.setRoom(null);
+ from.setModelObject(LocalDateTime.now());
+ to.setModelObject(LocalDateTime.now().plusDays(1));
+ i.setPassword(null);
+ i.setHash(null);
+ subject.setModelObject(null);
+ message.setModelObject(null);
+ timeZoneId.setModelObject(u.getTimeZoneId());
+ lang.setModelObject(u.getLanguageId());
+ url.setModelObject(null);
+ setModelObject(i);
+ target.add(this);
+ }
+
+ public void setDialog(InvitationDialog dialog) {
+ this.dialog = dialog;
+ }
+
+ public abstract boolean onSubmit(AjaxRequestTarget target, boolean generate, boolean send);
+}
\ No newline at end of file
Added: openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.html
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.html?rev=1756948&view=auto
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.html (added)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.html Fri Aug 19 17:29:56 2016
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<html xmlns:wicket="http://wicket.apache.org">
+<wicket:extend>
+ <div wicket:id="inviteeType">
+ <div>
+ <div class="column label"><input type="radio" wicket:id="user"/><label wicket:for="recipients"><wicket:message key="216" /></label></div>
+ <div class="column data om-select2"><select wicket:id="recipients" class="input invitees"></select></div>
+ </div>
+ <div wicket:id="groupContainer">
+ <div class="column label"><input type="radio" wicket:id="group"/><label wicket:for="groups"><wicket:message key="126" /></label></div>
+ <div class="column data om-select2"><select wicket:id="groups" class="input invitees"></select></div>
+ </div>
+ </div>
+ <div wicket:id="sip-container">
+ <div class="column label"><wicket:message key="1003"/></div>
+ <div class="column data"><span wicket:id="room.confno"></span></div>
+ </div>
+</wicket:extend>
+</html>
Added: openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.java?rev=1756948&view=auto
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.java (added)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.java Fri Aug 19 17:29:56 2016
@@ -0,0 +1,232 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") + you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.web.room.menu;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
+import static org.apache.openmeetings.web.app.Application.getBean;
+import static org.apache.openmeetings.web.app.Application.getInvitationLink;
+import static org.apache.openmeetings.web.app.WebSession.getRights;
+import static org.apache.openmeetings.web.app.WebSession.getUserId;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
+import org.apache.openmeetings.db.dao.room.RoomDao;
+import org.apache.openmeetings.db.dao.user.GroupDao;
+import org.apache.openmeetings.db.dao.user.GroupUserDao;
+import org.apache.openmeetings.db.dao.user.UserDao;
+import org.apache.openmeetings.db.entity.room.Invitation;
+import org.apache.openmeetings.db.entity.room.Invitation.MessageType;
+import org.apache.openmeetings.db.entity.user.Group;
+import org.apache.openmeetings.db.entity.user.GroupUser;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.db.util.AuthLevelUtil;
+import org.apache.openmeetings.service.room.InvitationManager;
+import org.apache.openmeetings.web.app.Application;
+import org.apache.openmeetings.web.app.WebSession;
+import org.apache.openmeetings.web.common.InvitationForm;
+import org.apache.openmeetings.web.util.UserMultiChoice;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.form.Radio;
+import org.apache.wicket.markup.html.form.RadioGroup;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.util.CollectionModel;
+import org.apache.wicket.util.string.Strings;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+import org.wicketstuff.select2.ChoiceProvider;
+import org.wicketstuff.select2.Response;
+import org.wicketstuff.select2.Select2MultiChoice;
+
+public class RoomInvitationForm extends InvitationForm {
+ private static final long serialVersionUID = 1L;
+ private static final Logger log = Red5LoggerFactory.getLogger(RoomInvitationForm.class, webAppRootKey);
+ private final RadioGroup<InviteeType> rdi = new RadioGroup<>("inviteeType", Model.of(InviteeType.user));
+ private final Long roomId;
+ private final WebMarkupContainer groupContainer = new WebMarkupContainer("groupContainer");
+ final UserMultiChoice recipients = new UserMultiChoice("recipients", new CollectionModel<User>(new ArrayList<User>()));
+ final Select2MultiChoice<Group> groups = new Select2MultiChoice<Group>("groups"
+ , new CollectionModel<Group>(new ArrayList<Group>())
+ , new ChoiceProvider<Group>() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void query(String term, int page, Response<Group> response) {
+ if (WebSession.getRights().contains(User.Right.Admin)) {
+ List<Group> groups = getBean(GroupDao.class).get(0, Integer.MAX_VALUE);
+ for (Group g : groups) {
+ if (Strings.isEmpty(term) || g.getName().toLowerCase().contains(term.toLowerCase())) {
+ response.add(g);
+ }
+ }
+ } else {
+ User u = getBean(UserDao.class).get(getUserId());
+ for (GroupUser ou : u.getGroupUsers()) {
+ if (Strings.isEmpty(term) || ou.getGroup().getName().toLowerCase().contains(term.toLowerCase())) {
+ response.add(ou.getGroup());
+ }
+ }
+ }
+ }
+
+ @Override
+ public Collection<Group> toChoices(Collection<String> ids) {
+ Collection<Group> c = new ArrayList<>();
+ for (String id : ids) {
+ c.add(getBean(GroupDao.class).get(Long.valueOf(id)));
+ }
+ return c;
+ }
+
+ @Override
+ public String getDisplayValue(Group choice) {
+ return choice.getName();
+ }
+
+ @Override
+ public String getIdValue(Group choice) {
+ Long id = choice.getId();
+ return id == null ? null : "" + id;
+ }
+ });
+ final WebMarkupContainer sipContainer = new WebMarkupContainer("sip-container");
+
+ enum InviteeType {
+ user
+ , group
+ }
+
+ public RoomInvitationForm(String id, Long roomId) {
+ super(id);
+ this.roomId = roomId;
+ boolean showGroups = AuthLevelUtil.hasAdminLevel(getRights());
+ add(rdi.add(new AjaxFormChoiceComponentUpdatingBehavior() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ boolean groupsEnabled = InviteeType.group == rdi.getModelObject();
+ updateButtons(target);
+ target.add(groups.setEnabled(groupsEnabled), recipients.setEnabled(!groupsEnabled));
+ }
+ }));
+ rdi.add(recipients.setLabel(Model.of(Application.getString(216))).setRequired(true).add(new AjaxFormComponentUpdatingBehavior("change") {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ url.setModelObject(null);
+ updateButtons(target);
+ }
+ }).setOutputMarkupId(true));
+ groupContainer.add(
+ groups.setLabel(Model.of(Application.getString(126))).setRequired(true).add(new AjaxFormComponentUpdatingBehavior("change") {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ url.setModelObject(null);
+ updateButtons(target);
+ }
+ }).setOutputMarkupId(true)
+ , new Radio<InviteeType>("group", Model.of(InviteeType.group))
+ );
+ rdi.add(groupContainer.setVisible(showGroups));
+ rdi.add(new Radio<InviteeType>("user", Model.of(InviteeType.user)));
+ add(sipContainer.setOutputMarkupPlaceholderTag(true).setOutputMarkupId(true));
+ sipContainer.add(new Label("room.confno", "")).setVisible(false);
+ }
+
+ private void updateButtons(AjaxRequestTarget target) {
+ if (rdi.getModelObject() == InviteeType.user) {
+ Collection<User> to = recipients.getModelObject();
+ dialog.send.setEnabled(to.size() > 0, target);
+ dialog.generate.setEnabled(to.size() == 1, target);
+ } else {
+ Collection<Group> to = groups.getModelObject();
+ dialog.send.setEnabled(to.size() > 0, target);
+ dialog.generate.setEnabled(false, target);
+ }
+ }
+
+ @Override
+ public void updateModel(AjaxRequestTarget target) {
+ super.updateModel(target);
+ Invitation i = getModelObject();
+ i.setRoom(getBean(RoomDao.class).get(roomId));
+ if (i.getRoom() != null) {
+ target.add(sipContainer.replace(new Label("room.confno", i.getRoom().getConfno())).setVisible(i.getRoom().isSipEnabled()));
+ }
+ recipients.setModelObject(new ArrayList<User>());
+ recipients.setEnabled(true);
+ groups.setModelObject(new ArrayList<Group>());
+ groups.setEnabled(false);
+ rdi.setModelObject(InviteeType.user);
+ }
+
+ @Override
+ public boolean onSubmit(AjaxRequestTarget target, boolean generate, boolean send) {
+ //TODO need to be reviewed
+ if (generate) {
+ Invitation i = create(recipients.getModelObject().iterator().next());
+ setModelObject(i);
+ url.setModelObject(getInvitationLink(getBean(ConfigurationDao.class).getBaseUrl(), i));
+ target.add(url);
+ return true;
+ } else if (send) {
+ if (Strings.isEmpty(url.getModelObject())) {
+ if (rdi.getModelObject() == InviteeType.user) {
+ for (User u : recipients.getModelObject()) {
+ Invitation i = create(u);
+ try {
+ getBean(InvitationManager.class).sendInvitationLink(i, MessageType.Create, subject.getModelObject(), message.getModelObject(), false);
+ } catch (Exception e) {
+ log.error("error while sending invitation by User ", e);
+ }
+ }
+ } else {
+ for (Group g : groups.getModelObject()) {
+ for (GroupUser ou : getBean(GroupUserDao.class).get(g.getId(), 0, Integer.MAX_VALUE)) {
+ Invitation i = create(ou.getUser());
+ try {
+ getBean(InvitationManager.class).sendInvitationLink(i, MessageType.Create, subject.getModelObject(), message.getModelObject(), false);
+ } catch (Exception e) {
+ log.error("error while sending invitation by Group ", e);
+ }
+ }
+ }
+ }
+ } else {
+ Invitation i = getModelObject();
+ try {
+ getBean(InvitationManager.class).sendInvitationLink(i, MessageType.Create, subject.getModelObject(), message.getModelObject(), false);
+ } catch (Exception e) {
+ log.error("error while sending invitation by URL ", e);
+ }
+ }
+ }
+ return false;
+ }
+}
Modified: openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomMenuPanel.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomMenuPanel.java?rev=1756948&r1=1756947&r2=1756948&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomMenuPanel.java (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomMenuPanel.java Fri Aug 19 17:29:56 2016
@@ -43,6 +43,7 @@ import org.apache.openmeetings.util.mess
import org.apache.openmeetings.web.app.Application;
import org.apache.openmeetings.web.app.Client;
import org.apache.openmeetings.web.app.WebSession;
+import org.apache.openmeetings.web.common.InvitationDialog;
import org.apache.openmeetings.web.common.OmButton;
import org.apache.openmeetings.web.common.menu.MenuPanel;
import org.apache.openmeetings.web.common.menu.RoomMenuItem;
@@ -190,7 +191,9 @@ public class RoomMenuPanel extends Panel
add(askBtn);
add((roomName = new Label("roomName", r.getName())).setOutputMarkupId(true));
add(shareBtn = new StartSharingButton("share", room.getClient()));
- add(invite = new InvitationDialog("invite", room.getRoom().getId()));
+ RoomInvitationForm rif = new RoomInvitationForm("form", room.getRoom().getId());
+ add(invite = new InvitationDialog("invite", rif));
+ rif.setDialog(invite);
add(createPoll = new CreatePollDialog("createPoll", room.getRoom().getId()));
add(vote = new VoteDialog("vote"));
add(pollResults = new PollResultsDialog("pollResults", room.getRoom().getId()));
Added: openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.html
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.html?rev=1756948&view=auto
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.html (added)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.html Fri Aug 19 17:29:56 2016
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<html xmlns:wicket="http://wicket.apache.org">
+<wicket:extend>
+ <div>
+ <div>
+ <div class="column label"><label wicket:for="recipients"><wicket:message key="216" /></label></div>
+ <div class="column data om-select2"><select wicket:id="recipients" class="input invitees"></select></div>
+ </div>
+ </div>
+</wicket:extend>
+</html>
Added: openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.java?rev=1756948&view=auto
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.java (added)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.java Fri Aug 19 17:29:56 2016
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License") + you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.openmeetings.web.user.record;
+
+import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
+import static org.apache.openmeetings.web.app.Application.getBean;
+import static org.apache.openmeetings.web.app.Application.getInvitationLink;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
+import org.apache.openmeetings.db.entity.room.Invitation;
+import org.apache.openmeetings.db.entity.room.Invitation.MessageType;
+import org.apache.openmeetings.db.entity.user.User;
+import org.apache.openmeetings.service.room.InvitationManager;
+import org.apache.openmeetings.web.app.Application;
+import org.apache.openmeetings.web.common.InvitationForm;
+import org.apache.openmeetings.web.util.UserMultiChoice;
+import org.apache.wicket.ajax.AjaxRequestTarget;
+import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
+import org.apache.wicket.model.Model;
+import org.apache.wicket.model.util.CollectionModel;
+import org.apache.wicket.util.string.Strings;
+import org.red5.logging.Red5LoggerFactory;
+import org.slf4j.Logger;
+
+public class RecordingInvitationForm extends InvitationForm {
+ private static final long serialVersionUID = 1L;
+ private static final Logger log = Red5LoggerFactory.getLogger(RecordingInvitationForm.class, webAppRootKey);
+ private Long recordingId;
+ final UserMultiChoice recipients = new UserMultiChoice("recipients", new CollectionModel<User>(new ArrayList<User>()));
+
+ public RecordingInvitationForm(String id) {
+ super(id);
+ add(recipients.setLabel(Model.of(Application.getString(216))).setRequired(true).add(new AjaxFormComponentUpdatingBehavior("change") {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onUpdate(AjaxRequestTarget target) {
+ url.setModelObject(null);
+ updateButtons(target);
+ }
+ }).setOutputMarkupId(true));
+ }
+
+ private void updateButtons(AjaxRequestTarget target) {
+ Collection<User> to = recipients.getModelObject();
+ dialog.send.setEnabled(to.size() > 0, target);
+ dialog.generate.setEnabled(to.size() == 1, target);
+ }
+
+ @Override
+ public void updateModel(AjaxRequestTarget target) {
+ super.updateModel(target);
+ //Invitation i = getModelObject();
+ //i.setReco
+ recipients.setModelObject(new ArrayList<User>());
+ recipients.setEnabled(true);
+ }
+
+ @Override
+ public boolean onSubmit(AjaxRequestTarget target, boolean generate, boolean send) {
+ //TODO need to be reviewed
+ if (generate) {
+ Invitation i = create(recipients.getModelObject().iterator().next());
+ setModelObject(i);
+ url.setModelObject(getInvitationLink(getBean(ConfigurationDao.class).getBaseUrl(), i));
+ target.add(url);
+ return true;
+ } else if (send) {
+ if (Strings.isEmpty(url.getModelObject())) {
+ for (User u : recipients.getModelObject()) {
+ Invitation i = create(u);
+ try {
+ getBean(InvitationManager.class).sendInvitationLink(i, MessageType.Create, subject.getModelObject(), message.getModelObject(), false);
+ } catch (Exception e) {
+ log.error("error while sending invitation by User ", e);
+ }
+ }
+ } else {
+ Invitation i = getModelObject();
+ try {
+ getBean(InvitationManager.class).sendInvitationLink(i, MessageType.Create, subject.getModelObject(), message.getModelObject(), false);
+ } catch (Exception e) {
+ log.error("error while sending invitation by URL ", e);
+ }
+ }
+ }
+ return false;
+ }
+
+ public void setRecordingId(Long recordingId) {
+ this.recordingId = recordingId;
+ }
+}
Modified: openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.html
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.html?rev=1756948&r1=1756947&r2=1756948&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.html (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.html Fri Aug 19 17:29:56 2016
@@ -39,12 +39,10 @@
<td><span wicket:id="roomName"></span></td>
</tr>
</table>
- <table>
- <tr>
- <td><span wicket:id="downloadBtn"></span></td>
- <td><button wicket:id="re-convert"><wicket:message key="1600"/></button></td>
- </tr>
- </table>
+ <span wicket:id="downloadBtn"></span>
+ <button wicket:id="re-convert"><wicket:message key="1600"/></button>
+ <button wicket:id="share"><wicket:message key="button.label.share"/></button>
</form>
+ <div wicket:id="invitation"></div>
</wicket:panel>
</html>
Modified: openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.java
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.java?rev=1756948&r1=1756947&r2=1756948&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.java (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.java Fri Aug 19 17:29:56 2016
@@ -38,6 +38,7 @@ import org.apache.openmeetings.db.entity
import org.apache.openmeetings.db.entity.record.Recording.Status;
import org.apache.openmeetings.db.entity.record.RecordingMetaData;
import org.apache.openmeetings.db.entity.room.Room;
+import org.apache.openmeetings.web.common.InvitationDialog;
import org.apache.openmeetings.web.util.AjaxDownload;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.basic.Label;
@@ -81,6 +82,17 @@ public class VideoInfo extends Panel {
private final IModel<Recording> rm = new CompoundPropertyModel<Recording>(new Recording());
private final IModel<String> roomName = Model.of((String)null);
private boolean isInterview = false;
+ private final InvitationDialog invite;
+ RecordingInvitationForm rif = new RecordingInvitationForm("form");
+ private final AjaxButton share = new AjaxButton("share") {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
+ rif.setRecordingId(rm.getObject().getId());
+ invite.open(target);
+ }
+ };
public VideoInfo(String id) {
this(id, null);
@@ -92,8 +104,11 @@ public class VideoInfo extends Panel {
setDefaultModel(rm);
form.add(new Label("name"), new Label("duration"), new Label("recordEnd"), new Label("roomName", roomName),
- downloadBtn.setEnabled(false), reConvert.setEnabled(false));
+ downloadBtn.setEnabled(false), reConvert.setEnabled(false), share.setEnabled(false));
add(download);
+ add(invite = new InvitationDialog("invitation", rif));
+ rif.setDialog(invite);
+
update(null, r);
}
@@ -128,7 +143,9 @@ public class VideoInfo extends Panel {
}
}
reConvert.setEnabled(reConvEnabled);
- downloadBtn.setEnabled(r.exists() || r.exists(EXTENSION_AVI));
+ boolean exists = r.exists() || r.exists(EXTENSION_AVI);
+ downloadBtn.setEnabled(exists);
+ share.setEnabled(exists);
if (target != null) {
target.add(form);
}
@@ -158,7 +175,7 @@ public class VideoInfo extends Panel {
@Override
public boolean isEnabled() {
- Recording r = VideoInfo.this.rm.getObject();
+ Recording r = rm.getObject();
return r != null && r.exists(EXTENSION_MP4);
}
@@ -176,7 +193,7 @@ public class VideoInfo extends Panel {
@Override
public boolean isEnabled() {
- Recording r = VideoInfo.this.rm.getObject();
+ Recording r = rm.getObject();
return r != null && r.exists(EXTENSION_AVI);
}
Modified: openmeetings/application/branches/3.2.x/openmeetings-web/src/main/webapp/css/menu.css
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/webapp/css/menu.css?rev=1756948&r1=1756947&r2=1756948&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/main/webapp/css/menu.css (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/main/webapp/css/menu.css Fri Aug 19 17:29:56 2016
@@ -48,3 +48,6 @@
max-height: 30px;
min-height: 30px;
}
+.recording .ui-menu .ui-menu-item {
+ display: block;
+}
Modified: openmeetings/application/branches/3.2.x/openmeetings-web/src/main/webapp/css/theme.css
URL: http://svn.apache.org/viewvc/openmeetings/application/branches/3.2.x/openmeetings-web/src/main/webapp/css/theme.css?rev=1756948&r1=1756947&r2=1756948&view=diff
==============================================================================
--- openmeetings/application/branches/3.2.x/openmeetings-web/src/main/webapp/css/theme.css (original)
+++ openmeetings/application/branches/3.2.x/openmeetings-web/src/main/webapp/css/theme.css Fri Aug 19 17:29:56 2016
@@ -636,3 +636,17 @@ form .input {
.no-close .ui-dialog-titlebar-close {
display: none;
}
+.table {
+ position: relative;
+}
+.table .column {
+ display: inline-block;
+ margin-bottom: 5px;
+}
+.table .column.label {
+ width: 20%;
+}
+.table .column.data {
+ width: 75%;
+ vertical-align: middle;
+}
Modified: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml?rev=1756948&r1=1756947&r2=1756948&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/app/Application.properties.xml Fri Aug 19 17:29:56 2016
@@ -1920,4 +1920,5 @@
<entry key="install.room.private.conference">Private Conference Room</entry>
<entry key="appointment.tab.general">General</entry>
<entry key="appointment.tab.advanced">Advanced</entry>
+ <entry key="button.label.share">Share</entry>
</properties>
Copied: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationDialog.html (from r1756947, openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/InvitationDialog.html)
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationDialog.html?p2=openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationDialog.html&p1=openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/InvitationDialog.html&r1=1756947&r2=1756948&rev=1756948&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/InvitationDialog.html (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationDialog.html Fri Aug 19 17:29:56 2016
@@ -20,67 +20,6 @@
-->
<html xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
- <form wicket:id="form">
- <table wicket:id="inviteeType">
- <tr>
- <td><input type="radio" wicket:id="user"/><label wicket:for="recipients"><wicket:message key="216" /></label></td>
- <td class="om-select2"><select wicket:id="recipients" class="input invitees"></select></td>
- </tr>
- <tr wicket:id="groupContainer">
- <td><input type="radio" wicket:id="group"/><label wicket:for="groups"><wicket:message key="126" /></label></td>
- <td class="om-select2"><select wicket:id="groups" class="input invitees"></select></td>
- </tr>
- <tr>
- <td><label wicket:for="subject"><wicket:message key="215" /></label></td>
- <td><input type="text" wicket:id="subject" class="input"/></td>
- </tr>
- <tr wicket:id="sip-container">
- <td><wicket:message key="1003"/></td>
- <td><span wicket:id="room.confno"></span></td>
- </tr>
- <tr>
- <td><label wicket:for="message"><wicket:message key="217" /></label></td>
- <td><textarea wicket:id="message" style="width: 280px; height: 70px;"></textarea></td>
- </tr>
- <tr>
- <td colspan="2"><input wicket:id="passwordProtected" type="checkbox"/> <label
- wicket:for="passwordProtected"><wicket:message key="524" /></label></td>
- </tr>
- <tr>
- <td><label wicket:for="password"><wicket:message key="525" /></label></td>
- <td><input wicket:id="password" type="password"/></td>
- </tr>
- <tr>
- <td><wicket:message key="526" /></td>
- <td>
- <div wicket:id="valid">
- <input type="radio" wicket:id="one"/><label wicket:for="one"><wicket:message key="529" /></label>
- <input type="radio" wicket:id="period"/><label wicket:for="period"><wicket:message key="528" /></label>
- <input type="radio" wicket:id="endless"/><label wicket:for="endless"><wicket:message key="527" /></label>
- </div>
- </td>
- </tr>
- <tr>
- <td><label wicket:for="validFrom"><wicket:message key="530" /></label></td>
- <td><span class="date time picker" wicket:id="validFrom"></span></td>
- </tr>
- <tr>
- <td><label wicket:for="validTo"><wicket:message key="531" /></label></td>
- <td><span class="date time picker" wicket:id="validTo"></span></td>
- </tr>
- <tr>
- <td><label wicket:for="timeZoneId"><wicket:message key="1143" /></label></td>
- <td><select wicket:id="timeZoneId"/></td>
- </tr>
- <tr>
- <td><label wicket:for="language"><wicket:message key="59" /></label></td>
- <td><select wicket:id="language"/></td>
- </tr>
- <tr>
- <td colspan="2"><input wicket:id="url" type="text" readonly="readonly" style="width: 100%;"/></td>
- </tr>
- </table>
- <span wicket:id="feedback"></span>
- </form>
+ <form wicket:id="form"></form>
</wicket:panel>
</html>
Copied: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationDialog.java (from r1756947, openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/InvitationDialog.java)
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationDialog.java?p2=openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationDialog.java&p1=openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/InvitationDialog.java&r1=1756947&r2=1756948&rev=1756948&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/InvitationDialog.java (original)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationDialog.java Fri Aug 19 17:29:56 2016
@@ -16,144 +16,29 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.openmeetings.web.room.menu;
+package org.apache.openmeetings.web.common;
-import static org.apache.openmeetings.util.OpenmeetingsVariables.webAppRootKey;
-import static org.apache.openmeetings.web.app.Application.getBean;
-import static org.apache.openmeetings.web.app.Application.getInvitationLink;
-import static org.apache.openmeetings.web.app.WebSession.AVAILABLE_TIMEZONES;
-import static org.apache.openmeetings.web.app.WebSession.getRights;
-import static org.apache.openmeetings.web.app.WebSession.getUserId;
-
-import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
import java.util.List;
-import java.util.UUID;
-import org.apache.openmeetings.db.dao.basic.ConfigurationDao;
-import org.apache.openmeetings.db.dao.room.InvitationDao;
-import org.apache.openmeetings.db.dao.room.RoomDao;
-import org.apache.openmeetings.db.dao.user.GroupDao;
-import org.apache.openmeetings.db.dao.user.GroupUserDao;
-import org.apache.openmeetings.db.dao.user.UserDao;
import org.apache.openmeetings.db.entity.room.Invitation;
-import org.apache.openmeetings.db.entity.room.Invitation.MessageType;
-import org.apache.openmeetings.db.entity.room.Invitation.Valid;
-import org.apache.openmeetings.db.entity.user.Group;
-import org.apache.openmeetings.db.entity.user.GroupUser;
-import org.apache.openmeetings.db.entity.user.User;
-import org.apache.openmeetings.db.entity.user.User.Type;
-import org.apache.openmeetings.db.util.AuthLevelUtil;
-import org.apache.openmeetings.service.room.InvitationManager;
-import org.apache.openmeetings.util.crypt.CryptProvider;
import org.apache.openmeetings.web.app.Application;
-import org.apache.openmeetings.web.app.WebSession;
-import org.apache.openmeetings.web.common.LanguageDropDown;
-import org.apache.openmeetings.web.util.UserMultiChoice;
import org.apache.wicket.ajax.AjaxRequestTarget;
-import org.apache.wicket.ajax.form.AjaxFormChoiceComponentUpdatingBehavior;
-import org.apache.wicket.ajax.form.AjaxFormComponentUpdatingBehavior;
-import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox;
-import org.apache.wicket.markup.html.WebMarkupContainer;
-import org.apache.wicket.markup.html.basic.Label;
-import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
-import org.apache.wicket.markup.html.form.PasswordTextField;
-import org.apache.wicket.markup.html.form.Radio;
-import org.apache.wicket.markup.html.form.RadioGroup;
-import org.apache.wicket.markup.html.form.TextArea;
-import org.apache.wicket.markup.html.form.TextField;
-import org.apache.wicket.model.CompoundPropertyModel;
-import org.apache.wicket.model.IModel;
-import org.apache.wicket.model.Model;
-import org.apache.wicket.model.PropertyModel;
-import org.apache.wicket.model.util.CollectionModel;
-import org.apache.wicket.util.string.Strings;
-import org.red5.logging.Red5LoggerFactory;
-import org.slf4j.Logger;
-import org.wicketstuff.select2.ChoiceProvider;
-import org.wicketstuff.select2.Response;
-import org.wicketstuff.select2.Select2MultiChoice;
-import com.googlecode.wicket.jquery.core.Options;
import com.googlecode.wicket.jquery.ui.widget.dialog.AbstractFormDialog;
import com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton;
-import com.googlecode.wicket.kendo.ui.form.datetime.AjaxDateTimePicker;
-import com.googlecode.wicket.kendo.ui.form.datetime.DateTimePicker;
-import com.googlecode.wicket.kendo.ui.panel.KendoFeedbackPanel;
public class InvitationDialog extends AbstractFormDialog<Invitation> {
private static final long serialVersionUID = 1L;
- private static final Logger log = Red5LoggerFactory.getLogger(InvitationDialog.class, webAppRootKey);
- private final DialogButton generate = new DialogButton("generate", Application.getString(1526));
- private final DialogButton send = new DialogButton("send", Application.getString(218));
+ public final DialogButton generate = new DialogButton("generate", Application.getString(1526));
+ public final DialogButton send = new DialogButton("send", Application.getString(218));
private final DialogButton cancel = new DialogButton("cancel", Application.getString(219));
private final InvitationForm form;
- private final KendoFeedbackPanel feedback = new KendoFeedbackPanel("feedback", new Options("button", true));
- private final Long roomId;
- private final IModel<String> subject = Model.of((String)null);
- private final IModel<String> message = Model.of((String)null);
- private final IModel<String> tzId = Model.of((String)null);
- private final IModel<InviteeType> inviteeType = Model.of(InviteeType.user);
- private long lang;
- private final TextField<String> url = new TextField<String>("url", Model.of((String)null));
- enum InviteeType {
- user
- , group
- }
- private final UserMultiChoice recipients = new UserMultiChoice("recipients", new CollectionModel<User>(new ArrayList<User>()));
- private final Select2MultiChoice<Group> groups = new Select2MultiChoice<Group>("groups"
- , new CollectionModel<Group>(new ArrayList<Group>())
- , new ChoiceProvider<Group>() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public void query(String term, int page, Response<Group> response) {
- if (WebSession.getRights().contains(User.Right.Admin)) {
- List<Group> groups = getBean(GroupDao.class).get(0, Integer.MAX_VALUE);
- for (Group g : groups) {
- if (Strings.isEmpty(term) || g.getName().toLowerCase().contains(term.toLowerCase())) {
- response.add(g);
- }
- }
- } else {
- User u = getBean(UserDao.class).get(getUserId());
- for (GroupUser ou : u.getGroupUsers()) {
- if (Strings.isEmpty(term) || ou.getGroup().getName().toLowerCase().contains(term.toLowerCase())) {
- response.add(ou.getGroup());
- }
- }
- }
- }
-
- @Override
- public Collection<Group> toChoices(Collection<String> ids) {
- Collection<Group> c = new ArrayList<>();
- for (String id : ids) {
- c.add(getBean(GroupDao.class).get(Long.valueOf(id)));
- }
- return c;
- }
-
- @Override
- public String getDisplayValue(Group choice) {
- return choice.getName();
- }
-
- @Override
- public String getIdValue(Group choice) {
- Long id = choice.getId();
- return id == null ? null : "" + id;
- }
- });
- private final WebMarkupContainer sipContainer = new WebMarkupContainer("sip-container");
-
- public InvitationDialog(String id, Long roomId) {
- super(id, Application.getString(214), new CompoundPropertyModel<Invitation>(new Invitation()));
- this.roomId = roomId;
- add(form = new InvitationForm("form", getModel()));
+
+ public InvitationDialog(String id, final InvitationForm _form) {
+ super(id, Application.getString(214),_form.getModel());
+ add(form = _form);
}
@Override
@@ -162,33 +47,9 @@ public class InvitationDialog extends Ab
}
public void updateModel(AjaxRequestTarget target) {
- Invitation i = new Invitation();
- User u = getBean(UserDao.class).get(getUserId());
- i.setInvitedBy(u);
- i.setRoom(getBean(RoomDao.class).get(roomId));
- if (i.getRoom() != null) {
- target.add(sipContainer.replace(new Label("room.confno", i.getRoom().getConfno())).setVisible(i.getRoom().isSipEnabled()));
- }
- Calendar d = Calendar.getInstance();
- i.setValidFrom(d.getTime());
- d.add(Calendar.DATE, 1);
- i.setValidTo(d.getTime());
- i.setPassword(null);
- i.setHash(null);
- subject.setObject(null);
- message.setObject(null);
- recipients.setModelObject(new ArrayList<User>());
- recipients.setEnabled(true);
- groups.setModelObject(new ArrayList<Group>());
- groups.setEnabled(false);
- tzId.setObject(u.getTimeZoneId());
- lang = u.getLanguageId();
- url.setModelObject(null);
- inviteeType.setObject(InviteeType.user);
- form.setModelObject(i);
+ form.updateModel(target);
send.setEnabled(false, target);
generate.setEnabled(false, target);
- target.add(form);
}
@Override
@@ -216,203 +77,18 @@ public class InvitationDialog extends Ab
@Override
protected void onError(AjaxRequestTarget target) {
- target.add(feedback);
+ form.onError(target);
}
@Override
public void onClick(AjaxRequestTarget target, DialogButton button) {
- //TODO need to be reviewed
- if (button.equals(cancel)) {
- super.onClick(target, button);
- } else if (button.equals(generate)) {
- Invitation i = create(recipients.getModelObject().iterator().next());
- form.setModelObject(i);
- url.setModelObject(getInvitationLink(getBean(ConfigurationDao.class).getBaseUrl(), i));
- target.add(url);
- } else if (button.equals(send)) {
- if (Strings.isEmpty(url.getModelObject())) {
- if (inviteeType.getObject() == InviteeType.user) {
- for (User u : recipients.getModelObject()) {
- Invitation i = create(u);
- try {
- getBean(InvitationManager.class).sendInvitationLink(i, MessageType.Create, subject.getObject(), message.getObject(), false);
- } catch (Exception e) {
- log.error("error while sending invitation by User ", e);
- }
- }
- } else {
- for (Group g : groups.getModelObject()) {
- for (GroupUser ou : getBean(GroupUserDao.class).get(g.getId(), 0, Integer.MAX_VALUE)) {
- Invitation i = create(ou.getUser());
- try {
- getBean(InvitationManager.class).sendInvitationLink(i, MessageType.Create, subject.getObject(), message.getObject(), false);
- } catch (Exception e) {
- log.error("error while sending invitation by Group ", e);
- }
- }
- }
- }
- } else {
- Invitation i = form.getModelObject();
- try {
- getBean(InvitationManager.class).sendInvitationLink(i, MessageType.Create, subject.getObject(), message.getObject(), false);
- } catch (Exception e) {
- log.error("error while sending invitation by URL ", e);
- }
- }
+ if (!form.onSubmit(target, button.equals(generate), button.equals(send))) {
super.onClick(target, button);
}
}
- private Invitation create(User u) {
- Invitation i = new Invitation(form.getModelObject());
- i.setId(null);
- i.setUpdated(null);
- i.setUsed(false);
-
- i.setPassword(CryptProvider.get().hash(i.getPassword())); //FIXME should be hidden
- //FIXME another HACK
- Calendar d = Calendar.getInstance();
- d.setTime(i.getValidFrom());
- d.add(Calendar.MINUTE, -5);
- i.setValidFrom(d.getTime());
-
- i.setInvitee(u);
- i.setHash(UUID.randomUUID().toString());
- if (Type.contact == u.getType()) {
- //TODO not sure it is right
- u.setLanguageId(lang);
- }
- return getBean(InvitationDao.class).update(i);
- }
-
@Override
protected void onSubmit(AjaxRequestTarget target) {
//designed to be empty because of multiple submit buttons
}
-
- private class InvitationForm extends Form<Invitation> {
- private static final long serialVersionUID = 1L;
- private final PasswordTextField passwd;
- private final DateTimePicker from;
- private final DateTimePicker to;
- private final DropDownChoice<String> timeZoneId;
- private final WebMarkupContainer groupContainer = new WebMarkupContainer("groupContainer");
-
- public InvitationForm(String id, IModel<Invitation> model) {
- super(id, model);
- boolean showGroups = AuthLevelUtil.hasAdminLevel(getRights());
- RadioGroup<InviteeType> rdi = new RadioGroup<>("inviteeType", inviteeType);
- add(rdi.add(new AjaxFormChoiceComponentUpdatingBehavior() {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- boolean groupsEnabled = InviteeType.group == inviteeType.getObject();
- updateButtons(target);
- target.add(groups.setEnabled(groupsEnabled), recipients.setEnabled(!groupsEnabled));
- }
- }));
- //TODO list should be updated on open
- rdi.add(recipients.setLabel(Model.of(Application.getString(216))).setRequired(true).add(new AjaxFormComponentUpdatingBehavior("change") {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- url.setModelObject(null);
- updateButtons(target);
- }
- }).setOutputMarkupId(true));
- groupContainer.add(
- groups.setLabel(Model.of(Application.getString(126))).setRequired(true).add(new AjaxFormComponentUpdatingBehavior("change") {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- url.setModelObject(null);
- updateButtons(target);
- }
- }).setOutputMarkupId(true)
- , new Radio<InviteeType>("group", Model.of(InviteeType.group))
- );
- rdi.add(groupContainer.setVisible(showGroups));
- rdi.add(new Radio<InviteeType>("user", Model.of(InviteeType.user)));
-
- rdi.add(new TextField<String>("subject", subject));
- rdi.add(new TextArea<String>("message", message));
- rdi.add(new AjaxCheckBox("passwordProtected") {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- InvitationForm.this.getModelObject().setPasswordProtected(getConvertedInput());
- passwd.setEnabled(getConvertedInput());
- target.add(passwd);
- }
- });
- RadioGroup<Valid> valid = new RadioGroup<Valid>("valid");
- valid.add(new AjaxFormChoiceComponentUpdatingBehavior() {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- boolean dateEnabled = InvitationForm.this.getModelObject().getValid() == Valid.Period;
- target.add(from.setEnabled(dateEnabled), to.setEnabled(dateEnabled), timeZoneId.setEnabled(dateEnabled));
- }
- });
- rdi.add(valid.add(new Radio<Valid>("one", Model.of(Valid.OneTime))
- , new Radio<Valid>("period", Model.of(Valid.Period))
- , new Radio<Valid>("endless", Model.of(Valid.Endless))));
- rdi.add(passwd = new PasswordTextField("password"));
- Invitation i = getModelObject();
- passwd.setLabel(Model.of(Application.getString(525))).setOutputMarkupId(true).setEnabled(i.isPasswordProtected());
- rdi.add(from = new AjaxDateTimePicker("validFrom", "yyyy/MM/dd", "HH:mm:ss")); //FIXME use user locale
- rdi.add(to = new AjaxDateTimePicker("validTo", "yyyy/MM/dd", "HH:mm:ss")); //FIXME use user locale
- rdi.add(timeZoneId = new DropDownChoice<String>("timeZoneId", tzId, AVAILABLE_TIMEZONES));
- from.setEnabled(i.getValid() == Valid.Period).setOutputMarkupId(true);
- to.setEnabled(i.getValid() == Valid.Period).setOutputMarkupId(true);
- timeZoneId.setEnabled(i.getValid() == Valid.Period).setOutputMarkupId(true)
- .add(new AjaxFormComponentUpdatingBehavior("change") {
- private static final long serialVersionUID = 1L;
-
- @Override
- protected void onUpdate(AjaxRequestTarget target) {
- //no-op added to preserve selection
- }
- });
- rdi.add(new LanguageDropDown("language", new PropertyModel<Long>(InvitationDialog.this, "lang")));
- rdi.add(url.setOutputMarkupId(true));
- rdi.add(sipContainer.setOutputMarkupPlaceholderTag(true).setOutputMarkupId(true));
- sipContainer.add(new Label("room.confno", "")).setVisible(false);
- add(feedback);
- }
-
- private void updateButtons(AjaxRequestTarget target) {
- if (inviteeType.getObject() == InviteeType.user) {
- Collection<User> to = recipients.getModelObject();
- send.setEnabled(to.size() > 0, target);
- generate.setEnabled(to.size() == 1, target);
- } else {
- Collection<Group> to = groups.getModelObject();
- send.setEnabled(to.size() > 0, target);
- generate.setEnabled(false, target);
- }
- }
-
- @Override
- protected void onValidate() {
- if (from.getConvertedInput() != null && to.getConvertedInput() != null && from.getConvertedInput().after(to.getConvertedInput())) {
- error(Application.getString(1592));
- }
- }
- }
-
- @Override
- protected void onDetach() {
- subject.detach();
- message.detach();
- tzId.detach();
- inviteeType.detach();
- super.onDetach();
- }
}
Added: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.html
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.html?rev=1756948&view=auto
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.html (added)
+++ openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.html Fri Aug 19 17:29:56 2016
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<html xmlns:wicket="http://wicket.apache.org">
+<wicket:panel>
+ <div class="invitation table">
+ <div>
+ <div class="column label"><label wicket:for="subject"><wicket:message key="215" /></label></div>
+ <div class="column data"><input type="text" wicket:id="subject" class="input"/></div>
+ </div>
+ <wicket:child/>
+ <div>
+ <div class="column label"><label wicket:for="message"><wicket:message key="217" /></label></div>
+ <div class="column data"><textarea wicket:id="message" style="width: 280px; height: 70px;"></textarea></div>
+ </div>
+ <div>
+ <input wicket:id="passwordProtected" type="checkbox"/> <label
+ wicket:for="passwordProtected"><wicket:message key="524" /></label>
+ </div>
+ <div>
+ <div class="column label"><label wicket:for="password"><wicket:message key="525" /></label></div>
+ <div class="column data"><input wicket:id="password" type="password"/></div>
+ </div>
+ <div>
+ <div class="column label"><wicket:message key="526" /></div>
+ <div class="column data">
+ <div wicket:id="valid">
+ <input type="radio" wicket:id="one"/><label wicket:for="one"><wicket:message key="529" /></label>
+ <input type="radio" wicket:id="period"/><label wicket:for="period"><wicket:message key="528" /></label>
+ <input type="radio" wicket:id="endless"/><label wicket:for="endless"><wicket:message key="527" /></label>
+ </div>
+ </div>
+ </div>
+ <div>
+ <div class="column label"><label wicket:for="from"><wicket:message key="530" /></label></div>
+ <div class="column data"><span class="date time picker" wicket:id="from"></span></div>
+ </div>
+ <div>
+ <div class="column label"><label wicket:for="to"><wicket:message key="531" /></label></div>
+ <div class="column data"><span class="date time picker" wicket:id="to"></span></div>
+ </div>
+ <div>
+ <div class="column label"><label wicket:for="timeZoneId"><wicket:message key="1143" /></label></div>
+ <div class="column data"><select wicket:id="timeZoneId"/></div>
+ </div>
+ <div>
+ <div class="column label"><label wicket:for="language"><wicket:message key="59" /></label></div>
+ <div class="column data"><select wicket:id="language"/></div>
+ </div>
+ <div>
+ <input wicket:id="url" type="text" readonly="readonly" style="width: 100%;"/>
+ </div>
+ </div>
+ <span wicket:id="feedback"></span>
+</wicket:panel>
+</html>