Search in sources :

Example 1 with JQueryBehavior

use of com.googlecode.wicket.jquery.core.JQueryBehavior in project openmeetings by apache.

the class HashPage method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    StringValue secure = p.get(HASH);
    StringValue invitation = p.get(INVITATION_HASH);
    WebSession ws = WebSession.get();
    ws.checkHashes(secure, invitation);
    String errorMsg = getString("invalid.hash");
    recContainer.setVisible(false);
    add(new EmptyPanel(PANEL_MAIN).setVisible(false));
    if (!invitation.isEmpty()) {
        Invitation i = ws.getInvitation();
        if (i == null) {
            errorMsg = getString("error.hash.invalid");
        } else if (!i.isAllowEntry()) {
            FastDateFormat sdf = FormatHelper.getDateTimeFormat(i.getInvitee());
            errorMsg = Valid.OneTime == i.getValid() ? getString("error.hash.used") : String.format("%s %s - %s, %s", getString("error.hash.period"), sdf.format(i.getValidFrom()), sdf.format(i.getValidTo()), i.getInvitee().getTimeZoneId());
        } else {
            Recording rec = i.getRecording();
            if (rec != null) {
                vi.setVisible(!i.isPasswordProtected());
                vp.setVisible(!i.isPasswordProtected());
                if (!i.isPasswordProtected()) {
                    vi.update(null, rec);
                    vp.update(null, rec);
                }
                recContainer.setVisible(true);
                error = false;
            }
            Room r = i.getRoom();
            if (r != null && !r.isDeleted()) {
                createRoom(r.getId());
                if (i.isPasswordProtected() && rp != null) {
                    mp.getChat().setVisible(false);
                    rp.setOutputMarkupPlaceholderTag(true).setVisible(false);
                }
            }
        }
    } else if (!secure.isEmpty()) {
        Long recId = getRecordingId(), roomId = ws.getRoomId();
        if (recId == null && roomId == null) {
            errorMsg = getString("1599");
        } else if (recId != null) {
            recContainer.setVisible(true);
            Recording rec = recDao.get(recId);
            vi.update(null, rec);
            vp.update(null, rec);
            error = false;
        } else {
            createRoom(roomId);
        }
    }
    StringValue swf = p.get(SWF);
    StringValue app = swf.isEmpty() ? p.get(APP) : swf;
    if (!app.isEmpty()) {
        if (APP_TYPE_NETWORK.equals(app.toString())) {
            replace(new NetTestPanel(PANEL_MAIN).add(AttributeModifier.append("class", "app")));
            error = false;
        }
        if (APP_TYPE_SETTINGS.equals(app.toString())) {
            replace(new VideoSettings(PANEL_MAIN).replace(new OmWebSocketPanel("ws-panel") {

                private static final long serialVersionUID = 1L;

                private WsClient c = null;

                @Override
                protected void onConnect(ConnectedMessage message) {
                    c = new WsClient(message.getSessionId(), message.getKey().hashCode());
                }

                @Override
                protected IWsClient getWsClient() {
                    return c;
                }
            }).add(new OmAjaxClientInfoBehavior() {

                private static final long serialVersionUID = 1L;

                @Override
                protected void onClientInfo(AjaxRequestTarget target, WebClientInfo info) {
                    super.onClientInfo(target, info);
                    target.appendJavaScript(String.format("VideoSettings.init(%s);VideoSettings.open();", VideoSettings.getInitJson("noclient")));
                }
            }));
            error = false;
        }
    }
    add(recContainer.add(vi.setShowShare(false).setOutputMarkupPlaceholderTag(true), vp.setOutputMarkupPlaceholderTag(true)), new InvitationPasswordDialog("i-pass", this));
    remove(urlParametersReceivingBehavior);
    add(new MessageDialog("access-denied", getString("invalid.hash"), errorMsg, DialogButtons.OK, DialogIcon.ERROR) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onConfigure(JQueryBehavior behavior) {
            super.onConfigure(behavior);
            behavior.setOption("autoOpen", error);
            behavior.setOption("resizable", false);
        }

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
        // no-op
        }
    });
}
Also used : WebClientInfo(org.apache.wicket.protocol.http.request.WebClientInfo) DialogButton(com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton) EmptyPanel(org.apache.wicket.markup.html.panel.EmptyPanel) OmWebSocketPanel(org.apache.openmeetings.web.common.OmWebSocketPanel) WsClient(org.apache.openmeetings.db.entity.basic.WsClient) IWsClient(org.apache.openmeetings.db.entity.basic.IWsClient) ConnectedMessage(org.apache.wicket.protocol.ws.api.message.ConnectedMessage) MessageDialog(com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog) StringValue(org.apache.wicket.util.string.StringValue) Room(org.apache.openmeetings.db.entity.room.Room) IWsClient(org.apache.openmeetings.db.entity.basic.IWsClient) JQueryBehavior(com.googlecode.wicket.jquery.core.JQueryBehavior) VideoSettings(org.apache.openmeetings.web.room.VideoSettings) Invitation(org.apache.openmeetings.db.entity.room.Invitation) OmAjaxClientInfoBehavior(org.apache.openmeetings.web.common.OmAjaxClientInfoBehavior) IPartialPageRequestHandler(org.apache.wicket.core.request.handler.IPartialPageRequestHandler) FastDateFormat(org.apache.commons.lang3.time.FastDateFormat) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) WebSession(org.apache.openmeetings.web.app.WebSession) NetTestPanel(org.apache.openmeetings.web.room.NetTestPanel) Recording(org.apache.openmeetings.db.entity.record.Recording)

