Parcourir la source

Added not support platform warning

TC pushbot 5 il y a 4 ans
Parent
commit
ddf0cd4f99
2 fichiers modifiés avec 32 ajouts et 9 suppressions
  1. 5 0
      main.go
  2. 27 9
      web/index.html

+ 5 - 0
main.go

@@ -9,6 +9,7 @@ import (
 	"os/exec"
 	"os/signal"
 	"path/filepath"
+	"runtime"
 	"strings"
 	"syscall"
 
@@ -83,6 +84,10 @@ func handleGetStatus(w http.ResponseWriter, r *http.Request) {
 	//Get username from request
 	username, _ := handler.GetUserInfoFromRequest(w, r)
 
+	if runtime.GOOS == "windows" {
+		sendErrorResponse(w, "not supported platform")
+		return
+	}
 	//Check if the user has already in samba user
 	log.Println("Checking User Status", username)
 	userExists := false

+ 27 - 9
web/index.html

@@ -58,7 +58,17 @@
                 <p>This operation will remove your samba user account from the system</p>
                 <button class="ui red button" onclick="removeUser(event)">Disable</button>
             </div>
-            
+            <div id="notSupported" style="display: none;">
+                <br>
+                <div class="ui header">
+                    <i class="red remove icon"></i>
+                    <div class="content">
+                        Platform Not Supported
+                        <div class="sub header">Are you using Windows?</div>
+                    </div>
+                </div>
+                <p>This setting interface is disabled automatically on not supported platforms.</p>
+            </div>
         <br><br>
         <script>
             //Do not allow window resize
@@ -71,17 +81,25 @@
 
                 //Get the account status
                 $.get("./getStatus?username=" + username, function(data){
-                    if (data == true){
-                        $("#acstatus").text("Enabled");
-                        $("#acstatus").attr("class","success");
+                    if (data.error !== undefined){
+                        //Not supported platforms
                         $("#enableAccount").hide();
-                        $("#disableAccount").show();
-                    } else{
-                        $("#acstatus").text("Disabled");
-                        $("#acstatus").attr("class","failed");
-                        $("#enableAccount").show();
                         $("#disableAccount").hide();
+                        $("#notSupported").show();
+                    }else{
+                        if (data == true){
+                            $("#acstatus").text("Enabled");
+                            $("#acstatus").attr("class","success");
+                            $("#enableAccount").hide();
+                            $("#disableAccount").show();
+                        } else{
+                            $("#acstatus").text("Disabled");
+                            $("#acstatus").attr("class","failed");
+                            $("#enableAccount").show();
+                            $("#disableAccount").hide();
+                        }
                     }
+                   
                 });
             });