Add initial elements for profile and account handling.
This commit is contained in:
parent
bed3bf3b59
commit
4bbd97b52c
@ -224,6 +224,12 @@ impl App {
|
||||
)).await.ok();
|
||||
}
|
||||
|
||||
QRPacketData::RUserInfo(response) => {
|
||||
socket.send(Message::Binary(
|
||||
encode_response(CODE_USER_INFO, response.encode())
|
||||
)).await.ok();
|
||||
}
|
||||
|
||||
QRPacketData::TestResult(response) => {
|
||||
socket.send(Message::Binary(
|
||||
encode_response(CODE_TEST_RESULT, response.encode())
|
||||
|
@ -45,6 +45,7 @@ pub const CODE_CHALLENGE_ANSWER :u16 = 0x0061;
|
||||
pub const CODE_CHALLENGE_LIST :u16 = 0x0062;
|
||||
|
||||
pub const CODE_USER_LIST :u16 = 0x0100;
|
||||
pub const CODE_USER_INFO :u16 = 0x0101;
|
||||
//pub const CODE_USER_AWAIT_GET :u16 = 0x0110;
|
||||
//pub const CODE_USER_AWAIT_SET :u16 = 0x0111;
|
||||
|
||||
|
@ -29,6 +29,9 @@ pub enum QRPacketData {
|
||||
QUserList,
|
||||
RUserList(PacketUserListResponse),
|
||||
|
||||
QUserInfo(PacketUserInfo),
|
||||
RUserInfo(PacketUserInfoResponse),
|
||||
|
||||
QSessionList(PacketSessionList),
|
||||
RSessionList(PacketSessionListResponse),
|
||||
|
||||
|
@ -21,6 +21,7 @@ mod challenge_answer; pub use challenge_answer::*;
|
||||
mod challenge_list; pub use challenge_list::*;
|
||||
|
||||
mod user_list; pub use user_list::*;
|
||||
mod user_info; pub use user_info::*;
|
||||
|
||||
mod test_result; pub use test_result::*;
|
||||
|
||||
|
51
server/src/protocol/packet/user_info.rs
Normal file
51
server/src/protocol/packet/user_info.rs
Normal file
@ -0,0 +1,51 @@
|
||||
use crate::util::pack::pack_u16;
|
||||
|
||||
use super::Packet;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct PacketUserInfo {
|
||||
pub handle:String,
|
||||
}
|
||||
impl PacketUserInfo {
|
||||
pub fn new() -> Self
|
||||
{
|
||||
Self {
|
||||
handle:String::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Packet for PacketUserInfo {
|
||||
type Data = Self;
|
||||
|
||||
fn decode(_data:&Vec<u8>, _index:&mut usize) -> Result<Self::Data, ()>
|
||||
{
|
||||
Ok(Self::new())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct PacketUserInfoResponse {
|
||||
pub status:u16,
|
||||
pub handle:String,
|
||||
pub is_online:bool,
|
||||
}
|
||||
impl PacketUserInfoResponse {
|
||||
pub fn new() -> Self
|
||||
{
|
||||
Self {
|
||||
status:0,
|
||||
handle:String::new(),
|
||||
is_online:false,
|
||||
}
|
||||
}
|
||||
}
|
||||
impl Packet for PacketUserInfoResponse {
|
||||
type Data = Self;
|
||||
|
||||
fn encode(&self) -> Vec<u8>
|
||||
{
|
||||
[
|
||||
pack_u16(self.status as u16),
|
||||
].concat()
|
||||
}
|
||||
}
|
102
www/js/scene.js
102
www/js/scene.js
@ -595,26 +595,13 @@ const SCENES = {
|
||||
Profile:class{
|
||||
constructor() { }
|
||||
load(data) {
|
||||
let buttons_top = [ ];
|
||||
let buttons_bottom = [ ];
|
||||
let buttons_left = [ ];
|
||||
let buttons_right = [ ];
|
||||
|
||||
// Top Buttons
|
||||
buttons_top.push(UI.button("Profile", () => { }));
|
||||
buttons_top.push(UI.button("History", () => { }));
|
||||
|
||||
// Bottom Buttons
|
||||
if(data.handle === CONTEXT.Auth.handle) {
|
||||
buttons_bottom.push(UI.button("Account", () => { }));
|
||||
buttons_bottom.push(UI.button("Security", () => { }));
|
||||
buttons_bottom.push(UI.button("Payments", () => { }));
|
||||
}
|
||||
buttons_bottom.push(UI.button(LANG("back"), () => { LOAD(SCENES.Browse); }));
|
||||
UI.mainmenu_account(data, "profile");
|
||||
|
||||
// Left Buttons
|
||||
let buttons_left = [ ];
|
||||
|
||||
// Right Buttons
|
||||
let buttons_right = [ ];
|
||||
if(data.handle === CONTEXT.Auth.handle) {
|
||||
buttons_right.push(UI.button(LANG("logout"), () => {
|
||||
BADGE_UPDATE(false);
|
||||
@ -626,8 +613,6 @@ const SCENES = {
|
||||
LOAD(SCENES.Browse);
|
||||
}));
|
||||
}
|
||||
|
||||
UI.nav(buttons_top, buttons_bottom);
|
||||
UI.mainnav(buttons_left, buttons_right);
|
||||
|
||||
// Main Content
|
||||
@ -637,6 +622,75 @@ const SCENES = {
|
||||
}
|
||||
},
|
||||
|
||||
Account:class{
|
||||
constructor() { }
|
||||
load(data) {
|
||||
UI.mainmenu_account(data, "account");
|
||||
|
||||
// Left Buttons
|
||||
let buttons_left = [ ];
|
||||
|
||||
// Right Buttons
|
||||
let buttons_right = [ ];
|
||||
buttons_right.push(UI.button(LANG("logout"), () => {
|
||||
BADGE_UPDATE(false);
|
||||
MESSAGE_COMPOSE([
|
||||
PACK.u16(OpCode.Deauthenticate),
|
||||
]);
|
||||
sessionStorage.clear();
|
||||
CONTEXT.Auth = null;
|
||||
LOAD(SCENES.Browse);
|
||||
}));
|
||||
UI.mainnav(buttons_left, buttons_right);
|
||||
|
||||
// Main Content
|
||||
|
||||
history.pushState(null, "Dzura - About", "/u/" + CONTEXT.Auth.handle);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
Subscription:class{
|
||||
constructor() { }
|
||||
load(data) {
|
||||
UI.mainmenu_account(null, "subscription");
|
||||
|
||||
// Left Buttons
|
||||
let buttons_left = [ ];
|
||||
|
||||
// Right Buttons
|
||||
let buttons_right = [ ];
|
||||
buttons_right.push(UI.button("Cancel", () => { }));
|
||||
|
||||
UI.mainnav(buttons_left, buttons_right);
|
||||
|
||||
// Main Content
|
||||
|
||||
history.pushState(null, "Dzura - About", "/u/" + CONTEXT.Auth.handle);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
Invitations:class{
|
||||
constructor() { }
|
||||
load(data) {
|
||||
UI.mainmenu_account(null, "invitations");
|
||||
|
||||
// Left Buttons
|
||||
let buttons_left = [ ];
|
||||
|
||||
// Right Buttons
|
||||
let buttons_right = [ ];
|
||||
|
||||
UI.mainnav(buttons_left, buttons_right);
|
||||
|
||||
// Main Content
|
||||
|
||||
history.pushState(null, "Dzura - About", "/u/" + CONTEXT.Auth.handle);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
GameLoad:class{
|
||||
constructor() {
|
||||
this.mode = null;
|
||||
@ -1091,18 +1145,6 @@ const SCENES = {
|
||||
LOAD(SCENES.Offline);
|
||||
}
|
||||
},
|
||||
|
||||
UserProfile:class{
|
||||
constructor() {
|
||||
|
||||
}
|
||||
preload() {
|
||||
|
||||
}
|
||||
load(data) {
|
||||
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
function LOAD(scene, data=null) {
|
||||
|
19
www/js/ui.js
19
www/js/ui.js
@ -195,6 +195,25 @@ const UI = {
|
||||
}
|
||||
},
|
||||
|
||||
mainmenu_account(data, page) {
|
||||
let buttons_top = [ ];
|
||||
let buttons_bottom = [ ];
|
||||
|
||||
// Top Buttons
|
||||
buttons_top.push(UI.button("Profile", () => { LOAD(SCENES.Profile, { handle:CONTEXT.Auth.handle }) }, page == "profile"));
|
||||
buttons_top.push(UI.button("History", () => { }, page == "history"));
|
||||
|
||||
// Bottom Buttons
|
||||
if(data === null || data.handle === CONTEXT.Auth.handle) {
|
||||
buttons_bottom.push(UI.button("Account", () => { LOAD(SCENES.Account) }, page == "account"));
|
||||
buttons_bottom.push(UI.button("Subscription", () => { LOAD(SCENES.Subscription) }, page == "subscription"));
|
||||
buttons_bottom.push(UI.button("Invitations", () => { LOAD(SCENES.Invitations) }, page == "invitations"));
|
||||
}
|
||||
buttons_bottom.push(UI.button(LANG("back"), () => { LOAD(SCENES.Browse); }));
|
||||
|
||||
UI.nav(buttons_top, buttons_bottom);
|
||||
},
|
||||
|
||||
session_table(records) {
|
||||
let rows = [ ];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user