Adding in archiver screen, temp api calls

This commit is contained in:
iamBadgers
2025-08-10 22:38:30 -07:00
parent 902cc4f2e8
commit 678095a004
3 changed files with 96 additions and 30 deletions

View File

@@ -1,2 +1,11 @@
<form> <div>
</form> <div class="details">
Hello There {{this.potato}}
<input/>
</div>
<div class="available-versions">
Avaiable Versions Go Here
{{this.reads}}
</div>
<button class="archive-button">Archive</button>
</div>

View File

@@ -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 { export class CharacterArchiver extends Application {
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() { static override get defaultOptions() {
const options = super.defaultOptions; const options = super.defaultOptions;
options.id = "character-archiver"; options.id = "character-archiver";
options.template = "modules/rush-character-archive-foundry-module/templates/CharacterArchiver.hbs"; options.template = `modules/${moduleId}/templates/CharacterArchiver.hbs`;
options.width = 500; options.width = 500;
options.height = 270; options.height = 270;
options.tabs = [{ navSelector: ".tabs", contentSelector: ".theatre-config-contents", initial: "main" }]; options.tabs = [];
return options; return options;
} }
override getData() {
return {
potato: "potato tato po tato",
reads: this.thingy
};
}
override activateListeners(html: JQuery<HTMLElement>): 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);
})
}
} }

View File

@@ -2,19 +2,19 @@ import { CharacterManagerClient } from "../proto/character.client";
import { GetCharacterRequest } from '../proto/character' import { GetCharacterRequest } from '../proto/character'
import { GrpcWebFetchTransport } from '@protobuf-ts/grpcweb-transport' 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 { id as moduleId } from "../module.json";
import DogBrowser from "./apps/NewCharacter"; // import DogBrowser from "./apps/NewCharacter";
import { initializeSettings } from "./settings"; import { initializeSettings } from "./settings";
import { CharacterArchiver } from "./apps/CharacterArchiver" import { CharacterArchiver } from "./apps/CharacterArchiver"
interface MyModule extends Game.ModuleData<ModuleData> { // interface MyModule extends Game.ModuleData<ModuleData> {
dogBrowser: DogBrowser; // dogBrowser: DogBrowser;
} // }
let module: MyModule; // let module: MyModule;
Hooks.once("init", async () => { Hooks.once("init", async () => {
@@ -45,10 +45,6 @@ Hooks.once("init", async () => {
console.log("Potato"); console.log("Potato");
console.log(`Initializing ${moduleId}`); 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. // Add to the character sheet header bar.
@@ -64,7 +60,7 @@ Hooks.on("getActorSheetHeaderButtons", (app: any, buttons: any) => {
icon: "fas fa-save", icon: "fas fa-save",
onclick: (ev: any) => { onclick: (ev: any) => {
console.log(ev) console.log(ev)
new CharacterArchiver().render(true); new CharacterArchiver("").render(true);
console.log("ARCHIVE ME!"); console.log("ARCHIVE ME!");
} }
@@ -85,7 +81,11 @@ Hooks.on("getActorDirectoryEntryContext", async (html: any, options: any) => {
return (game as Game).actors!.get(target.data("documentId")); 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( options.splice(
3, 3,
@@ -94,8 +94,12 @@ Hooks.on("getActorDirectoryEntryContext", async (html: any, options: any) => {
name: "Archive", name: "Archive",
icon: '<i class="fas fa-save"></i>', icon: '<i class="fas fa-save"></i>',
callback: (target: any) => { callback: (target: any) => {
console.log("char-->")
console.log(getActorData(target))
console.log("char--<")
console.log(target) console.log(target)
new CharacterArchiver().render(true); console.log(target[0].dataset.documentId)
new CharacterArchiver(target[0].dataset.documentId).render(true);
}, },
}, },
); );