Skip to content

Commit

Permalink
Fixes #8359: Redesigning the main menu
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelGauthier committed Jul 4, 2016
1 parent b8c3aa4 commit 40d7251
Show file tree
Hide file tree
Showing 25 changed files with 1,581 additions and 253 deletions.
12 changes: 6 additions & 6 deletions rudder-web/src/main/scala/bootstrap/liftweb/Boot.scala
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class Boot extends Loggable {

// All the following is related to the sitemap
val nodeManagerMenu =
Menu("NodeManagerHome", <span>Node Management</span>) /
Menu("NodeManagerHome", <i class="fa fa-sitemap"></i> ++ <span>Node Management</span>) /
"secure" / "nodeManager" / "index" >> TestAccess( ()
=> userIsAllowed("/secure/index",Read("node")) ) submenus (

Expand All @@ -189,7 +189,7 @@ class Boot extends Loggable {
)

def buildManagerMenu(name:String) =
Menu(name+"ManagerHome", <span>{name.capitalize} Policy</span>) /
Menu(name+"ManagerHome", <i class="fa fa-gears"></i> ++ <span>{name.capitalize} Policy</span>) /
"secure" / (name+"Manager") / "index" >> TestAccess ( ()
=> userIsAllowed("/secure/index",Read("configuration")) ) submenus (

Expand All @@ -210,11 +210,11 @@ class Boot extends Loggable {
)

def administrationMenu =
Menu("AdministrationHome", <span>Administration</span>) /
Menu("AdministrationHome", <i class="fa fa-gear"></i> ++ <span>Settings</span>) /
"secure" / "administration" / "index" >> TestAccess ( ()
=> userIsAllowed("/secure/index",Read("administration"), Read("technique")) ) submenus (

Menu("policyServerManagement", <span>Settings</span>) /
Menu("policyServerManagement", <span>General</span>) /
"secure" / "administration" / "policyServerManagement"
>> LocGroup("administrationGroup")
>> TestAccess ( () => userIsAllowed("/secure/index",Read("administration")) )
Expand Down Expand Up @@ -244,7 +244,7 @@ class Boot extends Loggable {
// (don't give rights if you don't know)
def workflowEnabled = RudderConfig.configService.rudder_workflow_enabled.getOrElse(false)

Menu("UtilitiesHome", <span>Utilities</span>) /
Menu("UtilitiesHome", <i class="fa fa-wrench"></i> ++ <span>Utilities</span>) /
"secure" / "utilities" / "index" >>
TestAccess ( () =>
if (workflowEnabled || CurrentUser.checkRights(Read("administration")))
Expand Down Expand Up @@ -291,7 +291,7 @@ class Boot extends Loggable {
}

val rootMenu = List(
Menu("Home", <span>Home</span>) / "secure" / "index" >> Hidden
Menu("Dashboard", <i class="fa fa-dashboard"></i> ++ <span>Dashboard</span>) / "secure" / "index"
, Menu("Login") / "index" >> Hidden
, nodeManagerMenu
, buildManagerMenu("configuration")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,29 +108,33 @@ class AsyncDeployment extends CometActor with CometListener with Loggable {
case IdleDeployer =>
deploymentStatus.current match {
case NoStatus =>
<span class="glyphicon glyphicon-question-sign"></span>
<span id="generation-status" class="label label-neutral"><span class="glyphicon glyphicon-question-sign"></span></span>
case _:SuccessStatus =>
<span class="glyphicon glyphicon-ok"></span>
<span id="generation-status" class="label label-success"><span class="fa fa-check"></span></span>
case _:ErrorStatus =>
<span class="glyphicon glyphicon-remove"></span>
<span id="generation-status" class="label label-danger"><span class="fa fa-times"></span></span>
}
case _ =>
<img src="/images/ajax-loader-small.gif" />
<span id="generation-status" class="label label-neutral"><i class="fa fa-refresh fa-spin"></i></span>
}

}

private[this] def lastStatus = {
def commonStatement(start : DateTime, end : DateTime, durationText : String, headText : String) = {
<li class="dropdown-header">{headText}</li>
<li class="dropdown-header">Started at {DateFormaterService.getFormatedDate(start)}</li>
<li class="dropdown-header" >Finished <span id="deployment-end">{DateFormaterService.getFormatedPeriod(end, DateTime.now)}</span> ago</li>
<li class="dropdown-header">{durationText} {DateFormaterService.getFormatedPeriod(start,end)}</li>
def commonStatement(start : DateTime, end : DateTime, durationText : String, headText : String, iconClass: String, statusClass : String) = {
<li>
<ul class="menu">
<li><a href="#" class={statusClass + " no-click"}><span class={iconClass}></span> {headText}</a></li>
<li><a href="#" class="no-click"><span class={statusClass +" fa fa-hourglass-start"}></span>Started at {DateFormaterService.getFormatedDate(start)}</a></li>
<li><a href="#" class="no-click"><span class={statusClass +" fa fa-hourglass-end"}></span>Finished <span id="deployment-end">{DateFormaterService.getFormatedPeriod(end, DateTime.now)}</span> ago</a></li>
<li><a href="#" class="no-click"><span class={statusClass +" fa fa-clock-o"}></span>{durationText} {DateFormaterService.getFormatedPeriod(start,end)}</a></li>
</ul>
</li>
}
deploymentStatus.current match {
case NoStatus => <li class="dropdown-header">Policy update status unavailable</li>
case SuccessStatus(id,start,end,configurationNodes) =>
commonStatement(start, end, "Update took", "Policies updated")
commonStatement(start, end, "Update took", "Policies updated","text-success fa fa-check","text-success")
case ErrorStatus(id,start,end,failure) =>
val popupContent =
failure.messageChain match {
Expand Down Expand Up @@ -163,8 +167,8 @@ class AsyncDeployment extends CometActor with CometListener with Loggable {

val callback = JsRaw("$('#errorDetailsDialog').bsModal('show');") & SetHtml("errorDetailsMessage" , popupContent)

commonStatement(start, end, "Error occured in", "Error during policy update") ++
<li>{ SHtml.a(Text("Details"), callback, ("href","#"))}</li>
commonStatement(start, end, "Error occured in", "Error during policy update","text-danger fa fa-times","text-danger") ++
<li class="footer">{ SHtml.a(Text("Details"), callback, ("href","#") , ("style","color:#a94442 !important;"))}</li>
}
}

Expand All @@ -184,22 +188,27 @@ class AsyncDeployment extends CometActor with CometListener with Loggable {
}

private[this] def layout = {

<lift:authz role="deployment_read">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span>Status</span> <span class="badge" id="generation-status"> {statusIcon}</span><span class="caret" style="margin-left:5px"></span></a>
<ul class="dropdown-menu" role="menu">
{lastStatus}
<li>{currentStatus}</li>
</ul>
</li>
{errorPopup}
<li class="dropdown notifications-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Status
<i class="fa fa-heartbeat"></i>
{statusIcon}
<i class="fa fa-angle-down" style="margin-left:15px;"></i>
</a>
<ul class="dropdown-menu" role="menu">
{lastStatus}
<li class="footer">
{currentStatus}
</li>
</ul>
</li>
{errorPopup}
</lift:authz>
}

private[this] def errorPopup = {
<div class="modal fade" id="errorDetailsDialog">
<div class="modal fade" id="errorDetailsDialog">
<div class="modal-backdrop fade in" style="height: 100%;"></div>
<div class="modal-dialog">
<div class="modal-content">
Expand Down Expand Up @@ -231,3 +240,4 @@ class AsyncDeployment extends CometActor with CometListener with Loggable {
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,18 @@ class WorkflowInformation extends CometActor with CometListener with Loggable {


val layout =

<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span>CR</span>
<span class="badge" id="number">42</span>
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
</ul>
</li>

<li class="dropdown notifications-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<span>CR</span>
<span id="number" class="badge rudder-badge"></span>
<i class="fa fa-angle-down" style="margin-left:15px;"></i>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<ul class="menu"></ul>
</li>
</ul>
</li>

def render = {
val xml = RudderConfig.configService.rudder_workflow_enabled match {
Expand All @@ -98,10 +99,10 @@ class WorkflowInformation extends CometActor with CometListener with Loggable {
if(workflowEnabled && (isValidator || isDeployer )) {
{
if (isValidator) pendingModifications
else ".dropdown-menu *+" #> NodeSeq.Empty
else ".menu *+" #> NodeSeq.Empty
} & {
if (isDeployer) pendingDeployment
else ".dropdown-menu *+" #> NodeSeq.Empty
else ".menu *+" #> NodeSeq.Empty
} &
"#number *" #> requestCount(workflowService)
} else {
Expand Down Expand Up @@ -129,53 +130,54 @@ class WorkflowInformation extends CometActor with CometListener with Loggable {
def pendingModifications = {
val xml = pendingModificationRec(workflowService)

".dropdown-menu *+" #> xml
".menu *+" #> xml
}

private[this] def pendingModificationRec(workflowService: WorkflowService): NodeSeq = {
workflowService match {
case ws:TwoValidationStepsWorkflowServiceImpl =>
ws.getItemsInStep(ws.Validation.id) match {
case Full(seq) =>
<li >
<a href="/secure/utilities/changeRequests/Pending_validation">
Pending review:
<span class="badge">{seq.size}</span>
</a>
</li>
<li>
<a href="/secure/utilities/changeRequests/Pending_validation">
<i class="fa fa fa-flag-o"></i>
Pending review
<span class="label pull-right">{seq.size}</span>
</a>
</li>
case e:EmptyBox =>
<p class="error">Error when trying to fetch pending change requests.</p>
<li><p class="error">Error when trying to fetch pending change requests.</p></li>
}
case either: EitherWorkflowService => pendingModificationRec(either.current)
case _ => //For other kind of workflows, this has no meaning
<p class="error">Error, the configured workflow does not have that step.</p>
<li><p class="error">Error, the configured workflow does not have that step.</p></li>
}
}

def pendingDeployment = {
val xml = pendingDeploymentRec(workflowService)

".dropdown-menu *+" #> xml
".menu *+" #> xml
}

private[this] def pendingDeploymentRec(workflowService: WorkflowService): NodeSeq = {
workflowService match {
case ws:TwoValidationStepsWorkflowServiceImpl =>
ws.getItemsInStep(ws.Deployment.id) match {
case Full(seq) =>
<li>
<a href="/secure/utilities/changeRequests/Pending_deployment">
Pending deployment:
<span class="badge">{seq.size}</span>
</a>
</li>

<li>
<a href="/secure/utilities/changeRequests/Pending_deployment">
<i class="fa fa fa-flag-checkered"></i>
Pending deployment
<span class="label pull-right">{seq.size}</span>
</a>
</li>
case e:EmptyBox =>
<p class="error">Error when trying to fetch pending change requests.</p>
<li><p class="error">Error when trying to fetch pending change requests.</p></li>
}
case either: EitherWorkflowService => pendingDeploymentRec(either.current)
case _ => //For other kind of workflows, this has no meaning
<p class="error">Error, the configured workflow does not have that step.</p>
<li><p class="error">Error, the configured workflow does not have that step.</p></li>
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class CreateCloneDirectivePopup(
override def validations = Nil
}

private[this] val formTracker = new FormTracker(directiveName :: directiveShortDescription :: reason.toList)
private[this] val formTracker = new FormTracker(directiveName :: directiveShortDescription :: reasons.toList)

private[this] var notifications = List.empty[NodeSeq]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class BootstrapMenu {
} yield {
sm.buildMenu(req.location).lines
} ).getOrElse(Nil)

}

val menu = {
Expand All @@ -63,12 +62,16 @@ class BootstrapMenu {

item.kids match {
case Nil =>
<li class={style}><a href={item.uri}>{item.text}</a></li>

<li class={style + " treeview"}>
<a href={item.uri}>{item.text}</a>
</li>
case kids =>
<li class={style + " dropdown"}>
<a href={item.uri} class="dropdown-toggle" data-toggle="dropdown">{item.text} <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu"> {
<li class={style + " treeview"}>
<a href="#">
{item.text}
<i class="fa fa-angle-left pull-right"></i>
</a>
<ul class="treeview-menu"> {
for (kid <- kids) yield {
<li><a href={kid.uri}>{kid.text}</a></li>
}
Expand All @@ -77,11 +80,6 @@ class BootstrapMenu {
}
}
}

<ul class="nav navbar-nav">
{menu}
</ul>

{menu}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ class QuickSearchNode extends DispatchSnippet with Loggable {
)


<lift:form class="navbar-form navbar-left">
<div class="form-group">
<lift:form class="sidebar-form">
<div class="input-group col-xs-12">
{searchInput}
</div>
</lift:form>

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ class Groups extends StatefulSnippet with SpringExtendableSnippet[Groups] with L
private[this] def showGroupSection(workflowEnabled: Boolean)(g: NodeGroup, parentCategoryId: NodeGroupCategoryId) = {
refreshRightPanel(GroupForm(g, parentCategoryId), workflowEnabled)&
JsRaw(s"""
jQuery('#groupDetails').show();
var groupId = JSON.stringify({'groupId':'${g.id.value}'});
window.location.hash = "#"+groupId""")
}
Expand Down
Loading

0 comments on commit 40d7251

Please sign in to comment.