diff --git a/src/templates/CharacterArchiver.hbs b/src/templates/CharacterArchiver.hbs index 2248026..b67f9b9 100644 --- a/src/templates/CharacterArchiver.hbs +++ b/src/templates/CharacterArchiver.hbs @@ -1,2 +1,11 @@ -
-
\ No newline at end of file +
+
+ Hello There {{this.potato}} + +
+
+ Avaiable Versions Go Here + {{this.reads}} +
+ +
\ No newline at end of file diff --git a/src/ts/apps/CharacterArchiver.ts b/src/ts/apps/CharacterArchiver.ts index 4498f27..2d219ef 100644 --- a/src/ts/apps/CharacterArchiver.ts +++ b/src/ts/apps/CharacterArchiver.ts @@ -1,14 +1,67 @@ +import { id as moduleId } from "../../module.json"; +import { CharacterManagerClient } from "../../proto/character.client"; +import { GetCharacterRequest } from '../../proto/character' +import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport' + export class CharacterArchiver extends Application { - - static override get defaultOptions() { - const options = super.defaultOptions; - options.id = "character-archiver"; - options.template = "modules/rush-character-archive-foundry-module/templates/CharacterArchiver.hbs"; - options.width = 500; - options.height = 270; - options.tabs = [{ navSelector: ".tabs", contentSelector: ".theatre-config-contents", initial: "main" }]; - return options; - } + + readonly characterId: String; + readonly character: Actor | undefined; + + readonly client = new CharacterManagerClient( + new GrpcWebFetchTransport({ + baseUrl: 'http://localhost/api', + format: 'binary', + }), + ); + + thingy: any; + + constructor(characterId: string) { + super() + this.characterId = characterId; + this.character = (game as Game).actors!.get(characterId); + } + + static override get defaultOptions() { + const options = super.defaultOptions; + options.id = "character-archiver"; + options.template = `modules/${moduleId}/templates/CharacterArchiver.hbs`; + options.width = 500; + options.height = 270; + options.tabs = []; + return options; + } + + override getData() { + return { + potato: "potato tato po tato", + reads: this.thingy + }; + } + + + override activateListeners(html: JQuery): void { + console.log("activating listeners"); + super.activateListeners(html); + html + .find("button.archive-button") + .on("click", this._archiveButton.bind(this)); + } + + 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); + }) + } } \ No newline at end of file diff --git a/src/ts/module.ts b/src/ts/module.ts index 330f26d..79e61da 100644 --- a/src/ts/module.ts +++ b/src/ts/module.ts @@ -2,19 +2,19 @@ import { CharacterManagerClient } from "../proto/character.client"; import { GetCharacterRequest } from '../proto/character' import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport' -import { ModuleData } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/packages.mjs"; +// import { ModuleData } from "@league-of-foundry-developers/foundry-vtt-types/src/foundry/common/packages.mjs"; import { id as moduleId } from "../module.json"; -import DogBrowser from "./apps/NewCharacter"; +// import DogBrowser from "./apps/NewCharacter"; import { initializeSettings } from "./settings"; import { CharacterArchiver } from "./apps/CharacterArchiver" -interface MyModule extends Game.ModuleData { - dogBrowser: DogBrowser; -} +// interface MyModule extends Game.ModuleData { +// dogBrowser: DogBrowser; +// } -let module: MyModule; +// let module: MyModule; Hooks.once("init", async () => { @@ -45,10 +45,6 @@ Hooks.once("init", async () => { console.log("Potato"); console.log(`Initializing ${moduleId}`); - - module = (game as Game).modules.get(moduleId) as MyModule; - module.dogBrowser = new DogBrowser(); - module.dogBrowser.render(true); }); // Add to the character sheet header bar. @@ -64,7 +60,7 @@ Hooks.on("getActorSheetHeaderButtons", (app: any, buttons: any) => { icon: "fas fa-save", onclick: (ev: any) => { console.log(ev) - new CharacterArchiver().render(true); + new CharacterArchiver("").render(true); console.log("ARCHIVE ME!"); } @@ -85,18 +81,26 @@ Hooks.on("getActorDirectoryEntryContext", async (html: any, options: any) => { return (game as Game).actors!.get(target.data("documentId")); }; - console.log(getActorData) + // console.log("char--^^") + // console.log(getActorData(html)) + // console.log(html[0]) + // console.log(options) + // console.log("char^^--") options.splice( 3, 0, { - name: "Archive", - icon: '', - callback: (target: any) => { - console.log(target) - new CharacterArchiver().render(true); - }, + name: "Archive", + icon: '', + callback: (target: any) => { + console.log("char-->") + console.log(getActorData(target)) + console.log("char--<") + console.log(target) + console.log(target[0].dataset.documentId) + new CharacterArchiver(target[0].dataset.documentId).render(true); + }, }, );