fix: normalize Mine Map shelf labels
This commit is contained in:
1 parent
06ed8248f5
commit
c6d01df31c
1 file changed
+9
-4
@@ -47,6 +47,11 @@
|
|||||||
return String(value);
|
return String(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function shelfLabel(value) {
|
||||||
|
const label = display(value, "Unlabelled shelf");
|
||||||
|
return /^shelf\b/i.test(label) ? label : "Shelf " + label;
|
||||||
|
}
|
||||||
|
|
||||||
function words(value) {
|
function words(value) {
|
||||||
return display(value, "Unknown").replaceAll("_", " ").toLowerCase();
|
return display(value, "Unknown").replaceAll("_", " ").toLowerCase();
|
||||||
}
|
}
|
||||||
@@ -497,8 +502,8 @@
|
|||||||
rack.appendChild(create("h2", "rack-title", "Rack " + rackEntry[0]));
|
rack.appendChild(create("h2", "rack-title", "Rack " + rackEntry[0]));
|
||||||
for (const shelfEntry of rackEntry[1]) {
|
for (const shelfEntry of rackEntry[1]) {
|
||||||
const shelf = create("section", "map-shelf");
|
const shelf = create("section", "map-shelf");
|
||||||
shelf.setAttribute("aria-label", "Shelf " + shelfEntry[0]);
|
shelf.setAttribute("aria-label", shelfLabel(shelfEntry[0]));
|
||||||
shelf.appendChild(create("h3", "shelf-title", "Shelf " + shelfEntry[0]));
|
shelf.appendChild(create("h3", "shelf-title", shelfLabel(shelfEntry[0])));
|
||||||
const grid = create("div", "position-grid");
|
const grid = create("div", "position-grid");
|
||||||
for (const position of shelfEntry[1]) {
|
for (const position of shelfEntry[1]) {
|
||||||
grid.appendChild(positionTile(position, scale));
|
grid.appendChild(positionTile(position, scale));
|
||||||
@@ -607,10 +612,10 @@
|
|||||||
detailRow("Current IP", position.current_ip);
|
detailRow("Current IP", position.current_ip);
|
||||||
const location = position.room_id
|
const location = position.room_id
|
||||||
? [position.site_name, position.room_name, "Rack " + position.rack_name,
|
? [position.site_name, position.room_name, "Rack " + position.rack_name,
|
||||||
"Shelf " + position.shelf_name, display(position.position_label,
|
shelfLabel(position.shelf_name), display(position.position_label,
|
||||||
"Position " + position.position_index)].join(" / ")
|
"Position " + position.position_index)].join(" / ")
|
||||||
: ["Unscoped", "Room label " + display(position.room_name),
|
: ["Unscoped", "Room label " + display(position.room_name),
|
||||||
"Rack " + display(position.rack_name), "Shelf " + display(position.shelf_name),
|
"Rack " + display(position.rack_name), shelfLabel(position.shelf_name),
|
||||||
display(position.position_label, "Position " + position.position_index)].join(" / ");
|
display(position.position_label, "Position " + position.position_index)].join(" / ");
|
||||||
detailRow("Location", location);
|
detailRow("Location", location);
|
||||||
detailRow("Lifecycle", words(position.lifecycle_status));
|
detailRow("Lifecycle", words(position.lifecycle_status));
|
||||||
|
|||||||
Reference in new issue
Block a user