浏览代码

Updated ARZ Serverless UI and catergories

Toby Chui 2 年之前
父节点
当前提交
1ebdc0cb9c

+ 14 - 14
mod/agi/external.agi.go

@@ -23,7 +23,7 @@ func (g *Gateway) ExtAPIHandler(w http.ResponseWriter, r *http.Request) {
 	sysdb := g.Option.UserHandler.GetDatabase()
 
 	if !sysdb.TableExists("external_agi") {
-		common.SendErrorResponse(w, "Bad Request, invaild database")
+		common.SendErrorResponse(w, "Invalid Request")
 		return
 	}
 
@@ -33,7 +33,7 @@ func (g *Gateway) ExtAPIHandler(w http.ResponseWriter, r *http.Request) {
 
 	// check if it contains only two part, [rexec uuid]
 	if len(subpathElements) != 3 {
-		common.SendErrorResponse(w, "Bad Request, invaild request sent")
+		common.SendErrorResponse(w, "Invalid Request")
 		return
 	}
 
@@ -41,7 +41,7 @@ func (g *Gateway) ExtAPIHandler(w http.ResponseWriter, r *http.Request) {
 	// get the info from the database
 	data, isExist := g.checkIfExternalEndpointExist(subpathElements[2])
 	if !isExist {
-		common.SendErrorResponse(w, "Bad Request, invaild UUID entered")
+		common.SendErrorResponse(w, "Malform Request, invaild UUID given")
 		return
 	}
 
@@ -51,12 +51,12 @@ func (g *Gateway) ExtAPIHandler(w http.ResponseWriter, r *http.Request) {
 	// get the userinfo and the realPath
 	userInfo, err := g.Option.UserHandler.GetUserInfoFromUsername(usernameFromDb)
 	if err != nil {
-		common.SendErrorResponse(w, "Bad username")
+		common.SendErrorResponse(w, "Invalid username")
 		return
 	}
 	_, realPath, err := virtualPathToRealPath(pathFromDb, userInfo)
 	if err != nil {
-		common.SendErrorResponse(w, "Bad filepath")
+		common.SendErrorResponse(w, "Invalid filepath")
 		return
 	}
 
@@ -79,7 +79,7 @@ func (g *Gateway) ExtAPIHandler(w http.ResponseWriter, r *http.Request) {
 func (g *Gateway) AddExternalEndPoint(w http.ResponseWriter, r *http.Request) {
 	userInfo, err := g.Option.UserHandler.GetUserInfoFromRequest(w, r)
 	if err != nil {
-		common.SendErrorResponse(w, "Bad user!")
+		common.SendErrorResponse(w, "User not logged in")
 		return
 	}
 	// get db
@@ -92,7 +92,7 @@ func (g *Gateway) AddExternalEndPoint(w http.ResponseWriter, r *http.Request) {
 	// uuid: [path, id]
 	path, err := common.Mv(r, "path", false)
 	if err != nil {
-		common.SendErrorResponse(w, "Bad parameter")
+		common.SendErrorResponse(w, "Invalid path given")
 		return
 	}
 
@@ -104,7 +104,7 @@ func (g *Gateway) AddExternalEndPoint(w http.ResponseWriter, r *http.Request) {
 
 	jsonStr, err := json.Marshal(dat)
 	if err != nil {
-		common.SendErrorResponse(w, "Bad JSON")
+		common.SendErrorResponse(w, "Invalid JSON string: " + err.Error())
 		return
 	}
 	sysdb.Write("external_agi", id, string(jsonStr))
@@ -116,7 +116,7 @@ func (g *Gateway) AddExternalEndPoint(w http.ResponseWriter, r *http.Request) {
 func (g *Gateway) RemoveExternalEndPoint(w http.ResponseWriter, r *http.Request) {
 	userInfo, err := g.Option.UserHandler.GetUserInfoFromRequest(w, r)
 	if err != nil {
-		common.SendErrorResponse(w, "Bad User")
+		common.SendErrorResponse(w, "User not logged in")
 		return
 	}
 
@@ -128,7 +128,7 @@ func (g *Gateway) RemoveExternalEndPoint(w http.ResponseWriter, r *http.Request)
 	// get path
 	uuid, err := common.Mv(r, "uuid", false)
 	if err != nil {
-		common.SendErrorResponse(w, "Bad parameter")
+		common.SendErrorResponse(w, "Invalid uuid given")
 		return
 	}
 
@@ -141,7 +141,7 @@ func (g *Gateway) RemoveExternalEndPoint(w http.ResponseWriter, r *http.Request)
 
 	// make sure user cant see other's endpoint
 	if data.Username != userInfo.Username {
-		common.SendErrorResponse(w, "Bad Request, you have no permission to access this UUID entry!")
+		common.SendErrorResponse(w, "Permission denied")
 		return
 	}
 
@@ -154,7 +154,7 @@ func (g *Gateway) RemoveExternalEndPoint(w http.ResponseWriter, r *http.Request)
 func (g *Gateway) ListExternalEndpoint(w http.ResponseWriter, r *http.Request) {
 	userInfo, err := g.Option.UserHandler.GetUserInfoFromRequest(w, r)
 	if err != nil {
-		common.SendErrorResponse(w, "Bad User")
+		common.SendErrorResponse(w, "User not logged in")
 		return
 	}
 
@@ -170,7 +170,7 @@ func (g *Gateway) ListExternalEndpoint(w http.ResponseWriter, r *http.Request) {
 	// O(n) method to do the lookup
 	entries, err := sysdb.ListTable("external_agi")
 	if err != nil {
-		common.SendErrorResponse(w, "Bad table")
+		common.SendErrorResponse(w, "Invalid table")
 		return
 	}
 	for _, keypairs := range entries {
@@ -189,7 +189,7 @@ func (g *Gateway) ListExternalEndpoint(w http.ResponseWriter, r *http.Request) {
 	// marhsal and return
 	returnJson, err := json.Marshal(dataFromDB)
 	if err != nil {
-		common.SendErrorResponse(w, "Bad JSON")
+		common.SendErrorResponse(w, "Invalid JSON: " + err.Error())
 		return
 	}
 	sendJSONResponse(w, string(returnJson))

二进制
web/ARZ Serverless/img/desktop_icon.png


二进制
web/ARZ Serverless/img/desktop_icon.psd


二进制
web/ARZ Serverless/img/function_icon.png


二进制
web/ARZ Serverless/img/function_icon.psd


二进制
web/ARZ Serverless/img/small_icon.png


二进制
web/ARZ Serverless/img/small_icon.psd


+ 12 - 9
web/ARZ Serverless/index.html

@@ -59,15 +59,16 @@
                </style>
     </head>
     <body>
+        <br>
         <div class="ui container" style="height: 100% !important;">
             <div>
-                <br>
-                <h1 class="ui header">
-                    <span id="normalStatus">ARZ Serverless</span>
-                    <div class="sub header">
-                       You can run our own AGI script without login by setting up the configuration below
+                <h2 class="ui header">
+                    <img src="img/desktop_icon.png">
+                    <div class="content">
+                        ARZ Serverless
+                      <div class="sub header">Allow external services to run AGI scripts</div>
                     </div>
-                </h1>
+                  </h2>
             </div>
             <div class="ui divider"></div>
             <div id="deleteSuceed" style="display:none;" class="ui green inverted segment"><i class="checkmark icon"></i>Deleted</div>
@@ -91,13 +92,15 @@
             </div>
             <div class="ui divider"></div>
             <div id="updateSuceed" style="display:none;" class="ui green inverted segment"><i class="checkmark icon"></i>Added</div>
-            <h4>Select AGI script Location</h4>
+            <h4>Select AGI Script</h4>
+            <p>Select a script to be executed by 3rd party application via RESTFUL request. <br>
+                Note that the AGI script will be executed with <b>your user scope</b></p>
             <div class="ui action fluid input">
                 <input id="agiPath" type="text" placeholder="Select Location" readonly="true">
                 <button class="ui black button" onclick="openfileselector();"><i class="folder open icon"></i> Open</button>
             </div>
             <br>
-            <button class="ui positive button" onclick="add();">Add</button>
+            <button class="ui positive button" onclick="add();"><i class="ui checkmark icon"></i> Add</button>
             <br><br>
         </div>
         <script>
@@ -106,7 +109,7 @@
                     appendTable(key, val.path);
                 });
                 if(Object.keys(data).length == 0) {
-                    $("#records").append(`<tr id="zeroRec"><td>0 record returned.</td></tr>`);
+                    $("#records").append(`<tr id="zeroRec"><td>No registered endpoint</td></tr>`);
                 }
             });
 

+ 1 - 1
web/ARZ Serverless/init.agi

@@ -6,7 +6,7 @@
 //Define the launchInfo for the module
 var moduleLaunchInfo = {
     Name: "ARZ Serverless",
-	Group: "Utilities",
+	Group: "System Tools",
 	IconPath: "ARZ Serverless/img/small_icon.png",
 	Version: "0.1",
 	StartDir: "ARZ Serverless/index.html"