From 4ec2fe04614f94a05897a3e4ecf685a74a0ca517 Mon Sep 17 00:00:00 2001
From: "Mark M. Florida" <mflorida@gmail.com>
Date: Mon, 16 May 2016 12:54:58 -0500
Subject: [PATCH] Site initialization stuff.

---
 .../webapp/WEB-INF/conf/xnat-security.xml     | 231 +-----------------
 src/main/webapp/WEB-INF/tags/page/xnat.tag    |   2 +-
 .../page/admin/data/config/site-setup.yaml    |   7 +-
 src/main/webapp/scripts/xmodal-v1/xmodal.css  |  17 +-
 src/main/webapp/scripts/xmodal-v1/xmodal.js   |   2 +
 src/main/webapp/scripts/xnat/ui/panel.js      |  33 ++-
 src/main/webapp/setup/index.jsp               | 132 ++++++----
 src/main/webapp/style/app.css                 |   5 +-
 8 files changed, 125 insertions(+), 304 deletions(-)

diff --git a/src/main/webapp/WEB-INF/conf/xnat-security.xml b/src/main/webapp/WEB-INF/conf/xnat-security.xml
index 933f700c..70943ffc 100644
--- a/src/main/webapp/WEB-INF/conf/xnat-security.xml
+++ b/src/main/webapp/WEB-INF/conf/xnat-security.xml
@@ -2,87 +2,14 @@
 <!--suppress SpringSecurityFiltersConfiguredInspection -->
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:p="http://www.springframework.org/schema/p"
-       xmlns:c="http://www.springframework.org/schema/c"
        xmlns:security="http://www.springframework.org/schema/security"
        xmlns:context="http://www.springframework.org/schema/context"
-       xmlns:util="http://www.springframework.org/schema/util"
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
-                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
-                           http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
-
-    <context:property-placeholder location="WEB-INF/conf/services.properties"
-                                  ignore-resource-not-found="true" ignore-unresolvable="true"/>
+                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
 
     <context:annotation-config/>
 
