text: <!--
  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  
  Copyright (c) 2017 Payara Foundation and/or its affiliates. All rights reserved.
  
  The contents of this file are subject to the terms of either the GNU
  General Public License Version 2 only ("GPL") or the Common Development
  and Distribution License("CDDL") (collectively, the "License").  You
  may not use this file except in compliance with the License.  You can
  obtain a copy of the License at
  https://github.com/payara/Payara/blob/master/LICENSE.txt
  See the License for the specific
  language governing permissions and limitations under the License.
  
  When distributing the software, include this License Header Notice in each
  file and include the License file at glassfish/legal/LICENSE.txt.
  
  GPL Classpath Exception:
  The Payara Foundation designates this particular file as subject to the "Classpath"
  exception as provided by the Payara Foundation in the GPL Version 2 section of the License
  file that accompanied this code.
  
  Modifications:
  If applicable, add the following below the License Header, with the fields
  enclosed by brackets [] replaced by your own identifying information:
  "Portions Copyright [year] [name of copyright owner]"
  
  Contributor(s):
  If you wish your version of this file to be governed by only the CDDL or
  only the GPL Version 2, indicate your decision by adding "[Contributor]
  elects to include this software in this distribution under the [CDDL or GPL
  Version 2] license."  If you don't indicate a single choice of license, a
  recipient has the option to distribute your version of this file under
  either the CDDL, the GPL Version 2 or to extend the choice of license to
  its licensees as provided above.  However, if you add GPL Version 2 code
  and therefore, elected the GPL Version 2 license, then the option applies
  only if the new code is made subject to such option by the copyright
  holder.
  -->
  
  <!initPage
      setResourceBundle(key="i18nc" bundle="org.glassfish.common.admingui.Strings");
      setResourceBundle(key="i18ncs" bundle="org.glassfish.cluster.admingui.Strings");
      setResourceBundle(key="i18ndn" bundle="fish.payara.admingui.notifier.datadog.Strings");
      setResourceBundle(key="i18nn" bundle="fish.payara.admingui.extras.Strings");
      />
  <!composition template="/templates/default.layout"  guiTitle="$resource{i18ndn.notifier.datadog.configuration.pageTitle}"  >
  <!define name="content">
  <event>
      <!beforeCreate 
          getRequestValue(key="configName" value="#{pageSession.configName}" );
          createMap(result="#{pageSession.attrsMap}")
          mapPut(map="#{pageSession.attrsMap}" key="target" value="#{pageSession.configName}");
          gf.restRequest(endpoint="#{sessionScope.NOTIFICATION_CONFIG_URL}/get-datadog-notifier-configuration?target=#{pageSession.configName}"
                  method="GET" result="#{requestScope.resp}");
          setPageSessionAttribute(key="valueMap", value="#{requestScope.resp.data.extraProperties.notifierConfiguration}");
          mapPut(map="#{pageSession.valueMap}" key="target" value="#{pageSession.configName}");
          setPageSessionAttribute(key="convertToFalseList", value={"enabled", "noisy", "dynamic"});
          
          if (#{pageSession.valueMap['enabled']}=true) {
              setPageSessionAttribute(key="enabledSelected", value="true");
          }
          if (#{pageSession.valueMap['noisy']}=true) {
  			setPageSessionAttribute(key="noisy", value="true");
  		}	
          setPageSessionAttribute(key="dynamic", value="true");        
      /> 
  </event>
  <sun:form id="propertyForm">
  #include "/common/shared/alertMsg_1.inc"
  #include "/payaraExtras/notification/notificationConfigTabs.inc"
      <sun:title id="propertyContentPage" title="$resource{i18ndn.notifier.datadog.configuration.pageTitle}"
                 helpText="$resource{i18ndn.notifier.datadog.configuration.pageHelpText}" >
          <sun:button id = "test" text="$resource{i18ndn.notifier.datadog.buttons.test}">
              <!command 
                  mapCopy(source="#{pageSession.valueMap}" dest="#{pageSession.attrsMap}");
                  mapRemove(map="#{pageSession.attrsMap}" key="enabled");
  				mapRemove(map="#{pageSession.attrsMap}" key="noisy");
                  mapRemove(map="#{pageSession.attrsMap}" key="noisy");
                  mapRemove(map="#{pageSession.attrsMap}" key="dynamic");
                  gf.restRequest(endpoint="#{sessionScope.NOTIFICATION_CONFIG_URL}/test-datadog-notifier-configuration?target=#{pageSession.configName}" method="GET" 
                      attrs="#{pageSession.attrsMap}" result="#{requestScope.result}");
                  if ("#{requestScope.result.data['exit_code']} = SUCCESS") {
                      prepareAlertMsg(summary="$resource{i18ndn.notifier.datadog.msg.success}", type="success");
                  } 
                  />
          </sun:button>
          <!facet pageButtonsTop>
              <sun:panelGroup id="topButtons">
                  <sun:button id="saveButton"  text="$resource{i18n.button.Save}"
                          onClick="if (guiValidate('#{reqMsg}','#{reqInt}','#{reqPort}')) submitAndDisable(this, '$resource{i18n.button.Processing}'); return false;" >
                      <!command
                          mapPut(map="#{pageSession.valueMap}" key="enabled" value="#{pageSession.enabledSelected}");
  						mapPut(map="#{pageSession.valueMap}" key="noisy" value="#{pageSession.noisy}");
                          mapPut(map="#{pageSession.valueMap}" key="noisy" value="#{pageSession.noisy}");
                          mapPut(map="#{pageSession.valueMap}" key="dynamic" value="#{pageSession.dynamic}");
                          prepareSuccessfulMsg();
                          gf.updateEntity(endpoint="#{sessionScope.NOTIFICATION_CONFIG_URL}/notification-datadog-configure"
                                  attrs="#{pageSession.valueMap}" convertToFalse="#{pageSession.convertToFalseList}");
                          />
                  </sun:button>
              </sun:panelGroup>
          </facet>
      </sun:title>
  
      <sun:propertySheet id="propertySheet">
  #include "/common/shared/configNameSection.inc"
          <sun:propertySheetSection id="datadogNotifierProperties">
              <sun:property id="enabledProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" 
                            label="$resource{i18ndn.notifier.datadog.configuration.enabledLabel}"
                            helpText="$resource{i18ndn.notifier.datadog.configuration.enabledLabelHelpText}">
                  <sun:checkbox id="enabledProp" selected="#{pageSession.enabledSelected}" selectedValue="true" />
              </sun:property>
              <sun:property id="noisy" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" 
                            label="$resource{i18nn.notification.configuration.notifier.noisyLabel}"  
                            helpText="$resource{i18nn.notification.configuration.notifier.noisyLabelHelpText}">
                  <sun:checkbox id="noisy" selected="#{pageSession.noisy}" selectedValue="true" />
              </sun:property>
              <sun:property id="dynamic" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" 
                            label="$resource{i18nn.notification.configuration.dynamic}"  
                            helpText="$resource{i18nn.notification.configuration.notifier.dynamicHelp}">
                  <sun:checkbox id="dynamic" selected="#{pageSession.dynamic}" selectedValue="true" />
              </sun:property>
              <sun:property id="keyProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}"
                            label="$resource{i18ndn.notifier.datadog.configuration.keyLabel}"
                            helpText="$resource{i18ndn.notifier.datadog.configuration.keyLabelHelpText}">
                  <sun:textField id="keyField" columns="$int{75}" maxLength="255"
                                 text="#{pageSession.valueMap['key']}" styleClass="required"
                                 required="#{true}"/>
              </sun:property>
          </sun:propertySheetSection>
      </sun:propertySheet>
  </sun:form>
  </define>
  </composition>