Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Jan 30, 2017
2 parents 5e74101 + e7661b5 commit 0f92643
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 19 deletions.
Expand Up @@ -58,13 +58,17 @@
<body class="hold-transition skin-blue-light">
<div wicket:id="mainPopup"/>
<div class="wrapper">
<header class="main-header">
<header wicket:id="mainHeader" class="main-header">
<!-- Logo -->
<a class="custom-logo" wicket:id="customLogo">
<i wicket:id="customLogoImgCss"/>
<img wicket:id="customLogoImgSrc"/>
</a>
<a class="logo" wicket:id="logo">
<span>&nbsp;</span>
<span>&nbsp;</span>>
</a>
<!-- Header Navbar: style can be found in header.less -->
<nav role="navigation" class="navbar navbar-static-top">
<nav wicket:id="navigation" role="navigation" class="navbar navbar-static-top">
<!-- Sidebar toggle button-->
<a wicket:id="menuToggle" role="button" data-toggle="offcanvas" class="sidebar-toggle" href="#">
<span class="sr-only"><wicket:message key="PageTemplate.toggleNavigation"/></span>
Expand Down
Expand Up @@ -38,6 +38,7 @@
import org.apache.wicket.ajax.AjaxNewWindowNotifyingBehavior;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.devutils.debugbar.DebugBar;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.feedback.FeedbackMessage;
Expand Down Expand Up @@ -161,6 +162,7 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {
private static final String OPERATION_LOAD_WORK_ITEM_COUNT = DOT_CLASS + "loadWorkItemCount";

private static final String ID_TITLE = "title";
private static final String ID_MAIN_HEADER = "mainHeader";
private static final String ID_PAGE_TITLE_CONTAINER = "pageTitleContainer";
private static final String ID_PAGE_TITLE_REAL = "pageTitleReal";
private static final String ID_PAGE_TITLE = "pageTitle";
Expand All @@ -183,6 +185,10 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {
private static final String ID_MAIN_POPUP_BODY = "popupBody";
private static final String ID_SUBSCRIPTION_MESSAGE = "subscriptionMessage";
private static final String ID_LOGO = "logo";
private static final String ID_CUSTOM_LOGO = "customLogo";
private static final String ID_CUSTOM_LOGO_IMG_SRC = "customLogoImgSrc";
private static final String ID_CUSTOM_LOGO_IMG_CSS = "customLogoImgCss";
private static final String ID_NAVIGATION = "navigation";

private static final String OPERATION_GET_SYSTEM_CONFIG = DOT_CLASS + "getSystemConfiguration";
private static final String OPERATION_GET_DEPLOYMENT_INFORMATION = DOT_CLASS + "getDeploymentInformation";
Expand Down Expand Up @@ -251,7 +257,8 @@ public abstract class PageBase extends WebPage implements ModelServiceLocator {
private boolean initialized = false;

private LoadableModel<Integer> workItemCountModel;

private LoadableModel<DeploymentInformationType> deploymentInfoModel;

public PageBase(PageParameters parameters) {
super(parameters);

Expand Down Expand Up @@ -307,7 +314,15 @@ protected Integer load() {
return null;
}
}
};
};
deploymentInfoModel = new LoadableModel<DeploymentInformationType>() {
private static final long serialVersionUID = 1L;

@Override
protected DeploymentInformationType load() {
return loadDeploymentInformationType();
}
};
}

public void resetWorkItemCountModel() {
Expand Down Expand Up @@ -494,28 +509,39 @@ protected void onBeforeRender() {
getSession().getFeedbackMessages().clear();
}

private void initHeaderLayout() {
private void initHeaderLayout(WebMarkupContainer container) {
WebMarkupContainer menuToggle = new WebMarkupContainer(ID_MENU_TOGGLE);
menuToggle.add(createUserStatusBehaviour(true));
add(menuToggle);
container.add(menuToggle);

UserMenuPanel rightMenu = new UserMenuPanel(ID_RIGHT_MENU);
rightMenu.add(createUserStatusBehaviour(true));
add(rightMenu);
container.add(rightMenu);

LocalePanel locale = new LocalePanel(ID_LOCALE);
locale.add(createUserStatusBehaviour(false));
add(locale);
container.add(locale);
}

private void initTitleLayout() {
private void initTitleLayout(WebMarkupContainer mainHeader) {
WebMarkupContainer pageTitleContainer = new WebMarkupContainer(ID_PAGE_TITLE_CONTAINER);
pageTitleContainer.add(createUserStatusBehaviour(true));
add(pageTitleContainer);
mainHeader.add(pageTitleContainer);

WebMarkupContainer pageTitle = new WebMarkupContainer(ID_PAGE_TITLE);
pageTitleContainer.add(pageTitle);
Label pageTitleReal = new Label(ID_PAGE_TITLE_REAL, createPageTitleModel());

String environmentName = "";
IModel<String> titleModel = createPageTitleModel();
IModel<String> fullTitleModel = null;
if (deploymentInfoModel != null && deploymentInfoModel.getObject() != null &&
StringUtils.isNotEmpty(deploymentInfoModel.getObject().getName())) {
environmentName = deploymentInfoModel.getObject().getName();
}
if (StringUtils.isNotEmpty(environmentName)){
fullTitleModel = new Model<String>(environmentName + ": " + titleModel.getObject());
}
Label pageTitleReal = new Label(ID_PAGE_TITLE_REAL, fullTitleModel != null ? fullTitleModel : titleModel);
pageTitleReal.setRenderBodyOnly(true);
pageTitle.add(pageTitleReal);

Expand Down Expand Up @@ -576,10 +602,14 @@ public boolean isVisible() {
});
}
};
add(breadcrumbs);
mainHeader.add(breadcrumbs);
}