Example 2 with JQueryBehavior

use of com.googlecode.wicket.jquery.core.JQueryBehavior in project openmeetings by apache.

the class RoomPanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    // let's refresh user in client
    cm.update(getClient().updateUser(userDao));
    Component accessDenied = new WebMarkupContainer(ACCESS_DENIED_ID).setVisible(false);
    room.add(AttributeModifier.append(ATTR_CLASS, r.getType().name()));
    room.add(menu = new RoomMenuPanel("menu", this));
    room.add(AttributeModifier.append("data-room-id", r.getId()));
    if (interview) {
        room.add(new WebMarkupContainer("wb-area").add(wb));
    } else {
        Droppable<BaseFileItem> wbArea = new Droppable<BaseFileItem>("wb-area") {

            private static final long serialVersionUID = 1L;

            @Override
            public void onConfigure(JQueryBehavior behavior) {
                super.onConfigure(behavior);
                behavior.setOption("hoverClass", Options.asString("ui-state-hover"));
                behavior.setOption("accept", Options.asString(".recorditem, .fileitem, .readonlyitem"));
            }

            @Override
            public void onDrop(AjaxRequestTarget target, Component component) {
                Object o = component.getDefaultModelObject();
                if (wb.isVisible() && o instanceof BaseFileItem) {
                    BaseFileItem f = (BaseFileItem) o;
                    if (sidebar.getFilesPanel().isSelected(f)) {
                        for (Entry<String, BaseFileItem> e : sidebar.getFilesPanel().getSelected().entrySet()) {
                            wb.sendFileToWb(e.getValue(), false);
                        }
                    } else {
                        wb.sendFileToWb(f, false);
                    }
                }
            }
        };
        room.add(wbArea.add(wb));
    }
    room.add(roomEnter);
    room.add(sidebar = new RoomSidebar("sidebar", this));
    add(roomClosed = new RedirectMessageDialog("room-closed", "1098", r.isClosed(), r.getRedirectURL()));
    if (r.isClosed()) {
        room.setVisible(false);
    } else if (cm.listByRoom(r.getId()).size() >= r.getCapacity()) {
        accessDenied = new ExpiredMessageDialog(ACCESS_DENIED_ID, getString("99"), menu);
        room.setVisible(false);
    } else if (r.getId().equals(WebSession.get().getRoomId())) {
    // secureHash/invitationHash, already checked
    } else {
        boolean allowed = false;
        String deniedMessage = null;
        if (r.isAppointment()) {
            Appointment a = apptDao.getByRoom(r.getId());
            if (a != null && !a.isDeleted()) {
                boolean isOwner = a.getOwner().getId().equals(getUserId());
                allowed = isOwner;
                log.debug("appointed room, isOwner ? {}", isOwner);
                if (!allowed) {
                    for (MeetingMember mm : a.getMeetingMembers()) {
                        if (getUserId().equals(mm.getUser().getId())) {
                            allowed = true;
                            break;
                        }
                    }
                }
                if (allowed) {
                    Calendar c = WebSession.getCalendar();
                    if (isOwner || c.getTime().after(a.getStart()) && c.getTime().before(a.getEnd())) {
                        eventDetail = new EventDetailDialog(EVENT_DETAILS_ID, a);
                    } else {
                        allowed = false;
                        deniedMessage = String.format("%s %s - %s", getString("error.hash.period"), getDateFormat().format(a.getStart()), getDateFormat().format(a.getEnd()));
                    }
                }
            }
        } else {
            allowed = r.getIspublic() || (r.getOwnerId() != null && r.getOwnerId().equals(getUserId()));
            log.debug("public ? " + r.getIspublic() + ", ownedId ? " + r.getOwnerId() + " " + allowed);
            if (!allowed) {
                User u = getClient().getUser();
                for (RoomGroup ro : r.getGroups()) {
                    for (GroupUser ou : u.getGroupUsers()) {
                        if (ro.getGroup().getId().equals(ou.getGroup().getId())) {
                            allowed = true;
                            break;
                        }
                    }
                    if (allowed) {
                        break;
                    }
                }
            }
        }
        if (!allowed) {
            if (deniedMessage == null) {
                deniedMessage = getString("1599");
            }
            accessDenied = new ExpiredMessageDialog(ACCESS_DENIED_ID, deniedMessage, menu);
            room.setVisible(false);
        }
    }
    waitForModerator = new MessageDialog("wait-for-moderator", getString("204"), getString("696"), DialogButtons.OK, DialogIcon.LIGHT) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
        // no-op
        }
    };
    waitApplyModeration = new MessageDialog("wait-apply-moderation", getString("204"), getString(r.isModerated() ? "641" : "498"), DialogButtons.OK, DialogIcon.LIGHT) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
        // no-op
        }
    };
    add(room, accessDenied, eventDetail, waitForModerator, waitApplyModeration);
    if (r.isWaitForRecording()) {
        add(new MessageDialog("wait-for-recording", getString("1316"), getString("1315"), DialogButtons.OK, DialogIcon.LIGHT) {

            private static final long serialVersionUID = 1L;

            @Override
            public void onConfigure(JQueryBehavior behavior) {
                super.onConfigure(behavior);
                behavior.setOption("autoOpen", true);
                behavior.setOption("resizable", false);
            }

            @Override
            public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
            // no-op
            }
        });
    } else {
        add(new WebMarkupContainer("wait-for-recording").setVisible(false));
    }
    if (room.isVisible()) {
        add(new NicknameDialog("nickname", this));
        add(download);
        add(new BaseWebSocketBehavior("media"));
    } else {
        add(new WebMarkupContainer("nickname").setVisible(false));
    }
    add(clientKicked = new MessageDialog("client-kicked", getString("797"), getString("606"), DialogButtons.OK, DialogIcon.ERROR) {

        private static final long serialVersionUID = 1L;

        @Override
        public void onClose(IPartialPageRequestHandler handler, DialogButton button) {
            menu.exit(handler);
        }
    });
}
Also used : Appointment(org.apache.openmeetings.db.entity.calendar.Appointment) DialogButton(com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton) User(org.apache.openmeetings.db.entity.user.User) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) GroupUser(org.apache.openmeetings.db.entity.user.GroupUser) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) RoomSidebar(org.apache.openmeetings.web.room.sidebar.RoomSidebar) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) MessageDialog(com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog) Component(org.apache.wicket.Component) JQueryBehavior(com.googlecode.wicket.jquery.core.JQueryBehavior) Droppable(com.googlecode.wicket.jquery.ui.interaction.droppable.Droppable) Calendar(java.util.Calendar) RoomMenuPanel(org.apache.openmeetings.web.room.menu.RoomMenuPanel) IPartialPageRequestHandler(org.apache.wicket.core.request.handler.IPartialPageRequestHandler) BaseWebSocketBehavior(org.apache.wicket.protocol.ws.api.BaseWebSocketBehavior) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) JSONObject(com.github.openjson.JSONObject) RoomGroup(org.apache.openmeetings.db.entity.room.RoomGroup)

