summaryrefslogtreecommitdiffstats
path: root/modules-available/dozmod/templates/images-delete.html
blob: 5bbebdc336f4ec24de68d3afcf41c29989a6641c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<h1>{{lang_bwlehrpoolsuite}}</h1>

<div class="panel panel-default">
	<div class="panel-heading">
		{{lang_deleteExpiredHeading}}
	</div>
	<div class="panel-body">
		<p>{{lang_description_delete_images}}</p>
		<div class="table-responsive">
			<form id="delform" method="post" action="?do=dozmod">
				<input type="hidden" name="token" value="{{token}}">
				<input type="hidden" name="section" value="expiredimages">
				<input type="hidden" name="action" value="delimages">
				<table class="table table-stripped table-condensed stupidtable">
					<thead>
					<tr>
						<th data-sort="string">{{lang_image}}</th>
						<th data-sort="int">{{lang_version}}</th>
						<th data-sort="string">{{lang_owner}}</th>
						<th><span class="glyphicon glyphicon-upload" title="{{lang_hasNewer}}"></span></th>
						<th data-sort="int">{{lang_size}}</th>
						<th>
							<div class="checkbox">
								<input id="del-all" type="checkbox">
								<label for="del-all"></label>
								<span class="glyphicon glyphicon-trash" title="{{lang_delete}}"></span>
							</div>
						</th>
					</tr>
					</thead>
					<tbody>
					{{#images}}
					<tr>
						<td class="text-left text-nowrap {{name_extra_class}}">{{displayname}}<br><span class="small">{{imageversionid}}</span>
						</td>
						<td class="text-left text-nowrap" data-sort-value="{{createtime}}">{{version}}</td>
						<td class="text-left text-nowrap"><a href="?do=dozmod&amp;section=actionlog&amp;action=showuser&amp;uuid={{userid}}">{{lastname}}, {{firstname}}</a></td>
						<td class="text-left text-nowrap"><span class="glyphicon {{hasNewerClass}}"></span></td>
						<td class="text-left text-nowrap" data-sort-value="{{rawfilesize}}">{{filesize}}</td>
						<td>
							<div class="checkbox">
								<input type="checkbox" id="images[{{imageversionid}}]" class="del-check"
										 name="images[{{imageversionid}}]" {{checked}}>
								<label for="images[{{imageversionid}}]"></label>
							</div>
						</td>
					</tr>
					{{/images}}
					</tbody>
				</table>
				<button {{perm.expiredimages.delete.disabled}} id="expired-delete"
						  class="btn btn-danger pull-right" type="submit">
					<span class="glyphicon glyphicon-trash"></span>
					{{lang_delButton}}
				</button>
			</form>
			<pre style="display:none" id="deloutput"></pre>
		</div>
	</div>
</div>

<div class="panel panel-default">
	<div class="panel-heading">
		{{lang_orphanedFilesHeading}}
	</div>
	<div class="panel-body">
		<p>{{lang_orphanedFilesDesc}}</p>
		<div id="orphan-ajax">
			<button {{perm.orphaned.scan.disabled}} id="orphan-scan"
					  class="btn btn-default pull-right" type="button">
				<span class="glyphicon glyphicon-search"></span>
				{{lang_scanButton}}
			</button>
		</div>
	</div>
</div>

<div class="hidden" id="confirm-orphan-delete">
	{{lang_confirmDeleteOrphanedFiles}}
</div>

<script type="text/javascript"><!--

document.addEventListener("DOMContentLoaded", function () {
	$('#del-all').click(function () {
		if ($(this).is(':checked')) {
			$('.del-check').prop('checked', true);
		} else {
			$('.del-check').prop('checked', false);
		}
	});
	var slxChangeSingle = function () {
		var ons = 0;
		var offs = 0;
		$('.del-check').each(function (idx, elem) {
			if (elem.checked) {
				ons++;
			} else {
				offs++;
			}
		});
		// TODO indeterminate doesn't work with styled checkbox
		$('#del-all').prop('checked', offs === 0).prop('indeterminate', ons > 0 && offs > 0);
	};
	$('.del-check').click(slxChangeSingle);
	slxChangeSingle();
	// Handler for delete expired images button
	var delform = $('#delform');
	delform.submit(function (e) {
		e.preventDefault();
		$('#expired-delete').prop('disabled', true);
		$.post('?do=dozmod', delform.serialize()).done(function (data) {
			$('#deloutput').text(data).css('display', '');
		}).fail(function () {
			$('#deloutput').text('ERROR').css('display', '');
		});
	});
	// Handler for scanning/deleting orphaned files
	var slxOrphans = function (del) {
		$.post('?do=dozmod', {
			token: TOKEN, section: 'expiredimages', action: 'orphaned', delete: del
		}).done(function (data) {
			$('#orphan-ajax').html(data).find('#orphan-delete')
				.click(slxModalConfirmHandler)
				.click(function () {
					slxOrphans(1);
				});
		}).fail(function () {
			$('#orphan-ajax').text('ERROR');
		});
	};
	// Handler for scanning for orphaned files
	$('#orphan-scan').click(function () {
		$('#orphan-scan').prop('disabled', true);
		slxOrphans(0);
	});
	window.addEventListener('unload', function () {
		// Do something here that forces browsers to throw away any JS state on nav.back
		$('input[type=checkbox]').prop('checked', false);
	});
}, false);

//--> </script>