Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinDevecka committed May 30, 2014
2 parents 38604be + b58fdf7 commit 42e052e
Show file tree
Hide file tree
Showing 9 changed files with 108 additions and 17 deletions.
Expand Up @@ -20,9 +20,10 @@
<div class="col-xs-10">
<input type="checkbox" wicket:id="check"/>

<i class="silk-user" wicket:id="icon"></i>
<i wicket:id="icon"/>
<span wicket:id="status"/>
<i class="fa fa-clock-o text-warning" wicket:id="trigger"/>
<i class="fa fa-clock-o text-success" wicket:id="trigger"/>
<i class="fa fa-shield text-warning" wicket:id="protected" wicket:message="title:CheckTableHeader.protected"/>

<a wicket:id="link"><span class="name" wicket:id="name"/></a>
<span class="description" wicket:id="description"/>
Expand Down
Expand Up @@ -19,6 +19,8 @@
import com.evolveum.midpoint.prism.PrismContainer;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.PrismProperty;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.result.OperationResult;
import com.evolveum.midpoint.web.component.BootstrapLabel;
import com.evolveum.midpoint.web.component.menu.cog.InlineMenu;
Expand All @@ -28,8 +30,7 @@
import com.evolveum.midpoint.web.page.PageBase;
import com.evolveum.midpoint.web.util.TooltipBehavior;
import com.evolveum.midpoint.web.util.WebMiscUtil;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
Expand Down Expand Up @@ -57,6 +58,7 @@ public class CheckTableHeader extends SimplePanel<ObjectWrapper> {
private static final String ID_STATUS = "status";
private static final String ID_SHOW_MORE = "showMore";
private static final String ID_TRIGGER = "trigger";
private static final String ID_PROTECTED = "protected";

public CheckTableHeader(String id, IModel<ObjectWrapper> model) {
super(id, model);
Expand All @@ -76,6 +78,13 @@ protected void onUpdate(AjaxRequestTarget target) {
add(check);

Label icon = new Label(ID_ICON);
icon.add(AttributeModifier.replace("class", new AbstractReadOnlyModel<String>() {

@Override
public String getObject() {
return createAccountIcon();
}
}));
add(icon);

Label trigger = new Label(ID_TRIGGER);
Expand All @@ -96,6 +105,17 @@ public boolean isVisible() {
});
add(trigger);

Label protectedIcon = new Label(ID_PROTECTED);
protectedIcon.add(new VisibleEnableBehaviour() {

@Override
public boolean isVisible() {
ObjectWrapper wrapper = getModelObject();
return wrapper.isProtectedAccount();
}
});
add(protectedIcon);

BootstrapLabel status = new BootstrapLabel(ID_STATUS, createStringResource("CheckTableHeader.label.error"),
new Model(BootstrapLabel.State.DANGER));
status.add(createFetchErrorVisibleBehaviour());
Expand Down Expand Up @@ -150,6 +170,20 @@ public boolean isVisible() {
add(menu);
}

private String createAccountIcon() {
ObjectWrapper wrapper = getModelObject();
PrismObject object = wrapper.getObject();
PrismProperty status = object.findProperty(new ItemPath(ShadowType.F_ACTIVATION, ActivationType.F_ADMINISTRATIVE_STATUS));
if (status != null && status.getRealValue() != null) {
ActivationStatusType value = (ActivationStatusType) status.getRealValue();
if (ActivationStatusType.DISABLED.equals(value)) {
return "fa fa-male text-muted";
}
}

return "fa fa-male";
}

private String createTriggerTooltip() {
ObjectWrapper wrapper = getModelObject();
PrismObject obj = wrapper.getObject();
Expand Down
Expand Up @@ -17,4 +17,5 @@
CheckTableHeader.label.error=Error
CheckTableHeader.showMore=Show more
CheckTableHeader.triggerPlanned=Trigger planned on {0}.
CheckTableHeader.triggerUnknownTime=Trigger without time planned.
CheckTableHeader.triggerUnknownTime=Trigger without time planned.
CheckTableHeader.protected=Protected
Expand Up @@ -66,10 +66,10 @@ LoggingConfigPanel.profiling.entryExit=Profiling entry/exit
StandardLoggerType.MAPPING=Mapping (c.e.m.common.mapping.Mapping)
StandardLoggerType.EXPRESSION=Expression (c.e.m.common.expression.Expression)
StandardLoggerType.SCRIPT_EXPRESSION=Script expression (c.e.m.common.expression.script.ScriptExpression)
StandardLoggerType.PROJECTOR=Projector (c.e.m.model.lens.projector.Projector)
StandardLoggerType.PROJECTOR_DETAIL=Projector detailed (c.e.m.model.lens.projector)
StandardLoggerType.CLOCKWORK=Clockwork (c.e.m.model.lens.Clockwork)
StandardLoggerType.CHANGE_EXECUTOR=Change executor (c.e.m.model.lens.ChangeExecutor)
StandardLoggerType.PROJECTOR=Projector (c.e.m.model.impl.lens.projector.Projector)
StandardLoggerType.PROJECTOR_DETAIL=Projector detailed (c.e.m.model.impl.lens.projector)
StandardLoggerType.CLOCKWORK=Clockwork (c.e.m.model.impl.lens.Clockwork)
StandardLoggerType.CHANGE_EXECUTOR=Change executor (c.e.m.model.impl.lens.ChangeExecutor)

logger.emptyLogger=Logger must not be empty
logger.duplicate=Logger with name '{0}' is already defined
Expand Down
Expand Up @@ -23,10 +23,10 @@ public enum StandardLoggerType {
MAPPING("com.evolveum.midpoint.model.common.mapping.Mapping"),
EXPRESSION("com.evolveum.midpoint.model.common.expression.Expression"),
SCRIPT_EXPRESSION("com.evolveum.midpoint.model.common.expression.script.ScriptExpression"),
PROJECTOR("com.evolveum.midpoint.model.lens.projector.Projector"),
PROJECTOR_DETAIL("com.evolveum.midpoint.model.lens.projector"),
CLOCKWORK("com.evolveum.midpoint.model.lens.Clockwork"),
CHANGE_EXECUTOR("com.evolveum.midpoint.model.lens.ChangeExecutor");
PROJECTOR("com.evolveum.midpoint.model.impl.lens.projector.Projector"),
PROJECTOR_DETAIL("com.evolveum.midpoint.model.impl.lens.projector"),
CLOCKWORK("com.evolveum.midpoint.model.impl.lens.Clockwork"),
CHANGE_EXECUTOR("com.evolveum.midpoint.model.impl.lens.ChangeExecutor");

private final String value;

Expand Down
Expand Up @@ -186,6 +186,21 @@ public String getObject() {
}
};
}

@Override
protected IModel<String> createTitleModel(final IModel<UserListItemDto> rowModel) {
return new AbstractReadOnlyModel<String>() {

@Override
public String getObject() {
String key = rowModel.getObject().getIconTitle();
if (key == null) {
return null;
}
return createStringResource(key).getString();
}
};
}
});

