Skip to content

Commit 621e47b

Browse files
authored
Merge pull request #136 from biothings/snapshot-cleanup
Cleanup Modal Update
2 parents bebc80c + 8b952a8 commit 621e47b

File tree

1 file changed

+62
-29
lines changed

1 file changed

+62
-29
lines changed

webapp/src/Cleanup.vue

+62-29
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,27 @@
2222
<!-- Actions Panel -->
2323
<div class="ui grid">
2424
<div class="row">
25-
<div class="four wide column">
26-
<button class="ui button delete-snapshots" @click="delete_snapshots($event)"
27-
data-content="You must choose at least one snapshot to delete">
28-
<i></i> Delete
29-
</button>
30-
<button class="ui button validate-snapshots" @click="validate_snapshots($event)">
31-
<i class="sync icon"></i> Validate
25+
<div class="five wide column">
26+
<div class="ui buttons">
27+
<div class="ui labeled icon button delete-snapshots" data-tooltip="Delete selected snapshots"
28+
v-on:click="delete_snapshots($event)">
29+
<i class="trash icon"></i>Delete
30+
</div>
31+
<div class="ui floating dropdown icon button button-spacing">
32+
<i class="dropdown icon"></i>
33+
<div class="menu">
34+
<div class="ui checkbox item"
35+
data-tooltip="Delete will ignore errors related to the environment"
36+
data-position="bottom center">
37+
<input type="checkbox" v-model="ignoreErrors" />
38+
<label>Ignore Env Errors</label>
39+
</div>
40+
</div>
41+
</div>
42+
</div>
43+
<button class="ui labeled icon button validate-snapshots" @click="validate_snapshots($event)"
44+
data-tooltip="Confirm that the snapshots exist in the S3 bucket">
45+
<i class="sync icon"></i>Validate
3246
</button>
3347
</div>
3448
<div class="ten wide column">
@@ -104,8 +118,8 @@
104118
</thead>
105119

106120
<tbody>
107-
<template v-for="build_config_snapshots in snapshots" v-bind="snapshots">
108-
<tr>
121+
<template v-for="build_config_snapshots in snapshots">
122+
<tr :key="'build-config-' + build_config_snapshots._id">
109123
<td colspan="5">
110124
<div class="ui checkbox checkbox-popup" title="Select all snapshots for this build config">
111125
<input type="checkbox" @click="toggleAllSnapshots($event, build_config_snapshots._id)">
@@ -114,7 +128,7 @@
114128
</td>
115129
</tr>
116130

117-
<tr v-for="snapshot_data in build_config_snapshots.items" v-bind="build_config_snapshots">
131+
<tr v-for="snapshot_data in build_config_snapshots.items" :key="'snapshot-' + snapshot_data._id">
118132
<td>
119133
<div class="ui checkbox">
120134
<input class="checkbox-snapshot" type="checkbox"
@@ -164,7 +178,6 @@ export default {
164178
onShow: function () {
165179
self.resetMessages();
166180
self.loadData();
167-
$(".checkbox-popup").popup();
168181
}
169182
});
170183
@@ -196,6 +209,7 @@ export default {
196209
snapshots_error: null,
197210
snapshots_validated: 0,
198211
show_snapshots_validated: false,
212+
ignoreErrors: false,
199213
}
200214
},
201215
methods: {
@@ -273,6 +287,18 @@ export default {
273287
self.environments.add(snapshot.environment)
274288
})
275289
})
290+
291+
self.$nextTick(function () {
292+
// Re-initialize the checkboxes
293+
$('.ui.checkbox').checkbox();
294+
295+
// Re-initialize the popups
296+
$(".checkbox-popup").popup({
297+
boundary: '.table-container',
298+
scrollContext: '.table-container',
299+
});
300+
});
301+
276302
self.loaded()
277303
})
278304
.catch(err => {
@@ -294,23 +320,22 @@ export default {
294320
}
295321
},
296322
delete_snapshots(event) {
297-
const self = this
323+
const self = this;
298324
this.resetMessages();
299-
const $checked_snapshots = $(".checkbox-snapshot:checked")
325+
const $checked_snapshots = $(".checkbox-snapshot:checked");
300326
if ($checked_snapshots.length == 0) {
301-
$(event.target).popup("show")
302-
return
327+
$(event.target).popup("show");
328+
return;
303329
}
304330
305-
self.loading()
331+
self.loading();
306332
307333
const cmd = function () {
308-
const data = { snapshots_data: {} };
334+
const data = { snapshots_data: {}, ignoreErrors: self.ignoreErrors };
309335
$checked_snapshots.map((_, element) => {
310336
const name = $(element).data("snapshotName");
311337
let environment = $(element).data("environment");
312338
313-
// Handle undefined environment
314339
if (environment === undefined) {
315340
environment = "__no_env__";
316341
}
@@ -321,22 +346,26 @@ export default {
321346
data.snapshots_data[environment].push(name);
322347
});
323348
324-
325-
return axios.put(axios.defaults.baseURL + '/delete_snapshots', data)
326-
}
349+
return axios.put(axios.defaults.baseURL + '/delete_snapshots', data);
350+
};
327351
328352
const onSuccess = function (response) {
329-
console.log('Snapshots deleted: ' + response.data.result)
330-
self.loadData()
331-
}
353+
console.log('Snapshots deleted: ' + response.data.result);
354+
self.loadData();
355+
356+
self.$nextTick(() => {
357+
$('.ui.checkbox').checkbox();
358+
});
359+
};
332360
333361
const onError = function (err) {
334-
self.loaderror("Error when deleting snapshots", err)
335-
console.error('Failed delete snapshots: ' + err)
336-
}
362+
self.loaderror("Error when deleting snapshots", err);
363+
console.error('Failed delete snapshots: ' + err);
364+
};
337365
338-
this.launchAsyncCommand(cmd, onSuccess, onError)
366+
this.launchAsyncCommand(cmd, onSuccess, onError);
339367
},
368+
340369
getBucketName(snapshot_data) {
341370
if (
342371
snapshot_data.conf &&
@@ -421,7 +450,6 @@ export default {
421450
const errorMessage = results.errors.join('<br>');
422451
this.snapshots_error = `<div class="text red"><b>Validation completed with errors</b><br>${errorMessage}</div>`;
423452
} else {
424-
// Successful validation
425453
this.snapshots_error = `<div class="text green"><b>Validation completed successfully</b><br>${snapshotsDeleted} snapshots were removed during validation.</div>`;
426454
}
427455
this.loadData(true);
@@ -481,6 +509,7 @@ export default {
481509
max-height: 60vh;
482510
overflow-y: auto;
483511
margin-top: 5px;
512+
position: relative;
484513
}
485514
486515
.cleanup.modal {
@@ -502,4 +531,8 @@ export default {
502531
border: 1px solid #e0b4b4;
503532
border-radius: 5px;
504533
}
534+
535+
.button-spacing {
536+
margin-right: 10px !important;
537+
}
505538
</style>

0 commit comments

Comments
 (0)