Archive button sends to backend via grpc

This commit is contained in:
iamBadgers
2025-08-16 19:14:28 -07:00
parent 678095a004
commit 468bf24214
2 changed files with 42 additions and 19 deletions

View File

@@ -1,7 +1,7 @@
<div>
<div class="details">
Hello There {{this.potato}}
<input/>
<input class="character-handle" value="{{this.handle}}"/>
</div>
<div class="available-versions">
Avaiable Versions Go Here

View File

@@ -1,6 +1,6 @@
import { id as moduleId } from "../../module.json";
import { CharacterManagerClient } from "../../proto/character.client";
import { GetCharacterRequest } from '../../proto/character'
import { Character, CreateCharacterRequest } from '../../proto/character'
import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport'
@@ -16,7 +16,11 @@ export class CharacterArchiver extends Application {
}),
);
thingy: any;
data = {
potato: "po tato potato",
reads: {},
handle: "default"
}
constructor(characterId: string) {
super()
@@ -35,10 +39,7 @@ export class CharacterArchiver extends Application {
}
override getData() {
return {
potato: "potato tato po tato",
reads: this.thingy
};
return this.data;
}
@@ -47,21 +48,43 @@ export class CharacterArchiver extends Application {
super.activateListeners(html);
html
.find("button.archive-button")
.on("click", this._archiveButton.bind(this));
.on("click", this.archiveButton.bind(this));
console.log(html.find(".character-handle"));
html
.find(".character-handle")
.on("change", this.handleChange.bind(this));
}
private async _archiveButton() {
private async archiveButton() {
console.log("Potato");
let request = GetCharacterRequest.fromJson({
})
console.log("Potato");
await this.client.getCharacter(request).then((res: any) => {
console.log(res)
this.thingy = res.response;
console.log(res);
this.render(true);
})
let characterMsg: Character = Character.fromJson({
playerName: "iamBadgers",
characterName: this.character!.name,
characterAlias: [],
version: "",
sourceTable: "",
json: JSON.stringify(this.character!.toJSON())
});
let request: CreateCharacterRequest = {
characterData: characterMsg
};
console.log("HERE: " + JSON.stringify(request));
this.client.createCharacter(request);
}
private async handleChange(e: Event) {
console.log(e.target);
const target = e.target as HTMLTextAreaElement;
this.data.handle = target.value;
console.log(this.data.handle);
}
}