Browse Source

Fixed diskmg unable to render not partitioned disk bug

IXTW 4 years ago
parent
commit
52791b19f8
3 changed files with 40 additions and 24 deletions
  1. 1 1
      .gitignore
  2. 39 23
      storage.bridge.go
  3. 0 0
      web/SystemAO/disk/space/img/disk.svg

+ 1 - 1
.gitignore

@@ -1,2 +1,2 @@
 #!/bin/bash
-sudo ./arozos -port 8080 -tls=true -tls_port 8443
+sudo ./arozos -port 8082 -hostname "ixtw" -tls=true -tls_port 8443

+ 39 - 23
storage.bridge.go

@@ -542,16 +542,16 @@
                            }
 
                            $("#diskInfoTable").append('<tr>\
-                            <td class="collapsing">\
-                                <i class="disk outline icon"></i>' + thisDisk[0] + '\
-                            </td>\
-                            <td class="">' + driveName + '</td>\
-                            <td class="collapsing">' + thisDisk[1] + '</td>\
-                            <td class="right aligned collapsing">' + thisDisk[3] + '</td>\
-                            <td class="right aligned collapsing">' + cap + '</td>\
-                            <td class="right aligned collapsing">' + free + '</td>\
-                            <td class="right aligned collapsing">' + perc + '%</td>\
-                        </tr>');
+                                <td class="collapsing">\
+                                    <i class="disk outline icon"></i>' + thisDisk[0] + '\
+                                </td>\
+                                <td class="">' + driveName + '</td>\
+                                <td class="collapsing">' + thisDisk[1] + '</td>\
+                                <td class="right aligned collapsing">' + thisDisk[3] + '</td>\
+                                <td class="right aligned collapsing">' + cap + '</td>\
+                                <td class="right aligned collapsing">' + free + '</td>\
+                                <td class="right aligned collapsing">' + perc + '%</td>\
+                            </tr>');
                        }
                     }
                 });
@@ -566,7 +566,20 @@
                        for (var i = 0; i < disks.length; i++){
                            var thisDisk = disks[i]["children"];
                            if (thisDisk === undefined || thisDisk === null){
-                               break;
+                                let thisSize = disks[i]["size"] || 0;
+                                let thisPartitionID = disks[i]["name"] || "✖";
+                                let mountPoint = disks[i]["mountpoint"] || "[NO PARTITION]";
+                                $("#diskInfoTable").append('<tr>\
+                                    <td class="collapsing">\
+                                        <i class="disk outline icon"></i>' + thisPartitionID + '\
+                                    </td>\
+                                    <td class="">' +  mountPoint + '</td>\
+                                    <td class="right aligned collapsing"></td>\
+                                    <td class="right aligned collapsing">' + bytesToSize(thisSize) + '</td>\
+                                    <td class="right aligned collapsing">' + bytesToSize(0) + '</td>\
+                                    <td class="right aligned collapsing"></td>\
+                                </tr>');
+                               continue;
                            }
                            for (var j =0; j < thisDisk.length; j++){
                                var thisPartition = thisDisk[j];
@@ -646,28 +659,27 @@
                       var disks = {};
                       var diskInfo = data[0]["blockdevices"];
                       for (var i =0; i < diskInfo.length; i++){
-                          var thisDisk = diskInfo[i];
-                          var diskID = thisDisk["name"];
+                          let thisDisk = diskInfo[i];
+                          let diskID = thisDisk["name"];
                           if (thisDisk["children"] === undefined || thisDisk["children"] === null){
                               //This disk do not have any child. Assume a large read-only raw partition.
-                              var size = thisDisk["size"] || 0;
-                              var partitionID = thisDisk["name"] || "✖";
-                              console.log(thisDisk);
+                              let thisSize = thisDisk["size"] || 0;
+                              let thisPartitionID = thisDisk["name"] || "✖";
                               disks[diskID] = {
-                                  "partitionsTotalSize":size,
-                                  "partitionNames":["Raw"],
-                                  "partitionID":[partitionID],
-                                  "partitionVolume":[size],
+                                  "partitionsTotalSize":thisSize,
+                                  "partitionNames":[""],
+                                  "partitionID":[thisPartitionID],
+                                  "partitionVolume":[thisSize],
                                   "Type":[thisDisk["type"]],
                                   "Mounted":[thisDisk["mountpoint"] !== null],
-                                  "Format":[""]
+                                  "Format":["raw"]
                                 };
-                              break;
+                                continue;
+                             
                           }
                           for (var j =0; j < thisDisk["children"].length;j++){
                             var thisPart = thisDisk["children"][j];
                             var disksFormats = data[1]["blockdevices"][i]["children"][j];
-                            console.log(thisPart["name"], thisPart);
                             if (disks == undefined || disks[diskID] == undefined){
                                 disks[diskID] = {
                                         "partitionsTotalSize":thisPart["size"],
@@ -747,6 +759,10 @@
                     }else if (diskInfo["partitionNames"][k] == "" && mode == "linux"){
                         topbarExtraClass = " unmounted";
                         diskInfo["partitionNames"][k] = "Not Mounted";
+                        if (diskInfo.Format.length == 1 && diskInfo.Format[0] == "raw"){
+                            topbarExtraClass = " unallocate"
+                            diskInfo["partitionNames"][k] = "Unallocated / Unpartitioned";
+                        }
                     }else if (diskInfo["partitionNames"][k] == "" && mode == "windows"){
                         //All viewable disks on Windows must be mounted
                         if (diskInfo["partitionID"][0] == "C:"){

+ 0 - 0
web/SystemAO/disk/space/img/disk.svg