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 [3/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/...

Added: openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.java?rev=1756948&view=auto
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/common/InvitationForm.java (added)
+++ openmeetings/application/trunk/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/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.html
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.html?rev=1756948&view=auto
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.html (added)
+++ openmeetings/application/trunk/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/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.java?rev=1756948&view=auto
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomInvitationForm.java (added)
+++ openmeetings/application/trunk/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/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomMenuPanel.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomMenuPanel.java?rev=1756948&r1=1756947&r2=1756948&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/room/menu/RoomMenuPanel.java (original)
+++ openmeetings/application/trunk/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/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.html
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.html?rev=1756948&view=auto
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.html (added)
+++ openmeetings/application/trunk/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/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.java?rev=1756948&view=auto
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/RecordingInvitationForm.java (added)
+++ openmeetings/application/trunk/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/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.html
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.html?rev=1756948&r1=1756947&r2=1756948&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.html (original)
+++ openmeetings/application/trunk/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/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.java
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.java?rev=1756948&r1=1756947&r2=1756948&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/java/org/apache/openmeetings/web/user/record/VideoInfo.java (original)
+++ openmeetings/application/trunk/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/trunk/openmeetings-web/src/main/webapp/css/menu.css
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/menu.css?rev=1756948&r1=1756947&r2=1756948&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/menu.css (original)
+++ openmeetings/application/trunk/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/trunk/openmeetings-web/src/main/webapp/css/theme.css
URL: http://svn.apache.org/viewvc/openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/theme.css?rev=1756948&r1=1756947&r2=1756948&view=diff
==============================================================================
--- openmeetings/application/trunk/openmeetings-web/src/main/webapp/css/theme.css (original)
+++ openmeetings/application/trunk/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;
+}