add new export actions erasure
This commit is contained in:
parent
b006ec1973
commit
47736c8679
|
@ -901,6 +901,43 @@ class ExportsView(View):
|
||||||
|
|
||||||
def actions_erasures(self):
|
def actions_erasures(self):
|
||||||
data = StringIO()
|
data = StringIO()
|
||||||
|
cw = csv.writer(
|
||||||
|
data,
|
||||||
|
delimiter=';',
|
||||||
|
lineterminator="\n",
|
||||||
|
quotechar='"',
|
||||||
|
quoting=csv.QUOTE_ALL,
|
||||||
|
)
|
||||||
|
|
||||||
|
cw.writerow(
|
||||||
|
[
|
||||||
|
'Data Storage Serial',
|
||||||
|
'Snapshot ID',
|
||||||
|
'Type of Erasure',
|
||||||
|
'PHID Erasure Host',
|
||||||
|
'Result',
|
||||||
|
'Time',
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
args = request.args.get('ids')
|
||||||
|
ids = args.split(',') if args else []
|
||||||
|
|
||||||
|
query = EraseBasic.query.filter_by(author=g.user)
|
||||||
|
query = query.filter(EraseBasic.id.in_(ids))
|
||||||
|
query = query.order_by(EraseBasic.created.desc())
|
||||||
|
|
||||||
|
for ac in query:
|
||||||
|
row = [
|
||||||
|
ac.device.serial_number.upper(),
|
||||||
|
ac.snapshot.uuid,
|
||||||
|
ac.type,
|
||||||
|
ac.get_phid(),
|
||||||
|
ac.severity,
|
||||||
|
ac.created.strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
|
]
|
||||||
|
cw.writerow(row)
|
||||||
|
|
||||||
return self.response_csv(data, "Erasures.csv")
|
return self.response_csv(data, "Erasures.csv")
|
||||||
|
|
||||||
def build_erasure_certificate(self):
|
def build_erasure_certificate(self):
|
||||||
|
|
|
@ -322,6 +322,19 @@ function export_file(type_file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function export_actions_erasure(type_file) {
|
||||||
|
const actions = TableController.getSelectedDevices();
|
||||||
|
const actions_id = $.map(actions, (x) => $(x).attr("data-action-erasure")).join(",");
|
||||||
|
|
||||||
|
if (actions_id) {
|
||||||
|
const url = `/inventory/export/${type_file}/?ids=${actions_id}`;
|
||||||
|
window.location.href = url;
|
||||||
|
} else {
|
||||||
|
$("#exportAlertModal").click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class lotsSearcher {
|
class lotsSearcher {
|
||||||
static enable() {
|
static enable() {
|
||||||
if (this.lotsSearchElement) this.lotsSearchElement.disabled = false;
|
if (this.lotsSearchElement) this.lotsSearchElement.disabled = false;
|
||||||
|
|
|
@ -308,6 +308,17 @@ function export_file(type_file) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function export_actions_erasure(type_file) {
|
||||||
|
const actions = TableController.getSelectedDevices();
|
||||||
|
const actions_id = $.map(actions, (x) => $(x).attr("data-action-erasure")).join(",");
|
||||||
|
if (actions_id) {
|
||||||
|
const url = `/inventory/export/${type_file}/?ids=${actions_id}`;
|
||||||
|
window.location.href = url;
|
||||||
|
} else {
|
||||||
|
$("#exportAlertModal").click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class lotsSearcher {
|
class lotsSearcher {
|
||||||
static lots = [];
|
static lots = [];
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
<span class="d-none" id="exportAlertModal" data-bs-toggle="modal" data-bs-target="#exportErrorModal"></span>
|
<span class="d-none" id="exportAlertModal" data-bs-toggle="modal" data-bs-target="#exportErrorModal"></span>
|
||||||
<ul class="dropdown-menu" aria-labelledby="btnExport">
|
<ul class="dropdown-menu" aria-labelledby="btnExport">
|
||||||
<li>
|
<li>
|
||||||
<a href="javascript:export_file('actions_erasures')" class="dropdown-item">
|
<a href="javascript:export_actions_erasure('actions_erasures')" class="dropdown-item">
|
||||||
<i class="bi bi-file-spreadsheet"></i>
|
<i class="bi bi-file-spreadsheet"></i>
|
||||||
Data Storage Spreadsheet
|
Data Storage Spreadsheet
|
||||||
</a>
|
</a>
|
||||||
|
@ -64,6 +64,7 @@
|
||||||
<input type="checkbox" class="deviceSelect" data="{{ ac.device.id }}"
|
<input type="checkbox" class="deviceSelect" data="{{ ac.device.id }}"
|
||||||
data-device-type="{{ ac.device.type }}" data-device-manufacturer="{{ ac.device.manufacturer }}"
|
data-device-type="{{ ac.device.type }}" data-device-manufacturer="{{ ac.device.manufacturer }}"
|
||||||
data-device-dhid="{{ ac.device.dhid }}" data-device-vname="{{ ac.device.verbose_name }}"
|
data-device-dhid="{{ ac.device.dhid }}" data-device-vname="{{ ac.device.verbose_name }}"
|
||||||
|
data-action-erasure="{{ ac.id }}"
|
||||||
{% if form_new_allocate.type.data and ac.device.id in list_devices %}
|
{% if form_new_allocate.type.data and ac.device.id in list_devices %}
|
||||||
checked="checked"
|
checked="checked"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -90,7 +91,7 @@
|
||||||
<td>
|
<td>
|
||||||
{{ ac.severity }}
|
{{ ac.severity }}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ ac.created.strftime('%Y-%m-%d %H:%M:%S')}}</td>
|
<td>{{ ac.created.strftime('%Y-%m-%d %H:%M:%S') }}</td>
|
||||||
<td>
|
<td>
|
||||||
<a href="{{ url_for('inventory.export', export_id='snapshot') }}?id={{ ac.snapshot.uuid }}">
|
<a href="{{ url_for('inventory.export', export_id='snapshot') }}?id={{ ac.snapshot.uuid }}">
|
||||||
<i class="bi bi-box-arrow-up-right"></i>
|
<i class="bi bi-box-arrow-up-right"></i>
|
||||||
|
|
Reference in New Issue