{% extends "base.html" %}

{% block title %}
	Admin Tools
{% endblock %}

{% block content %}
	<div class="row">
		<div class="col-md-6">
			<div class="list-group">
				<a class="list-group-item list-group-item-action" href="{{ url_for('users.list_all') }}">User list</a>
				<a class="list-group-item list-group-item-action" href="{{ url_for('admin.tag_list') }}">Tag Editor</a>
				<a class="list-group-item list-group-item-action" href="{{ url_for('admin.license_list') }}">License Editor</a>
				<a class="list-group-item list-group-item-action" href="{{ url_for('admin.version_list') }}">Version Editor</a>
				<a class="list-group-item list-group-item-action" href="{{ url_for('admin.warning_list') }}">Warning Editor</a>
				<a class="list-group-item list-group-item-action" href="{{ url_for('admin.send_bulk_email') }}">Send bulk email</a>
				<a class="list-group-item list-group-item-action" href="{{ url_for('admin.send_bulk_notification') }}">Send bulk notification</a>
				<a class="list-group-item list-group-item-action" href="{{ url_for('admin.switch_user') }}">Sign in as another user</a>
			</div>
		</div>

		<div class="col-md-6">
			<div class="card mb-4">
				<h2 class="card-header">Do action</h2>

				<form method="post" action="" class="card-body">
					<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
					<div class="row px-3">
						<select name="action" class="custom-select col">
							{% for id, action in actions.items() %}
								<option value="{{ id }}" {% if loop.first %}selected{% endif %}>
									{{ action["title"] }}
								</option>
							{% endfor %}
						</select>
						<input type="submit" value="Perform" class="col-sm-auto btn btn-primary ml-2" />
					</div>
				</form>
			</div>

			<div class="card">
				<h2 class="card-header">Restore Package</h2>

				<form method="post" action="" class="card-body">
					<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
					<input type="hidden" name="action" value="restore" />
					<div class="row px-3">
						<select name="package" class="custom-select col">
							{% for p in deleted_packages %}
								<option value={{ p.id }}>{{ p.id}}) {{ p.title }} by {{ p.author.display_name }}</option>
							{% endfor %}
						</select>
						<input type="submit" value="Restore" class="col-sm-auto btn btn-primary ml-2" />
					</div>
				</form>

				<form method="post" action="" class="card-body">
					<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
					<input type="hidden" name="action" value="delremovedpackages" />

					<p>
						{{ _("Deletion is permanent.") }}
					</p>

					<input type="submit" value="Delete Removed Packages" class="btn btn-danger" />
				</form>
			</div>
		</div>
	</div>
{% endblock %}