浏览代码

Added more smb share ui

aroz 1 年之前
父节点
当前提交
0102920326

+ 3 - 0
mod/fileservers/servers/samba/handlers.go

@@ -15,6 +15,9 @@ func (s *ShareManager) ListSambaShares(w http.ResponseWriter, r *http.Request) {
 		return
 	}
 
+	//Remove those shares that is reserved by systems
+	shares = s.FilterSystemCreatedShares(shares)
+
 	js, _ := json.Marshal(shares)
 	utils.SendJSONResponse(w, string(js))
 }

+ 12 - 0
mod/fileservers/servers/samba/samba.go

@@ -115,6 +115,18 @@ func (s *ShareManager) ReadSambaShares() ([]ShareConfig, error) {
 	return shares, nil
 }
 
+// A basic filter to remove system created smb shares entry in the list
+func (s *ShareManager) FilterSystemCreatedShares(shares []ShareConfig) []ShareConfig {
+	namesToRemove := []string{"global", "homes", "printers", "print$"}
+	filteredShares := []ShareConfig{}
+	for _, share := range shares {
+		if !utils.StringInArray(namesToRemove, share.Name) {
+			filteredShares = append(filteredShares, share)
+		}
+	}
+	return filteredShares
+}
+
 // CreateNewSambaShare converts the shareConfig to string and appends it to smb.conf if the share name does not already exist
 func (s *ShareManager) CreateNewSambaShare(shareToCreate *ShareConfig) error {
 	// Path to smb.conf

+ 13 - 2
web/SystemAO/disk/instr/samba.html

@@ -1,2 +1,13 @@
-<h1>Work In Progress</h1>
-<p>Personal Settings</p>
+<div class="ui basic yellow message">
+    <h4 class="ui header">
+        <i class="yellow folder icon"></i>
+        <div class="content">
+            Accessing ArozOS Local Disks using SMB
+        </div>
+    </h4>
+    <p>To access your ArozOS local disk storage using SMB,  you can first enable SMB on your account and open the IP address of this host in your File Explorer or Mac Finder (with smb:// prefix)</p>
+    <small>Samba can only share local disks or partitions. Remote file system mounted into ArozOS cannot be shared by SMB.</small>
+</div>
+<p>Click "Activate" to enable SMB access to your file system</p>
+<button class="ui basic button"><i class="ui green circle check icon"></i> Activate</button>
+<button class="ui basic disabled button"><i class="ui red circle times icon"></i> Disable</button>

+ 63 - 1
web/SystemAO/disk/samba.html

@@ -1 +1,63 @@
-<p>Admin Settings</p>
+<h3>Samba Share Lists</h3>
+<p>A list of SMB shares currently written into smb.conf</p>
+<div id="sharelist">
+
+</div>
+<div class="ui divider"></div>
+<h3>Add Samba Share</h3>
+<p>Create a new SMB share folder from local disk</p>
+<script>
+
+     function initShareListTable(){
+        $.get("../../system/storage/samba/list", function(data){
+            if (data.error){
+                msgbox(data.error, false);
+            }else{
+                generateTable(data);
+            }
+        });
+     }
+     initShareListTable();
+     function generateTable(data) {
+            // Start the table
+            let table = `
+                <table class="ui basic celled unstackable table">
+                    <thead>
+                        <tr>
+                            <th>Name</th>
+                            <th>Path</th>
+                            <th>Valid Users</th>
+                            <th>Read Only</th>
+                            <th>Browseable</th>
+                            <th>Guest Ok</th>
+                            <th>Actions</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+            `;
+
+            // Populate the table rows
+            data.forEach(item => {
+                table += `
+                    <tr>
+                        <td><i class="ui yellow folder icon"></i> ${item.Name}</td>
+                        <td><i class="ui grey hdd icon"></i> ${item.Path}</td>
+                        <td>${item.ValidUsers.join(", ")}</td>
+                        <td>${item.ReadOnly?'<i class="ui green check icon"></i>':'<i class="ui red times icon"></i>'}</td>
+                        <td>${item.Browseable?'<i class="ui green check icon"></i>':'<i class="ui red times icon"></i>'}</td>
+                        <td>${item.GuestOk?'<i class="ui green check icon"></i>':'<i class="ui red times icon"></i>'}</td>
+                        <td><button class="ui basic circular mini red icon button"><i class="ui trash icon"></i> Remove</button></td>
+                    </tr>
+                `;
+            });
+
+            // Close the table
+            table += `
+                    </tbody>
+                </table>
+            `;
+
+            // Insert the table into the div
+            $("#sharelist").html(table);
+        }
+</script>