<div class="tile-header">
	<div class="headline">
		<mvc:message code="settings.server.status" />
	</div>
</div>
<div class="tile-content table-responsive">
	<table id="serverStatus_status" class="table js-table">
		<tbody>
			<tr>
				<td><mvc:message code="serverStatus.status.overall" /></td>
				<c:set var="isOkOverallStatus" value="${serverStatus.overallStatus}"/>
				<td class="serverstatus_status ${isOkOverallStatus ? 'serverstatus_status-success' : 'serverstatus_status-error'}">
					${isOkOverallStatus ? 'OK' : 'ERROR'}
				</td>
			</tr>
			<tr>
				<td><mvc:message code="serverStatus.status.jobqueue" /></td>
				<c:set var="isOkJobQueueStatus" value="${serverStatus.jobQueueStatus}"/>
				<td class="serverstatus_status ${isOkJobQueueStatus ? 'serverstatus_status-success' : 'serverstatus_status-error'}">
					${isOkJobQueueStatus ? 'OK' : 'ERROR'}
				</td>
			</tr>
			<tr>
				<td><mvc:message code="serverStatus.status.import" /></td>
				<c:set var="isOkImportStatus" value="${serverStatus.importStatus}"/>
				<td class="serverstatus_status ${isOkImportStatus ? 'serverstatus_status-success' : 'serverstatus_status-error'}">
					${isOkImportStatus ? 'OK' : 'STALLING'}
				</td>
			</tr>
			<tr>
				<td><mvc:message code="serverStatus.status.dbOverall" /></td>
				<c:set var="isOkDbStatus" value="${serverStatus.dbStatus}"/>
				<td class="serverstatus_status ${isOkDbStatus ? 'serverstatus_status-success' : 'serverstatus_status-error'}">
					${isOkDbStatus ? 'OK' : 'ERROR'}
				</td>
			</tr>
			<tr>
				<td><mvc:message code="serverStatus.status.dbConnection" /></td>
				<c:set var="isOkDbConnectionStatus" value="${serverStatus.dbConnectStatus}"/>
				<td class="serverstatus_status ${isOkDbConnectionStatus ? 'serverstatus_status-success' : 'serverstatus_status-error'}">
					${isOkDbConnectionStatus ? 'OK' : 'Cannot connect to DB'}
				</td>
			</tr>
			<tr>
				<td><mvc:message code="serverStatus.status.report" /></td>
				<c:set var="isOkReportStatus" value="${serverStatus.reportStatus}"/>
				<td class="serverstatus_status ${isOkReportStatus ? 'serverstatus_status-success' : 'serverstatus_status-error'}">
					${isOkReportStatus ? 'OK' : 'ERROR'}
				</td>
			</tr>
			<tr>
				<td><mvc:message code="serverStatus.status.license" /></td>
				<c:set var="isLicenseStatusOK" value="${serverStatus.licenseStatusOK}"/>
				<td class="serverstatus_status ${isLicenseStatusOK ? 'serverstatus_status-success' : 'serverstatus_status-warning'}">
					${isLicenseStatusOK ? 'OK' : 'WARNING'}
				</td>
			</tr>
			<tr>
				<td>
					<mvc:message code="serverStatus.status.discspace" />
					<button class="icon icon-help" data-help="help_${helplanguage}/settings/serverstatus/DiskSpaceLeft.xml" tabindex="-1" type="button"></button>
				</td>

				<c:choose>
					<c:when test="${serverStatus.diskSpaceFreePercentage >= 25}">
						<td class="serverstatus_status serverstatus_status-success">>= 25%</td>
					</c:when>
					<c:when test="${serverStatus.diskSpaceFreePercentage >= 10}">
						<td class="serverstatus_status serverstatus_status-warning">>= 10%</td>
					</c:when>
					<c:otherwise>
						<td class="serverstatus_status serverstatus_status-error">< 10%</td>
					</c:otherwise>
				</c:choose>
			</tr>
			<tr class="${isOkImportStatus ? 'serverstatus_import_status_ok' : 'serverstatus_import_status_error'}">
				<td colspan="2">
					<c:url var="killRunningImportsUrl" value="/serverstatus/killRunningImports.action"/>
					<button type="button" class="btn btn-primary btn-regular col-sm-12 kill-import-btn whitespace_normal">
						<mvc:message code="serverStatus.killImports" />
					</button>
				</td>
			</tr>
		</tbody>
	</table>
</div>

<!-- ----------Kill Running Imports Light Box------------------------------------------- -->
<div class="modal-backdrop in kill-import-modal"></div>
<div class="modal kill-import-modal">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="tile">
				
				<div class="tile-header">
					<div class="headline">
						<mvc:message code="serverStatus.killImports" />
					</div>
				</div>
			
				<div class="tile-content">
					<div class="col-sm-12 kill-import-modal-content">
						<p class="kill-import-text-warning"><strong><mvc:message code="serverStatus.killImports.Xplain1" /></strong></p>
						<p><mvc:message code="serverStatus.killImports.Xplain2" /></p>
					</div>
					<div class="row">
						<div class="col-sm-12 kill-import-modal-content">
							<div class="btn-group">
								<div class="col-sm-4 pull-left">
									<button type="button" class="btn btn-large pull-left kill-import-btn">
										<i class="icon icon-times"></i> <span class="text"><mvc:message code="button.Cancel" /></span>
									</button>
								</div>
								<div class="col-sm-4 pull-right">
									<button type="button" class="btn btn-large btn-primary pull-right kill-import-btn" data-form-url="${killRunningImportsUrl}" data-form-submit="">
										<i class="icon icon-check"></i> <span class="text"><mvc:message code="button.OK" /></span>
										</button>
									</div>
								</div>
							</div>
						</div>
					</div>
					
				</div>
			</div>
		</div>
	</div>
<script>
jQuery('.kill-import-btn').on('click', function() {
	if (jQuery('.kill-import-modal').is(':visible')) {
		jQuery('.kill-import-modal').hide();
	} else {
		jQuery('.kill-import-modal').show();
	}
});
</script>
