<h2>{{ 'systemStatus' | translate }}</h2>

<div ng-hide="systemStatus" class="loading-panel panel">
</div>

<div ng-show="systemStatus" class="panel panel-default">
	<br />

	<form class="form-horizontal">

		<div class="form-group">
			<label class="col-sm-4 control-label">Is on premises</label>
			<div class="col-sm-8">
				<p class="form-control-static">
					{{ systemStatus.isOnPremises.toString() | translate }}
					<button class="btn btn-default btn-xs" ng-click="toggleIsOnPremises()">{{ 'toggle' | translate }}</button>
				</p>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-4 control-label">Cryptographic keys</label>
			<div class="col-sm-8">
				<p class="form-control-static">
					{{systemStatus.machineKeyHint}}
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-4 control-label">Log configured</label>
			<div class="col-sm-8">
				<p class="form-control-static">
					<span ng-class="{ 'text-success': systemStatus.logConfigured, 'text-warning' : !systemStatus.logConfigured }">
						{{ systemStatus.logConfigured.toString() | translate }}
					</span>
					<span ng-show="systemStatus.logConfigured">({{systemStatus.logConfigHint}})</span>
					<button class="btn btn-default btn-xs" ng-click="testLog()">{{ 'ssTestLog' | translate }}</button>
				</p>
			</div>
		</div>

		<div class="form-group">
			<label class="col-sm-4 control-label">SDK license loaded</label>
			<div class="col-sm-8">
				<p class="form-control-static">
					<span ng-class="{ 'text-success': systemStatus.sdkLicenseLoaded, 'text-danger' : !systemStatus.sdkLicenseLoaded }">
						{{ systemStatus.sdkLicenseLoaded.toString() | translate }}
					</span>
					<span ng-show="systemStatus.sdkLicenseLoaded">({{systemStatus.sdkLicenseInfo}})</span>
					<span ng-show="!systemStatus.sdkLicenseLoaded">({{systemStatus.sdkLicenseError}})</span>
					<button class="btn btn-default btn-xs" ng-click="changeSdkLicense()">{{ 'ssChange' | translate }}</button>
				</p>
			</div>
		</div>

	</form>

</div>

<h2>{{ 'regionAndTime' | translate }}</h2>

<div ng-hide="regionAndTime" class="loading-panel panel">
</div>

<div ng-show="regionAndTime" class="panel panel-default">

	<form class="form-horizontal">
		<br />

		<!-- Culture (editable) -->
		<lacuna-editable-item on-save="saveRegionAndTime(key, value)" on-edit="editCulture()">
			<item-label>{{ 'ssNewcomerCulture' | translate }}</item-label>
			<item-value>{{ regionAndTime.culture.displayName }}</item-value>
			<item-editor>
				<select class="form-control" ng-options="culture.id as culture.displayName for culture in cultures" ng-model="$editor.data.value"></select>
			</item-editor>
		</lacuna-editable-item>

		<!-- Time Zone (editable) -->
		<lacuna-editable-item on-save="saveRegionAndTime(key, value)" on-edit="editTimeZone()">
			<item-label>{{ 'ssNewcomerTimeZone' | translate }}</item-label>
			<item-value>{{ regionAndTime.timeZone.displayName }}</item-value>
			<item-editor>
				<select class="form-control" ng-options="timezone.id as timezone.displayName for timezone in timezones" ng-model="$editor.data.value"></select>
			</item-editor>
		</lacuna-editable-item>

		<!-- Date Format (editable) -->
		<lacuna-editable-item on-save="saveRegionAndTime(key, value)" on-edit="editDateFormat()">
			<item-label>{{ 'ssNewcomerDateFormat' | translate }}</item-label>
			<item-value>{{ 'dateFormats_' + regionAndTime.dateFormat | translate }}</item-value>
			<item-editor>
				<select class="form-control" ng-options="format as ('dateFormats_' + format | translate) for format in dateFormats" ng-model="$editor.data.value"></select>
			</item-editor>
		</lacuna-editable-item>

	</form>

</div>

<h2>{{ 'storageService' | translate }}</h2>

<div ng-hide="settings" class="loading-panel panel">
</div>

