Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelGauthier committed Aug 17, 2020
1 parent 31e33d7 commit c1bdd8e
Show file tree
Hide file tree
Showing 18 changed files with 397 additions and 493 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,6 @@ import com.normation.box._

object DirectiveEditForm {

/**
* This is part of component static initialization.
* Any page which contains (or may contains after an ajax request)
* that component have to add the result of that method in it.
*/
def staticInit: NodeSeq = RuleGrid.staticInit

private def body = ChooseTemplate(
"templates-hidden" :: "components" :: "ComponentDirectiveEditForm" :: Nil
, "component-body"
Expand Down Expand Up @@ -142,7 +135,6 @@ class DirectiveEditForm(
}

def showForm(): NodeSeq = {
staticInit ++
(
"#container [id]" #> htmlId_policyConf &
"#editForm" #> showDirectiveForm()
Expand Down Expand Up @@ -260,7 +252,7 @@ class DirectiveEditForm(
( "" , NodeSeq.Empty )
}
(
"#editForm *" #> { (n: NodeSeq) => SHtml.ajaxForm(n) } andThen
"#editForm" #> { (n: NodeSeq) => SHtml.ajaxForm(n) } andThen
// don't show the action button when we are creating a popup
"#pendingChangeRequestNotification" #> { xml:NodeSeq =>
PendingChangeRequestDisplayer.checkByDirective(xml, directive.id)
Expand All @@ -273,13 +265,14 @@ class DirectiveEditForm(
ClearClearable &
//activation button: show disactivate if activated
"#directiveTitle *" #> <span class={ if(fullActiveTechnique.isEnabled) "" else "is-disabled" }>{directive.name}</span> &
"#shortDescription *" #> directive.shortDescription &
"#disactivateButtonLabel" #> {
if (directive.isEnabled) "Disable" else "Enable"
} &
"#removeAction *" #> {
"#removeAction" #> {
SHtml.ajaxSubmit("Delete", () => onSubmitDelete(),("class" ,"btn btn-danger"))
} &
"#desactivateAction *" #> {
"#desactivateAction" #> {
val status = directive.isEnabled ? DGModAction.Disable | DGModAction.Enable
SHtml.ajaxSubmit(status.name, () => onSubmitDisable(status), ("class" ,"btn btn-default"))
} &
Expand Down Expand Up @@ -338,8 +331,7 @@ class DirectiveEditForm(
|checkMigrationButton("${currentVersion}","${versionSelectId}");
|$$('#${directiveVersion.uniqueFieldId.getOrElse("id_not_found")}').change( function () {
| checkMigrationButton("${currentVersion}","${versionSelectId}")
|} );
|adjustHeight("#edit-box","#directiveToolbar")""".stripMargin)
|} );""".stripMargin)
)
)
}
Expand All @@ -365,9 +357,7 @@ class DirectiveEditForm(
}

private[this] def showErrorNotifications() : JsCmd = {
onFailureCallback() & Replace("editForm", showDirectiveForm) &
//restore user to the update parameter tab
JsRaw("""scrollToElement("notifications", "#directiveDetails");""")
onFailureCallback() & Replace("editForm", showDirectiveForm)
}

