#*
 * Copyright 2012 LinkedIn, Inc
 * 
 * Licensed 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.
*#
<!DOCTYPE html> 
<html>
  <head>
    <title>#appname()</title>
    <link rel="stylesheet" type="text/css" href="${context}/css/azkaban.css">    
    <link rel="shortcut icon" href="${context}/favicon.ico" />
	<script type="text/javascript" src="${context}/js/jquery/jquery.js"></script>    
	<script type="text/javascript" src="${context}/js/namespace.js"></script>
	<script type="text/javascript" src="${context}/js/underscore-1.2.1-min.js"></script>
	<script type="text/javascript" src="${context}/js/backbone-0.5.3-min.js"></script>
	<script type="text/javascript" src="${context}/js/azkaban.admin.setup.js"></script>
    #parse( "azkaban/webapp/servlet/velocity/style.vm" )
	<script type="text/javascript">
		var contextURL = "${context}";
		var verified = $verified;
		var message = "$message";
	</script>
  </head>
  <body>
    <div class="header">
    #parse("azkaban/webapp/servlet/admin/velocity/title.vm" )
    </div>
    <div class="shadow-box admin">
    	<div id="all-jobs-content">
			<div class="section-hd">
				<h2>Azkaban Setup DB</h2>
			</div>
		</div>
		<div class="comment">
			We need to setup the datastore that Azkaban will use. Currently the only store that is supported is JDBC MySQL.
		</div>
		<div id="dbuploadpanel" class="admin-panel">
			<h3>DB Connector Jar</h3>
			<div class="comment">
				Since Azkaban does not distribute GPL packages, the MySQL JDBC Connector Jar is not included with the default distribution.<br/> 
				You will need to upload it here. The jar file should be named <span class="bold">mysql-connector-*.jar</span>
			</div>
			<form class="upload" id="upload-form" enctype="multipart/form-data" method="post" action="$!context/?upload">
				<fieldset>
					<dl>
						<dd><input id="file" name="file" class="file" type="file" /></dd>
						<input type="hidden" name="action" value="upload" />
					</dl>
				</fieldset>
				<div class="yes button1 btn2" id="upload-jar-btn">Upload Jar</div>
				<div id="installed" class="installed">#if($installedJar) Currently installed Jar <span class="bold">$installedJar</span> #else No jars Installed.#end</div>
			</form>
		</div>
		<div id="dbsettingspanel" class="admin-panel">
			<h3>DB Connection Settings</h3>
			<div class="comment">
				Fill in the parameters to connect to your database. The database should already be set up to give the azkaban user read, write, update, insert tables to the azkaban user for the hosts that serve the admin client, azkaban web client and the executor server. 
				Also give admin host create, drop, alter table if you want the admin tool to automatically setup the database. Azkaban does not need access to add and remove user permissions.
			</div>
			<form id="dbconnection">
				<table>
					<tr><td class="left">Host</td>		<td class="param"><input type="text" id="host" name="host" value="$host"></input></td>				<td class="desc">The mysql instance host url/ip. i.e. mysql.mytestdomain.com</td></tr>
					<tr><td class="left">Port</td>		<td class="param"><input type="text" id="port" name="port" value="$port"></input></td>				<td class="desc">The port. Default Mysql is 3306</td></tr>
					<tr><td class="left">Database</td>	<td class="param"><input type="text" id="database" name="database" value="$database"></input></td>	<td class="desc">The database name.</td></tr>
					<tr><td class="left">User</td>		<td class="param"><input type="text" id="username" name="username" value="$username"></input></td>	<td class="desc">The username which azkaban will use to connect to the db.</td></tr>
					<tr><td class="left">Password</td>	<td class="param"><input type="password" id="password" name="password" value="$password"></input></td>	<td class="desc">The password which azkaban will use to connect to the db.</td></tr>
				</table>
				<div class="button1 btn2" id="save-connection-button">Test Connection</div><div id="save-results"></div>
			</form>

		</div>
		<div class="shadow-box-footer">
		  <div id="saveAndContinue" class="btn2 button1">Continue</div>
		  <a href="${context}/" class="btn3 button1">Go Back</a>
    	</div>

    </div>
  </body>
</html>