Example 3 with JQueryBehavior

use of com.googlecode.wicket.jquery.core.JQueryBehavior in project openmeetings by apache.

the class FileTreePanel method onInitialize.

@Override
protected void onInitialize() {
    super.onInitialize();
    download.setDefaultModelObject(newDownloadMenuList());
    Droppable<BaseFileItem> trashToolbar = new Droppable<BaseFileItem>("trash-toolbar") {

        private static final long serialVersionUID = 1L;

        @Override
        public void onConfigure(JQueryBehavior behavior) {
            super.onConfigure(behavior);
            behavior.setOption("hoverClass", Options.asString("ui-state-hover trash-toolbar-hover"));
            behavior.setOption("accept", Options.asString(".recorditem, .fileitem"));
        }

        @Override
        public JQueryBehavior newWidgetBehavior(String selector) {
            return new DroppableBehavior(selector, this) {

                private static final long serialVersionUID = 1L;

                @Override
                protected JQueryAjaxBehavior newOnDropAjaxBehavior(IJQueryAjaxAware source) {
                    return new OnDropAjaxBehavior(source) {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public CharSequence getCallbackFunctionBody(CallbackParameter... parameters) {
                            String dialogId = UUID.randomUUID().toString();
                            String statement = "var $drop = $(this);";
                            statement += "$('body').append('<div id=" + dialogId + ">" + getString("713") + "</div>');";
                            statement += "$( '#" + dialogId + "' ).dialog({ title: '" + escapeEcmaScript(getString("80")) + "', classes: {'ui-dialog-titlebar': 'ui-corner-all no-close'}, buttons: [";
                            statement += "	{ text: '" + escapeEcmaScript(getString("54")) + "', click: function() { $drop.append(ui.draggable); $(this).dialog('close'); " + super.getCallbackFunctionBody(parameters) + " } },";
                            statement += "	{ text: '" + escapeEcmaScript(getString("lbl.cancel")) + "', click: function() { $(this).dialog('close'); } } ";
                            statement += "],";
                            statement += "close: function(event, ui) { $(this).dialog('destroy').remove(); }";
                            statement += "});";
                            return statement;
                        }
                    };
                }
            };
        }

        @Override
        public void onDrop(AjaxRequestTarget target, Component component) {
            Object o = component.getDefaultModelObject();
            if (o instanceof BaseFileItem) {
                BaseFileItem f = (BaseFileItem) o;
                if (isSelected(f)) {
                    deleteAll(target);
                } else {
                    delete(f, target);
                }
            }
        }
    };
    form.add(trashToolbar);
    trashToolbar.add(getUpload());
    trashToolbar.add(createDir);
    trashToolbar.add(new WebMarkupContainer("refresh").add(new AjaxEventBehavior(EVT_CLICK) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onEvent(AjaxRequestTarget target) {
            update(target);
        }
    }));
    trashToolbar.add(trashBorder = new ConfirmableAjaxBorder("trash", getString("80"), getString("713"), trashConfirm) {

        private static final long serialVersionUID = 1L;

        @Override
        protected boolean isClickable() {
            return !readOnly && !selected.isEmpty();
        }

        @Override
        protected void onSubmit(AjaxRequestTarget target) {
            deleteAll(target);
        }
    });
    form.add(trees.add(tree).setOutputMarkupId(true));
    updateSizes();
    form.add(sizes.add(new Label("homeSize", homeSize), new Label("publicSize", publicSize)).setOutputMarkupId(true));
    form.add(errorsDialog);
    setReadOnly(false, null);
}
Also used : JQueryBehavior(com.googlecode.wicket.jquery.core.JQueryBehavior) AjaxEventBehavior(org.apache.wicket.ajax.AjaxEventBehavior) Droppable(com.googlecode.wicket.jquery.ui.interaction.droppable.Droppable) ConfirmableAjaxBorder(org.apache.openmeetings.web.common.ConfirmableAjaxBorder) Label(org.apache.wicket.markup.html.basic.Label) CallbackParameter(org.apache.wicket.ajax.attributes.CallbackParameter) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) BaseFileItem(org.apache.openmeetings.db.entity.file.BaseFileItem) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) IJQueryAjaxAware(com.googlecode.wicket.jquery.core.ajax.IJQueryAjaxAware) Component(org.apache.wicket.Component) DroppableBehavior(com.googlecode.wicket.jquery.ui.interaction.droppable.DroppableBehavior)