<div ng-show="settings" class="panel panel-default">

	<form class="form-horizontal">
		<br />

		<!-- Storage Service (editable) -->
		<lacuna-editable-item on-save="saveStorageSetting(key, value)" on-edit="editStorageService()">
			<item-label>
				<span ng-switch="storageServiceAvailable">
					<span class="label label-success" ng-switch-when="true">{{ 'ssReady' | translate }}</span>
					<span class="label label-warning" ng-switch-when="false">{{ 'ssUnavailable' | translate }}</span>
				</span>
				{{ 'ssStorageService' | translate }}
			</item-label>
			<item-value>{{ 'storageService_' + settings.StorageService | translate }}</item-value>
			<item-editor>
				<select class="form-control" ng-options="id as ('storageService_' + id | translate) for id in storageServices" ng-model="$editor.data.value"></select>
			</item-editor>
		</lacuna-editable-item>

		<!-- Local Storage Directory (editable) -->
		<lacuna-editable-item on-save="saveStorageSetting(key, value)" on-edit="editSetting('LocalStorageDirectory')">
			<item-label>{{ 'ssLocalStorageDirectory' | translate }}</item-label>
			<item-value>
				<span ng-show="settings.LocalStorageDirectory">{{ settings.LocalStorageDirectory }}</span>
				<em class="text-muted" ng-hide="settings.LocalStorageDirectory">{{ 'ssLocalStorageDirectoryEmpty' | translate }}</em>
			</item-value>
			<item-editor>
				<input type="text" class="form-control" ng-model="$editor.data.value">
			</item-editor>
		</lacuna-editable-item>

		<!-- Azure Configuration (editable) -->
		<lacuna-editable-item on-save="saveStorageSetting(key, value)" on-edit="editSensitiveSetting('AzureConfiguration')">
			<item-label>{{ 'ssAzureConfiguration' | translate }}</item-label>
			<item-value>
				<em class="text-muted" ng-show="settings.AzureConfiguration">{{ 'hidden' | translate }}</em>
				<em class="text-muted" ng-hide="settings.AzureConfiguration">{{ 'none' | translate }}</em>
			</item-value>
			<item-editor>
				<input type="text" class="form-control" ng-model="$editor.data.value" placeholder="{{ 'ssAzureConfigurationPlaceholder' | translate }}">
			</item-editor>
		</lacuna-editable-item>

		<!-- Amazon S3 Configuration (editable) -->
		<lacuna-editable-item on-save="saveStorageSetting(key, value)" on-edit="editSensitiveSetting('AmazonS3Configuration')">
			<item-label>{{ 'ssAmazonS3Configuration' | translate }}</item-label>
			<item-value>
				<em class="text-muted" ng-show="settings.AmazonS3Configuration">{{ 'hidden' | translate }}</em>
				<em class="text-muted" ng-hide="settings.AmazonS3Configuration">{{ 'none' | translate }}</em>
			</item-value>
			<item-editor>
				<input type="text" class="form-control" ng-model="$editor.data.value" placeholder="{{ 'ssAmazonS3ConfigurationPlaceholder' | translate }}">
			</item-editor>
		</lacuna-editable-item>

	</form>

</div>

<h2>{{ 'cacheConfiguration' | translate }}</h2>

<div ng-hide="settings" class="loading-panel panel">
</div>

<div ng-show="settings" class="panel panel-default">

	<form class="form-horizontal">
		<br />

		<!-- Cache Configuration(editable) -->
		<lacuna-editable-item on-save="saveSetting(key, value)" on-edit="editSetting('CacheConfiguration')">
			<item-label>
				{{ 'ssCacheConfiguration' | translate }}
			</item-label>
			<item-value>{{ 'cacheConfiguration_' + settings.CacheConfiguration | translate }}</item-value>
			<item-editor>
				<select class="form-control" ng-options="id as ('cacheConfiguration_' + id | translate) for id in cacheConfigurations" ng-model="$editor.data.value"></select>
			</item-editor>
		</lacuna-editable-item>
	</form>
</div>


<h2>{{ 'ssTasksStatus' | translate }}</h2>

<div ng-hide="tasksStatus" class="loading-panel panel">
</div>

