Author: solomax Date: Thu Apr 25 03:09:13 2013 New Revision: 1471821 URL: http://svn.apache.org/r1471821 Log: [OPENMEETINGS-615] Dashboard tab of User Profile is implemented
Added: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/ProfilePanel.html openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/ProfilePanel.java openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/WidgetsPanel.html openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/WidgetsPanel.java Modified: openmeetings/trunk/singlewebapp/WebContent/openmeetings/css/theme.css openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/app/WebSession.java openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/dashboard/WelcomeWidgetView.java openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/rooms/RoomsTabbedPanel.java openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/MainPage.html openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/MainPage.java Modified: openmeetings/trunk/singlewebapp/WebContent/openmeetings/css/theme.css URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/WebContent/openmeetings/css/theme.css?rev=1471821&r1=1471820&r2=1471821&view=diff ============================================================================== --- openmeetings/trunk/singlewebapp/WebContent/openmeetings/css/theme.css (original) +++ openmeetings/trunk/singlewebapp/WebContent/openmeetings/css/theme.css Thu Apr 25 03:09:13 2013 @@ -582,3 +582,9 @@ div.tableWrapper { width: 100%; cursor: pointer; } +.widget { + width: 100%; +} +.widget td { + min-width: 150px; +} Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/app/WebSession.java URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/app/WebSession.java?rev=1471821&r1=1471820&r2=1471821&view=diff ============================================================================== --- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/app/WebSession.java (original) +++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/app/WebSession.java Thu Apr 25 03:09:13 2013 @@ -19,6 +19,8 @@ package org.apache.openmeetings.web.app; import static org.apache.openmeetings.persistence.beans.basic.Configuration.DEFAUT_LANG_KEY; +import static org.apache.openmeetings.web.app.Application.getBean; +import static org.apache.openmeetings.web.app.Application.getDashboardContext; import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -73,8 +75,8 @@ public class WebSession extends Abstract public Roles getRoles() { Roles r = null; if (isSignedIn()) { - userLevel = Application.getBean(UserManager.class).getUserLevelByID(userId); - AuthLevelUtil authLevel = Application.getBean(AuthLevelUtil.class); + userLevel = getBean(UserManager.class).getUserLevelByID(userId); + AuthLevelUtil authLevel = getBean(AuthLevelUtil.class); r = new Roles(Roles.USER); if (authLevel.checkUserLevel(userLevel)) { r.add(Roles.USER); @@ -92,9 +94,9 @@ public class WebSession extends Abstract } public boolean signIn(String login, String password) { - Sessiondata sessData = Application.getBean(SessiondataDao.class).startsession(); + Sessiondata sessData = getBean(SessiondataDao.class).startsession(); SID = sessData.getSession_id(); - Object u = Application.getBean(UserManager.class).loginUser(SID, login, password, + Object u = getBean(UserManager.class).loginUser(SID, login, password, null, null, false); if (u instanceof User) { @@ -115,7 +117,7 @@ public class WebSession extends Abstract } public static String getString(long id) { - FieldManager fieldManager = Application.getBean(FieldManager.class); + FieldManager fieldManager = getBean(FieldManager.class); String s = fieldManager.getString(id, getLanguage()); return s == null ? "[Missing]" : s; } @@ -123,14 +125,14 @@ public class WebSession extends Abstract public static long getLanguage() { WebSession session = get(); if (session.isSignedIn()) { - return Application.getBean(UsersDao.class).get(session.userId).getLanguage_id(); + return getBean(UsersDao.class).get(session.userId).getLanguage_id(); } else { - return Application.getBean(ConfigurationDao.class).getConfValue(DEFAUT_LANG_KEY, Long.class, "1"); + return getBean(ConfigurationDao.class).getConfValue(DEFAUT_LANG_KEY, Long.class, "1"); } } public static FieldLanguage getLanguageObj() { - return Application.getBean(FieldLanguageDao.class).getFieldLanguageById(getLanguage()); + return getBean(FieldLanguageDao.class).getFieldLanguageById(getLanguage()); } public static String getSid() { @@ -172,7 +174,7 @@ public class WebSession extends Abstract } private void initDashboard() { - DashboardContext dashboardContext = Application.getDashboardContext(); + DashboardContext dashboardContext = getDashboardContext(); //FIXME check title etc. dashboard = dashboardContext.getDashboardPersiter().load(); if (dashboard == null) { Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/dashboard/WelcomeWidgetView.java URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/dashboard/WelcomeWidgetView.java?rev=1471821&r1=1471820&r2=1471821&view=diff ============================================================================== --- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/dashboard/WelcomeWidgetView.java (original) +++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/dashboard/WelcomeWidgetView.java Thu Apr 25 03:09:13 2013 @@ -25,6 +25,8 @@ import org.apache.openmeetings.data.user import org.apache.openmeetings.persistence.beans.user.User; import org.apache.openmeetings.web.app.Application; import org.apache.openmeetings.web.components.UploadableProfileImagePanel; +import org.apache.openmeetings.web.components.user.profile.ProfilePanel; +import org.apache.openmeetings.web.pages.MainPage; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; import org.apache.wicket.markup.html.basic.Label; @@ -50,7 +52,8 @@ public class WelcomeWidgetView extends W @Override public void onClick(AjaxRequestTarget target) { - //FIXME should have action + //FIXME active id !!!!! + target.add(((MainPage)getPage()).getContents().replace(new ProfilePanel("child"))); } }.add(new Label("unread", Model.of("" + Application.getBean(PrivateMessagesDao.class) .getNumberMessages(getUserId(), 0L, false))))); @@ -59,7 +62,8 @@ public class WelcomeWidgetView extends W @Override public void onClick(AjaxRequestTarget target) { - //FIXME should have action + //FIXME active id !!!!! + target.add(((MainPage)getPage()).getContents().replace(new ProfilePanel("child"))); } }); } Added: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/ProfilePanel.html URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/ProfilePanel.html?rev=1471821&view=auto ============================================================================== --- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/ProfilePanel.html (added) +++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/ProfilePanel.html Thu Apr 25 03:09:13 2013 @@ -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:panel> + <div id="tabs"> + <ul> + <li wicket:id="tabs"><a wicket:id="link"><wicket:container wicket:id="name"></wicket:container></a></li> + </ul> + <wicket:container wicket:id="panels"><div wicket:id="tab"></div></wicket:container> + </div> + </wicket:panel> +</html> Added: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/ProfilePanel.java URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/ProfilePanel.java?rev=1471821&view=auto ============================================================================== --- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/ProfilePanel.java (added) +++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/ProfilePanel.java Thu Apr 25 03:09:13 2013 @@ -0,0 +1,60 @@ +/* + * 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.components.user.profile; + +import org.apache.openmeetings.web.components.UserPanel; +import org.apache.wicket.AttributeModifier; +import org.apache.wicket.markup.html.WebMarkupContainer; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.panel.Panel; +import org.apache.wicket.markup.repeater.RepeatingView; +import org.apache.wicket.model.Model; + +import com.googlecode.wicket.jquery.core.JQueryBehavior; + +public class ProfilePanel extends UserPanel { + private static final long serialVersionUID = -830146821166434373L; + + + private void addTab(RepeatingView tabs, String name, String id) { + WebMarkupContainer tab = new WebMarkupContainer(tabs.newChildId()); + tab.add(new WebMarkupContainer("link") + .add(new Label("name", Model.of(name))) + .add(new AttributeModifier("href", "#" + id))); + tabs.add(tab); + } + + private void addPanel(RepeatingView panels, String id, Panel p) { + WebMarkupContainer tab = new WebMarkupContainer(panels.newChildId()); + tab.add(p.setMarkupId(id)).setRenderBodyOnly(true); + panels.add(tab); + } + + public ProfilePanel(String id) { + super(id); + RepeatingView tabs = new RepeatingView("tabs"); + addTab(tabs, "Widgets", "tab1"); //FIXME localize, inteligentId + + RepeatingView panels = new RepeatingView("panels"); + addPanel(panels, "tab1", new WidgetsPanel("tab")); + + add(new JQueryBehavior("#tabs", "tabs")); + add(tabs, panels); + } +} Added: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/WidgetsPanel.html URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/WidgetsPanel.html?rev=1471821&view=auto ============================================================================== --- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/WidgetsPanel.html (added) +++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/WidgetsPanel.html Thu Apr 25 03:09:13 2013 @@ -0,0 +1,31 @@ +<?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> + <table class="widget"> + <tr wicket:id="widgets"> + <td wicket:id="name"></td> + <td wicket:id="description"></td> + <td><label wicket:for="display">[Display]</label><input type="checkbox" wicket:id="display"/></td> + </tr> + </table> + </wicket:panel> +</html> \ No newline at end of file Added: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/WidgetsPanel.java URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/WidgetsPanel.java?rev=1471821&view=auto ============================================================================== --- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/WidgetsPanel.java (added) +++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/profile/WidgetsPanel.java Thu Apr 25 03:09:13 2013 @@ -0,0 +1,82 @@ +/* + * 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.components.user.profile; + +import static org.apache.openmeetings.web.app.Application.getDashboardContext; +import static org.apache.openmeetings.web.app.WebSession.getDashboard; + +import org.apache.wicket.ajax.AjaxRequestTarget; +import org.apache.wicket.ajax.markup.html.form.AjaxCheckBox; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.list.ListItem; +import org.apache.wicket.markup.html.list.ListView; +import org.apache.wicket.markup.html.panel.Panel; +import org.apache.wicket.model.Model; + +import ro.fortsoft.wicket.dashboard.Dashboard; +import ro.fortsoft.wicket.dashboard.Widget; +import ro.fortsoft.wicket.dashboard.WidgetDescriptor; +import ro.fortsoft.wicket.dashboard.web.DashboardContext; + +public class WidgetsPanel extends Panel { + private static final long serialVersionUID = -3959536582694664524L; + + private Widget isDisplayed(WidgetDescriptor wd) { + //FIXME the only way to compare is By TITLE + for (Widget w : getDashboard().getWidgets()) { + if (w.getTitle().equals(wd.getName())) { + return w; + } + } + return null; + } + public WidgetsPanel(String id) { + super(id); + + add(new ListView<WidgetDescriptor>("widgets" + , getDashboardContext().getWidgetRegistry().getWidgetDescriptors()) { + private static final long serialVersionUID = 1L; + + @Override + protected void populateItem(ListItem<WidgetDescriptor> item) { + final WidgetDescriptor wd = item.getModelObject(); + item.add(new Label("name", wd.getName())); + item.add(new Label("description", wd.getDescription())); + item.add(new AjaxCheckBox("display", Model.of(isDisplayed(wd) != null)) { + private static final long serialVersionUID = -7079665921153653164L; + + @Override + protected void onUpdate(AjaxRequestTarget target) { + Widget w = isDisplayed(wd); + boolean b = getModelObject(); + DashboardContext dashboardContext = getDashboardContext(); + Dashboard d = getDashboard(); + if (w != null && !b) { + d.deleteWidget(w.getId()); + } + if (w == null && b) { + d.addWidget(dashboardContext.getWidgetFactory().createWidget(wd)); + } + dashboardContext.getDashboardPersiter().save(d); + } + }); + } + }); + } +} Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/rooms/RoomsTabbedPanel.java URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/rooms/RoomsTabbedPanel.java?rev=1471821&r1=1471820&r2=1471821&view=diff ============================================================================== --- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/rooms/RoomsTabbedPanel.java (original) +++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/components/user/rooms/RoomsTabbedPanel.java Thu Apr 25 03:09:13 2013 @@ -18,13 +18,14 @@ */ package org.apache.openmeetings.web.components.user.rooms; +import static org.apache.openmeetings.web.app.Application.getBean; +import static org.apache.openmeetings.web.app.WebSession.getUserId; + import org.apache.openmeetings.data.conference.dao.RoomDao; import org.apache.openmeetings.data.user.dao.UsersDao; import org.apache.openmeetings.persistence.beans.domain.Organisation; import org.apache.openmeetings.persistence.beans.domain.Organisation_Users; import org.apache.openmeetings.persistence.beans.user.User; -import org.apache.openmeetings.web.app.Application; -import org.apache.openmeetings.web.app.WebSession; import org.apache.openmeetings.web.components.UserPanel; import org.apache.wicket.AttributeModifier; import org.apache.wicket.markup.html.WebMarkupContainer; @@ -41,7 +42,7 @@ public class RoomsTabbedPanel extends Us public RoomsTabbedPanel(String id) { super(id); - User u = Application.getBean(UsersDao.class).get(WebSession.getUserId()); + User u = getBean(UsersDao.class).get(getUserId()); add(new ListView<Organisation_Users>("orgTabs", u.getOrganisation_users()) { private static final long serialVersionUID = -145637079945252731L; @@ -60,7 +61,7 @@ public class RoomsTabbedPanel extends Us protected void populateItem(ListItem<Organisation_Users> item) { Organisation org = item.getModelObject().getOrganisation(); item.add(new RoomsPanel("rooms" - , Application.getBean(RoomDao.class).getOrganisationRooms(org.getOrganisation_id())) + , getBean(RoomDao.class).getOrganisationRooms(org.getOrganisation_id())) .setMarkupId("org" + org.getOrganisation_id())).setRenderBodyOnly(true); } }); Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/MainPage.html URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/MainPage.html?rev=1471821&r1=1471820&r2=1471821&view=diff ============================================================================== --- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/MainPage.html (original) +++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/MainPage.html Thu Apr 25 03:09:13 2013 @@ -43,7 +43,7 @@ </script> <div id="topLinks"><span id="contactsAndMessages"><wicket:ommessage key="1188"/></span><span - id="profile"><wicket:ommessage key="5"/></span><span + id="profile"><a wicket:id="profile"><wicket:ommessage key="5"/></a></span><span id="logout"><a wicket:id="logout"><wicket:ommessage key="310"/></a></span><span id="reportBug"><wicket:ommessage key="284"/></span><span><a wicket:id="about">About</a></span></div> Modified: openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/MainPage.java URL: http://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/MainPage.java?rev=1471821&r1=1471820&r2=1471821&view=diff ============================================================================== --- openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/MainPage.java (original) +++ openmeetings/trunk/singlewebapp/src/org/apache/openmeetings/web/pages/MainPage.java Thu Apr 25 03:09:13 2013 @@ -25,6 +25,7 @@ import org.apache.openmeetings.web.compo import org.apache.openmeetings.web.components.user.AboutDialog; import org.apache.openmeetings.web.components.user.ChatPanel; import org.apache.openmeetings.web.components.user.dashboard.OmDashboardPanel; +import org.apache.openmeetings.web.components.user.profile.ProfilePanel; import org.apache.wicket.MarkupContainer; import org.apache.wicket.ajax.AjaxRequestTarget; import org.apache.wicket.ajax.markup.html.AjaxLink; @@ -41,9 +42,10 @@ public class MainPage extends BasePage { private static final long serialVersionUID = 6421960759218157999L; private static final Logger log = Red5LoggerFactory.getLogger(MainPage.class, OpenmeetingsVariables.webAppRootKey); private final MenuPanel menu; + private final MarkupContainer contents; public MainPage() { - MarkupContainer contents = new WebMarkupContainer("contents"); + contents = new WebMarkupContainer("contents"); //FIXME need to be generalized with MenuPanel contents.add(new OmDashboardPanel("child")).setOutputMarkupId(true).setMarkupId("contents"); add(contents); @@ -58,6 +60,14 @@ public class MainPage extends BasePage { setResponsePage(Application.get().getSignInPageClass()); } }); + add(new AjaxLink<Void>("profile") { + private static final long serialVersionUID = 4065339709905366840L; + + @Override + public void onClick(AjaxRequestTarget target) { + target.add(contents.replace(new ProfilePanel("child"))); + } + }); final AboutDialog about = new AboutDialog("aboutDialog"); add(new AjaxLink<Void>("about") { private static final long serialVersionUID = 4065339709905366840L; @@ -85,4 +95,8 @@ public class MainPage extends BasePage { } }); } + + public MarkupContainer getContents() { + return contents; + } }