-
Notifications
You must be signed in to change notification settings - Fork 0
/
MaskMillQueue.html
executable file
·94 lines (75 loc) · 2.61 KB
/
MaskMillQueue.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
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="css/Mask.css">
<link rel="stylesheet" type="text/css" href="css/mui-style.css">
<script type="module" src="js/MaskTable.js"></script>
</head>
<h3>Masks in Mill Queue</h3>
<!-- Search bar / page number -->
<div id="searchBar" style="display: flex; justify-content: space-between; align-items: center;">
<div id="searchInputContainer">
<input type="text" id="searchInput" placeholder="Search Table..." />
<button id="submitTableSearch" onclick="searchTable()">Search Table</button>
</div>
<div id="pageSizeContainer">
<label for="pageSizeInput">Page Size (rows):</label>
<input type="number" id="pageSizeInput" value="10" min="1" onchange="updatePageSize()" />
</div>
</div>
<div style="overflow-x: auto; white-space: nowrap;">
<table class="mui-table mui-table--bordered" style="min-width: 100%;">
<thead class="tabHead">
<tr id="headerRow"></tr>
</thead>
<tbody id="GeneratedMaskTable"></tbody>
</table>
</div>
<div id="paginationContainer"></div>
<!--<script type="module">-->
<!-- import { displayTable } from './js/MaskTable.js';-->
<!-- import { setMenuOff } from './js/MaskTable.js';-->
<!-- setMenuOff();-->
<!-- const apiUrl = '/mill-queue';-->
<!-- displayTable(apiUrl);-->
<!--</script>-->
<script type="module">
import { displayTable } from './js/MaskTable.js';
import { setMenuOff } from './js/MaskTable.js';
let apiRootUrl;
// Fetch configuration to get the API root URL
fetch('js/MaskConfig.json')
.then(response => response.json())
.then(config => {
apiRootUrl = config.apiRootUrl;
queryApi(); // Once the config is loaded, check user type
})
.catch(error => {
alert(`Error reading configuration: ${error}`);
});
// Function to check if the user is an admin
function queryApi() {
if (!apiRootUrl) return;
const apiUrl = apiRootUrl + `/user-type`;
fetch(apiUrl, {
mode: 'cors',
credentials: 'include'
})
.then(response => response.json())
.then(info => {
const userType = info.data['user_type'];
const apiUrl = '/mill-queue';
if (userType !== "maskadmin") {
// setMenuOff only if the user is not an admin
setMenuOff();
displayTable(apiUrl);
} else {
let options = ['Edit Use Date', 'Archive', 'Plot', 'Details', 'ReMill', 'Fits File', 'Delete Barcode'];
displayTable(apiUrl, options);
}
})
.catch(error => {
alert(`Error fetching user type: ${error}`);
});
}
</script>