-    <util:list id="decisionVoters">
-        <ref bean="roleVoter"/>
-        <ref bean="authenticatedVoter"/>
-    </util:list>
-
-    <bean class="org.springframework.security.access.vote.UnanimousBased" id="unanimousBased"
-          c:decisionVoters-ref="decisionVoters"/>
-
-    <bean class="org.springframework.security.access.vote.RoleVoter" id="roleVoter" p:rolePrefix="ROLE_"/>
-
-    <bean class="org.springframework.security.access.vote.AuthenticatedVoter" id="authenticatedVoter"/>
-
-    <bean class="org.nrg.xnat.security.OnXnatLogin" id="logUserLogin"/>
-
-    <bean class="org.nrg.xnat.security.XnatUrlAuthenticationFailureHandler" id="authFailure">
-        <constructor-arg value="/app/template/Login.vm?failed=true"/>
-        <constructor-arg value="/app/template/PostRegister.vm"/>
-    </bean>
-
-    <bean id="loginUrlAuthenticationEntryPoint" class="org.nrg.xnat.security.XnatAuthenticationEntryPoint"
-          c:loginFormUrl="/app/template/Login.vm">
-        <property name="dataPaths">
-            <list value-type="java.lang.String">
-                <value>/data/**</value>
-                <value>/REST/**</value>
-                <value>/fs/**</value>
-            </list>
-        </property>
-        <property name="interactiveAgents">
-            <list value-type="java.lang.String">
-                <value>.*MSIE.*</value>
-                <value>.*Mozilla.*</value>
-                <value>.*AppleWebKit.*</value>
-                <value>.*Opera.*</value>
-            </list>
-        </property>
-    </bean>
-
-    <bean id="concurrencyFilter" class="org.springframework.security.web.session.ConcurrentSessionFilter"
-          c:sessionRegistry-ref="sessionRegistry" c:expiredUrl="/app/template/Login.vm"/>
-    <bean id="sessionRegistry" class="org.springframework.security.core.session.SessionRegistryImpl"/>
-    <bean id="sas"
-          class="org.springframework.security.web.authentication.session.ConcurrentSessionControlAuthenticationStrategy">
-        <constructor-arg name="sessionRegistry" ref="sessionRegistry"/>
-        <property name="maximumSessions" value="${security.sessions.concurrent_max}"/>
-        <property name="exceptionIfMaximumExceeded" value="true"/>
-    </bean>
-    <bean id="xnatLogoutSuccessHandler" class="org.nrg.xnat.security.XnatLogoutSuccessHandler"
-          p:openXnatLogoutSuccessUrl="/" p:securedXnatLogoutSuccessUrl="/app/template/Login.vm"/>
-    <bean id="logoutFilter" class="org.springframework.security.web.authentication.logout.LogoutFilter">
-        <constructor-arg name="logoutSuccessHandler" ref="xnatLogoutSuccessHandler"
-                         type="org.springframework.security.web.authentication.logout.LogoutSuccessHandler"/>
-        <constructor-arg name="handlers">
-            <list>
-                <ref bean="xnatLogoutHandler"/>
-                <ref bean="securityContextLogoutHandler"/>
-            </list>
-        </constructor-arg>
-        <property name="filterProcessesUrl" value="/app/action/LogoutUser"/>
-    </bean>
-    <bean id="securityContextLogoutHandler"
-          class="org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler">
-        <property name="invalidateHttpSession" value="true"/>
-    </bean>
-    <bean id="xnatLogoutHandler" class="org.nrg.xnat.security.XnatLogoutHandler"/>
-
     <security:http auto-config="false" use-expressions="true" entry-point-ref="loginUrlAuthenticationEntryPoint">
         <security:csrf disabled="true"/>
         <security:custom-filter position="CHANNEL_FILTER" ref="channelProcessingFilter"/>
@@ -99,160 +26,4 @@
         </security:headers>
     </security:http>
 
-    <bean class="org.nrg.xnat.security.FilterSecurityInterceptorBeanPostProcessor">
-        <property name="openUrls">
-            <list>
-                <value>/app/action/AcceptProjectAccess/par/*</value>
-                <value>/app/action/ModifyPassword*</value>
-                <value>/app/action/XDATForgotLogin*</value>
-                <value>/app/action/XDATRegisterUser*</value>
-                <value>/app/action/InactiveAccountEmail*</value>
-                <value>/app/template/XDATScreen_UpdateUser.vm*</value>
-                <value>/app/template/Error.vm*</value>
-                <value>/app/template/ForgotLogin.vm*</value>
-                <value>/app/template/Login.vm*</value>
-                <value>/app/template/PostRegister.vm*</value>
-                <value>/app/template/InactiveAccount.vm*</value>
-                <value>/app/template/Register.vm*</value>
-                <value>/app/template/ResendEmail.vm*</value>
-                <value>/app/template/ResendVerification.vm*</value>
-                <value>/app/template/VerificationSent.vm*</value>
-                <value>/app/template/VerifyEmail.vm*</value>
-                <value>/favicon.ico</value>
-                <value>/data/JSESSION</value>
-                <value>/REST/JSESSION</value>
-                <value>/data/services/auth*</value>
-                <value>/REST/services/auth*</value>
-                <value>/data/services/sendemailverification*</value>
-                <value>/REST/services/sendemailverification*</value>
-                <value>/images/**</value>
-                <value>/scripts/**</value>
-                <value>/style/**</value>
-                <value>/themes/**</value>
-                <value>/files/**</value>
-                <value>/pages/**</value>
-                <value>/page/**</value>
-                <value>/applet/**</value>
-            </list>
-        </property>
-        <property name="adminUrls">
-            <list>
-                <value>/app/template/AdminSummary.vm*</value>
-                <value>/app/template/Configuration.vm*</value>
-                <value>/app/template/XDATScreen_EditScript.vm/user/Test*</value>
-                <value>/app/template/XDATScreen_active_sessions.vm*</value>
-                <value>/app/template/XDATScreen_admin.vm*</value>
-                <value>/app/template/XDATScreen_admin_options.vm*</value>
-                <value>/app/template/XDATScreen_admin_projectAccess.vm*</value>
-                <value>/app/template/XDATScreen_bundles.vm*</value>
-                <value>/app/template/XDATScreen_dataTypes.vm*</value>
-                <value>/app/template/XDATScreen_email.vm*</value>
-                <value>/app/template/XDATScreen_emailSpecifications.vm*</value>
-                <value>/app/template/XDATScreen_groups.vm*</value>
-                <value>/app/template/XDATScreen_manage_info.vm*</value>
-                <value>/app/template/XDATScreen_manage_news.vm*</value>
-                <value>/app/template/XDATScreen_manage_pipeline.vm*</value>
-                <value>/app/template/XDATScreen_roles.vm*</value>
-                <value>/monitoring*</value>
-                <value>/setup/**</value>
-            </list>
-        </property>
-    </bean>
-
-    <bean id="channelProcessingFilter" class="org.nrg.xnat.security.TranslatingChannelProcessingFilter">
-        <property name="channelDecisionManager">
-            <bean class="org.springframework.security.web.access.channel.ChannelDecisionManagerImpl">
-                <property name="channelProcessors">
-                    <list>
-                        <bean class="org.springframework.security.web.access.channel.SecureChannelProcessor"/>
-                        <bean class="org.springframework.security.web.access.channel.InsecureChannelProcessor"/>
-                    </list>
-                </property>
-            </bean>
-        </property>
-        <property name="requiredChannel" value="${security.channel}"/>
-    </bean>
-
-    <bean id="servicesProperties" class="org.nrg.xnat.security.config.PropertyAggregator">
-        <constructor-arg name="fileNames">
-            <util:list>
-                <value>WEB-INF/conf/services.properties</value>
-            </util:list>
-        </constructor-arg>
-    </bean>
-
-    <bean id="aliasTokenAuthProvider" class="org.nrg.xnat.security.alias.AliasTokenAuthenticationProvider"
-          p:name="token"/>
-
-    <bean id="databaseAuthenticationProviderConfigurator"
-          class="org.nrg.xnat.security.config.DatabaseAuthenticationProviderConfigurator" p:configuratorId="db"/>
-    <bean id="ldapAuthenticationProviderConfigurator"
-          class="org.nrg.xnat.security.config.LdapAuthenticationProviderConfigurator" p:configuratorId="ldap"/>
-
-    <bean id="providerAggregator" class="org.nrg.xnat.security.config.AuthenticationProviderAggregator">
-        <constructor-arg name="standaloneProviders">
-            <list value-type="org.springframework.security.authentication.AuthenticationProvider">
-                <ref bean="aliasTokenAuthProvider"/>
-            </list>
-        </constructor-arg>
-        <constructor-arg name="configurators">
-            <map key-type="java.lang.String"
-                 value-type="org.nrg.xnat.security.config.AuthenticationProviderConfigurator">
-                <entry key="db" value-ref="databaseAuthenticationProviderConfigurator"/>
-                <entry key="ldap" value-ref="ldapAuthenticationProviderConfigurator"/>
-            </map>
-        </constructor-arg>
-        <constructor-arg name="properties" ref="servicesProperties"/>
-    </bean>
-
-    <bean id="customAuthenticationManager" name="org.springframework.security.authenticationManager"
-          class="org.nrg.xnat.security.XnatProviderManager"
-          c:providers-ref="providerAggregator" c:properties-ref="servicesProperties"/>
-
-    <bean id="customAuthenticationFilter" class="org.nrg.xnat.security.XnatAuthenticationFilter">
-        <property name="authenticationManager" ref="customAuthenticationManager"/>
-        <property name="authenticationSuccessHandler" ref="logUserLogin"/>
-        <property name="authenticationFailureHandler" ref="authFailure"/>
-        <property name="sessionAuthenticationStrategy" ref="sas"/>
-    </bean>
-
-    <bean id="customBasicAuthenticationFilter" class="org.nrg.xnat.security.XnatBasicAuthenticationFilter"
-          c:manager-ref="customAuthenticationManager" c:entryPoint-ref="loginUrlAuthenticationEntryPoint">
-        <property name="sessionAuthenticationStrategy" ref="sas"/>
-    </bean>
-
-    <bean id="expiredPasswordFilter" class="org.nrg.xnat.security.XnatExpiredPasswordFilter">
-        <property name="changePasswordPath" value="/app/template/XDATScreen_UpdateUser.vm"/>
-        <property name="changePasswordDestination" value="/app/action/ModifyPassword"/>
-        <property name="logoutDestination" value="/app/action/LogoutUser"/>
-        <property name="loginPath" value="/app/template/Login.vm"/>
-        <property name="loginDestination" value="/app/action/XDATLoginUser"/>
-        <property name="inactiveAccountPath" value="/app/template/InactiveAccount.vm"/>
-        <property name="inactiveAccountDestination" value="/app/action/XnatInactiveAccount"/>
-        <property name="emailVerificationPath" value="/app/template/VerifyEmail.vm"/>
-        <property name="emailVerificationDestination" value="/data/services/sendEmailVerification"/>
-    </bean>
-
-    <bean id="xnatInitCheckFilter" class="org.nrg.xnat.security.XnatInitCheckFilter">
-        <property name="initializationPaths">
-            <list value-type="java.lang.String">
-                <value>/xapi/siteConfig/batch</value>
-            </list>
-        </property>
-        <property name="configurationPath" value="/setup"/>
-        <property name="nonAdminErrorPath" value="/app/template/Unconfigured.vm"/>
-        <property name="exemptedPaths">
-            <list value-type="java.lang.String">
-                <value>/app/template/XDATScreen_UpdateUser.vm</value>
-                <value>/app/action/ModifyPassword</value>
-                <value>/app/template/Login.vm</value>
-                <value>/style/app.css</value>
-                <value>/login</value>
-            </list>
-        </property>
-    </bean>
-
-    <bean id="customDatabaseService" class="org.nrg.xnat.security.userdetailsservices.XnatDatabaseUserDetailsService"
-          p:dataSource-ref="dataSource"/>
-
 </beans>
diff --git a/src/main/webapp/WEB-INF/tags/page/xnat.tag b/src/main/webapp/WEB-INF/tags/page/xnat.tag
index 165ba583..368cdd1e 100644
--- a/src/main/webapp/WEB-INF/tags/page/xnat.tag
+++ b/src/main/webapp/WEB-INF/tags/page/xnat.tag
@@ -21,7 +21,7 @@
 
     ${headTop}
 
-    <title>${title}</title>
+    <title>${empty title ? 'XNAT' : title}</title>
 
     <c:set var="SITE_ROOT" value="${sessionScope.siteRoot}"/>
     <%--<c:set var="_scripts" value="${SITE_ROOT}/scripts"/>--%>
diff --git a/src/main/webapp/page/admin/data/config/site-setup.yaml b/src/main/webapp/page/admin/data/config/site-setup.yaml
index 6e4a509f..bf53e954 100644
--- a/src/main/webapp/page/admin/data/config/site-setup.yaml
+++ b/src/main/webapp/page/admin/data/config/site-setup.yaml
@@ -2,9 +2,12 @@ initialSetup:
     kind: panel.multiForm
     name: initialSetup
     label: XNAT Initial Setup
-    method: POST
-    action: /xapi/siteConfig/batch
+    method: GET
+    action: /setup?init=true
+    callback: XNAT.app.setupComplete
     contentType: json
+    element:
+        id: site-setup
     load:
         lookup: XNAT.data.siteConfig
         refresh: /xapi/siteConfig
diff --git a/src/main/webapp/scripts/xmodal-v1/xmodal.css b/src/main/webapp/scripts/xmodal-v1/xmodal.css
index 9ad44b97..894379cc 100644
--- a/src/main/webapp/scripts/xmodal-v1/xmodal.css
+++ b/src/main/webapp/scripts/xmodal-v1/xmodal.css
@@ -53,12 +53,6 @@ div.xmodal .title .maximize {
 div.xmodal .title .maximize { right: 34px; line-height: 10px; }
 div.xmodal .title .maximize:hover { cursor: pointer; }
 
-/* base64 close-yui.gif */
-/*div.xmodal .title .close {*/
-    /*background: transparent center center no-repeat ;*/
-    /*background-image: url(data:image/gif;base64,R0lGODlhGQAPALMJALGxsZ2dnezs7HNzc21tbYWFhfX19cHBwf///////wAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAAkALAAAAAAZAA8AAAROMJ1Jq71Tos27/9sEjqMIAgZnAOVxEkVqFAT7md4MC3QM4jnaAJb6uUaC4UBAAnZ0Q58RpCvwiNNPAKsLZHOBIsIQ/pLOCCf6J8G4MYkIADs=);*/
-/*}*/
-
 div.xmodal .body { width: 100% ; height: 100% ; position: absolute ; overflow: hidden ; }
 div.xmodal .body.scroll { overflow-y: auto ; }
 div.xmodal .body .inner { display: none ; padding: 20px ; font-size: 13px ; line-height: 17px ; }