<div ng-show="tasksStatus" class="panel panel-default">

	<br />
	<form class="form-horizontal">
		<div class="form-group">

			<label class="col-sm-4 control-label">
				<span ng-switch="tasksStatus.refreshTransactionCount.successful">
					<span class="label label-success" ng-switch-when="true">{{ 'ssTaskSuccessful' | translate }}</span>
					<span class="label label-warning" ng-switch-when="false">{{ 'ssTaskFailed' | translate }}</span>
				</span>
				{{ 'ssRefreshTransactionCount' | translate }}
			</label>
			<div ng-show="tasksStatus.refreshTransactionCount.lastExecution" class="col-sm-8">
				<p class="form-control-static">
					{{ 'ssLastExecution' | translate }}: {{ tasksStatus.refreshTransactionCount.lastExecution | date: 'yyyy-MM-dd HH:mm:ss' }}
				</p>
			</div>
			<div ng-hide="tasksStatus.refreshTransactionCount.lastExecution" class="col-sm-8">
				<p class="form-control-static">
					{{ 'ssUnavailable' | translate }}
				</p>
			</div>

		</div>

		<div class="form-group">
			<label class="col-sm-4 control-label">
				<span ng-switch="tasksStatus.refreshTransactionLimits.successful">
					<span class="label label-success" ng-switch-when="true">{{ 'ssTaskSuccessful' | translate }}</span>
					<span class="label label-warning" ng-switch-when="false">{{ 'ssTaskFailed' | translate }}</span>
				</span>
				{{ 'ssRefreshTransactionLimits' | translate }}
			</label>
			<div ng-show="tasksStatus.refreshTransactionLimits.lastExecution" class="col-sm-8">
				<p class="form-control-static">
					{{ 'ssLastExecution' | translate }}: {{ tasksStatus.refreshTransactionLimits.lastExecution | date: 'yyyy-MM-dd HH:mm:ss' }}
				</p>
			</div>
			<div ng-hide="tasksStatus.refreshTransactionLimits.lastExecution" class="col-sm-8">
				<p class="form-control-static">
					{{ 'ssUnavailable' | translate }}
				</p>
			</div>
		</div>
	</form>
</div>


<h2>{{ 'ssBlockchainSettings' | translate }}</h2>
<div ng-hide="settings" class="loading-panel panel">
</div>
<div ng-show="settings" class="panel panel-default">
	<form class="form-horizontal" name="timestampingForm">
		<br />
		<!-- BStamperUri Configuration(editable) -->
		<lacuna-editable-item on-save="saveSetting(key, value)" on-edit="editSetting('BStamperConfiguration')">
			<item-label>
				{{ 'ssHashBlockLocation' | translate }}
			</item-label>
			<item-value>{{ 'bStamperConfiguration_' + settings.BStamperConfiguration | translate }}</item-value>
			<item-editor>
				<select class="form-control" ng-options="id as ('bStamperConfiguration_' + id | translate) for id in bStamperConfigurations" ng-model="$editor.data.value"></select>
			</item-editor>
		</lacuna-editable-item>
		<!-- BStamperUri Uri Configuration (editable) -->
		<lacuna-editable-item on-save="saveStorageSetting(key, value)" on-edit="editSetting('BStamperUri')">
			<item-label>{{ 'ssBStamperUri' | translate }}</item-label>
			<item-value>
				<em class="text-muted" ng-show="settings.BStamperUri">{{ settings.BStamperUri }}</em>
				<em class="text-muted" ng-hide="settings.BStamperUri">{{ 'none' | translate }}</em>
			</item-value>
			<item-editor>
				<input type="text" class="form-control" ng-model="$editor.data.value">
			</item-editor>
		</lacuna-editable-item>
		<!-- BStamperApiKey Configuration (editable) -->
		<lacuna-editable-item on-save="saveStorageSetting(key, value)" on-edit="editSetting('BStamperApiKey')">
			<item-label>{{ 'ssBStamperApiKey' | translate }}</item-label>
			<item-value>
				<em class="text-muted" ng-show="settings.BStamperApiKey">{{ settings.BStamperApiKey }}</em>
				<em class="text-muted" ng-hide="settings.BStamperApiKey">{{ 'none' | translate }}</em>
			</item-value>
			<item-editor>
				<input type="text" class="form-control" ng-model="$editor.data.value">
			</item-editor>
		</lacuna-editable-item>
	</form>
</div>
