diff --git a/src/templates/CharacterArchiver.hbs b/src/templates/CharacterArchiver.hbs index bb1a31d..603033d 100644 --- a/src/templates/CharacterArchiver.hbs +++ b/src/templates/CharacterArchiver.hbs @@ -5,7 +5,9 @@
Avaiable Versions Go Here - {{this.reads}} + {{#each this.reads}} +
{{this.characterName}} {{this.playerName}} {{this.sourceTable}} {{this.version}}
+ {{/each}}
- \ No newline at end of file + diff --git a/src/ts/apps/CharacterArchiver.ts b/src/ts/apps/CharacterArchiver.ts index 1b76783..44d11af 100644 --- a/src/ts/apps/CharacterArchiver.ts +++ b/src/ts/apps/CharacterArchiver.ts @@ -3,6 +3,11 @@ import { CharacterManagerClient } from "../../proto/character.client"; import { Character, CreateCharacterRequest } from '../../proto/character' import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport' +interface CharacterArchiverData { + potato: string; + reads: Character[]; + playerHandle: string; +} export class CharacterArchiver extends Application { @@ -16,10 +21,10 @@ export class CharacterArchiver extends Application { }), ); - data = { + data: CharacterArchiverData = { potato: "po tato potato", - reads: {}, - handle: "default" + reads: [], + playerHandle: "default" } constructor(characterId: string) { @@ -38,20 +43,21 @@ export class CharacterArchiver extends Application { return options; } - override getData() { - return this.data; + override async getData() { + return this.loadArchiveList().then((characters) => { + this.data.reads = characters; + return this.data; + }) } override activateListeners(html: JQuery): void { - console.log("activating listeners"); super.activateListeners(html); + html .find("button.archive-button") .on("click", this.archiveButton.bind(this)); - console.log(html.find(".character-handle")); - html .find(".character-handle") .on("input", this.handleChange.bind(this)); @@ -66,9 +72,8 @@ export class CharacterArchiver extends Application { characterName: this.character!.name, characterAlias: [], version: "", - sourceTable: "", + sourceTable: "BADGERS", json: JSON.stringify(this.character!.toJSON()) - }); let request: CreateCharacterRequest = { @@ -84,12 +89,20 @@ export class CharacterArchiver extends Application { private async handleChange(e: Event) { clearTimeout(this.timeout); - this.timeout = setTimeout(() => { + this.timeout = setTimeout(async () => { console.log(e.target); const target = e.target as HTMLTextAreaElement; - this.data.handle = target.value; - console.log(this.data.handle); + this.data.playerHandle = target.value; + console.log(this.data.playerHandle); + console.log(await this.loadArchiveList()); }, 500); } -} + private async loadArchiveList(): Promise { + return this.client.listCharacters({ + playerName: "iamBadgers", + characterName: this.character!.name || "" + }).response + .then((response) => response.characters); + } +};