@@ -81,7 +75,7 @@ div.xmodal .footer .buttons { display: table-cell ; padding-right: 15px ; vertic
 div.xmodal .footer .buttons .link { display: inline-block; padding: 10px; font-size: 13px; text-decoration: underline; }
 div.xmodal .footer .button {
     display: inline-block ; margin-left: 10px ; padding: 1px 15px !important ; float: right ;
-    line-height: 23px ; vertical-align: middle ; font-size: 13px ; font-weight: bold ; text-decoration: none !important ; }
+    line-height: 23px ; vertical-align: middle ; font-size: 13px ; text-decoration: none !important ; }
 div.xmodal .footer a.button { height: 24px ; line-height: 24px; } /* set height only for <a> buttons */
 div.xmodal .footer .button,
 div.xmodal .footer .button.cancel.default {
@@ -103,13 +97,6 @@ div.xmodal.loading .body .inner { text-align: center ; }
 
 .modal_content, .modal_template { display: none ; }
 
-/*
-custom form styles
-by Will Horton
-for db.humanconnectome.org
-*/
-
-/* custom form styles from HCP didn't work for core XNAT */
-
+/* sorry Will */
 
 div.xmodal.embedded { top: 0; left: 0; border: none; box-shadow: none; display: block; z-index: auto;  }
diff --git a/src/main/webapp/scripts/xmodal-v1/xmodal.js b/src/main/webapp/scripts/xmodal-v1/xmodal.js
index bdb5bed4..b1399e3c 100644
--- a/src/main/webapp/scripts/xmodal-v1/xmodal.js
+++ b/src/main/webapp/scripts/xmodal-v1/xmodal.js
@@ -684,6 +684,8 @@ if (typeof jQuery == 'undefined') {
             // we can use 'className', 'classNames' or 'classes'
             this.classNames = this.className = this.classes = _opts.classNames ;
 
+            this.top = firstDefined(_opts.top||undefined, '22px');
+
             this.width = 600;
             this.minWidth = 'inherit';
             this.maxWidth = 'inherit';
diff --git a/src/main/webapp/scripts/xnat/ui/panel.js b/src/main/webapp/scripts/xnat/ui/panel.js
index c60998c8..9c5eda3b 100644
--- a/src/main/webapp/scripts/xnat/ui/panel.js
+++ b/src/main/webapp/scripts/xnat/ui/panel.js
@@ -112,7 +112,7 @@ var XNAT = getObject(XNAT || {});
     };
 
     // creates a panel that's a form that can be submitted
-    panel.form = function panelForm(opts){
+    panel.form = function panelForm(opts, callback){
 
         opts = cloneObject(opts);
         opts.element = opts.element || opts.config || {};
@@ -127,7 +127,7 @@ var XNAT = getObject(XNAT || {});
                 ['button.btn.btn-sm.btn-primary.save.pull-right|type=submit', 'Submit'],
                 ['span.pull-right', '&nbsp;&nbsp;&nbsp;'],
                 _resetBtn,
-                ['button.btn.btn-sm.btn-link.defaults.pull-left', 'Default Settings'],
+                //['button.btn.btn-sm.btn-link.defaults.pull-left', 'Default Settings'],
                 ['div.clear']
             ],
 
@@ -259,6 +259,8 @@ var XNAT = getObject(XNAT || {});
             $formPanel.dataAttr('status', 'dirty');
         });
 