IColumn column = new LinkColumn<UserListItemDto>(createStringResource("ObjectType.name"),
Expand Down Expand Up @@ -291,7 +306,7 @@ public UserListItemDto createDataObjectWrapper(PrismObject<UserType> obj) {
GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)));
provider.setOptions(options);

TablePanel table = new TablePanel<UserListItemDto>(ID_TABLE, provider, columns);
TablePanel table = new TablePanel(ID_TABLE, provider, columns);
table.setOutputMarkupId(true);

UsersStorage storage = getSessionStorage().getUsers();
Expand All @@ -313,6 +328,7 @@ private UserListItemDto createRowDto(PrismObject<UserType> obj) {
dto.setAccountCount(createAccountCount(obj));
dto.setCredentials(obj.findContainer(UserType.F_CREDENTIALS));
dto.setIcon(WebMiscUtil.createUserIcon(obj));
dto.setIconTitle(WebMiscUtil.createUserIconTitle(obj));

dto.getMenuItems().add(new InlineMenuItem(createStringResource("pageUsers.menu.enable"),
new ColumnMenuAction<UserListItemDto>() {
Expand Down
Expand Up @@ -45,6 +45,7 @@ public class UserListItemDto extends Selectable implements InlineMenuable {
private String email;
private int accountCount;
private String icon;
private String iconTitle;
private PrismContainer credentials;
private List<InlineMenuItem> menuItems;

Expand Down Expand Up @@ -78,6 +79,14 @@ public void setIcon(String icon) {
this.icon = icon;
}

public String getIconTitle() {
return iconTitle;
}

public void setIconTitle(String iconTitle) {
this.iconTitle = iconTitle;
}

public String getName() {
return name;
}
Expand Down
Expand Up @@ -56,6 +56,9 @@ Boolean.NULL=Undefined
Boolean.TRUE=True
Boolean.FALSE=False

User.superuser=Superuser
User.disabled=Disabled

OriginType.SYNC_ACTION=Sync action
OriginType.RECONCILIATION=Reconciliation
OriginType.INBOUND=Inbound
Expand Down
Expand Up @@ -429,7 +429,6 @@ public static boolean isSuccessOrHandledError(OperationResult result) {

public static String createUserIcon(PrismObject<UserType> object) {
UserType user = object.asObjectable();
CredentialsType credentials = user.getCredentials();

//if user has superuser role assigned, it's superuser
for (AssignmentType assignment : user.getAssignment()) {
Expand All @@ -438,13 +437,41 @@ public static String createUserIcon(PrismObject<UserType> object) {
continue;
}
if (StringUtils.equals(targetRef.getOid(), SystemObjectsType.ROLE_SUPERUSER.value())) {
return "silk-user_red";
return "fa fa-male text-danger";
}
}

return "silk-user";
ActivationType activation = user.getActivation();
if (activation != null && ActivationStatusType.DISABLED.equals(activation.getEffectiveStatus())){
return "fa fa-male text-muted";
}

return "fa fa-male";
}

public static String createUserIconTitle(PrismObject<UserType> object) {
UserType user = object.asObjectable();

//if user has superuser role assigned, it's superuser
for (AssignmentType assignment : user.getAssignment()) {
ObjectReferenceType targetRef = assignment.getTargetRef();
if (targetRef == null) {
continue;
}
if (StringUtils.equals(targetRef.getOid(), SystemObjectsType.ROLE_SUPERUSER.value())) {
return "User.superuser";
}
}

ActivationType activation = user.getActivation();
if (activation != null && ActivationStatusType.DISABLED.equals(activation.getEffectiveStatus())){
return "User.disabled";
}

return null;
}


public static double getSystemLoad() {
com.sun.management.OperatingSystemMXBean operatingSystemMXBean = (com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean();
RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
Expand Down

0 comments on commit 42e052e

Please sign in to comment.