Datagen database viewer barely works
Some checks failed
test / run-tests-client (push) Successful in 42s
test / run-tests-backend (push) Failing after 16s

This commit is contained in:
BinarySandia04 2024-10-22 14:53:24 +02:00
parent 1aab2bd811
commit 763e8b7912
38 changed files with 35 additions and 175 deletions

View File

@ -4,7 +4,7 @@ const Schema = mongoose.Schema;
const DatagenEntrySchema = new Schema({ const DatagenEntrySchema = new Schema({
id: {type: String, required: true}, id: {type: String, required: true},
schema: { type: String, required: true}, schema: { type: String, required: true},
data: { type: Object }, data: { type: Object, default: {} },
datagen_collection: {type: mongoose.Types.ObjectId, ref: "DatagenCollection"}, datagen_collection: {type: mongoose.Types.ObjectId, ref: "DatagenCollection"},
}); });

View File

@ -69,7 +69,7 @@ async function appendDatagen(file, modelName, info, datagenCollection){
let fileData = JSON.parse(fs.readFileSync(file)); let fileData = JSON.parse(fs.readFileSync(file));
return await DatagenEntry.create({ return await DatagenEntry.create({
id: fileData.id, id: fileData.id,
data: fileData.value, data: fileData.value !== undefined ? fileData.value : {},
schema: modelName, schema: modelName,
datagen_collection: datagenCollection datagen_collection: datagenCollection
}); });

View File

@ -1,4 +1,4 @@
import { FetchConcepts, InitData } from "./data"; import { FetchConcepts, GetConcepts, InitData } from "./data";
import { Global } from '@/services/PluginGlobals'; import { Global } from '@/services/PluginGlobals';
var dndModule; var dndModule;
@ -44,6 +44,8 @@ function Main(Api){
Api.createWindow(databaseWindow, { Api.createWindow(databaseWindow, {
title: "Campaign items", title: "Campaign items",
id: 'campaign-items-window', id: 'campaign-items-window',
fetchConcepts: FetchConcepts, // Requests reactive ref update
getConcepts: GetConcepts, // Needs to return reactive ref value
close: () => Api.clearWindow("campaign-items-window") close: () => Api.clearWindow("campaign-items-window")
}); });
} }

View File

@ -37,19 +37,18 @@ function FetchBookList(){
} }
function OpenBook(element){ function OpenBook(element){
console.log(element);
console.log("!!!!!");
dndModule.getDatagenData(element.id).then(response => { dndModule.getDatagenData(element.id).then(response => {
console.log(response.data);
Api.createWindow(PluginData.windows.database, { Api.createWindow(PluginData.windows.database, {
title: element.name, title: element.name,
id: 'campaign-items-window', id: 'campaign-items-window',
elements: response.data.elements, elements: response.data.elements,
transformer: (element) => element.data,
topper: { topper: {
icon: "/plugins/" + element.package + "/" + element.icon, icon: "/plugins/" + element.package + "/" + element.icon,
title: element.name, title: element.name,
description: element.desc description: element.desc
}, },
getConcepts: () => response.data.elements,
close: () => Api.clearWindow("campaign-items-window") close: () => Api.clearWindow("campaign-items-window")
}); });
}); });

View File

@ -38,8 +38,22 @@ onMounted(() => {
SetResizable(id, true); SetResizable(id, true);
SetMinSize(id, {width: 800, height: 300}); SetMinSize(id, {width: 800, height: 300});
watch(GetConcepts, () => { // console.log(data);
let elements = GetConcepts();
watch(data.getConcepts, () => {
updateView();
});
if(data.fetchConcepts) data.fetchConcepts();
updateView();
});
function updateView(){
let elements = data.getConcepts();
if(data.transformer) elements = elements.map(element => data.transformer(element));
console.log(elements);
weapons.value = elements.filter((e) => e.type == "Weapon"); weapons.value = elements.filter((e) => e.type == "Weapon");
equipment.value = elements.filter((e) => e.type == "Equipment"); equipment.value = elements.filter((e) => e.type == "Equipment");
consumables.value = elements.filter((e) => e.type == "Consumable"); consumables.value = elements.filter((e) => e.type == "Consumable");
@ -49,11 +63,8 @@ onMounted(() => {
features.value = elements.filter((e) => e.type == "Feature"); features.value = elements.filter((e) => e.type == "Feature");
console.log(elements); console.log(elements);
console.log(elements); }
});
FetchConcepts();
});
function OpenCreateItemPrompt(){ function OpenCreateItemPrompt(){
Api.createWindow(PluginData.windows.create_item_prompt, {id: 'create_item_prompt', title: 'Create Item', close: () => Api.clearWindow('create_item_prompt')}) Api.createWindow(PluginData.windows.create_item_prompt, {id: 'create_item_prompt', title: 'Create Item', close: () => Api.clearWindow('create_item_prompt')})
} }

View File

@ -1,4 +0,0 @@
{
"id": "effects/test_effect",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "consumables/test_consumable",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "container/test_container",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "equipment/test_equipment",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "feature/test_feature",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "spells/test_spell",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "tools/test_tool",
"value": {}
}

View File

@ -1,5 +1,5 @@
{ {
"id": "weapon/test_weapon", "id": "weapons/test_weapon",
"value": { "value": {
"name": "Test datagen weapon", "name": "Test datagen weapon",
"description": "Test test test", "description": "Test test test",

View File

@ -1,4 +0,0 @@
{
"id": "monsters/test_monster",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "classes/test_class",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "races/test_race",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "table/test_table",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "effects/test_effect",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "consumables/test_consumable",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "container/test_container",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "equipment/test_equipment",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "feature/test_feature",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "spells/test_spell",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "tools/test_tool",
"value": {}
}

View File

@ -1,19 +0,0 @@
{
"id": "weapon/test_weapon",
"value": {
"name": "Test datagen weapon",
"description": "Test test test",
"icon": "icons/weapons/ammunition/shot-round-blue.webp",
"type": "Weapon",
"rarity": "Rare",
"quantity": "1",
"weight": "10",
"price": "10",
"data": {
"weapon_type": "Natural",
"properties": [
"Finesse"
]
}
}
}

View File

@ -1,4 +1,6 @@
{ {
"id": "monsters/test_monster", "id": "monsters/test_monster",
"value": {} "value": {
}
} }

View File

@ -1,4 +0,0 @@
{
"id": "classes/test_class",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "races/test_race",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "table/test_table",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "effects/test_effect",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "consumables/test_consumable",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "container/test_container",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "equipment/test_equipment",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "feature/test_feature",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "spells/test_spell",
"value": {}
}

View File

@ -1,4 +0,0 @@
{
"id": "tools/test_tool",
"value": {}
}

View File

@ -1,19 +0,0 @@
{
"id": "weapon/test_weapon",
"value": {
"name": "Test datagen weapon",
"description": "Test test test",
"icon": "icons/weapons/ammunition/shot-round-blue.webp",
"type": "Weapon",
"rarity": "Rare",
"quantity": "1",
"weight": "10",
"price": "10",
"data": {
"weapon_type": "Natural",
"properties": [
"Finesse"
]
}
}
}

View File

@ -1,4 +0,0 @@
{
"id": "monsters/test_monster",
"value": {}
}