+        opts.onload = opts.onload || callback;
+
         $formPanel.on('reload-data', function(){
             xmodal.loading.open();
             opts.load.url = opts.load.url || opts.load.refresh;
@@ -270,6 +272,8 @@ var XNAT = getObject(XNAT || {});
             $formPanel.triggerHandler('reload-data');
         };
 
+        opts.callback = opts.callback || callback || diddly;
+
         // intercept the form submit to do it via REST instead
         $formPanel.on('submit', function(e){
 
@@ -360,6 +364,9 @@ var XNAT = getObject(XNAT || {});
                         xmodal.message('Data saved successfully.', {
                             action: function(){
                                 loadData(obj);
+                                if (callback && isFunction(callback)) {
+
+                                }
                             }
                         });
                     }
@@ -394,7 +401,7 @@ var XNAT = getObject(XNAT || {});
     };
 
     // creates a panel that submits all forms contained within
-    panel.multiForm = function(opts){
+    panel.multiForm = function(opts, callback){
 
         opts = cloneObject(opts);
         opts.element = opts.element || opts.config || {};
@@ -405,7 +412,7 @@ var XNAT = getObject(XNAT || {});
 
             submitBtn = spawn('button', {
                 type: 'submit',
-                classes: 'btn btn-sm btn-primary save pull-right',
+                classes: 'btn submit save pull-right',
                 html: 'Save All'
             }),
 
@@ -466,15 +473,20 @@ var XNAT = getObject(XNAT || {});
                         return false;
                     }
 
-                    multiform.errors = 0;
-                    multiform.count = 0;
+                    // multiform.errors = 0;
+                    // multiform.count = 0;
 
                     xmodal.loading.close(loader.$modal);
+
+                    // fire the callback function after all forms are submitted error-free
+
+
                     xmodal.message({
                         title: 'Setup Complete',
                         content: 'Your XNAT site is ready to use. Click "OK" to continue to the home page.',
                         action: function(){
-                            window.location.href = XNAT.url.rootUrl('/');
+                            window.location.href = XNAT.url.rootUrl('/setup?init=true');
+                            //window.location.href = XNAT.url.rootUrl('/');
                             //$forms.each.triggerHandler('reload-data');
                         }
                     });
@@ -684,7 +696,12 @@ var XNAT = getObject(XNAT || {});
         var textarea = spawn('textarea', opts.element);
         return XNAT.ui.template.panelDisplay(opts, textarea).spawned;
     };
+    panel.input.textares = panel.textarea;
 
+    //////////////////////////////////////////////////
+    // SELECT MENU PANEL ELEMENTS
+    //////////////////////////////////////////////////
+    
     panel.select = {};
 
     panel.select.menu = function panelSelectSingle(opts, multi){
@@ -792,7 +809,7 @@ var XNAT = getObject(XNAT || {});
             opts.body = opts.body.concat(setupElements(opts.elements))
         }
 
-        saveBtn = footerButton('Save', 'submit', true, 'save pull-right');
+        saveBtn   = footerButton('Save', 'submit', true, 'save pull-right');
         revertBtn = footerButton('Discard Changes', 'button', true, 'revert pull-right');
 
         opts.footer = [
diff --git a/src/main/webapp/setup/index.jsp b/src/main/webapp/setup/index.jsp
index d83608cc..cbabee9e 100644
--- a/src/main/webapp/setup/index.jsp
+++ b/src/main/webapp/setup/index.jsp
@@ -21,53 +21,91 @@
 
                 <pg:restricted msg="${message}">
 
-                    <c:import url="/xapi/siteConfig" var="siteConfig"/>
-
-                    <script>
-                        XNAT.data = extend({}, XNAT.data, {
-                            siteConfig: ${siteConfig}
-                        });
-                        // get rid of the 'targetSource' property
-                        delete XNAT.data.siteConfig.targetSource;
-                    </script>
-
-                    <header id="content-header">
-                        <h2 class="pull-left">XNAT Site Setup</h2>
-                        <div class="hidden message pull-left">
-                            The settings below need to be configured before this XNAT system
-                            can be used. Please set the properties below and submit the form continue.
-                        </div>
-                        <div class="clearfix"></div>
-                    </header>
-
-                    <!-- Setup tab container -->
-                    <div id="site-setup-panels">
-
-
-                        <!-- ======================== -->
-                        <!-- PANELS WILL SHOW UP HERE -->
-                        <!-- ======================== -->
-
-
-                    </div>
-                    <!-- /#site-setup-panels -->
-
-
-                    <script>
-
-                        XNAT.xhr.get({
-                            url: XNAT.url.rootUrl('/page/admin/data/config/site-setup.yaml'),
-                            //url: XNAT.url.rootUrl('/xapi/spawner/resolve/siteAdmin/siteSetup'),
-                            success: function(data){
-                                if (typeof data === 'string') {
-                                    data = YAML.parse(data);
-                                }
-                                var setupPanels = XNAT.spawner.spawn(data);
-                                setupPanels.render('#site-setup-panels');
-                            }
-                        });
-
-                    </script>
+                    <c:choose>
+                        <c:when test="${not empty param.init && param.init == true}">
+
+                            <p>Initializing site...</p>
+
+                            <script>
+
+//                                xmodal.loading.open('#site-init');
+
+                                XNAT.xhr.postJSON({
+                                    url: XNAT.url.rootUrl('/xapi/siteConfig/batch'),
+                                    data: JSON.stringify({initialized:true}),
+                                    success: function(){
+                                        window.location.href = XNAT.url.rootUrl('/');
+                                    }
+                                }).fail(function(e, txt, jQxhr){
+                                    xmodal.loading.close('#site-init');
+                                    xmodal.message({
+                                        title: 'Error',
+                                        content: [
+                                            'An error occurred during initialization',
+                                            e,
+                                                txt
+                                        ].join(': <br>')
+                                    })
+                                });
+                            </script>
+
+                        </c:when>
+                        <c:otherwise>
+
+                            <c:import url="/xapi/siteConfig" var="siteConfig"/>
+
+                            <script>
+                                XNAT.data = extend({}, XNAT.data, {
+                                    siteConfig: ${siteConfig}
+                                });
+                                // get rid of the 'targetSource' property
+                                delete XNAT.data.siteConfig.targetSource;
+                            </script>
+
+                            <header id="content-header">
+                                <h2 class="pull-left">XNAT Site Setup</h2>
+                                <div class="hidden message pull-left">
+                                    The settings below need to be configured before this XNAT system
+                                    can be used. Please set the properties below and submit the form continue.
+                                </div>
+                                <div class="clearfix"></div>
+                            </header>
+
+                            <!-- Setup tab container -->
+                            <div id="site-setup-panels">
+
+
+                                <!-- ======================== -->
+                                <!-- PANELS WILL SHOW UP HERE -->
+                                <!-- ======================== -->
+
+
+                            </div>
+                            <!-- /#site-setup-panels -->
+
+
+                            <script>
+
+                                XNAT.app.setupComplete = function(){
+                                    XNAT.xhr.form('#site-setup', {});
+                                };
+
+                                XNAT.xhr.get({
+                                    url: XNAT.url.rootUrl('/page/admin/data/config/site-setup.yaml'),
+                                    //url: XNAT.url.rootUrl('/xapi/spawner/resolve/siteAdmin/siteSetup'),
+                                    success: function(data){
+                                        if (typeof data === 'string') {
+                                            data = YAML.parse(data);
+                                        }
+                                        var setupPanels = XNAT.spawner.spawn(data);
+                                        setupPanels.render('#site-setup-panels');
+                                    }
+                                });
+
+                            </script>
+
+                        </c:otherwise>
+                    </c:choose>
 
 
                 </pg:restricted>
diff --git a/src/main/webapp/style/app.css b/src/main/webapp/style/app.css
index fe115152..09d92db0 100644
--- a/src/main/webapp/style/app.css
+++ b/src/main/webapp/style/app.css
@@ -988,6 +988,7 @@ body input[type="reset"] {
 }
 
 /* style for button hover */
+.btn,
 .btn1:hover,
 .btn2:hover,
 body button:hover,
@@ -1001,6 +1002,7 @@ body input[type="reset"]:hover {
 .btn1,
 .btn.primary,
 .btn.submit,
+.btn.save,
 body input.btn1,
 body input.btn1[type="button"],
 body input.btn1[type="submit"] {
@@ -1012,9 +1014,10 @@ body input.btn1[type="submit"] {
 .btn1:hover,
 .btn.primary:hover,
 .btn.submit:hover,
+.btn.save:hover,
 body input.btn1:hover,
 body input.btn1[type="button"]:hover,
-body input.btn1[type="submit"]:hover {
+body [type="submit"]:hover {
     background: #096BB7;
 }
 
-- 
GitLab