add auxmsg publish
This commit is contained in:
parent
1fd828f6fd
commit
42bb254d84
3 changed files with 19 additions and 6 deletions
|
@ -221,7 +221,7 @@ func (self *GameTableServer) writeToDB(tableMsg models.TableMessage) error {
|
|||
}
|
||||
}
|
||||
|
||||
// map image change and token addition/removal require admin authorization
|
||||
// map image change, aux message, and token addition/removal require admin authorization
|
||||
if tableMsg.Auth != nil {
|
||||
authorized, _ := self.udb.ValidateToken(*tableMsg.Auth)
|
||||
if authorized {
|
||||
|
@ -231,6 +231,12 @@ func (self *GameTableServer) writeToDB(tableMsg models.TableMessage) error {
|
|||
return err
|
||||
}
|
||||
}
|
||||
if tableMsg.AuxMsg != nil {
|
||||
err := self.dbAdapter.SetAuxMessage(key, *tableMsg.AuxMsg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
@ -17,12 +17,13 @@ type DiceRoll struct {
|
|||
Timestamp time.Time `json:"timestamp"`
|
||||
}
|
||||
|
||||
|
||||
type Token struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
SpriteUri string `json:"spriteUrl"`
|
||||
X int `json:"x"`
|
||||
Y int `json:"y"`
|
||||
X *int `json:"x"`
|
||||
Y *int `json:"y"`
|
||||
}
|
||||
|
||||
type Table struct {
|
||||
|
|
|
@ -23,9 +23,8 @@ async function getTable(name, pass) {
|
|||
document.getElementById("input_table_name").value = name;
|
||||
document.getElementById("input_table_pass").value = pass;
|
||||
dial();
|
||||
infoHtml = "<a href='#' onclick='getTables()'>← table list</a><br><pre>";
|
||||
infoHtml += await res.text();
|
||||
infoHtml += "</pre>"
|
||||
infoHtml = "<a href='#' onclick='getTables()'>← table list</a><br>";
|
||||
infoHtml += `<textarea id='auxMsgZone'>${(await res.json()).auxMsg}</textarea><br><button onclick='publishAuxMsg()'>Change</button>`
|
||||
infoHtml += "<button onclick='destroyTable()'>Destroy</button>"
|
||||
infoHtml += "<input id='map_img_upload' type='file'>Map Image</input><button onclick='uploadMapImg()'>Upload</button>"
|
||||
if (mapImgs.ok) {
|
||||
|
@ -48,6 +47,13 @@ async function getTable(name, pass) {
|
|||
}
|
||||
}
|
||||
|
||||
function publishAuxMsg() {
|
||||
const txtArea = document.getElementById("auxMsgZone");
|
||||
if (txtArea != null) {
|
||||
publish({auxMsg: txtArea.value, auth: adminToken.access_token});
|
||||
}
|
||||
}
|
||||
|
||||
function sendMapImg(url) {
|
||||
publish({mapImg: url, auth: adminToken.access_token});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue