Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
RaphaelGauthier committed Nov 22, 2018
1 parent d3bd4ad commit 1753503
Show file tree
Hide file tree
Showing 26 changed files with 10,347 additions and 218 deletions.
Expand Up @@ -73,18 +73,17 @@ class AgentScheduleEditForm(
case eb:EmptyBox =>
val e = eb ?~! s"Error when trying to parse user data: '${jsonSchedule}'"
logger.error(e.messageChain)
S.error("cfagentScheduleMessage", e.messageChain)
JsRaw(s"""createErrorNotification("${e.messageChain}")""")
case Full(agentInterval) =>
saveConfigureCallback(agentInterval) match {
case eb:EmptyBox =>
val e = eb ?~! s"Error when trying to store in base new agent schedule: '${jsonSchedule}'"
logger.error(e.messageChain)
S.error("cfagentScheduleMessage", e.messageChain)

JsRaw(s"""createErrorNotification("${e.messageChain}")""")
case Full(success) =>
// start a promise generation, Since we check if there is change to save, if we got there it mean that we need to redeploy
startNewPolicyGeneration()
S.notice("cfagentScheduleMessage", "Agent schedule saved")
JsRaw(s"""createSuccessNotification("Agent Schedule saved.")""")
}
}
}
Expand Down
Expand Up @@ -161,21 +161,21 @@ class ComplianceModeEditForm [T <: ComplianceMode] (
case eb:EmptyBox =>
val e = eb ?~! s"Error when trying to parse user data: '${jsonMode}'"
logger.error(e.messageChain)
S.error("complianceModeMessage", e.messageChain)
JsRaw(s"""createErrorNotification("${ e.messageChain}")""")
case Full(complianceMode) =>
saveConfigureCallback(complianceMode) match {
case eb:EmptyBox =>
val e = eb ?~! s"Error when trying to store in base new compliance mode: '${jsonMode}'"
logger.error(e.messageChain)
S.error("complianceModeMessage", e.messageChain)
JsRaw(s"""createErrorNotification("${ e.messageChain}")""")

case Full(success) =>
// start a promise generation, Since we check if there is change to save, if we got there it mean that we need to redeploy
startNewPolicyGeneration()
S.notice("complianceModeMessage", "Compliance mode saved")
JsRaw("""createSuccessNotification("Compliance mode saved")""")
}
//necessary to avoid the non-exhaustive warning due to "type pattern T is unchecked since eliminated by erasure" pb above
case x => S.error("complianceModeMessage", s"Compliance mode is not of the awaited type (dev error): please report that error")
case x => JsRaw(s"""createErrorNotification("Compliance mode is not of the awaited type (dev error): please report that error")""")
}
}

Expand Down
Expand Up @@ -690,9 +690,9 @@ class DirectiveEditForm(
if (action == DGModAction.Delete) {
val nSeq = <div id={ htmlId_policyConf }>Directive successfully deleted</div>
(_: ChangeRequestId) => JsRaw("$('#confirmUpdateActionDialog').bsModal('hide');") & onRemoveSuccessCallBack() & SetHtml(htmlId_policyConf, nSeq) &
successPopup(NodeSeq.Empty)
successNotification()
} else {
(_: ChangeRequestId) => JsRaw("$('#confirmUpdateActionDialog').bsModal('hide');") & successPopup(NodeSeq.Empty) & onSuccessCallback(Left(newDirective))
(_: ChangeRequestId) => JsRaw("$('#confirmUpdateActionDialog').bsModal('hide');") & successNotification() & onSuccessCallback(Left(newDirective))
}
}

Expand All @@ -708,7 +708,7 @@ class DirectiveEditForm(
, workflowService
, onSuccessCallback = successCallback
, onFailureCallback = failureCallback
, onCreateSuccessCallBack = ( result => onSuccessCallback(result) & successPopup(NodeSeq.Empty))
, onCreateSuccessCallBack = ( result => onSuccessCallback(result) & successNotification())
, onCreateFailureCallBack = onFailure _
, parentFormTracker = formTracker
)
Expand Down Expand Up @@ -751,8 +751,7 @@ class DirectiveEditForm(

///////////// success pop-up ///////////////

private[this] def successPopup(message: NodeSeq) : JsCmd = {
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog") """) &
JsRaw(s""" $$("#successDialogContent").html('${message}') """)
private[this] def successNotification() : JsCmd = {
JsRaw("""createSuccessNotification()""")
}
}
Expand Up @@ -331,7 +331,7 @@ class NodeGroupCategoryForm(

///////////// success pop-up ///////////////
private[this] def successPopup : JsCmd = {
JsRaw("""callPopupWithTimeout(200, "successConfirmationDialog");""")
JsRaw("""createSuccessNotification()""")
}

}
Expand Up @@ -417,8 +417,7 @@ class NodeGroupForm(
}

