Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelGauthier committed Dec 28, 2016
1 parent 3b84a19 commit 1fe681a
Show file tree
Hide file tree
Showing 17 changed files with 1,146 additions and 112 deletions.
Expand Up @@ -276,6 +276,7 @@ class DirectiveEditForm(
</a> &
"#techniqueDescription *" #> technique.description &
"#nameField" #> {piName.toForm_!} &
"#tagField *" #> tagsEditForm.cfTagsDirectiveConfiguration &
"#rudderID *" #> {directive.id.value} &
"#shortDescriptionField" #> piShortDescription.toForm_! &
"#longDescriptionField" #> piLongDescription.toForm_! &
Expand Down Expand Up @@ -423,6 +424,8 @@ class DirectiveEditForm(
override def subContainerClassName = "col-xs-12"
}

def tagsEditForm = new TagsEditForm()

def showDeprecatedVersion (version : TechniqueVersion) = {
val deprecationInfo = fullActiveTechnique.techniques(version).deprecrationInfo match {
case Some(_) => "(deprecated)"
Expand Down
Expand Up @@ -97,12 +97,13 @@ class RuleCompliance (
private[this] val getAllNodeInfos = RudderConfig.nodeInfoService.getAll _

import RuleCompliance._

def tagsEditForm = new TagsEditForm()
def display : NodeSeq = {

(
"#ruleName" #> rule.name &
"#ruleCategory" #> categoryService.shortFqdn(rootRuleCategory, rule.categoryId) &
"#tagField *" #> tagsEditForm.cfTagsRuleConfiguration &
"#rudderID" #> rule.id.value &
"#ruleShortDescription" #> rule.shortDescription &
"#ruleLongDescription" #> rule.longDescription &
Expand Down
Expand Up @@ -124,6 +124,17 @@ class RuleDisplayer (
, () => refreshGrid
) )
}

def includeSubCategory = {
SHtml.ajaxCheckbox(
true
, value => OnLoad(JsRaw(s"""
include=${value};
filterTableInclude('#grid_rules_grid_zone',filter,include); """)) & check()
, ("id","includeCheckbox")
)
}

def viewCategories(ruleCategoryTree : RuleCategoryTree) : NodeSeq = {

val actionButton =
Expand All @@ -139,6 +150,7 @@ class RuleDisplayer (
{actionButton}
</div>
</lift:authz>
<div id="includeSubCategory">{includeSubCategory}<span>Display Rules from subcategories</span></div>
<div id="treeParent" style="overflow:auto; margin-top:10px; max-height:443px;">
<div id="categoryTree" class="tw-bs">
{ruleCategoryTree.tree}
Expand Down Expand Up @@ -176,15 +188,6 @@ class RuleDisplayer (
, directive
)
}
def includeSubCategory = {
SHtml.ajaxCheckbox(
true
, value => OnLoad(JsRaw(s"""
include=${value};
filterTableInclude('#grid_rules_grid_zone',filter,include); """)) & check()
, ("id","includeCheckbox")
)
}

def actionButton = {
if (directive.isDefined) {
Expand All @@ -200,7 +203,6 @@ class RuleDisplayer (
{actionButton}
</span>
</lift:authz>
<div style={s"margin:10px 0px 0px ${if (directive.isDefined) 0 else 50}px; float:left"}>{includeSubCategory} <span style="margin-left:10px;"> Display Rules from subcategories</span></div>
<hr class="spacer"/>
{ ruleGrid.rulesGridWithUpdatedInfo(None, !directive.isDefined, true, false) ++
Script(OnLoad(ruleGrid.asyncDisplayAllRules(None, true, configService.display_changes_graph().openOr(true)).applied))
Expand All @@ -212,7 +214,7 @@ class RuleDisplayer (

def display = {
val columnToFilter = {
if (directive.isDefined) 2 else 1
if (directive.isDefined) 3 else 2
}

ruleCategoryTree match {
Expand Down
Expand Up @@ -260,8 +260,8 @@ class RuleGrid(
logger.warn(fail.messageChain)
(true, Some(fail.msg))
}
val onLoad =
s"""createRuleTable (
val onLoad = s"""
createRuleTable (
"${htmlId_rulesGridId}"
, ${tableData.json.toJsCmd}
, ${showCheckboxColumn}
Expand All @@ -275,13 +275,83 @@ class RuleGrid(
);
createTooltip();
createTooltiptr();
$$('#${htmlId_rulesGridWrapper}').css("margin","10px 0px 0px 0px");
angular.bootstrap('#showFiltersRules', ['filters']);
"""
<div id={htmlId_rulesGridZone}>
<span class="error" id="ruleTableError">{errorProperty.getOrElse("")}</span>
<div id={htmlId_modalReportsPopup} class="nodisplay">
<div id={htmlId_reportsPopup} ></div>
</div>
<div id="showFiltersRules" ng-controller="filterTagRuleCtrl" class="filters tw-bs" ng-cloak="">
<div class="filters-container">
<form class="filterTag form-inline">
<div class="space-top">
<ul class="nav nav-tabs nav-tabs-filter" role="tablist">
<li role="presentation">
<a href="" class="toggleTabFilter" role="tab" ng-click="toggleTagForm('search','#searchStr');">
Filter
<span class="fa fa-chevron-right" ng-class="{'fa-rotate-90':!hide.search}"></span>
</a>
</li>
<li role="presentation">
<a href="" class="toggleTabFilter" role="tab" ng-click="toggleTagForm('tag','.input-key')">
Filter by tag
<span class="fa fa-chevron-right" ng-class="{'fa-rotate-90':!hide.tag}"></span>
</a>
</li>
<li role="presentation">
<a href="" class="toggleTabFilter updateTable" id="updateRuleTable" role="tab">
<i class="fa fa-refresh"></i>
</a>
</li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane tab-filter" id="form-search" ng-class="{'active':!hide.search}">
<div class="form-group">
<div class="input-group">
<label for="searchStr" class="input-group-addon"><span class="ion ion-search"></span></label>
<input type="text" id="searchStr" class="input-sm form-control" placeholder="Filter" ng-model="strSearch" ng-keyup="filterGlobal(strSearch)"/>
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane tab-filter" id="form-tag" ng-class="{'active':!hide.tag}">
<div class="form-group">
<div class="input-group">
<input placeholder="key" class="form-control input-sm input-key " type="text" ng-model="newTag.key"/>
<span class="input-group-addon addon-json">=</span>
<input placeholder="value" class="form-control input-sm input-value" type="text" ng-model="newTag.value"/>
<span class="input-group-btn">
<button type="button" ng-click="addTag()" class="btn btn-success btn-sm" ng-disabled=" (isEmptyOrBlank(newTag.key) && isEmptyOrBlank(newTag.value)); ">
<span class="fa fa-plus"></span>
</button>
</span>
</div>
</div>
<div class="btn-group only-tags" role="group" aria-label="...">
<button type="button" class="btn btn-default btn-sm" ng-click="onlyAll($event)" ng-class="{'active': getOnlyAllValue() }">All</button>
<button type="button" class="btn btn-default btn-sm" ng-click="onlyKey($event)" ng-class="{'active':only.key}">Filter keys only</button>
<button type="button" class="btn btn-default btn-sm" ng-click="onlyValue($event)" ng-class="{'active':only.value}">Filter values only</button>
</div>
</div>
<div role="tabpanel" class="tab-pane" ng-class="{'active':tags.length>0 || strSearch.length>0}">
<div class="tags-container">
<span class="rudder-tag tag-search" ng-if="strSearch.length>0">
<span class="tag-value" ng-bind="strSearch"></span>
<span class="fa fa-times" ng-click="clearSearch()"></span>
</span>
<span class="rudder-tag" ng-repeat="tag in tags" ng-class="{'onlyKey':only.key, 'onlyValue':only.value, 'already-exist':tag.alreadyExist}" ng-click="modifyTag($index,tag)">
<span class="tag-key" ng-bind="tag.key"></span>
<span class="tag-separator">=</span>
<span class="tag-value" ng-bind="tag.value"></span>
<span class="fa fa-times" ng-click="removeTag($index)"></span>
</span>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<table id={htmlId_rulesGridId} class="display" cellspacing="0"> </table>
<div class={htmlId_rulesGridId +"_pagination, paginatescala"} >
<div id={htmlId_rulesGridId +"_paginate_area"}></div>
Expand Down Expand Up @@ -316,7 +386,7 @@ class RuleGrid(
${completeCategories.map(c => s"""$$('#${c.value}Checkbox').prop("checked",${status}); """).mkString("\n")}
${indeterminate.map(c => s"""$$('#${c.value}Checkbox').prop("indeterminate",true); """).mkString("\n")}
"""))
}
}
}
} catch {
case e:Exception =>
Expand Down Expand Up @@ -640,6 +710,8 @@ class RuleGrid(
val t5 = System.currentTimeMillis
TimingDebugLogger.trace(s"Rule grid: transforming into data: get rule data: callback: ${t5-t4}ms")

val tags = """[{"key":"environment","value":"production"},{"key":"customer","value":"Acme prod"}]"""

RuleLine (
line.rule.name
, line.rule.id
Expand All @@ -653,6 +725,7 @@ class RuleGrid(
, reasons
, policyMode
, explanation
, tags
)
}
}
Expand Down Expand Up @@ -687,6 +760,7 @@ case class RuleLine (
, reasons : Option[String]
, policyMode : String
, explanation : String
, tags : String
) extends JsTableLine {

/* Would love to have a reflexive way to generate that map ... */
Expand All @@ -710,6 +784,7 @@ case class RuleLine (
, ( "trClass", trClass )
, ( "policyMode", policyMode )
, ( "explanation", explanation )
, ( "tags", tags)
)

base +* JsObj(optFields:_*)
Expand Down
Expand Up @@ -218,7 +218,7 @@ object DisplayDirectiveTree extends Loggable {
}
val htmlId = s"jsTree-${directive.id.value}"
override val attrs = (
("data-jstree" -> """{ "type" : "directive" }""") ::
("data-jstree" -> """{"type":"directive", "tags":[{"key":"environment", "value":"production"},{"key":"customer", "value":"Acme corp"}]}""") ::
( "id" -> htmlId) ::
("class" -> classes ) ::
Nil
Expand All @@ -231,8 +231,8 @@ object DisplayDirectiveTree extends Loggable {
val tooltipId = Helpers.nextFuncName
<span class="treeActions">
<span class="tooltipable treeAction noRight directiveDetails fa fa-pencil" tooltipid={tooltipId} title="" onclick={redirectToDirectiveLink(directive.id).toJsCmd}> </span>
<div class="tooltipContent" id={tooltipId}><div>Configure this Directive.</div></div>
</span>
<div class="tooltipContent" id={tooltipId}><div>Configure this Directive.</div></div>
</span>
} else {
NodeSeq.Empty
}
Expand Down Expand Up @@ -280,7 +280,7 @@ object DisplayDirectiveTree extends Loggable {
<div>Technique version: {directive.techniqueVersion.toString}</div>
<div>{s"Used in ${isAssignedTo} rules" }</div>
{ if(!directive.isEnabled) <div>Disable</div> }
</div>
</div>

}

Expand All @@ -292,7 +292,7 @@ object DisplayDirectiveTree extends Loggable {
}
}

displayCategory(directiveLib, "jstn_0").toXml
displayCategory(directiveLib, "jstn_0").toXml ++ Script(OnLoad(JsRaw("angular.bootstrap('#activeTechniquesTree_actions_zone', ['filters']);")))
}

}

0 comments on commit 1fe681a

Please sign in to comment.