UI changes
This commit is contained in:
@@ -376,6 +376,10 @@ func AddBarrierIP(db *gorm.DB, SessionID string, barrierIP string, MachineName s
|
|||||||
|
|
||||||
if exists == false {
|
if exists == false {
|
||||||
var NewBarrierIP BarrierIP
|
var NewBarrierIP BarrierIP
|
||||||
|
// generate new UUID for barrier
|
||||||
|
id := uuid.New()
|
||||||
|
NewBarrierIP.ID = id.String()
|
||||||
|
|
||||||
NewBarrierIP.BarrierIP = barrierIP
|
NewBarrierIP.BarrierIP = barrierIP
|
||||||
NewBarrierIP.UserID = user.UserID
|
NewBarrierIP.UserID = user.UserID
|
||||||
NewBarrierIP.MachineName = MachineName
|
NewBarrierIP.MachineName = MachineName
|
||||||
@@ -416,3 +420,29 @@ func RemoveBarrierIP(db *gorm.DB, barrierIP string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetBarrierInfo(db *gorm.DB, SessionID string) (barriers []*BarrierIP, err error) {
|
||||||
|
// Get User Information
|
||||||
|
user, err := GetUserInformation(db, SessionID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get barrier information for a particular
|
||||||
|
UserRows, err := db.Model(&BarrierIP{}).Where("user_id = ?", user.UserID).Rows()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer UserRows.Close()
|
||||||
|
|
||||||
|
for UserRows.Next() {
|
||||||
|
var barrier BarrierIP
|
||||||
|
err := db.ScanRows(UserRows, &barrier)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
barriers = append(barriers, &barrier)
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
435
server/server.go
435
server/server.go
@@ -1,261 +1,268 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Server Starts the server for the client side
|
// Server Starts the server for the client side
|
||||||
func Server(port string) error {
|
func Server(port string) error {
|
||||||
|
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
|
|
||||||
r.Static("/assets", "./templates/assets")
|
r.Static("/assets", "./templates/assets")
|
||||||
|
|
||||||
r.LoadHTMLGlob("./templates/*.html")
|
r.LoadHTMLGlob("./templates/*.html")
|
||||||
// htmlRender.TemplatesDir = "templates/" // default
|
// htmlRender.TemplatesDir = "templates/" // default
|
||||||
// htmlRender.Ext = ".html" // default
|
// htmlRender.Ext = ".html" // default
|
||||||
|
|
||||||
// Tell gin to use our html render
|
// Tell gin to use our html render
|
||||||
|
|
||||||
// Initialise connection to Sqlite DB
|
// Initialise connection to Sqlite DB
|
||||||
connect, err := Connect()
|
connect, err := Connect()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gets default information about the game sessions
|
// Gets default information about the game sessions
|
||||||
r.GET("/", func(c *gin.Context) {
|
r.GET("/", func(c *gin.Context) {
|
||||||
// Get client session ID
|
// Get client session ID
|
||||||
session, err := c.Cookie("SessionID")
|
session, err := c.Cookie("SessionID")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Redirect(http.StatusFound, "/login")
|
c.Redirect(http.StatusFound, "/login")
|
||||||
}
|
}
|
||||||
|
|
||||||
// User information based on session ID
|
// User information based on session ID
|
||||||
User, err := GetUserInformation(connect, session)
|
User, err := GetUserInformation(connect, session)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Redirect(http.StatusFound, "/login")
|
c.Redirect(http.StatusFound, "/login")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get information of all game sessions available
|
// Get list of add barrier related IPs added
|
||||||
GameSessions, err := DisplayGameSessions(connect)
|
Barrier, err := GetBarrierInfo(connect, session)
|
||||||
if err != nil {
|
fmt.Println(Barrier)
|
||||||
c.String(http.StatusOK, fmt.Sprint(err))
|
if err != nil {
|
||||||
}
|
c.String(http.StatusOK, fmt.Sprint(err))
|
||||||
c.HTML(http.StatusOK, "index.html", gin.H{
|
}
|
||||||
"title": "Xplane11-WebRTC",
|
// Get information of all game sessions available
|
||||||
"GameSessions": GameSessions,
|
GameSessions, err := DisplayGameSessions(connect)
|
||||||
"User": User,
|
if err != nil {
|
||||||
})
|
c.String(http.StatusOK, fmt.Sprint(err))
|
||||||
})
|
}
|
||||||
|
c.HTML(http.StatusOK, "index.html", gin.H{
|
||||||
|
"title": "Xplane11-WebRTC",
|
||||||
|
"GameSessions": GameSessions,
|
||||||
|
"User": User,
|
||||||
|
"BarrierIPS": Barrier,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Opens the forgot password page
|
// Opens the forgot password page
|
||||||
r.GET("/forgotpassword", func(c *gin.Context) {
|
r.GET("/forgotpassword", func(c *gin.Context) {
|
||||||
c.HTML(http.StatusOK, "forgotpassword.html", gin.H{
|
c.HTML(http.StatusOK, "forgotpassword.html", gin.H{
|
||||||
"title": "Xplane11-WebRTC",
|
"title": "Xplane11-WebRTC",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Opens the login page
|
// Opens the login page
|
||||||
r.GET("/login", func(c *gin.Context) {
|
r.GET("/login", func(c *gin.Context) {
|
||||||
c.HTML(http.StatusOK, "login.html", gin.H{
|
c.HTML(http.StatusOK, "login.html", gin.H{
|
||||||
"title": "Xplane11-WebRTC",
|
"title": "Xplane11-WebRTC",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Validate login information
|
// Validate login information
|
||||||
r.POST("/login", func(c *gin.Context) {
|
r.POST("/login", func(c *gin.Context) {
|
||||||
// you can bind multipart form with explicit binding declaration:
|
// you can bind multipart form with explicit binding declaration:
|
||||||
// c.ShouldBindWith(&form, binding.Form)
|
// c.ShouldBindWith(&form, binding.Form)
|
||||||
// or you can simply use autobinding with ShouldBind method:
|
// or you can simply use autobinding with ShouldBind method:
|
||||||
// source: https://github.com/gin-gonic/gin#multiparturlencoded-binding
|
// source: https://github.com/gin-gonic/gin#multiparturlencoded-binding
|
||||||
var users Users
|
var users Users
|
||||||
// in this case proper binding will be automatically selected
|
// in this case proper binding will be automatically selected
|
||||||
if err := c.ShouldBind(&users); err != nil {
|
if err := c.ShouldBind(&users); err != nil {
|
||||||
c.String(http.StatusBadRequest, "bad request")
|
c.String(http.StatusBadRequest, "bad request")
|
||||||
}
|
}
|
||||||
|
|
||||||
result, err := AuthLogin(connect, &users)
|
result, err := AuthLogin(connect, &users)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.String(http.StatusOK, fmt.Sprint(err))
|
c.String(http.StatusOK, fmt.Sprint(err))
|
||||||
} else {
|
} else {
|
||||||
if result == "success" {
|
if result == "success" {
|
||||||
// Create Login session
|
// Create Login session
|
||||||
session, err := CreateLoginSession(connect, &users)
|
session, err := CreateLoginSession(connect, &users)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.String(http.StatusExpectationFailed, "error")
|
c.String(http.StatusExpectationFailed, "error")
|
||||||
}
|
}
|
||||||
// TODO redirect to homepage
|
// TODO redirect to homepage
|
||||||
// Set client Cookie as Session ID
|
// Set client Cookie as Session ID
|
||||||
// To be changed when we use HTTPS
|
// To be changed when we use HTTPS
|
||||||
c.SetCookie("SessionID", session.SessionKey, 3600, "/", "*", false, true)
|
c.SetCookie("SessionID", session.SessionKey, 3600, "/", "*", false, true)
|
||||||
// redirects to the home page
|
// redirects to the home page
|
||||||
//c.Redirect(http.StatusFound, "/")
|
//c.Redirect(http.StatusFound, "/")
|
||||||
|
|
||||||
// Sends message success. which then redirects back to the home page
|
// Sends message success. which then redirects back to the home page
|
||||||
c.String(http.StatusOK, "Success!")
|
c.String(http.StatusOK, "Success!")
|
||||||
} else {
|
} else {
|
||||||
c.String(http.StatusOK, "Something is wrong with from our side. Email us: me@akilan.io to find out more. ")
|
c.String(http.StatusOK, "Something is wrong with from our side. Email us: me@akilan.io to find out more. ")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Route for logout
|
// Route for logout
|
||||||
r.GET("/logout", func(c *gin.Context) {
|
r.GET("/logout", func(c *gin.Context) {
|
||||||
// Get client session ID
|
// Get client session ID
|
||||||
session, err := c.Cookie("SessionID")
|
session, err := c.Cookie("SessionID")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Redirect(http.StatusFound, "/login")
|
c.Redirect(http.StatusFound, "/login")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove Session ID from the database
|
// Remove Session ID from the database
|
||||||
RemoveLoginSession(connect, session)
|
RemoveLoginSession(connect, session)
|
||||||
|
|
||||||
// redirect to the login page
|
// redirect to the login page
|
||||||
c.Redirect(http.StatusFound, "/login")
|
c.Redirect(http.StatusFound, "/login")
|
||||||
})
|
})
|
||||||
|
|
||||||
// Opens the registration page
|
// Opens the registration page
|
||||||
r.GET("/register", func(c *gin.Context) {
|
r.GET("/register", func(c *gin.Context) {
|
||||||
c.HTML(http.StatusOK, "registration.html", gin.H{
|
c.HTML(http.StatusOK, "registration.html", gin.H{
|
||||||
"title": "Xplane11-WebRTC",
|
"title": "Xplane11-WebRTC",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// Register user information required
|
// Register user information required
|
||||||
r.POST("/register", func(c *gin.Context) {
|
r.POST("/register", func(c *gin.Context) {
|
||||||
// you can bind multipart form with explicit binding declaration:
|
// you can bind multipart form with explicit binding declaration:
|
||||||
// c.ShouldBindWith(&form, binding.Form)
|
// c.ShouldBindWith(&form, binding.Form)
|
||||||
// or you can simply use autobinding with ShouldBind method:
|
// or you can simply use autobinding with ShouldBind method:
|
||||||
// source: https://github.com/gin-gonic/gin#multiparturlencoded-binding
|
// source: https://github.com/gin-gonic/gin#multiparturlencoded-binding
|
||||||
var users Users
|
var users Users
|
||||||
// in this case proper binding will be automatically selected
|
// in this case proper binding will be automatically selected
|
||||||
if err := c.ShouldBind(&users); err != nil {
|
if err := c.ShouldBind(&users); err != nil {
|
||||||
c.String(http.StatusBadRequest, "bad request")
|
c.String(http.StatusBadRequest, "bad request")
|
||||||
}
|
}
|
||||||
|
|
||||||
err = RegisterUser(connect, &users)
|
err = RegisterUser(connect, &users)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.String(http.StatusOK, fmt.Sprint(err))
|
c.String(http.StatusOK, fmt.Sprint(err))
|
||||||
} else {
|
} else {
|
||||||
c.String(http.StatusOK, "Success! Head back to the login page")
|
c.String(http.StatusOK, "Success! Head back to the login page")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Add new server information
|
// Add new server information
|
||||||
r.POST("/AddGameSession", func(c *gin.Context) {
|
r.POST("/AddGameSession", func(c *gin.Context) {
|
||||||
|
|
||||||
// TODO: Binding
|
// TODO: Binding
|
||||||
// you can bind multipart form with explicit binding declaration:
|
// you can bind multipart form with explicit binding declaration:
|
||||||
// c.ShouldBindWith(&form, binding.Form)
|
// c.ShouldBindWith(&form, binding.Form)
|
||||||
// or you can simply use autobinding with ShouldBind method:
|
// or you can simply use autobinding with ShouldBind method:
|
||||||
// source: https://github.com/gin-gonic/gin#multiparturlencoded-binding
|
// source: https://github.com/gin-gonic/gin#multiparturlencoded-binding
|
||||||
var gameSession GameSession
|
var gameSession GameSession
|
||||||
|
|
||||||
gameSession.Rate, _ = strconv.ParseFloat(c.PostForm("Rate"), 8)
|
gameSession.Rate, _ = strconv.ParseFloat(c.PostForm("Rate"), 8)
|
||||||
gameSession.Server.GPU = c.PostForm("GPU")
|
gameSession.Server.GPU = c.PostForm("GPU")
|
||||||
gameSession.Link = c.PostForm("Link")
|
gameSession.Link = c.PostForm("Link")
|
||||||
gameSession.Server.CPU = c.PostForm("CPU")
|
gameSession.Server.CPU = c.PostForm("CPU")
|
||||||
gameSession.Server.GPU = c.PostForm("GPU")
|
gameSession.Server.GPU = c.PostForm("GPU")
|
||||||
gameSession.Server.Platform = c.PostForm("Platform")
|
gameSession.Server.Platform = c.PostForm("Platform")
|
||||||
gameSession.Server.Hostname = c.PostForm("HostName")
|
gameSession.Server.Hostname = c.PostForm("HostName")
|
||||||
gameSession.Server.RAM = c.PostForm("RAM")
|
gameSession.Server.RAM = c.PostForm("RAM")
|
||||||
gameSession.Server.Disk = c.PostForm("Disk")
|
gameSession.Server.Disk = c.PostForm("Disk")
|
||||||
|
|
||||||
// in this case proper binding will be automatically selected
|
// in this case proper binding will be automatically selected
|
||||||
//if err := c.ShouldBind(&gameSession); err != nil {
|
//if err := c.ShouldBind(&gameSession); err != nil {
|
||||||
// c.String(http.StatusBadRequest, "bad request")
|
// c.String(http.StatusBadRequest, "bad request")
|
||||||
//}
|
//}
|
||||||
|
|
||||||
err = AddServerSpecs(connect, &gameSession)
|
err = AddServerSpecs(connect, &gameSession)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.String(http.StatusOK, fmt.Sprint(err))
|
c.String(http.StatusOK, fmt.Sprint(err))
|
||||||
} else {
|
} else {
|
||||||
c.String(http.StatusOK, "Success")
|
c.String(http.StatusOK, "Success")
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// route to add barrier IP information
|
// route to add barrier IP information
|
||||||
r.POST("/AddBarrierIP", func(c *gin.Context) {
|
r.POST("/AddBarrierIP", func(c *gin.Context) {
|
||||||
// Get client session ID
|
// Get client session ID
|
||||||
session, err := c.Cookie("SessionID")
|
session, err := c.Cookie("SessionID")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Redirect(http.StatusFound, "/login")
|
c.Redirect(http.StatusFound, "/login")
|
||||||
}
|
}
|
||||||
|
|
||||||
barrierIP := c.PostForm("BarrierIP")
|
barrierIP := c.PostForm("BarrierIP")
|
||||||
MachineName := c.PostForm("MachineName")
|
MachineName := c.PostForm("MachineName")
|
||||||
|
|
||||||
BarrierIP, err := AddBarrierIP(connect, session, barrierIP, MachineName)
|
_, err = AddBarrierIP(connect, session, barrierIP, MachineName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.String(http.StatusOK, fmt.Sprint(err))
|
c.String(http.StatusOK, fmt.Sprint(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.JSON(http.StatusOK, BarrierIP)
|
c.String(http.StatusOK, "Success")
|
||||||
})
|
})
|
||||||
|
|
||||||
// Removes barrier ip information from the table
|
// Removes barrier ip information from the table
|
||||||
// based on the barrier ip address provided.
|
// based on the barrier ip address provided.
|
||||||
r.POST("RemoveBarrierIP", func(c *gin.Context) {
|
r.POST("RemoveBarrierIP", func(c *gin.Context) {
|
||||||
// Get client session ID
|
// Get client session ID
|
||||||
_, err = c.Cookie("SessionID")
|
_, err = c.Cookie("SessionID")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Redirect(http.StatusFound, "/login")
|
c.Redirect(http.StatusFound, "/login")
|
||||||
}
|
}
|
||||||
|
|
||||||
barrierIP := c.PostForm("BarrierIP")
|
barrierIP := c.PostForm("BarrierIP")
|
||||||
// Remove Barrier IP
|
// Remove Barrier IP
|
||||||
err = RemoveBarrierIP(connect, barrierIP)
|
err = RemoveBarrierIP(connect, barrierIP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.String(http.StatusOK, fmt.Sprint(err))
|
c.String(http.StatusOK, fmt.Sprint(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
c.String(http.StatusOK, "BarrierIP removed successfully")
|
c.String(http.StatusOK, "BarrierIP removed successfully")
|
||||||
})
|
})
|
||||||
|
|
||||||
go CheckIfGameSessionIsActiveOrRemove(connect)
|
go CheckIfGameSessionIsActiveOrRemove(connect)
|
||||||
|
|
||||||
// Run gin server on the specified port
|
// Run gin server on the specified port
|
||||||
err = r.Run(":" + port)
|
err = r.Run(":" + port)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CheckIfGameSessionIsActiveOrRemove(gorm *gorm.DB) {
|
func CheckIfGameSessionIsActiveOrRemove(gorm *gorm.DB) {
|
||||||
for {
|
for {
|
||||||
time.Sleep(10 * time.Second)
|
time.Sleep(10 * time.Second)
|
||||||
Gamesessions, err := DisplayGameSessions(gorm)
|
Gamesessions, err := DisplayGameSessions(gorm)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(Gamesessions) != 0 {
|
if len(Gamesessions) != 0 {
|
||||||
fmt.Println(Gamesessions[0].Link)
|
fmt.Println(Gamesessions[0].Link)
|
||||||
}
|
}
|
||||||
|
|
||||||
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
|
||||||
for i, _ := range Gamesessions {
|
for i, _ := range Gamesessions {
|
||||||
req, err := http.NewRequest("GET", Gamesessions[i].Link, nil)
|
req, err := http.NewRequest("GET", Gamesessions[i].Link, nil)
|
||||||
// Sending request to the backend server
|
// Sending request to the backend server
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
_, err = client.Do(req)
|
_, err = client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// remove from database game session
|
// remove from database game session
|
||||||
_, err = RemoveTableGameSessionID(gorm, Gamesessions[i].GameSessionID)
|
_, err = RemoveTableGameSessionID(gorm, Gamesessions[i].GameSessionID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,18 +76,20 @@
|
|||||||
class="input"
|
class="input"
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="Barrier IP address"
|
placeholder="Barrier IP address"
|
||||||
|
name="BarrierIP"
|
||||||
|
id="BarrierIP"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">Machine Name</label>
|
<label class="label">Machine Name</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input class="input" type="text" placeholder="Machine name" />
|
<input class="input" type="text" name="MachineName" id="MachineName" placeholder="Machine name" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field is-grouped">
|
<div class="field is-grouped">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button type="button" class="custom-button button-dark">
|
<button type="button" class="custom-button button-dark" onclick="AddBarrierNode();return false;">
|
||||||
Add Barrier Information
|
Add Barrier Information
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -97,12 +99,14 @@
|
|||||||
<div class="barrier-session-info-wrapper block">
|
<div class="barrier-session-info-wrapper block">
|
||||||
<div class="barrier-session-info">
|
<div class="barrier-session-info">
|
||||||
<div class="light-text">Barrier Session information</div>
|
<div class="light-text">Barrier Session information</div>
|
||||||
|
{{ range .BarrierIPS }}
|
||||||
<div>
|
<div>
|
||||||
<div class="small-text">Barrier IP address and HostName</div>
|
<div class="small-text">{{ .BarrierIP }} and {{ .MachineName }}</div>
|
||||||
<button type="button" class="custom-button button-light">
|
<button type="button" class="custom-button button-light" onclick="RemoveBarrierSessions({{ .BarrierIP }});return false;">
|
||||||
Remove
|
Remove
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -110,12 +114,13 @@
|
|||||||
{{ range .GameSessions }}
|
{{ range .GameSessions }}
|
||||||
<div class="custom-card">
|
<div class="custom-card">
|
||||||
<article class="tile is-child box">
|
<article class="tile is-child box">
|
||||||
<p class="title">{{ .Server.GPU }}</p>
|
<p class="title">{{ .Server.Hostname }}</p>
|
||||||
<p class="server-info">RAM: {{ .Server.RAM }} MB</p>
|
<p class="server-info">RAM: {{ .Server.RAM }} MB</p>
|
||||||
<p class="server-info">Rate: {{ .Rate }}$/hr</p>
|
<p class="server-info">Rate: {{ .Rate }}$/hr</p>
|
||||||
<p class="server-info">CPU: {{ .Server.CPU }}</p>
|
<p class="server-info">CPU: {{ .Server.CPU }}</p>
|
||||||
<p class="server-info">Disk: {{ .Server.Disk }} MB</p>
|
<p class="server-info">Disk: {{ .Server.Disk }} MB</p>
|
||||||
<p class="server-info">Platform: {{ .Server.Platform }}</p>
|
<p class="server-info">Platform: {{ .Server.Platform }}</p>
|
||||||
|
<p class="server-info">GPU: {{ .Server.GPU }}</p>
|
||||||
<br />
|
<br />
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@@ -139,7 +144,7 @@
|
|||||||
aria-labelledby="modal-1-title"
|
aria-labelledby="modal-1-title"
|
||||||
>
|
>
|
||||||
<header class="modal__header">
|
<header class="modal__header">
|
||||||
<h2 class="modal__title" id="modal-1-title">Modal Title</h2>
|
<h2 class="modal__title" id="modal-1-title">Choose barrier session</h2>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="modal__close"
|
class="modal__close"
|
||||||
@@ -148,11 +153,14 @@
|
|||||||
></button>
|
></button>
|
||||||
</header>
|
</header>
|
||||||
<main class="modal__content" id="modal-1-content">
|
<main class="modal__content" id="modal-1-content">
|
||||||
<p>
|
{{ range .BarrierIPS }}
|
||||||
Try hitting the <code>tab</code> key and notice how the focus
|
<div class="form-check">
|
||||||
stays within the modal itself. Also, <code>esc</code> to close
|
<input class="form-check-input" type="radio" name="flexRadioDefault" id="flexRadioDefault{{ .MachineName }}">
|
||||||
modal.
|
<label class="form-check-label" for="flexRadioDefault{{ .MachineName }}">
|
||||||
</p>
|
{{ .BarrierIP }} and {{ .MachineName }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
</main>
|
</main>
|
||||||
<footer class="modal__footer">
|
<footer class="modal__footer">
|
||||||
<button
|
<button
|
||||||
@@ -200,6 +208,78 @@
|
|||||||
function goToLink() {
|
function goToLink() {
|
||||||
window.open(link, "_blank");
|
window.open(link, "_blank");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The function is called on OnClick action
|
||||||
|
function AddBarrierNode() {
|
||||||
|
// Getting element information of all the fields
|
||||||
|
// required for registration
|
||||||
|
var BarrierIP = document.getElementById("BarrierIP").value
|
||||||
|
var MachineName = document.getElementById("MachineName").value
|
||||||
|
|
||||||
|
|
||||||
|
// // When EmailID is not entered
|
||||||
|
// if (BarrierIP == "") {
|
||||||
|
// document.getElementById("EmailIDError").innerHTML = "Enter EmailID"
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // When EmailID is entered
|
||||||
|
// if (BarrierIP != "") {
|
||||||
|
// document.getElementById("EmailIDError").innerHTML = ""
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // When password and confirm password don't match
|
||||||
|
// if (MachineName != "") {
|
||||||
|
// document.getElementById("PasswordError").innerHTML = ""
|
||||||
|
// }
|
||||||
|
// // When the password matches then clear the field
|
||||||
|
// if (MachineName == "") {
|
||||||
|
// document.getElementById("PasswordError").innerHTML = "Enter password"
|
||||||
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
|
// binding data to uri encoded string
|
||||||
|
uriencoded = "BarrierIP=" + BarrierIP + "&MachineName=" + MachineName
|
||||||
|
|
||||||
|
// Submitting the registration information
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("POST", "/AddBarrierIP", true);
|
||||||
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
xhr.send(uriencoded);
|
||||||
|
|
||||||
|
xhr.onload = function () {
|
||||||
|
console.log(xhr.responseText)
|
||||||
|
// // Outputting response text
|
||||||
|
// document.getElementById("ResponseText").innerHTML = xhr.responseText
|
||||||
|
// Create Sessions browser
|
||||||
|
// if response is success then redirect
|
||||||
|
if (xhr.responseText === "Success") {
|
||||||
|
window.location.replace("/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function RemoveBarrierSessions(ipaddress) {
|
||||||
|
// binding data to uri encoded string
|
||||||
|
uriencoded = "BarrierIP=" + ipaddress
|
||||||
|
|
||||||
|
// Submitting the registration information
|
||||||
|
var xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("POST", "/RemoveBarrierIP", true);
|
||||||
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
xhr.send(uriencoded);
|
||||||
|
|
||||||
|
xhr.onload = function () {
|
||||||
|
console.log(xhr.responseText)
|
||||||
|
// // Outputting response text
|
||||||
|
// document.getElementById("ResponseText").innerHTML = xhr.responseText
|
||||||
|
// Create Sessions browser
|
||||||
|
// if response is success then redirect
|
||||||
|
if (xhr.responseText === "BarrierIP removed successfully") {
|
||||||
|
window.location.replace("/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<script async type="text/javascript" src="assets/js/bulma.js"></script>
|
<script async type="text/javascript" src="assets/js/bulma.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
Reference in New Issue
Block a user