ソースを参照

Added toggle to server page

aroz 1 年間 前
コミット
382e601925
2 ファイル変更27 行追加9 行削除
  1. 25 8
      mod/fileservers/servers/samba/required.go
  2. 2 1
      web/SystemAO/disk/samba.html

+ 25 - 8
mod/fileservers/servers/samba/required.go

@@ -1,7 +1,6 @@
 package samba
 
 import (
-	"errors"
 	"fmt"
 	"log"
 	"os/exec"
@@ -16,7 +15,7 @@ import (
 Functions requested by the file server service router
 */
 func (m *ShareManager) ServerToggle(enabled bool) error {
-	return errors.New("not supported")
+	return SetSmbdEnableState(enabled)
 }
 
 func (m *ShareManager) IsEnabled() bool {
@@ -29,13 +28,31 @@ func (m *ShareManager) IsEnabled() bool {
 	return smbdRunning
 }
 
-func (m *ShareManager) GetEndpoints(userinfo *user.User) []*fileservers.Endpoint {
+func (m *ShareManager) GetEndpoints(userInfo *user.User) []*fileservers.Endpoint {
+	//Get a list of connection endpoint for this user
 	eps := []*fileservers.Endpoint{}
-	eps = append(eps, &fileservers.Endpoint{
-		ProtocolName: "//",
-		Port:         0,
-		Subpath:      "/",
-	})
+	for _, fsh := range userInfo.GetAllAccessibleFileSystemHandler() {
+		if fsh.IsNetworkDrive() {
+			continue
+		}
+		fshID := fsh.UUID
+		if fsh.RequierUserIsolation() {
+			//User seperated storage. Only mount the user one
+			fshID = userInfo.Username + "_" + fsh.UUID
+		}
+
+		shareExists, err := m.ShareExists(fshID)
+		if err != nil || !shareExists {
+			continue
+		}
+
+		eps = append(eps, &fileservers.Endpoint{
+			ProtocolName: "//",
+			Port:         0,
+			Subpath:      "/" + fshID,
+		})
+	}
+
 	return eps
 }
 

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

@@ -5,12 +5,13 @@
         float: right;
     }
 </style>
-<h3>Enable Samba Service</h3>
+<!-- <h3>Enable Samba Service</h3>
 <p>Change current systemctl state of smbd (start / stop).</p>
 <div class="ui toggle checkbox">
     <input type="checkbox" id="enablesmbd">
     <label>Enable smbd (Samba Sharing Service)</label>
 </div>
+-->
 
 <div class="ui divider"></div>
 <h3><i class="ui green share alternate icon"></i> Samba Share Lists</h3>