Пример #1
0
func HostsJson() func(c *gin.Context) {
	return func(c *gin.Context) {
		if auth.IsAuthorized(c) == true {
			rows := [][]string{}
			api := wengine.GetApi("", "", "")
			_, hosts := api.HostsList()
			//
			header := []string{"ID"}
			for id := range hosts {
				host := hosts[id]
				row := []string{host.Id}
				rows = append(rows, row)
			}
			data_items := []gin.H{gin.H{"data_type": "wapour-table", "name": "Files Table", "id": "files_table", "title": "Files Table", "rows": rows, "header": header}}
			var data = gin.H{"data_items": data_items}
			c.JSON(200, gin.H{"status": "ok", "data": data})
		} else {
			c.JSON(401, gin.H{"status": "Unauthorized", "data": gin.H{}})
		}
	}
}
Пример #2
0
func ActionsJson() func(c *gin.Context) {

	return func(c *gin.Context) {
		if auth.IsAuthorized(c) == true {
			rows := [][]string{}
			api := wengine.GetApi("", "", "")
			_, action_list := api.ActionsList()
			header := []string{"Name", "Command"}
			for id := range action_list {
				action := action_list[id]
				row := []string{action.Name, action.Command}
				rows = append(rows, row)
			}
			data_items := []gin.H{gin.H{"data_type": "wapour-table", "name": "Actions Table", "id": "actions_table", "title": "Actions Table", "rows": rows, "header": header}}
			var data = gin.H{"data_items": data_items}
			c.JSON(200, gin.H{"status": "ok", "data": data})
		} else {
			c.JSON(401, gin.H{"status": "Unauthorized", "data": gin.H{}})
		}
	}
}
Пример #3
0
func FilesJson() func(c *gin.Context) {

	return func(c *gin.Context) {
		if auth.IsAuthorized(c) == true {
			rows := [][]string{}
			api := wengine.GetApi("", "", "")
			_, file_list := api.FilesList()
			//
			header := []string{"Name", "Path", "IsDir"}
			for id := range file_list {
				file := file_list[id]
				row := []string{file.Name, file.Path, fmt.Sprintf("%v", file.IsDir)}
				rows = append(rows, row)
			}
			data_items := []gin.H{gin.H{"data_type": "wapour-table", "name": "Files Table", "id": "files_table", "title": "Files Table", "rows": rows, "header": header}}
			var data = gin.H{"data_items": data_items}
			c.JSON(200, gin.H{"status": "ok", "data": data})
		} else {
			c.JSON(401, gin.H{"status": "Unauthorized", "data": gin.H{}})
		}
	}
}