Aggregations

JQueryBehavior (com.googlecode.wicket.jquery.core.JQueryBehavior)3 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)3 Droppable (com.googlecode.wicket.jquery.ui.interaction.droppable.Droppable)2 DialogButton (com.googlecode.wicket.jquery.ui.widget.dialog.DialogButton)2 MessageDialog (com.googlecode.wicket.jquery.ui.widget.dialog.MessageDialog)2 BaseFileItem (org.apache.openmeetings.db.entity.file.BaseFileItem)2 Component (org.apache.wicket.Component)2 IPartialPageRequestHandler (org.apache.wicket.core.request.handler.IPartialPageRequestHandler)2 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)2 JSONObject (com.github.openjson.JSONObject)1 IJQueryAjaxAware (com.googlecode.wicket.jquery.core.ajax.IJQueryAjaxAware)1 DroppableBehavior (com.googlecode.wicket.jquery.ui.interaction.droppable.DroppableBehavior)1 Calendar (java.util.Calendar)1 FastDateFormat (org.apache.commons.lang3.time.FastDateFormat)1 IWsClient (org.apache.openmeetings.db.entity.basic.IWsClient)1 WsClient (org.apache.openmeetings.db.entity.basic.WsClient)1 Appointment (org.apache.openmeetings.db.entity.calendar.Appointment)1 MeetingMember (org.apache.openmeetings.db.entity.calendar.MeetingMember)1 Recording (org.apache.openmeetings.db.entity.record.Recording)1 Invitation (org.apache.openmeetings.db.entity.room.Invitation)1