Skip to content

Commit

Permalink
More reasonable dashboard stats, icon style for archived objects
Browse files Browse the repository at this point in the history
  • Loading branch information
semancik committed Apr 14, 2016
1 parent cc1ca8a commit 5aa0c0d
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 17 deletions.
Expand Up @@ -47,6 +47,7 @@ public class GuiStyleConstants {

public static final String CLASS_ICON_STYLE_NORMAL = "icon-style-normal";
public static final String CLASS_ICON_STYLE_DISABLED = "icon-style-disabled";
public static final String CLASS_ICON_STYLE_ARCHIVED = "icon-style-archived";
public static final String CLASS_ICON_STYLE_PRIVILEGED = "icon-style-privileged";
public static final String CLASS_ICON_STYLE_WARNING = "icon-style-warning";
public static final String CLASS_ICON_STYLE_UP = "icon-style-up";
Expand Down
Expand Up @@ -768,8 +768,12 @@ public static String createServiceIcon(PrismObject<ServiceType> object) {

private static <F extends FocusType> String getIconEnabledDisabled(PrismObject<F> object, String baseIcon) {
ActivationType activation = object.asObjectable().getActivation();
if (activation != null && ActivationStatusType.DISABLED.equals(activation.getEffectiveStatus())) {
return baseIcon + " " + GuiStyleConstants.CLASS_ICON_STYLE_DISABLED;
if (activation != null) {
if (ActivationStatusType.DISABLED.equals(activation.getEffectiveStatus())) {
return baseIcon + " " + GuiStyleConstants.CLASS_ICON_STYLE_DISABLED;
} else if (ActivationStatusType.ARCHIVED.equals(activation.getEffectiveStatus())) {
return baseIcon + " " + GuiStyleConstants.CLASS_ICON_STYLE_ARCHIVED;
}
}

return baseIcon + " " + GuiStyleConstants.CLASS_ICON_STYLE_NORMAL;
Expand Down
Expand Up @@ -233,21 +233,30 @@ private void initInfoBoxes() {

private <F extends FocusType> InfoBoxPanel createFocusInfoBoxPanel(String id, Class<F> type, String bgColor, String icon, String keyPrefix, OperationResult result, Task task) {
InfoBoxType infoBoxType = new InfoBoxType(bgColor, icon, getString(keyPrefix + ".label"));
Integer totalCount;
Integer allCount;
try {
totalCount = getModelService().countObjects(type, null, null, task, result);
if (totalCount == null) {
totalCount = 0;
allCount = getModelService().countObjects(type, null, null, task, result);
if (allCount == null) {
allCount = 0;
}

EqualFilter<ActivationStatusType> filter = EqualFilter.createEqual(SchemaConstants.PATH_ACTIVATION_EFFECTIVE_STATUS,
type, getPrismContext(), ActivationStatusType.ENABLED);
ObjectQuery query = ObjectQuery.createObjectQuery(filter);
Integer activeCount = getModelService().countObjects(type, query, null, task, result);
if (activeCount == null) {
activeCount = 0;
EqualFilter<ActivationStatusType> filterDisabled = EqualFilter.createEqual(SchemaConstants.PATH_ACTIVATION_EFFECTIVE_STATUS,
type, getPrismContext(), ActivationStatusType.DISABLED);
Integer disabledCount = getModelService().countObjects(type, ObjectQuery.createObjectQuery(filterDisabled), null, task, result);
if (disabledCount == null) {
disabledCount = 0;
}

EqualFilter<ActivationStatusType> filterArchived = EqualFilter.createEqual(SchemaConstants.PATH_ACTIVATION_EFFECTIVE_STATUS,
type, getPrismContext(), ActivationStatusType.ARCHIVED);
Integer archivedCount = getModelService().countObjects(type, ObjectQuery.createObjectQuery(filterArchived), null, task, result);
if (archivedCount == null) {
archivedCount = 0;
}

int activeCount = allCount - disabledCount - archivedCount;
int totalCount = allCount - archivedCount;

infoBoxType.setNumber(activeCount + " " + getString(keyPrefix + ".number"));

int progress = 0;
Expand All @@ -256,7 +265,12 @@ private <F extends FocusType> InfoBoxPanel createFocusInfoBoxPanel(String id, Cl
}
infoBoxType.setProgress(progress);

infoBoxType.setDescription(totalCount + " " + getString(keyPrefix + ".total"));
StringBuilder descSb = new StringBuilder();
descSb.append(totalCount).append(" ").append(getString(keyPrefix + ".total"));
if (archivedCount != 0) {
descSb.append(" ( + ").append(archivedCount).append(" ").append(getString(keyPrefix + ".archived")).append(")");
}
infoBoxType.setDescription(descSb.toString());

} catch (Exception e) {
infoBoxType.setNumber("ERROR: "+e.getMessage());
Expand Down
Expand Up @@ -1516,17 +1516,21 @@ PageDashboard.title=Dashboard
PageDashboard.usedRam=Used RAM
PageDashboard.workItems=My work items
PageDashboard.infobox.users.label=Users
PageDashboard.infobox.users.number=active
PageDashboard.infobox.users.number=enabled
PageDashboard.infobox.users.total=total
PageDashboard.infobox.users.archived=archived
PageDashboard.infobox.orgs.label=Organizational units
PageDashboard.infobox.orgs.number=active
PageDashboard.infobox.orgs.number=enabled
PageDashboard.infobox.orgs.total=total
PageDashboard.infobox.orgs.archived=archived
PageDashboard.infobox.roles.label=Roles
PageDashboard.infobox.roles.number=active
PageDashboard.infobox.roles.number=enabled
PageDashboard.infobox.roles.total=total
PageDashboard.infobox.roles.archived=archived
PageDashboard.infobox.services.label=Services
PageDashboard.infobox.services.number=active
PageDashboard.infobox.services.number=enabled
PageDashboard.infobox.services.total=total
PageDashboard.infobox.services.archived=archived
PageDashboard.infobox.resources.label=Resources
PageDashboard.infobox.resources.number=up
PageDashboard.infobox.resources.total=total
Expand Down
4 changes: 4 additions & 0 deletions gui/admin-gui/src/main/webapp/less/midpoint-theme.less
Expand Up @@ -149,6 +149,10 @@ th.cog, td.cog {
color: #909090;
}

.icon-style-archived {
color: #c0c0c0;
}

.icon-style-privileged {
color: #a94442;
}
Expand Down

0 comments on commit 5aa0c0d

Please sign in to comment.