<div class="panel panel-default" ng-controller="KeyManager_Controller"><div class="panel-heading"><h4 class="panel-title pull-left">{{title}}</h4><span class="pull-right">{{version}}</span><div class="clearfix"></div></div></div>

<div class="row">
    <div class="col-md-4">
        <div class="panel panel-default" ng-controller="KeyManager_ControlsController">
            <div class="panel-heading">
				<h3 class="panel-title">Controls</h3>
            </div>
			<div class="panel-body">
				<table style="width:100%">
					<tr>
						<td style="padding-bottom: .5em;" class="text-muted">Dependencies</td>
            <td ng-hide="$root.status.installed" style="text-align:right;padding-bottom: .5em;"><button type="button" style="width: 90px;" class="btn btn-{{installLabel}} btn-xs" data-toggle="modal" data-target="#dependenciesInstallModal" ng-disabled="processing">{{install}}</button></td>
            <td ng-show="$root.status.installed" style="text-align:right;padding-bottom: .5em;"><button type="button" style="width: 90px;" class="btn btn-{{installLabel}} btn-xs" data-toggle="modal" data-target="#dependenciesRemoveModal" ng-disabled="processing">{{install}}</button></td>
					</tr>
					<tr ng-show="$root.status.installed">
						<td style="padding-bottom: .5em;" class="text-muted">SSH Key Pair</td>
						<td style="text-align:right;padding-bottom: .5em;"><button type="button" style="width: 90px;" class="btn btn-{{keyLabel}} btn-xs" ng-disabled="generating" ng-click="handleKey()">{{key}}</button></td>
					</tr>
				</table>
			</div>

      <div class="modal fade" id="dependenciesInstallModal" tabindex="-1" role="dialog" aria-labelledby="dependenciesModalLabel">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              <h4 class="modal-title" id="dependenciesInstallModalLabel">Install dependencies</h4>
            </div>
            <div class="modal-body">
              All required dependencies have to be installed first. This may take a few minutes.<br /><br />
              Please wait, do not leave or refresh this page. Once the install is complete, this page will refresh automatically.
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-info" ng-click="handleDependencies('internal')" data-dismiss="modal">Internal</button>
              <button type="button" class="btn btn-info" ng-hide="device == 'tetra' || sdAvailable == false" ng-click="handleDependencies('sd')" data-dismiss="modal">SD Card</button>
            </div>
          </div>
        </div>
      </div>

      <div class="modal fade" id="dependenciesRemoveModal" tabindex="-1" role="dialog" aria-labelledby="dependenciesModalLabel">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
              <h4 class="modal-title" id="dependenciesRemoveModalLabel">Remove dependencies</h4>
            </div>
            <div class="modal-body">
              All required dependencies will be removed. This may take a few minutes.<br /><br />
              Please wait, do not leave or refresh this page. Once the remove is complete, this page will refresh automatically.
            </div>
            <div class="modal-footer">
              <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
              <button type="button" class="btn btn-info" ng-click="handleDependencies()" data-dismiss="modal">Confirm</button>
            </div>
          </div>
        </div>
      </div>

        </div>
    </div>
    </div>
</div>

<div class="panel panel-default" ng-show="$root.status.installed && $root.status.generated" ng-controller="KeyManager_RemoteHostController">
	<div class="panel-heading">
        <h4 class="panel-title">Remote Host</h4>
    </div>
    <div class="panel-body">

      <div class="form-group">
          <div class="input-group">
              <span class="input-group-addon input-sm">Remote Host</span>
              <input type="text" class="form-control input-sm" ng-model="host" placeholder="Remote SSH Server Host">
          </div>
      </div>

      <div class="form-group">
          <div class="input-group">
              <span class="input-group-addon input-sm">Remote Port</span>
              <input type="text" class="form-control input-sm" ng-model="port" placeholder="Remote SSH Server Port (Typically 22)">
          </div>
      </div>

      <div class="form-group">
          <div class="input-group">
              <span class="input-group-addon input-sm">Remote User</span>
              <input type="text" class="form-control input-sm" ng-model="user" placeholder="Remote SSH Server User">
          </div>
      </div>

      <div class="form-group">
          <div class="input-group">
              <span class="input-group-addon input-sm">Remote Password</span>
              <input type="password" class="form-control input-sm" ng-model="password" placeholder="Remote SSH Server Password">
          </div>
      </div>

      <button type="submit" class="btn btn-{{addHostLabel}} btn-sm" ng-disabled="working || (host == '' || port == '' )" ng-click="addToKnownHosts()">{{addHost}}</button>
      <button type="submit" class="btn btn-{{copyKeyLabel}} btn-sm" ng-disabled="working || (host == '' || port == '' || user == '' || password == '')" ng-click="copyToRemoteHost()">{{copyKey}}</button>

    </div>
</div>


<div class="panel panel-default" ng-show="$root.status.installed" ng-controller="KeyManager_KnownHostsController">
    <div class="panel-heading pointer" data-toggle="collapse" data-target="#KnownHosts">
        <h4 class="panel-title">Known Hosts</h4>
    </div>
    <div id="KnownHosts" class="panel-collapse collapse">
        <div class="panel-body">
			<button type="submit" class="btn btn-{{saveKnownHostsLabel}} btn-sm pull-right" ng-disabled="saving" ng-click="saveKnownHostsData()">{{saveKnownHosts}}</button><div class="clearfix"></div>
			<form class="form-horizontal">
                <textarea class="form-control" rows="20" ng-model="knownHostsData"></textarea>
            </form>
        </div>
    </div>
</div>

<div class="panel panel-default" ng-show="$root.status.installed" ng-controller="KeyManager_OutputController">
	<div class="panel-heading">
        <h4 class="panel-title">Output</h4>
    </div>
    <div class="panel-body">
      <div class="btn-group pull-right">
        <button class="btn btn-danger btn-sm" ng-click="clearOutput()">Clear Log</button>
      </div>
      <div class="clearfix"></div>
      <pre class="scrollable-pre log-pre">{{output}}</pre>
    </div>
</div>