private[this] def showIsSingle(): NodeSeq = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ class NodeGroupForm(
val displayCompliance = DisplayColumn.FromConfig
val ruleGrid = new RuleGrid("rules_for_current_group", None, false, None, displayCompliance, displayCompliance)
val rules = dependencyService.targetDependencies(target).map( _.rules.toSet.filter(!_.isSystem).map(_.id)).toOption
RuleGrid.staticInit ++ ruleGrid.rulesGridWithUpdatedInfo(None, false, false) ++ Script(OnLoad(ruleGrid.asyncDisplayAllRules(rules).applied))
ruleGrid.rulesGridWithUpdatedInfo(None, false, false) ++ Script(OnLoad(ruleGrid.asyncDisplayAllRules(rules).applied))
}
private[this] val groupNameString = nodeGroup.fold(
t => rootCategory.allTargets.get(t).map(_.name).getOrElse(t.target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class RuleDisplayer (
}
def actionButtonCategory: NodeSeq =
if (directive.isEmpty) {
SHtml.ajaxButton("", () => showCategoryPopup(None), ("class" -> "new-icon category btn btn-success btn-outline btn-sm"))
SHtml.ajaxButton("Add Category", () => showCategoryPopup(None), ("class" -> "new-icon category btn btn-success btn-outline btn-sm"))
} else {
NodeSeq.Empty
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,21 +73,6 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent._
import scala.xml._

object RuleGrid {
def staticInit =
<head>
<style type="text/css">
#actions_zone , .dataTables_length , .dataTables_filter {{ display: inline-block; }}
.greenCompliance {{ background-color: #5cb85c }}
.orangeCompliance {{ background-color: #FF6600 }}
.redCompliance {{ background-color: #c9302c }}
.noCompliance {{ background-color:#b4b4b4; }}
.applyingCompliance {{ background-color:#5bc0de; }}
.compliance {{ text-align: center; }}
</style>
</head>
}

/**
* An ADT to denote if a column should be display or not,
* or if is should be decided from config service.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,10 +434,6 @@ object DisplayDirectiveTree extends Loggable {
if(!angular.element(scopeElmnt).scope()){
angular.bootstrap(scopeElmnt, ['filters']);
}
adjustHeight('#activeTechniquesTree');
$$('#showFiltersDirective').on('click', function () {
setTimeout(function(){adjustHeight('#activeTechniquesTree');}, 550);
});
$$(".bsTooltip").bsTooltip({container: "${if(addEditLink){"#editRuleZonePortlet"}else{"#boxDirectiveTree"}}"})
"""))
directiveLib.subCategories.filterNot(_.isSystem).sortBy( _.name ).flatMap { cat => displayCategory(cat, cat.id.value).toXml }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ class DirectiveManagement extends DispatchSnippet with Loggable {
* Head information (JsTree dependencies,...)
*/
def head() : NodeSeq = {
DirectiveEditForm.staticInit ++
(
<head>
{Script(OnLoad(parseJsArg()))}
Expand Down Expand Up @@ -204,10 +203,6 @@ class DirectiveManagement extends DispatchSnippet with Loggable {
}

buildDirectiveTree('#${htmlId_activeTechniquesTree}', [ directiveId ], '${S.contextPath}', 1);
$$(window).on('resize',function(){
adjustHeight('#activeTechniquesTree');
});
adjustHeight('#activeTechniquesTree');
$$('#activeTechniquesTree').on('scroll',function(){$$('.tooltip').hide();});
createTooltip();
""")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import net.liftweb.http.js._
import JsCmds._
import com.normation.rudder.web.components.popup.CreateOrCloneRulePopup
import JE._
import com.normation.rudder.web.components.{RuleEditForm, RuleGrid}
import com.normation.rudder.web.components.{RuleEditForm}
import com.normation.rudder.domain.policies.Rule
import bootstrap.liftweb.RudderConfig
import com.normation.plugins.DefaultExtendableSnippet
Expand Down Expand Up @@ -93,7 +93,6 @@ class RuleManagement extends DispatchSnippet with DefaultExtendableSnippet[RuleM

def head(changeMsgEnabled : Boolean) : NodeSeq = {
RuleEditForm.staticInit ++
RuleGrid.staticInit ++
{<head>
{Script(
JsRaw("""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ app.controller('filterTagCtrl', function ($scope, $http, $location, $timeout, $r
$scope.searchTree($scope.directiveTreeId);
if($scope.fullPage){
$timeout(function() {
adjustHeight($scope.directiveTreeId);
},0);
}
} else {
Expand Down Expand Up @@ -173,9 +172,6 @@ app.controller('filterTagCtrl', function ($scope, $http, $location, $timeout, $r
if($scope.showFilters){
$('.input-key').focus();
}
if($scope.fullPage){
adjustHeight($scope.directiveTreeId);
}
}

$scope.onlyKey = function(elem){
Expand Down Expand Up @@ -296,9 +292,6 @@ app.controller('filterTagCtrl', function ($scope, $http, $location, $timeout, $r
}
);
}
if($scope.fullPage){
adjustHeight($scope.directiveTreeId);
}
});

app.config(function($locationProvider) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,13 @@

$(document).ready(function(){
var treeId = '#activeTechniquesTree';
var formId = '#edit-box';
var storageTreeId = 'directiveTreeSettings_nodesState'
$(window).on('resize',function(){
adjustHeight(treeId);
adjustHeight(formId,"#directiveToolbar");
});
$(treeId).on("searchtag.jstree",function(e, data){
data.res.length>0 ? $('#activeTechniquesTree_alert').hide() : $('#activeTechniquesTree_alert').show();
adjustHeight(treeId);
});
$(treeId).on("clear_search.jstree",function(e, data){
$('#activeTechniquesTree_alert').hide();
$(this).jstree(true).show_all();
adjustHeight(treeId);
});
$(treeId).on('close_node.jstree', function(e, data){
updateTreeSettings(storageTreeId, data, false);
Expand Down
Loading

0 comments on commit c1bdd8e

Please sign in to comment.