Skip to content
Snippets Groups Projects
Commit 1fe3a579 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Continued with the user management

parent 269c07d7
No related branches found
No related tags found
No related merge requests found
Showing
with 87 additions and 42 deletions
...@@ -24,21 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -24,21 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import kieker.webgui.common.IUserManagerFacade; import kieker.webgui.common.IUserManagerFacade;
import kieker.webgui.common.Role; import kieker.webgui.common.Role;
import kieker.webgui.common.User; import kieker.webgui.common.User;
/***************************************************************************
* Copyright 2012 Kieker Project (http://kieker-monitoring.net)
*
* Licensed 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.
***************************************************************************/
/** /**
* @author Nils Christian Ehmke * @author Nils Christian Ehmke
...@@ -65,6 +50,8 @@ public final class CurrentUserManagementBean { ...@@ -65,6 +50,8 @@ public final class CurrentUserManagementBean {
public void addUser(final String username, final String password, final List<Role> roles) { public void addUser(final String username, final String password, final List<Role> roles) {
this.userManagerFacade.addUser(username, password, roles); this.userManagerFacade.addUser(username, password, roles);
// TODO Check that the op was successful before adding the user to our list
this.users.add(new User(username, roles, true));
} }
public void removeUser(final String username) { public void removeUser(final String username) {
......
...@@ -22,10 +22,12 @@ public class User { ...@@ -22,10 +22,12 @@ public class User {
private final String name; private final String name;
private final List<Role> roles; private final List<Role> roles;
private final boolean enabled;
public User(final String name, final List<Role> roles) { public User(final String name, final List<Role> roles, final boolean enabled) {
this.name = name; this.name = name;
this.roles = roles; this.roles = roles;
this.enabled = enabled;
} }
public String getName() { public String getName() {
...@@ -36,4 +38,9 @@ public class User { ...@@ -36,4 +38,9 @@ public class User {
return this.roles; return this.roles;
} }
public boolean isEnabled() {
return enabled;
}
} }
...@@ -103,6 +103,7 @@ public class UserManagerFacadeImpl implements IUserManagerFacade { ...@@ -103,6 +103,7 @@ public class UserManagerFacadeImpl implements IUserManagerFacade {
@Override @Override
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
public List<User> getUsers() { public List<User> getUsers() {
// FIXME Users without roles
final List<User> result = new ArrayList<User>(); final List<User> result = new ArrayList<User>();
ResultSet queryResult = null; ResultSet queryResult = null;
...@@ -110,7 +111,7 @@ public class UserManagerFacadeImpl implements IUserManagerFacade { ...@@ -110,7 +111,7 @@ public class UserManagerFacadeImpl implements IUserManagerFacade {
final Map<String, User> tempMap = new TreeMap<String, User>(); final Map<String, User> tempMap = new TreeMap<String, User>();
final PreparedStatement getQuery = this.connection final PreparedStatement getQuery = this.connection
.prepareStatement("select u.name, ur.role from KIEKERUser u, Userroles ur where u.name=ur.name"); .prepareStatement("select u.name, ur.role, u.enabled from KIEKERUser u, Userroles ur where u.name=ur.name");
// Run through all results // Run through all results
queryResult = getQuery.executeQuery(); queryResult = getQuery.executeQuery();
...@@ -119,6 +120,7 @@ public class UserManagerFacadeImpl implements IUserManagerFacade { ...@@ -119,6 +120,7 @@ public class UserManagerFacadeImpl implements IUserManagerFacade {
final String username = queryResult.getString(1); final String username = queryResult.getString(1);
final int roleID = queryResult.getInt(2); final int roleID = queryResult.getInt(2);
final Role role = Role.fromID(roleID); final Role role = Role.fromID(roleID);
final boolean enabled = queryResult.getBoolean(3);
// If the user doesn't exist in our map yet, add him. // If the user doesn't exist in our map yet, add him.
// In each case we add the role to the user // In each case we add the role to the user
...@@ -127,7 +129,7 @@ public class UserManagerFacadeImpl implements IUserManagerFacade { ...@@ -127,7 +129,7 @@ public class UserManagerFacadeImpl implements IUserManagerFacade {
} else { } else {
final List<Role> roles = new ArrayList<Role>(); final List<Role> roles = new ArrayList<Role>();
roles.add(role); roles.add(role);
tempMap.put(username, new User(username, roles)); tempMap.put(username, new User(username, roles, enabled));
} }
} }
......
#------------------------------------------------------------------------------
#
# Diese Datei beinhaltet sämtliche Nachrichten, Buttonbeschriftungen etc.,
# welche innerhalb der Benutzerverwaltungsseite benutzt werden.
#
#------------------------------------------------------------------------------
newUser = Neuer Benutzer
updateUserList = Benutzerliste Aktualisieren
editUser = Benutzer Bearbeiten
disableUser = Benutzer Deaktivieren
enableUser = Benutzer Aktivieren
deleteUser = Benutzer Löschen
username = Benutzername
userroles = Benutzerrollen
enabled = Aktiviert
\ No newline at end of file
#------------------------------------------------------------------------------
#
# This file contains all messages, button captions etc. which are used within
# the user management page.
#
#------------------------------------------------------------------------------
newUser = New User
updateUserList = Update Userlist
editUser = Edit User
disableUser = Disable User
enableUser = Enable User
deleteUser = Delete User
username = Username
userroles = Userroles
enabled = Enabled
\ No newline at end of file
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<navigation-rule> <navigation-rule>
<navigation-case> <navigation-case>
<from-outcome>userManagement</from-outcome> <from-outcome>userManagement</from-outcome>
<to-view-id>/pages/admin/UserManagement.xhtml</to-view-id> <to-view-id>/pages/admin/UserManagementPage.xhtml</to-view-id>
</navigation-case> </navigation-case>
</navigation-rule> </navigation-rule>
</faces-config> </faces-config>
\ No newline at end of file
...@@ -51,6 +51,6 @@ ...@@ -51,6 +51,6 @@
<url-mapping id="userManagement"> <url-mapping id="userManagement">
<pattern value="/pages/admin/userManagement" /> <pattern value="/pages/admin/userManagement" />
<view-id value="/faces/pages/admin/UserManagement.xhtml" /> <view-id value="/faces/pages/admin/UserManagementPage.xhtml" />
</url-mapping> </url-mapping>
</pretty-config> </pretty-config>
\ No newline at end of file
...@@ -42,6 +42,13 @@ ...@@ -42,6 +42,13 @@
width:32px; width:32px;
} }
.ui-icon-userEnableDisable {
background: url('../img/icons/SnapEnabledSmall.png') no-repeat !important;
height:16px;
width:16px;
}
.ui-icon-snapDisabled { .ui-icon-snapDisabled {
background: url('../img/icons/SnapDisabled.png') no-repeat !important; background: url('../img/icons/SnapDisabled.png') no-repeat !important;
height:32px; height:32px;
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
<hr/> <hr/>
<div style="text-align: right"> <div style="text-align: right">
<p:commandButton value="#{localizedMessages.ok}" action="#{projectsBean.addProject(stringBean.string, currentProjectOverviewBean)}" update=":projectsListForm :messages" oncomplete="newProjectDialog.hide()" /> <p:commandButton value="#{localizedMessages.ok}" action="#{projectsBean.addProject(stringBean.string, currentProjectOverviewBean)}" update=":projectsListForm :messages" oncomplete="newProjectDialog.hide()" />
<p:spacer width="10px" height="10" />
<p:commandButton value="#{localizedMessages.cancel}" onclick="newProjectDialog.hide()" />
</div> </div>
</h:form> </h:form>
</p:dialog> </p:dialog>
...@@ -39,8 +37,6 @@ ...@@ -39,8 +37,6 @@
<hr/> <hr/>
<div style="text-align: right"> <div style="text-align: right">
<p:commandButton value="#{localizedMessages.ok}" action="#{projectsBean.renameProject(currentProjectOverviewBean.projectName, stringBean.string)}" update=":projectsListForm :messages" oncomplete="renameProjectDialog.hide()" /> <p:commandButton value="#{localizedMessages.ok}" action="#{projectsBean.renameProject(currentProjectOverviewBean.projectName, stringBean.string)}" update=":projectsListForm :messages" oncomplete="renameProjectDialog.hide()" />
<p:spacer width="10px" height="10" />
<p:commandButton value="#{localizedMessages.cancel}" onclick="renameProjectDialog.hide()" />
</div> </div>
</h:form> </h:form>
</p:dialog> </p:dialog>
...@@ -55,8 +51,6 @@ ...@@ -55,8 +51,6 @@
<hr/> <hr/>
<div style="text-align: right"> <div style="text-align: right">
<p:commandButton value="#{localizedMessages.ok}" action="#{projectsBean.deleteProject(currentProjectOverviewBean.projectName)}" update=":projectsListForm :messages" oncomplete="deleteProjectDialog.hide()" /> <p:commandButton value="#{localizedMessages.ok}" action="#{projectsBean.deleteProject(currentProjectOverviewBean.projectName)}" update=":projectsListForm :messages" oncomplete="deleteProjectDialog.hide()" />
<p:spacer width="10px" height="10" />
<p:commandButton value="#{localizedMessages.cancel}" onclick="deleteProjectDialog.hide()" />
</div> </div>
</h:form> </h:form>
</p:dialog> </p:dialog>
...@@ -74,8 +68,6 @@ ...@@ -74,8 +68,6 @@
<hr/> <hr/>
<div style="text-align: right"> <div style="text-align: right">
<p:commandButton value="#{localizedMessages.ok}" action="#{projectsBean.copyProject(currentProjectOverviewBean.projectName, stringBean.string, currentProjectOverviewBean)}" update=":projectsListForm :messages" oncomplete="copyProjectDialog.hide()" /> <p:commandButton value="#{localizedMessages.ok}" action="#{projectsBean.copyProject(currentProjectOverviewBean.projectName, stringBean.string, currentProjectOverviewBean)}" update=":projectsListForm :messages" oncomplete="copyProjectDialog.hide()" />
<p:spacer width="10px" height="10" />
<p:commandButton value="#{localizedMessages.cancel}" onclick="copyProjectDialog.hide()" />
</div> </div>
</h:form> </h:form>
</p:dialog> </p:dialog>
......
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
xmlns:p="http://primefaces.org/ui"> xmlns:p="http://primefaces.org/ui">
<p:dialog id="newUserDialog" header="Neuer Benutzer" resizable="false" modal="true" widgetVar="newUserDlg"> <p:dialog id="newUserDialog" header="Neuer Benutzer" resizable="false" modal="true" widgetVar="newUserDlg">
<h:form> <!-- Make sure that closing of the dialog also clears the input field. -->
<p:ajax event="close" update=":newUserDialogForm" />
<h:form id="newUserDialogForm">
<h:panelGrid columnClasses="col1 , col2" columns="2" cellpadding="5"> <h:panelGrid columnClasses="col1 , col2" columns="2" cellpadding="5">
<h:outputText value="Benutzername: " /> <h:outputText value="Benutzername: " />
<p:inputText value="#{newUserBean.username}" style="width: 100%" /> <p:inputText value="#{newUserBean.username}" style="width: 100%" />
...@@ -15,7 +16,7 @@ ...@@ -15,7 +16,7 @@
<h:outputText value="Passwort: " /> <h:outputText value="Passwort: " />
<p:inputText value="#{newUserBean.password}" style="width: 100%" /> <p:inputText value="#{newUserBean.password}" style="width: 100%" />
<h:outputText value="Benutzerrollen: " /> <h:outputText value="Benutzerrollen: " />
<p:selectManyCheckbox value="#{newUserBean.roles}" layout="pageDirection" converter="roleStringConverter"> <p:selectManyCheckbox value="#{newUserBean.roles}" layout="pageDirection" converter="roleStringConverter">
<f:selectItem itemLabel="Benutzer" itemValue="#{ROLE_USER}" /> <f:selectItem itemLabel="Benutzer" itemValue="#{ROLE_USER}" />
...@@ -25,7 +26,7 @@ ...@@ -25,7 +26,7 @@
<hr/> <hr/>
<div style="text-align: right"> <div style="text-align: right">
<p:commandButton value="#{localizedMessages.ok}" action="#{currentUserManagementBean.addUser(newUserBean.username, newUserBean.password, rolesBean.roles)}" oncomplete="newUserDlg.hide()"/> <p:commandButton value="#{localizedMessages.ok}" action="#{currentUserManagementBean.addUser(newUserBean.username, newUserBean.password, newUserBean.roles)}" oncomplete="newUserDlg.hide()" update=":usersListForm"/>
</div> </div>
</h:form> </h:form>
</p:dialog> </p:dialog>
......
...@@ -16,40 +16,51 @@ ...@@ -16,40 +16,51 @@
<ui:param name="showProjectName" value="false"/> <ui:param name="showProjectName" value="false"/>
<ui:define name="bundleIncludes"> <ui:define name="bundleIncludes">
<f:loadBundle var="localizedUserManagementMessages" basename="lang.UserManagementPage"/>
</ui:define> </ui:define>
<ui:define name="cssIncludes"> <ui:define name="cssIncludes">
<link rel="stylesheet" type="text/css" href="/css/UserManagement.css" /> <link rel="stylesheet" type="text/css" href="/css/UserManagement.css" />
</ui:define> </ui:define>
<!-- Those are the menu bar entries left from the help-submenu. --> <!-- Those are the menu bar entries left from the help-submenu. -->
<ui:define name="furtherMenuBarEntries"> <ui:define name="furtherMenuBarEntries">
<p:submenu label="#{localizedMessages.file}"> <p:submenu label="#{localizedMessages.file}">
<p:menuitem styleClass="element-with-whitespace" icon="ui-icon-newProject" value=" Neuer Benutzer" onclick="newUserDlg.show()" ajax="true"/> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-newProject" value=" #{localizedUserManagementMessages.newUser}" onclick="newUserDlg.show()" ajax="true"/>
<p:separator/> <p:separator/>
<p:menuitem styleClass="element-with-whitespace" icon="ui-icon-reload" value=" Benutzerliste Aktualisieren" update=":usersListForm" action="#{currentUserManagementBean.updateList()}" ajax="true"/> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-reload" value=" #{localizedUserManagementMessages.updateUserList}" update=":usersListForm" action="#{currentUserManagementBean.updateList()}" ajax="true"/>
<p:separator/> <p:separator/>
<p:menuitem styleClass="element-with-whitespace" icon="ui-icon-settings" value=" Einstellungen" onclick="settingsDlg.show()" ajax="true"/> <p:menuitem styleClass="element-with-whitespace" icon="ui-icon-settings" value=" #{localizedMessages.settings}" onclick="settingsDlg.show()" ajax="true"/>
</p:submenu> </p:submenu>
</ui:define> </ui:define>
<ui:define name="centerContent"> <ui:define name="centerContent">
<h:form id="usersListForm"> <h:form id="usersListForm">
<p:dataTable value="#{currentUserManagementBean.users}" var="user" emptyMessage="#{localizedMessages.noRecordsFound}" rows="15" paginator="true" paginatorPosition="both" rowsPerPageTemplate="5,10,15,25,50" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"> <p:dataTable value="#{currentUserManagementBean.users}" var="user" emptyMessage="#{localizedMessages.noRecordsFound}" rows="15" paginator="true" paginatorPosition="both" rowsPerPageTemplate="5,10,15,25,50" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
<p:column headerText="Benutzername"> <p:column headerText="#{localizedUserManagementMessages.username}" sortBy="#{user.name}">
#{user.name} <p:commandLink id="dynaButton" value="#{user.name}"/>
<p:menu overlay="true" trigger="dynaButton" my="left top" at="left bottom" style="width:210px">
<p:menuitem icon="ui-icon-edit" styleClass="element-with-whitespace" value=" #{localizedUserManagementMessages.editUser}"/>
<p:menuitem icon="ui-icon-userEnableDisable" styleClass="element-with-whitespace" value=" #{user.enabled ? localizedUserManagementMessages.disableUser : localizedUserManagementMessages.enableUser}"/>
<p:separator/>
<p:menuitem icon="ui-icon-delete" styleClass="element-with-whitespace" value=" #{localizedUserManagementMessages.deleteUser}"/>
</p:menu>
</p:column> </p:column>
<p:column headerText="Benutzerrollen"> <p:column headerText="#{localizedUserManagementMessages.userroles}" sortBy="#{user.roles}">
#{user.roles} #{user.roles}
</p:column> </p:column>
<p:column headerText="#{localizedUserManagementMessages.enabled}" sortBy="#{user.enabled}" style="text-align: center">
#{user.enabled ? localizedMessages.yes : localizedMessages.no}
</p:column>
</p:dataTable> </p:dataTable>
</h:form> </h:form>
</ui:define> </ui:define>
<ui:define name="furtherDialogIncludes"> <ui:define name="furtherDialogIncludes">
<ui:include src="../../dialogs/UserManagementDialogs.xhtml" /> <ui:include src="../../dialogs/UserManagementDialogs.xhtml" />
</ui:define> </ui:define>
</ui:composition> </ui:composition>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment