|
@@ -5,10 +5,8 @@
|
|
|
<meta charset="UTF-8">
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
|
|
|
<link rel="stylesheet" href="../../../script/semantic/semantic.min.css">
|
|
|
- <link rel="stylesheet" href="../disk/quota/script/Chart.min.css">
|
|
|
<script type="text/javascript" src="../../../script/jquery.min.js"></script>
|
|
|
<script type="text/javascript" src="../../../script/semantic/semantic.min.js"></script>
|
|
|
- <script src="../disk/quota/script/Chart.min.js"></script>
|
|
|
<style>
|
|
|
.mdevice{
|
|
|
color: rgb(136, 136, 136);
|
|
@@ -221,6 +219,9 @@
|
|
|
<br>
|
|
|
<div id="raidDiskList">
|
|
|
|
|
|
+ </div>
|
|
|
+ <div class="ui yellow message" style="display:none;" id="raidDataLossWarning">
|
|
|
+ <i class="yellow exclamation triangle icon"></i> Not enough redundant disks. Further removal / failure of disk will result in data loss.<br>
|
|
|
</div>
|
|
|
<div class="ui divider"></div>
|
|
|
<table class="ui very basic compact celled table" style="padding-left: 1em; padding-right: 1em;">
|
|
@@ -228,10 +229,10 @@
|
|
|
<tr>
|
|
|
<td>
|
|
|
<h4><i class="green add icon"></i> Add New Disk</h4>
|
|
|
- <p>Add a new disk to the array. If your array have an empty slot (aka removed disk), the disk will be added as working disk, otherwise, it will be added as a spare disk.</p>
|
|
|
+ <p>Add a new disk to the array. If your array have an empty slot (removed disk), the disk will be added as working disk, otherwise, it will be added as a spare disk.</p>
|
|
|
</td>
|
|
|
<td>
|
|
|
- <button onclick="" class="circular small basic ui button">
|
|
|
+ <button onclick="addDiskToArray();" class="circular small basic ui button">
|
|
|
<i class="green add icon"></i> Add Disk
|
|
|
</button>
|
|
|
</td>
|
|
@@ -321,6 +322,28 @@
|
|
|
removePendingSourceVol: ""
|
|
|
};
|
|
|
|
|
|
+ /* New Disk Function */
|
|
|
+ function addDiskToArray(arrayName=raidManager.editingArray){
|
|
|
+ let payload = {
|
|
|
+ "md": arrayName,
|
|
|
+ }
|
|
|
+ payload = encodeURIComponent(JSON.stringify(payload));
|
|
|
+ parent.newFloatWindow({
|
|
|
+ url: "SystemAO/disk/raid/newdisk.html#" + payload,
|
|
|
+ width: 390,
|
|
|
+ height: 620,
|
|
|
+ appicon: "SystemAO/disk/raid/img/raid.svg",
|
|
|
+ title: `Add new disk to RAID`,
|
|
|
+ parent: ao_module_windowID,
|
|
|
+ callback: "handleAddDiskCallback"
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ window.handleAddDiskCallback = function(data){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /* Disk Remove Functions */
|
|
|
function removeDisk(arrayName, diskPath){
|
|
|
console.log(arrayName, diskPath);
|
|
|
$("#oprconfirm").html("Remove <b>" + diskPath + "</b> from <b>" + arrayName + "</b>");
|
|
@@ -435,6 +458,7 @@
|
|
|
})
|
|
|
|
|
|
let deiviceSizeMap = {};
|
|
|
+ let workingDiskCount = 0;
|
|
|
//Load the device size map
|
|
|
$.get("../../system/disk/raid/devinfo?devName=" + deviceName, function(sizemap){
|
|
|
deiviceSizeMap = sizemap;
|
|
@@ -464,6 +488,7 @@
|
|
|
|
|
|
//Render the disk list
|
|
|
$("#raidDiskList").html("");
|
|
|
+ workingDiskCount = data.DeviceInfo.length;
|
|
|
for (var i = 0; i < data.DeviceInfo.length; i++){
|
|
|
let thisDeviceInfo = data.DeviceInfo[i];
|
|
|
let raidDeviceNo = thisDeviceInfo.RaidDevice;
|
|
@@ -481,9 +506,11 @@
|
|
|
if (thisDeviceInfo.State.includes("faulty")){
|
|
|
//Disk labeled as failed
|
|
|
driveIcon = "drive-failed.svg"
|
|
|
+ workingDiskCount--;
|
|
|
diskIsFailed = true;
|
|
|
}else if (thisDeviceInfo.State.includes("removed")){
|
|
|
driveIcon = "drive-notfound.svg"
|
|
|
+ workingDiskCount--;
|
|
|
}else if (thisDeviceInfo.State.includes("rebuilding")){
|
|
|
driveIcon = "drive-spare.svg"
|
|
|
}
|
|
@@ -499,7 +526,12 @@
|
|
|
|
|
|
//Handle case where raidDeviceNo is -1 (Not mounted / failed)
|
|
|
if (raidDeviceNo == -1){
|
|
|
- raidDeviceNo = "Failed";
|
|
|
+ if (thisDeviceInfo.State.includes("complete")){
|
|
|
+ raidDeviceNo = "Rebuilding";
|
|
|
+ }else{
|
|
|
+ raidDeviceNo = "Faulty";
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//A random UID for this DOM element to make handling easier
|
|
@@ -520,7 +552,7 @@
|
|
|
<div class="raidDeviceOptions">
|
|
|
<div class="content">
|
|
|
<button class="ui tiny basic button"><i class="ui info circle grey icon"></i> SMART</button>
|
|
|
- <button class="ui tiny basic button" onclick="removeDisk('${deviceName}','${driveName}');"><i class="ui red trash icon"></i> Remove Disk from Volume</button>
|
|
|
+ <button class="ui tiny basic button removeDiskBtn ${diskIsFailed?"faulty":"normal"}" onclick="removeDisk('${deviceName}','${driveName}');"><i class="ui red trash icon"></i> Remove Disk from Volume</button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="ui divider"></div>
|
|
@@ -533,8 +565,24 @@
|
|
|
//Invalid disk, e.g. Removed
|
|
|
$(".raiddevice." + raiddeviceUID).find(".raidDeviceOptions").hide();
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ //Check if the current setup is already at the min no. of disk
|
|
|
+ let allowRemoveDisk = true;
|
|
|
+ if (data.RaidLevel == "raid0"){
|
|
|
+ //Do not allow for disk remove
|
|
|
+ allowRemoveDisk = false;
|
|
|
+ }else if (data.RaidLevel == "raid1" && workingDiskCount < 2){
|
|
|
+ allowRemoveDisk = false;
|
|
|
+ }else if (data.RaidLevel == "raid5" && workingDiskCount < 3){
|
|
|
+ allowRemoveDisk = false;
|
|
|
+ }else if (data.RaidLevel == "raid6" && workingDiskCount < 4){
|
|
|
+ allowRemoveDisk = false;
|
|
|
+ }
|
|
|
|
|
|
+ if (!allowRemoveDisk){
|
|
|
+ $(".removeDiskBtn.normal").addClass("disabled");
|
|
|
+ $("#raidDataLossWarning").show();
|
|
|
}
|
|
|
|
|
|
});
|