-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaskDelete.html
executable file
·121 lines (102 loc) · 3.08 KB
/
MaskDelete.html
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
<body>
<h3>Slitmask Barcode Delete</h3>
<br><br>
<table>
<tr>
<th>Mask Barcode</th>
<th> - </th>
<th>Mask Design Id</th>
<th> - </th>
<th>Mask Blueprint Id</th>
<th> - </th>
<th>Mask Design Name</th>
<th> - </th>
<th>Current Use Date</th>
<th> - </th>
<th>Mask Status</th>
</tr>
<tr>
<td align="center"><div id="barcode-id"></div></td>
<td> - </td>
<td align="center"><div id="design-id"></div></td>
<td> - </td>
<td align="center"><div id="blue-id"></div></td>
<td> - </td>
<td align="center"><div id="design-name-id"></div></td>
<td> - </td>
<td align="center"><div id="use-date-id"></div></td>
<td> - </td>
<td align="center"><div id="mask-status-id"></div></td>
</tr>
</table>
<br><br>
<div id="loadingIndicator" style="display: none;">
<div class="spinner-border" role="status">
<span class="visually-hidden">Loading...</span>
</div>
</div>
<h4>Delete a barcode from the database. Deleting a mask will remove the
Mask table that is associated with the mask-id (barcode). The purpose
of this functionality is if two or more barcodes have been scanned for a mask.</h4> <br>
<input type="input" id="barcode-to-delete" name="barcode-to-delete" placeholder="Barcode Number"> <br><br>
<form>
<button type="button" id="downloadBtn" onclick="deleteBarcode()">Delete Barcode</button>
</form>
<script>
let apiRootUrl;
let blueId;
function deleteBarcode() {
let apiUrl = `${apiRootUrl}/delete-mask`;
let maskId = document.getElementById("barcode-to-delete").value;
let fullUrl;
if (maskId === "") {
alert('No barcode (maskid) associated with mask design! Please enter a valid Barcode.');
return;
} else {
fullUrl = `${apiUrl}?mask-id=${maskId}&blue-id=${blueId}`;
}
// Disable the button
const downloadBtn = document.getElementById('downloadBtn');
downloadBtn.disabled = true;
showLoadingIndicator();
fetch(fullUrl, {
mode: 'cors',
credentials: 'include'
})
.then(response => {
if (response.status === 422) {
return response.json().then(data => {
throw new Error("Invalid Parameters: " + data.error || "Unknown error occurred.");
});
} else if (!response.ok) {
return response.json().then(data => {
throw new Error("Error: " + data.error || "Unknown error occurred.");
});
} else {
return response.json();
}
})
.then(data => {
if (data.success === 1) {
alert(data.data.msg);
window.addEventListener('focus', reloadPage);
} else {
throw new Error("Error: " + data.data.error + "\n" + data.data.msg);
}
})
.catch(error => {
alert(`${error}`);
})
.finally(() => {
// Enable the button again
downloadBtn.disabled = false;
// Hide loading indicator
hideLoadingIndicator();
});
}
// expose the deleteBarcode to be used in index.html
window.onload = deleteBarcode;
// load the Date-Use and Design ID
window.onload = loadParams();
</script>
</body>