<div class="view-customize">
	<div class="backup-restore">
		<div class="backup-zone">
			{{#if session.isGlobalAdmin}}
				<p>
					Documize is a multi-tenanted application enabling both "tech.mycompany.com" and "sales.mycompany.com" to run using the same executable/database.
					As a Documize <b>Global Administrator</b>, you will be performing a complete system-wide backup across all tenants.
					A Documize <b>Tenant Administrator</b> can login to perform a tenant-level backup (e.g. marketing.mycompany.com).
				</p>
			{{else}}
				<p>
					Documize is a multi-tenanted application enabling both "tech.mycompany.com" and "sales.mycompany.com" to run using the same executable/database.
					A Documize <b>Global Administrator</b>, you will be performing a complete system-wide backup across all tenants.
					As a Documize <b>Tenant Administrator</b> you can perform a tenant-level backup (e.g. marketing.mycompany.com).
				</p>
			{{/if}}
			<p>Please use a Tenant Backup when migrating between self-host and Documize Cloud hosting.</p>
			<p>It can take <b>several minutes</b> to complete the backup process &mdash; please be patient while the backup operation is in progress.</p>

			<div class="margin-top-30 margin-bottom-20">
				{{#ui/ui-checkbox selected=backupSpec.retain}}
					Retain backup file on server
				{{/ui/ui-checkbox}}
			</div>

			{{#if backupRunning}}
				<h3 class="text-success">Backup running, please wait...</h3>
			{{else}}
				{{ui/ui-button color=constants.Color.Yellow light=true icon=constants.Icon.Database label=(concat "BACKUP TENANT (" appMeta.appHost ")") onClick=(action "onBackup")}}
				{{#if session.isGlobalAdmin}}
					{{ui/ui-button-gap}}
					{{ui/ui-button color=constants.Color.Yellow light=true icon=constants.Icon.Database label="BACKUP SYSTEM" onClick=(action "onSystemBackup")}}
				{{/if}}
			{{/if}}
			{{#if backupFailed}}
				<div class="backup-fail">Backup failed &mdash; please check server logs</div>
			{{/if}}
			{{#if backupSuccess}}
				<div class="backup-success">Backup successful ({{backupFilename}})</div>
			{{/if}}
		</div>
	</div>

	<div class="backup-restore">
		<div class="restore-zone">
			{{#if session.isGlobalAdmin}}
				<p>Restore from a <b>system backup</b> should only be performed on an <b>empty Documize database.</b></p>
			{{/if}}
			<p>Restore operation will <b>re-create</b> users, groups, permissions, spaces, categories and content.</p>
			<p>It can take <b>several minutes</b> to complete the restore process &mdash; please be patient while the restore operation is in progress.</p>

			<div class="margin-top-30 margin-bottom-20">
				<div class="custom-file">
					<input type="file" class="custom-file-input" id="restore-file" accept="application/zip" multiple="false" onchange={{action "upload"}}>
					<label class="custom-file-label" for="restore-file">Choose backup file</label>
				</div>
				<div class="margin-top-20"></div>
			</div>

			{{#if restoreFailed}}
				<div class="restore-fail">Restore failed &mdash; please check server logs</div>
			{{else if restoreSuccess}}
				<div class="restore-success">Restore completed &mdash; restart your browser and log in</div>
			{{else}}
				{{#if restoreUploadReady}}
					{{ui/ui-button color=constants.Color.Red light=false icon=constants.Icon.Database label=restoreButtonLabel onClick=(action "onShowRestoreModal")}}
				{{/if}}
			{{/if}}
		</div>
	</div>
</div>

<div id="confirm-restore-modal" class="modal" tabindex="-1" role="dialog">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">Confirm Restore</div>
			<div class="modal-body">
				<form onsubmit={{action "onRestore"}}>
					<div class="form-group">
						<label for="delete-space-name">Please type RESTORE to commence the process</label>
						{{input type="text" id="confirm-restore" class="form-control mousetrap" placeholder="Please type RESTORE" value=confirmRestore}}
						<small class="form-text text-muted">You should only restore to an empty Documize instance</small>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				{{ui/ui-button color=constants.Color.Gray light=true label=constants.Label.Cancel dismiss=true}}
				{{ui/ui-button-gap}}
				{{ui/ui-button color=constants.Color.Red light=true label=constants.Label.Restore onClick=(action "onRestore")}}
			</div>
		</div>
	</div>
</div>