private void initLayout() {
WebMarkupContainer mainHeader = new WebMarkupContainer(ID_MAIN_HEADER);
mainHeader.setOutputMarkupId(true);
add(mainHeader);

AjaxLink logo = new AjaxLink(ID_LOGO) {
private static final long serialVersionUID = 1L;

Expand All @@ -589,14 +619,65 @@ public void onClick(AjaxRequestTarget target) {
setResponsePage(page);
}
};
add(logo);
logo.add(new VisibleEnableBehaviour(){
@Override
public boolean isVisible(){
return !isCustomLogoVisible();
}
});
mainHeader.add(logo);

AjaxLink customLogo = new AjaxLink(ID_CUSTOM_LOGO) {
private static final long serialVersionUID = 1L;

@Override
public void onClick(AjaxRequestTarget target) {
//TODO may be this should lead to customerUrl ?
Class<? extends Page> page = MidPointApplication.get().getHomePage();
setResponsePage(page);
}
};
customLogo.add(new VisibleEnableBehaviour(){
@Override
public boolean isVisible(){
return isCustomLogoVisible();
}
});
mainHeader.add(customLogo);

WebMarkupContainer customLogoImgSrc = new WebMarkupContainer(ID_CUSTOM_LOGO_IMG_SRC);
WebMarkupContainer customLogoImgCss = new WebMarkupContainer(ID_CUSTOM_LOGO_IMG_CSS);
if (deploymentInfoModel != null && deploymentInfoModel.getObject() != null &&
deploymentInfoModel.getObject().getLogo() != null){
if (StringUtils.isNotEmpty(deploymentInfoModel.getObject().getLogo().getCssClass())) {
customLogoImgCss.add(new AttributeAppender("class", deploymentInfoModel.getObject().getLogo().getCssClass()));
customLogoImgSrc.setVisible(false);
} else {
customLogoImgSrc.add(new AttributeAppender("src",
deploymentInfoModel.getObject().getLogo().getImageUrl()));
customLogoImgCss.setVisible(false);
}
}
customLogo.add(customLogoImgSrc);
customLogo.add(customLogoImgCss);

Label title = new Label(ID_TITLE, createPageTitleModel());
title.setRenderBodyOnly(true);
add(title);

initHeaderLayout();
initTitleLayout();
WebMarkupContainer navigation = new WebMarkupContainer(ID_NAVIGATION);
mainHeader.add(navigation);

initHeaderLayout(navigation);
initTitleLayout(navigation);

if (deploymentInfoModel != null && deploymentInfoModel.getObject() != null &&
StringUtils.isNotEmpty(deploymentInfoModel.getObject().getHeaderColor())){
mainHeader.add(new AttributeAppender("style",
"background-color: " + deploymentInfoModel.getObject().getHeaderColor() + "; !important;"));
navigation.add(new AttributeAppender("style",
"background-color: " + deploymentInfoModel.getObject().getHeaderColor() + "; !important;"));
}
initDebugBarLayout();

List<SideBarMenuItem> menuItems = createMenuItems();
Expand Down Expand Up @@ -1701,11 +1782,20 @@ public void clearBreadcrumbs() {
getBreadcrumbs().clear();
}

private boolean isCustomLogoVisible(){
if (deploymentInfoModel != null && deploymentInfoModel.getObject() != null
&& deploymentInfoModel.getObject().getLogo() != null
&& (StringUtils.isNotEmpty(deploymentInfoModel.getObject().getLogo().getImageUrl())
|| StringUtils.isNotEmpty(deploymentInfoModel.getObject().getLogo().getCssClass()))) {
return true;
}
return false;
}

private String getSubscriptionId(){
DeploymentInformationType deploymentInformationType = loadDeploymentInformationType();
if (deploymentInformationType == null){
if (deploymentInfoModel == null || deploymentInfoModel.getObject() == null){
return null;
}
return deploymentInformationType.getSubscriptionIdentifier();
return deploymentInfoModel.getObject().getSubscriptionIdentifier();
}
}
9 changes: 9 additions & 0 deletions gui/admin-gui/src/main/webapp/less/midpoint-theme.less
Expand Up @@ -31,6 +31,15 @@
background: url("../img/midpoint_logo_white_180.png") no-repeat 10px 3px;
}
}
& .custom-logo {

& > img {
display:block;
float:left;
padding-left: 10px;
vertical-align: middle;
}
}

& nav.navbar.navbar-static-top {
//background-color: red;
Expand Down

0 comments on commit 0f92643

Please sign in to comment.