Messing with displaying the available versions

This commit is contained in:
iamBadgers
2025-08-17 18:58:33 -07:00
parent ec98fb9975
commit 7b3e206240
2 changed files with 31 additions and 16 deletions

View File

@@ -5,7 +5,9 @@
</div> </div>
<div class="available-versions"> <div class="available-versions">
Avaiable Versions Go Here Avaiable Versions Go Here
{{this.reads}} {{#each this.reads}}
<div>{{this.characterName}} {{this.playerName}} {{this.sourceTable}} {{this.version}}</div>
{{/each}}
</div> </div>
<button class="archive-button">Archive</button> <button class="archive-button">Archive</button>
</div> </div>

View File

@@ -3,6 +3,11 @@ import { CharacterManagerClient } from "../../proto/character.client";
import { Character, CreateCharacterRequest } from '../../proto/character' import { Character, CreateCharacterRequest } from '../../proto/character'
import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport' import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport'
interface CharacterArchiverData {
potato: string;
reads: Character[];
playerHandle: string;
}
export class CharacterArchiver extends Application { export class CharacterArchiver extends Application {
@@ -16,10 +21,10 @@ export class CharacterArchiver extends Application {
}), }),
); );
data = { data: CharacterArchiverData = {
potato: "po tato potato", potato: "po tato potato",
reads: {}, reads: [],
handle: "default" playerHandle: "default"
} }
constructor(characterId: string) { constructor(characterId: string) {
@@ -38,20 +43,21 @@ export class CharacterArchiver extends Application {
return options; return options;
} }
override getData() { override async getData() {
return this.loadArchiveList().then((characters) => {
this.data.reads = characters;
return this.data; return this.data;
})
} }
override activateListeners(html: JQuery<HTMLElement>): void { override activateListeners(html: JQuery<HTMLElement>): void {
console.log("activating listeners");
super.activateListeners(html); super.activateListeners(html);
html html
.find("button.archive-button") .find("button.archive-button")
.on("click", this.archiveButton.bind(this)); .on("click", this.archiveButton.bind(this));
console.log(html.find(".character-handle"));
html html
.find(".character-handle") .find(".character-handle")
.on("input", this.handleChange.bind(this)); .on("input", this.handleChange.bind(this));
@@ -66,9 +72,8 @@ export class CharacterArchiver extends Application {
characterName: this.character!.name, characterName: this.character!.name,
characterAlias: [], characterAlias: [],
version: "", version: "",
sourceTable: "", sourceTable: "BADGERS",
json: JSON.stringify(this.character!.toJSON()) json: JSON.stringify(this.character!.toJSON())
}); });
let request: CreateCharacterRequest = { let request: CreateCharacterRequest = {
@@ -84,12 +89,20 @@ export class CharacterArchiver extends Application {
private async handleChange(e: Event) { private async handleChange(e: Event) {
clearTimeout(this.timeout); clearTimeout(this.timeout);
this.timeout = setTimeout(() => { this.timeout = setTimeout(async () => {
console.log(e.target); console.log(e.target);
const target = e.target as HTMLTextAreaElement; const target = e.target as HTMLTextAreaElement;
this.data.handle = target.value; this.data.playerHandle = target.value;
console.log(this.data.handle); console.log(this.data.playerHandle);
console.log(await this.loadArchiveList());
}, 500); }, 500);
} }
} private async loadArchiveList(): Promise<Character[]> {
return this.client.listCharacters({
playerName: "iamBadgers",
characterName: this.character!.name || ""
}).response
.then((response) => response.characters);
}
};