-
Notifications
You must be signed in to change notification settings - Fork 0
/
StorageLayoutMapper.html
426 lines (412 loc) · 19.9 KB
/
StorageLayoutMapper.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
<html>
<head>
<title>Storage Layout Mapper Page</title>
<style>
body {
background-color:black;
color: white;
}
</style>
<!-- <base href="https://AvengerMoJo.github.io/" target="_blank"> -->
<meta charset="UTF-8">
<meta name="description" content="Storage Layout Mapping tool.">
<meta name="keywords" content="AvengerMoJo, Storage, Layout, Mapping">
<meta name="author" content="AvengerMoJo">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script>
function updateURL() {
//const queryString = window.location.search;
var server_name, boxtype, server_u, customx, customy,
drive_slot, drive_row, drive_col, drive_type, orientation, drives_type;
var server_info_completed = true;
const params = new URLSearchParams( window.location.search );
if( params.get("ServerModelName") != null ) {
document.getElementById("ServerModelName").value = server_name = params.get("ServerModelName");
} else {
server_info_completed = false;
}
if( params.get("BoxType") != null ) {
let shs = document.getElementById("ServerHeightDisplay");
let customxy = document.getElementById("CustomXY");
document.getElementById("BoxType").value = boxtype = params.get("BoxType");
if( boxtype == "Custom" ) {
document.getElementById("CustomX").value = customx = +params.get("CustomX");
document.getElementById("CustomY").value = customy = +params.get("CustomY");
customxy.style.display="initial";
shs.style.display = "none";
} else if( boxtype == "Rackmount" || boxtype == "Tower" ) {
if( params.get("ServerHeight") ){
document.getElementById("ServerHeight").value = document.getElementById("ServerHeightSelect").value = server_u = params.get("ServerHeight");
shs.style.display = "initial";
customxy.style.display="none";
} else {
server_info_completed = false;
}
}
} else {
server_info_completed = false;
}
if( params.get("TotalDrive") ){
document.getElementById("TotalDrive").value = document.getElementById("TotalDriveText").value = drive_slot = params.get("TotalDrive");
} else {
server_info_completed = false;
}
if( params.get("DriveRow") ){
document.getElementById("DriveRow").value = document.getElementById("DriveRowSelect").value = drive_row = params.get("DriveRow");
} else {
server_info_completed = false;
}
if( params.get("DriveCol") ){
document.getElementById("DriveCol").value = document.getElementById("DriveColSelect").value = drive_col = params.get("DriveCol");
} else {
server_info_completed = false;
}
if( params.get("DriveOrientation") ){
document.getElementById("DriveOrientation").value = orientation = params.get("DriveOrientation");
} else {
server_info_completed = false;
}
if( params.get("DriveType") ) {
document.getElementById("DriveType").value = drive_type = params.get("DriveType");
drives_type = new Array(drive_slot);
for(let i=0; i< drive_slot; i++ ){
drives_type[i]= drive_type;
}
} else {
server_info_completed = false;
}
if( server_info_completed ) {
clear(draw);
if( boxtype == "Custom" ) {
server_obj = drawDriveLayout(draw, server_name, boxtype, drive_slot, drive_row, drive_col, drives_type, orientation, undefined, customx, customy, 5, 5);
}
else if ( boxtype == "Rackmount" || boxtype == "Tower" ) {
server_obj = drawDriveLayout(draw, server_name, boxtype, drive_slot, drive_row, drive_col, drives_type, orientation, server_u, undefined, undefined, 5, 5);
}
}
}
window.onload=updateURL;
</script>
<script type="module" crossorigin src="https://avengermojo.github.io/assets/storage.ec424dc4.js"></script>
<link rel="modulepreload" href="https://avengermojo.github.io/assets/vendor.ec54b159.js">
<link rel="stylesheet" href="https://avengermojo.github.io/assets/storage.7824debe.css">
</head>
<body>
<h1>Storage Drive Layout Configurator</h1>
<div class="setting" id="setting">
<div class="ServerModel">
<p>Server Model Name:
<input width=100% type="text" value="<name>" class="ServerModelName" id="ServerModelName"/>
</p>
</div>
<div class="BoxTypeDisplay" id="BoxTypeDisplay">
<p>Server Chassis Type:
<select name="BoxType" id="BoxType">
<option value="Rackmount">Rackmount</option>
<option value="Tower">Tower</option>
<option value="Custom">Custom</option>
</select>
</p>
<div name="CustomXY" id="CustomXY" style="display:none">
<p>Custom Width: <input type="number" class="CustomX" id="CustomX" value=40>mm (millimeter)</p>
<p>Custom Height: <input type="number" class="CustomY" id="CustomY" value=40>mm (millimeter)</p>
<script>
var server_type = document.getElementById("BoxType");
server_type.oninput = function() {
let customxy = document.getElementById("CustomXY");
let shs = document.getElementById("ServerHeightDisplay");
if( server_type.value == "Custom" ){
customxy.style.display = "initial";
shs.style.display = "none";
} else {
customxy.style.display="none";
shs.style.display ="initial";
}
}
</script>
</div>
</div>
<div class="ServerHeightDisplay" id="ServerHeightDisplay">
<p>Server Height:
<select name="ServerHeightSelect" id="ServerHeightSelect">
<option value="1">1U</option>
<option value="2">2U</option>
<option value="3">3U</option>
<option value="4">4U</option>
<option value="5">5U</option>
<option value="6">6U</option>
<option value="7">7U</option>
<option value="8">8U</option>
</select>
<input width=100% type="range" min="1" max="8" value="1" class="slider" id="ServerHeight">
<script>
var server_height_slider = document.getElementById("ServerHeight");
var server_height_select = document.getElementById("ServerHeightSelect");
server_height_select.value = server_height_slider.value;
server_height_slider.oninput = function() {
server_height_select.value = server_height_slider.value;
}
server_height_select.oninput = function() {
server_height_slider.value = server_height_select.value;
}
</script>
</p>
</div>
<div class="DriveRowDisplay">
<p>Drive Row Number:
<select name="DriveRowSelect" id="DriveRowSelect">
<option value="1">1 Row</option>
<option value="2">2 Row</option>
<option value="3">3 Row</option>
<option value="4">4 Row</option>
<option value="5">5 Row</option>
<option value="6">6 Row</option>
<option value="7">7 Row</option>
<option value="8">8 Row</option>
</select>
<input width=100% type="range" min="1" max="8" value="1" class="slider" id="DriveRow">
<script>
var drive_row_slider = document.getElementById("DriveRow");
var drive_row_select = document.getElementById("DriveRowSelect");
drive_row_select.value= drive_row_slider.value;
drive_row_slider.oninput = function() {
drive_row_select.value = drive_row_slider.value;
}
drive_row_select.oninput = function() {
drive_row_slider.value = drive_row_select.value;
}
</script>
</p>
</div>
<div class="DriveCol">
<p>Drive Column Number:
<select name="DriveColSelect" id="DriveColSelect">
<option value="1">1 Column</option>
<option value="2">2 Column</option>
<option value="3">3 Column</option>
<option value="4">4 Column</option>
<option value="5">5 Column</option>
<option value="6">6 Column</option>
<option value="7">7 Column</option>
<option value="8">8 Column</option>
<option value="9">9 Column</option>
<option value="10">10 Column</option>
<option value="11">11 Column</option>
<option value="12">12 Column</option>
<option value="13">13 Column</option>
<option value="14">14 Column</option>
<option value="15">15 Column</option>
<option value="16">16 Column</option>
<option value="17">17 Column</option>
<option value="18">18 Column</option>
<option value="19">19 Column</option>
<option value="20">20 Column</option>
<option value="21">21 Column</option>
<option value="22">22 Column</option>
<option value="23">23 Column</option>
<option value="24">24 Column</option>
</select>
<input width=100% type="range" min="1" max="24" value="1" class="slider" id="DriveCol">
<script>
var drive_col_slider = document.getElementById("DriveCol");
var drive_col_select = document.getElementById("DriveColSelect");
drive_col_select.value = drive_col_slider.value;
drive_col_slider.oninput = function() {
drive_col_select.value = drive_col_slider.value;
}
drive_col_select.oninput = function() {
drive_col_slider.value = drive_col_select.value;
}
</script>
</p>
</div>
<div class="TotalDrive">
<p>Total Drive Number:
<input type="text" class="TotalDriveText" id="TotalDriveText" value="1">
<input width=100% type="range" min="1" max="120" value="1" class="slider" id="TotalDrive">
<script>
var total_driver_slider = document.getElementById("TotalDrive");
var total_driver_text= document.getElementById("TotalDriveText");
total_driver_text.value = total_driver_slider.value;
total_driver_slider.oninput = function() {
total_driver_text.value = total_driver_slider.value;
}
total_driver_text.oninput = function() {
total_driver_slider.value = total_driver_text.value;
}
</script>
</p>
</div>
<div class="DriveType">
<p>Hard Drive Type:
<select name="DriveType" id="DriveType">
<option value="3.5' HDD">3.5' HDD</option>
<option value="2.5' HDD">2.5' HDD</option>
<option value="2.5' HDD">2.5' SSD</option>
<option value="NVMe">NVMe</option>
</select>
</p>
</div>
<div class="DriveOrientation">
<p>Hard Drive Orientation:
<select name="DriveOrientation" id="DriveOrientation">
<option value="Vertical">Vertical</option>
<option value="Horizontal">Horizontal</option>
<option value="Others">Others</option>
</select>
</p>
</div>
<div id="Draw" class="Draw">
<button onclick="window.call('SVG')">Draw</button>
<script>
function call(graphtype) {
const url = new URL( window.location );
server_name = document.getElementById("ServerModelName").value;
url.searchParams.set("ServerModelName", server_name);
boxtype = document.getElementById("BoxType").value;
url.searchParams.set("BoxType", boxtype);
if( boxtype == "Custom" ) {
customx = +document.getElementById("CustomX").value;
url.searchParams.set("CustomX", customx);
customy = +document.getElementById("CustomY").value;
url.searchParams.set("CustomY", customy);
url.searchParams.delete("ServerHeight");
} else if( boxtype == "Rackmount" || boxtype == "Tower" ) {
server_u = +document.getElementById("ServerHeight").value;
url.searchParams.set("ServerHeight", server_u);
url.searchParams.delete("CustomX");
url.searchParams.delete("CustomY");
}
drive_slot = document.getElementById("TotalDrive").value;
url.searchParams.set("TotalDrive", drive_slot);
drive_row = document.getElementById("DriveRow").value;
url.searchParams.set("DriveRow", drive_row);
drive_col = document.getElementById("DriveCol").value;
url.searchParams.set("DriveCol", drive_col);
drive_type = document.getElementById("DriveType").value;
url.searchParams.set("DriveType", drive_type);
drives_type = new Array(drive_slot);
for( i=0; i< drive_slot; i++ ){
// console.log( "TotalDrive " + drive_slot + "Drive Type =" + drive_type )
drives_type[i]= drive_type;
}
orientation = document.getElementById("DriveOrientation").value;
url.searchParams.set("DriveOrientation", orientation);
if( graphtype == "SVG" ) {
clear(draw);
if( boxtype == "Custom" ) {
server_obj = drawDriveLayout(draw, server_name, boxtype, drive_slot, drive_row, drive_col, drives_type, orientation, undefined, customx, customy, 5, 5);
} else {
server_obj = drawDriveLayout(draw, server_name, boxtype, drive_slot, drive_row, drive_col, drives_type, orientation, server_u, undefined, undefined, 5, 5);
}
} else if( graphtype == "Diagrams-Shape" ) {
if( boxtype == "Custom" ) {
server_obj = drawDriveLayout(draw, server_name, boxtype, drive_slot, drive_row, drive_col, drives_type, orientation, undefined, customx, customy, 5, 5);
diaShapeDraw(server_obj);
} else {
server_obj = drawDriveLayout(draw, server_name, boxtype, drive_slot, drive_row, drive_col, drives_type, orientation, server_u, undefined, undefined, 5, 5);
diaShapeDraw(server_obj);
}
}
window.history.pushState({}, "", url);
}
</script>
<div id="Download" class="Download">
<input width=100% type="text" min="1" max="60" value="sample.svg" class="Filename" id="Filename">
<button onclick="window.download()">Download</button>
<script>
function download() {
var filename = document.getElementById("Filename").value;
downloadString( draw.svg(), "text/csv", filename);
}
</script>
</div>
</div>
</div>
<div id="tab" class="tab">
<script>
function switchTab(theEvent, tabName) {
var i, tabview, tablinks;
tabview = document.getElementsByClassName("tabview");
for (i = 0; i < tabview.length; i++) {
tabview[i].style.display = "none";
}
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
document.getElementById(tabName).style.display = "block";
theEvent.currentTarget.className += " active";
}
function updateColorTab(){
var elements = document.getElementsByClassName('HardDrive');
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var select_hd_id = document.getElementById("HardDriveID");
select_hd_id.options[ select_hd_id.options.length ] = new Option(element.id, element.id);
}
}
</script>
<button class="tablinks" onclick="switchTab(event, 'Json')">JSON</button>
<button class="tablinks" onclick="switchTab(event, 'diagrams.net')">diagrams.net</button>
<button class="tablinks" onclick="switchTab(event, 'ColorTab');updateColorTab();">Color Change</button>
<div id="Json" class="tabview">
<button onclick="window.jsonview()">JSON-View</button>
<script>
function jsonview() {
showjson( draw.svg() );
}
</script>
<div id="JsonView" class="code">
<pre><code id="jsonstring"></code></pre>
</div>
</div>
<div id="diagrams.net" class="tabview">
<button onclick="window.shapeview()">Diagrams-Shape</button>
<script>
function shapeview() {
console.log(" Object server = " +server_obj);
diaShapeDraw(server_obj);
}
</script>
<div id="DiagramsShapeView" class="code">
<pre><textarea id="diastring" rows="25" cols="80"></textarea></pre>
</div>
</div>
<div id="ColorTab" class="tabview">
<button onclick="window.colorchangeview()">ColorChange</button>
<script>
function colorchangeview() {
color = document.getElementById("HardDriveColor").value;
drive = document.getElementById("HardDriveID").value;
if( drive == "All" ) {
var elements = document.getElementsByClassName('HardDrive');
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
element.style.fill = color;
}
} else {
document.getElementById(drive).style.fill = color;
}
//document.getElementById( document.getElementById("HardDriveID").value).style.fill = document.getElementById("DriveColor").value;
}
</script>
<div id="ColorChangeView" class="menu">
<p>Color HD change into:
<select name="HardDriveColor" id="HardDriveColor">
<option value="white">White</option>
<option value="green">Green</option>
<option value="orange">Orange</option>
<option value="red">Red</option>
</select>
</p>
<p>Change Color for HardDrive ID :</p>
<select name="HardDriveID" id="HardDriveID">
<option value="All">All</option>
</select>
</div>
</div>
</div>
<div id="box" class="box"></div>
</body>
</html>