private[this] def successPopup : JsCmd = {
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog")
""")
JsRaw("""createSuccessNotification()""")
}

}
Expand Up @@ -591,22 +591,15 @@ class RuleEditForm(
</div>
}

val content =
if ( ruleTarget.excludedTarget.targets.size + ruleTarget.includedTarget.targets.size== 0 ) {
if ( selectedDirectiveIds.size == 0 ) {
warning("This Rule is not applied to any Groups and does not have any Directives to apply.")
} else {
warning("This Rule is not applied to any Groups.")
}
} else {
if ( selectedDirectiveIds.size == 0 ) {
warning("This Rule does not have any Directives to apply.")
} else {
NodeSeq.Empty
} }
val warningNotification =
((ruleTarget.excludedTarget.targets.size + ruleTarget.includedTarget.targets.size == 0), (selectedDirectiveIds.size == 0)) match{
case (true, true) => JsRaw("""createWarningNotification("This Rule is not applied to any Groups and does not have any Directives to apply.")""")
case (true, false) => JsRaw("""createWarningNotification("This Rule is not applied to any Groups.")""")
case (false, true) => JsRaw("""createWarningNotification("This Rule does not have any Directives to apply.")""")
case (_) => JsRaw("")
}

SetHtml("successDialogContent",content) &
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog")""")
JsRaw("""createSuccessNotification()""") & warningNotification
}

}
Expand Up @@ -259,6 +259,6 @@ class TechniqueCategoryEditForm(

///////////// success pop-up ///////////////
private[this] def successPopup : JsCmd = {
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog")""")
JsRaw("""createSuccessNotification()""")
}
}
Expand Up @@ -588,8 +588,7 @@ class TechniqueEditForm(

///////////// success pop-up ///////////////
private[this] def successPopup : JsCmd = {
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog")
""")
JsRaw("""createSuccessNotification()""")
}

}
Expand Up @@ -308,6 +308,6 @@ class Archives extends DispatchSnippet with Loggable {

///////////// success pop-up ///////////////
private[this] def successPopup : JsCmd = {
JsRaw("""callPopupWithTimeout(200, "successConfirmationDialog")""")
JsRaw("""createSuccessNotification()""")
}
}
Expand Up @@ -45,6 +45,7 @@ import js._
import JsCmds._
import com.normation.rudder.web.model.CurrentUser
import bootstrap.liftweb.RudderConfig
import net.liftweb.http.js.JE.JsRaw

class ClearCache extends DispatchSnippet with Loggable {

Expand All @@ -60,16 +61,15 @@ class ClearCache extends DispatchSnippet with Loggable {
// JsCmd which will be sent back to the browser
// as part of the response
def process(): JsCmd = {
//clear errors
S.clearCurrentNotices
clearCacheService.action(CurrentUser.actor) match {
val createNotification = clearCacheService.action(CurrentUser.actor) match {
case empty:EmptyBox =>
val e = empty ?~! "Error while clearing caches"
S.error(e.messageChain)
JsRaw(s"""createErrorNotification("${e.messageChain}")""")
case Full(result) =>
S.notice("clearCacheNotice","Caches were successfully cleared")
JsRaw("""createSuccessNotification("Caches were successfully cleared")""")

}
Replace("clearCacheForm", outerXml.applyAgain)
Replace("clearCacheForm", outerXml.applyAgain) & createNotification
}

//process the list of networks
Expand Down
Expand Up @@ -39,18 +39,14 @@ package com.normation.rudder.web.snippet.administration

import net.liftweb._
import http._
import common._
import util.Helpers._
import js._
import JsCmds._
import bootstrap.liftweb.RudderConfig
import net.liftweb.common._
import net.liftweb.http._
import net.liftweb.http.js.JE.JsRaw
import net.liftweb.http.js._
import net.liftweb.http.js.JsCmds._
import net.liftweb.util.Helpers._


class DyngroupReloading extends DispatchSnippet with Loggable {

private[this] val updateDynamicGroups = RudderConfig.updateDynamicGroups
Expand All @@ -60,21 +56,14 @@ class DyngroupReloading extends DispatchSnippet with Loggable {
case "render" => reload
}


def reload : IdMemoizeTransform = SHtml.idMemoize { outerXml =>

// our process method returns a
// JsCmd which will be sent back to the browser
// as part of the response
def process(): JsCmd = {
//clear errors
S.clearCurrentNotices

updateDynamicGroups.startManualUpdate

S.notice("dyngroupReloadingNotice", "Dynamic group reloading started")

Replace("dyngroupReloadingForm", outerXml.applyAgain)
Replace("dyngroupReloadingForm", outerXml.applyAgain) & JsRaw("""createSuccessNotification("Dynamic group reloading started")""")
}

val initJs = SetHtml("dynGroupUpdateInterval", <span>{updateDynamicGroupsInterval}</span>)
Expand Down
Expand Up @@ -170,9 +170,8 @@ class EditPolicyServerAllowedNetwork extends DispatchSnippet with Loggable {
}) match {
case Full(_) =>
asyncDeploymentAgent ! AutomaticStartDeployment(modId, CurrentUser.actor)

Replace(allowedNetworksFormId, outerXml.applyAgain) &
successPopup
successNotification
case e:EmptyBox => SetHtml(allowedNetworksFormId,errorMessage(s"#${allowedNetworksFormId}", e)(outerXml.applyAgain))
}

Expand Down Expand Up @@ -231,7 +230,7 @@ class EditPolicyServerAllowedNetwork extends DispatchSnippet with Loggable {
}

///////////// success pop-up ///////////////
private[this] def successPopup : JsCmd = {
JsRaw(""" callPopupWithTimeout(200, "successConfirmationDialog")""")
private[this] def successNotification : JsCmd = {
JsRaw(""" createSuccessNotification() """)
}
}

0 comments on commit 1753503

Please sign in to comment.