mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-06 20:14:10 +08:00
🎨 Sync 2026-10-12 21:43:19
This commit is contained in:
1 parent
3a82c347ab
commit
bfe30ffbef
51 files changed
+8523
-149
No files matched your search
@@ -1,7 +1,66 @@
|
||||
<style>
|
||||
.diskman-table { table-layout: auto; width: 100%; }
|
||||
.diskman-table > tbody > tr > th,
|
||||
.diskman-table > tbody > tr > td {
|
||||
padding-left: 6px;
|
||||
padding-right: 6px;
|
||||
white-space: nowrap;
|
||||
overflow-wrap: normal;
|
||||
width: auto;
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
.diskman-table > tbody > tr > [data-name="path"],
|
||||
.diskman-table > tbody > tr > [data-name="model"] {
|
||||
width: auto;
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.diskman-table > tbody > tr > .cbi-section-actions {
|
||||
width: 6em;
|
||||
min-width: 6em;
|
||||
flex: 0 0 6em;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
window.onload = function () {
|
||||
//disk partition info
|
||||
let p_colors = ["#c0c0ff", "#fbbd00", "#e97c30", "#a0e0a0", "#e0c0ff"]
|
||||
function renderPartitions(item, disk_info) {
|
||||
if (!disk_info.partitions || !disk_info.partitions.length) return
|
||||
let isTable = item.nodeName == "TR"
|
||||
if (isTable) item.closest("table").classList.add("diskman-table")
|
||||
let row = document.createElement(isTable ? "tr" : "div")
|
||||
let cell = document.createElement(isTable ? "td" : "div")
|
||||
if (isTable) cell.colSpan = item.children.length
|
||||
else {
|
||||
row.className = "tr cbi-section-table-row cbi-rowstyle-1"
|
||||
cell.className = "td"
|
||||
}
|
||||
cell.style.cssText = "padding:0; border:0;"
|
||||
let container = document.createElement("div")
|
||||
container.style.cssText = "position:relative; height:1.8em; overflow:hidden;"
|
||||
let bar = document.createElement("div")
|
||||
// Keep partition labels out of the table's intrinsic width calculation.
|
||||
bar.style.cssText = "position:absolute; inset:0; display:flex;"
|
||||
disk_info.partitions.forEach((part, index) => {
|
||||
let segment = document.createElement("div")
|
||||
let label = (part.name != '-' && part.name || '') + ' ' + (part.fs != 'Free Space' && part.fs || '') + ' ' + part.size_formated + ' ' + (part.useage != '-' && part.useage || '')
|
||||
let share = disk_info.size > 0 ? part.size / disk_info.size * 100 : 0
|
||||
// Flex normalizes the weights even when there are many small partitions.
|
||||
segment.style.cssText = "min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; text-align:center; color:#525F7F;"
|
||||
segment.style.flex = Math.max(share || 0, 8) + " 1 0%"
|
||||
segment.style.backgroundColor = p_colors[index % p_colors.length]
|
||||
segment.title = label
|
||||
segment.textContent = label
|
||||
bar.appendChild(segment)
|
||||
})
|
||||
container.appendChild(bar)
|
||||
cell.appendChild(container)
|
||||
row.appendChild(cell)
|
||||
item.parentNode.insertBefore(row, item.nextSibling)
|
||||
}
|
||||
let lines = document.querySelectorAll('[id^=cbi-disk-]')
|
||||
lines.forEach((item) => {
|
||||
let dev = item.id.match(/cbi-disk-(.*)/)[1]
|
||||
@@ -19,7 +78,7 @@
|
||||
} else if (cell.getAttribute("data-name") == "sata_ver" || cell.childNodes[1] && cell.childNodes[1].id.match(/sata_ver/)) {
|
||||
cell.innerText = disk_info.sata_ver || "-"
|
||||
} else if (cell.getAttribute("data-name") == "health_status" || cell.childNodes[1] && cell.childNodes[1].id.match(/health_status/)) {
|
||||
cell.innerText = (disk_info.health || "-") + "\n" + (disk_info.status || "-")
|
||||
cell.innerText = (disk_info.health || "-") + " / " + (disk_info.status || "-")
|
||||
} else if (cell.getAttribute("data-name") == "health" || cell.childNodes[1] && cell.childNodes[1].id.match(/health/)) {
|
||||
cell.innerText = disk_info.health || "-"
|
||||
} else if (cell.getAttribute("data-name") == "status" || cell.childNodes[1] && cell.childNodes[1].id.match(/status/)) {
|
||||
@@ -27,44 +86,7 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
// handle partitons info
|
||||
if (disk_info.partitions && disk_info.partitions.length > 0) {
|
||||
let partitons_div
|
||||
if (item.nodeName == "TR") {
|
||||
partitons_div = '<tr width="100%" style="white-space:nowrap;"><td style="margin:0px; padding:0px; border:0px; white-space:nowrap;" colspan="15">'
|
||||
} else if (item.nodeName == "DIV") {
|
||||
partitons_div = '<div class="tr cbi-section-table-row cbi-rowstyle-1"><div style="white-space:nowrap; position:absolute; width:100%">'
|
||||
}
|
||||
let expand = 0
|
||||
let need_expand = 0
|
||||
disk_info.partitions.forEach((part) => {
|
||||
let p = part.size / disk_info.size * 100
|
||||
if (p <= 8) {
|
||||
expand += 8
|
||||
need_expand += p
|
||||
part.part_percent = 8
|
||||
}
|
||||
})
|
||||
let n = 0
|
||||
disk_info.partitions.forEach((part) => {
|
||||
let p = part.size / disk_info.size * 100
|
||||
if (p > 8) {
|
||||
part.part_percent = p * (100 - expand) / (100 - need_expand)
|
||||
}
|
||||
let part_percent = part.part_percent + '%'
|
||||
let p_color = p_colors[n++]
|
||||
if (n > 4) { n = 0 }
|
||||
let inline_txt = (part.name != '-' && part.name || '') + ' ' + (part.fs != 'Free Space' && part.fs || '') + ' ' + part.size_formated + ' ' + (part.useage != '-' && part.useage || '')
|
||||
let partiton_div = '<div title="' + inline_txt + '" style="color: #525F7F; display:inline-block; text-align:center;background-color:' + p_color + '; width:' + part_percent + '">' + inline_txt + '</div>'
|
||||
partitons_div += partiton_div
|
||||
})
|
||||
if (item.nodeName == "TR") {
|
||||
partitons_div += '</td></tr>'
|
||||
} else if (item.nodeName == "DIV") {
|
||||
partitons_div += '</div><div> </div></div>'
|
||||
}
|
||||
item.insertAdjacentHTML('afterend', partitons_div);
|
||||
}
|
||||
renderPartitions(item, disk_info)
|
||||
})
|
||||
})
|
||||
//raid table
|
||||
@@ -82,28 +104,7 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
// handle partitons info
|
||||
let partitons_div
|
||||
if (item.nodeName == "TR") {
|
||||
partitons_div = '<tr width="100%" style="white-space:nowrap;"><td style="margin:0px; padding:0px; border:0px; white-space:nowrap;" colspan="15">'
|
||||
} else if (item.nodeName == "DIV") {
|
||||
partitons_div = '<div class="tr cbi-section-table-row cbi-rowstyle-1"><div style="white-space:nowrap; position:absolute; width:100%">'
|
||||
}
|
||||
let n = 0
|
||||
disk_info.partitions.forEach((part) => {
|
||||
let part_percent = part.size / disk_info.size * 100 + '%'
|
||||
let p_color = p_colors[n++]
|
||||
if (n > 4) { n = 0 }
|
||||
let inline_txt = (part.name != '-' && part.name || '') + ' ' + (part.fs != 'Free Space' && part.fs || '') + ' ' + part.size_formated + ' ' + (part.useage != '-' && part.useage || '')
|
||||
let partiton_div = '<div title="' + inline_txt + '" style="display:inline-block; text-align:center;background-color:' + p_color + '; width:' + part_percent + '">' + inline_txt + '</div>'
|
||||
partitons_div += partiton_div
|
||||
})
|
||||
if (item.nodeName == "TR") {
|
||||
partitons_div += '</td></tr>'
|
||||
} else if (item.nodeName == "DIV") {
|
||||
partitons_div += '</div><div> </div></div>'
|
||||
}
|
||||
item.insertAdjacentHTML('afterend', partitons_div);
|
||||
renderPartitions(item, disk_info)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user