<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
-->
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12 text-center text-narrow" ng-switch="state.status">
            <div ng-switch-when="prompt">
                <h2>Are you sure you wish to logout?</h2>
                <p>
                    <a class="btn btn-lg btn-primary" ng-click="vm.logout()">Yes</a>
                    <a class="btn btn-lg btn-outline" href="/">No, return to <%= getBrandedText('product.name') %></a>
                </p>
                <div br-server-status></div>
            </div>
            
            <div ng-switch-when="logging-out">
                <h2>Logging out...</h2>
                <p>&nbsp;</p>
                <p><a class="btn btn-lg btn-primary" ng-click="vm.retry()">Retry</a></p>
            </div>
            
            <div ng-switch-when="just-logged-out">
                <h2>Logout successful</h2>
                <p>Thank you for using <%= getBrandedText('product.name') %>. See you soon!</p>
                <p><i>Note that some browsers may cache credentials, 
                    particularly if you have this app open in multiple tabs
                    so you might not be prompted on a subsequent log in.</i></p>
                <p>&nbsp;</p>
                <p><a class="btn btn-lg btn-primary" href="/{{ debug || salt ? '#!/?' : '' }}{{ debug ? '&debug=true' : ''}}{{ salt ? '&salt='+(salt+1) : ''}}">Log back in</a></p>
                <p ng-if="debug"><a class="btn btn-lg btn-outline" ng-click="vm.confirm()">Confirm and clear</a></p>
            </div>
            
            <div ng-switch-when="already-logged-out">
                <h2>Already logged out</h2>
                <p>Thank you for using <%= getBrandedText('product.name') %>. See you soon!</p>
                <p>&nbsp;</p>
                <p><a class="btn btn-lg btn-primary" href="/{{ debug || salt ? '#!/?' : '' }}{{ debug ? '&debug=true' : ''}}{{ salt ? '&salt='+(salt+1) : ''}}">Log back in</a></p>
                <p ng-if="debug"><a class="btn btn-lg btn-outline" ng-click="vm.confirm()">Confirm and clear</a></p>
            </div>
            
            <div ng-switch-when="logout-confirmed">
                <h2>Logout confirmed</h2>
                <p>Thank you for using <%= getBrandedText('product.name') %>. See you soon!</p>
                <p>The application is no longer able to log in to the server.</p>
                <p>&nbsp;</p>
                <p><a class="btn btn-lg btn-primary" href="/{{ debug || salt ? '#!/?' : '' }}{{ debug ? '&debug=true' : ''}}{{ salt ? '&salt='+(salt+1) : ''}}">Log back in</a></p>
                <p ng-if="debug"><a class="btn btn-lg btn-outline" ng-click="vm.confirm()">Confirm and clear again</a></p>
            </div>
            <div ng-switch-when="success-after-logout">
                <h2>Logged out again</h2>
                <p>Thank you for using <%= getBrandedText('product.name') %>. See you soon!</p>
                
                <p>The app was able to log in successfully and logout again.</p>
                <p>If you did not log again, this suggests the browser may be caching credentials or the server is unsecured.</p> 
                <p>The server has confirmed it has deleted the session.</p>
                <p>&nbsp;</p>
                <p><a class="btn btn-lg btn-primary" href="/{{ debug || salt ? '#!/?' : '' }}{{ debug ? '&debug=true' : ''}}{{ salt ? '&salt='+(salt+1) : ''}}">Log back in</a></p>
                <p ng-if="debug"><a class="btn btn-lg btn-outline" ng-click="vm.confirm()">Confirm and clear</a></p>
            </div>
            
            
            <div ng-switch-default>
                <h2>Logout failed<span ng-if="state.message">: {{ state.message }}</span></h2>
                <p ng-if="state.code==403"><i>CSRF cookie errors are common in development or can indicate that multiple sessions are open.
                    Closing other tabs and retrying will usually fix this.</i></p>
                <p><i>More information may be available in the logs.</i></p>
                <p>&nbsp;</p>
                <p><a class="btn btn-lg btn-primary" ng-click="vm.retry()">Retry</a></p>
                <p ng-if="debug"><a class="btn btn-lg btn-outline" ui-sref="/prompt">Prompt to logout again</a></p>
                <p><a class="btn btn-lg btn-outline" href="/">Return to <%= getBrandedText('product.name') %> (login if needed)</a></p>
            </div>
        </div>
    </div>
</div>
