Started book menu
This commit is contained in:
parent
140700251d
commit
35c0817bb0
@ -1,11 +0,0 @@
|
|||||||
const mongoose = require("mongoose");
|
|
||||||
const Schema = mongoose.Schema;
|
|
||||||
|
|
||||||
const CharacterSchema = new Schema({
|
|
||||||
name: {type: String, required: true},
|
|
||||||
data: { type: Object },
|
|
||||||
owner: {type: mongoose.Types.ObjectId, ref: "CampaignUser"},
|
|
||||||
splash_image: { type: String },
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = mongoose.model('Character', CharacterSchema);
|
|
@ -1,35 +0,0 @@
|
|||||||
const express = require('express');
|
|
||||||
const router = express.Router();
|
|
||||||
|
|
||||||
const passport = require('passport');
|
|
||||||
const rateLimitMiddleware = require("../config/rate-limiter");
|
|
||||||
|
|
||||||
const Campaign = require("../models/Campaign");
|
|
||||||
const CampaignUser = require("../models/CampaignUser");
|
|
||||||
const Character = require('../models/Character');
|
|
||||||
|
|
||||||
const upload = require("../config/storage");
|
|
||||||
|
|
||||||
// Get characters from a campaign
|
|
||||||
router.get('/list', (req, res) => {
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Character info
|
|
||||||
router.post('/create', rateLimitMiddleware, (req, res) => {
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
router.delete('/delete', rateLimitMiddleware, (req, res) => {
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get('/get', (req, res) => {
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
router.put('/update', (req, res) => {
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = router;
|
|
13
backend/routes/datagen.js
Normal file
13
backend/routes/datagen.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
|
||||||
|
// Get characters from a campaign
|
||||||
|
router.get('/:plugin', (req, res) => {
|
||||||
|
res.json({
|
||||||
|
datagens: [
|
||||||
|
{title: "Hello world"}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
@ -77,7 +77,8 @@ app.use(checkAuth);
|
|||||||
|
|
||||||
// ROUTES WITH AUTH
|
// ROUTES WITH AUTH
|
||||||
app.use('/campaign', require('./routes/campaign'));
|
app.use('/campaign', require('./routes/campaign'));
|
||||||
app.use('/maps', require('./routes/map'))
|
app.use('/maps', require('./routes/map'));
|
||||||
|
app.use('/datagen', require('./routes/datagen'))
|
||||||
app.use('/admin', require('./routes/admin'))
|
app.use('/admin', require('./routes/admin'))
|
||||||
// GET localhost:8081/concept/list
|
// GET localhost:8081/concept/list
|
||||||
|
|
||||||
|
@ -156,6 +156,7 @@ class ClientModule {
|
|||||||
#_plugin;
|
#_plugin;
|
||||||
#_id;
|
#_id;
|
||||||
#_router;
|
#_router;
|
||||||
|
#_baseRouter;
|
||||||
|
|
||||||
#_buttons;
|
#_buttons;
|
||||||
#_previewData;
|
#_previewData;
|
||||||
@ -169,6 +170,7 @@ class ClientModule {
|
|||||||
this.#_plugin = plugin;
|
this.#_plugin = plugin;
|
||||||
this.#_id = id;
|
this.#_id = id;
|
||||||
this.#_router = new ClientRouter(`/plugins/${plugin.package}/_module/${id}`, {});
|
this.#_router = new ClientRouter(`/plugins/${plugin.package}/_module/${id}`, {});
|
||||||
|
this.#_baseRouter = new ClientRouter("", {})
|
||||||
this.#_socket = new ClientSocket(`plugins/${plugin.package}/${id}`)
|
this.#_socket = new ClientSocket(`plugins/${plugin.package}/${id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +217,10 @@ class ClientModule {
|
|||||||
get _plugin(){
|
get _plugin(){
|
||||||
return this.#_plugin;
|
return this.#_plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getDatagen(){
|
||||||
|
return this.#_baseRouter.get(`/datagen/${this.#_id}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ClientSocket {
|
class ClientSocket {
|
||||||
|
@ -24,20 +24,15 @@ function FetchConcepts(){
|
|||||||
}).catch(err => console.log(err));
|
}).catch(err => console.log(err));
|
||||||
}
|
}
|
||||||
|
|
||||||
function FetchData(){
|
|
||||||
FetchConcepts();
|
|
||||||
}
|
|
||||||
|
|
||||||
let GetConcepts = () => data.value.concepts;
|
let GetConcepts = () => data.value.concepts;
|
||||||
let GetConcept = (id) => dndModule.router.get('/item/get', {id})
|
let GetItem = (id) => dndModule.router.get('/item/get', {id})
|
||||||
|
|
||||||
|
|
||||||
export {
|
export {
|
||||||
InitData,
|
InitData,
|
||||||
FetchData,
|
|
||||||
|
|
||||||
FetchConcepts,
|
FetchConcepts,
|
||||||
|
|
||||||
GetConcepts,
|
GetConcepts,
|
||||||
GetConcept,
|
GetItem,
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
import { FetchConcepts, FetchData, InitData } from "./data";
|
import { FetchConcepts, InitData } from "./data";
|
||||||
import { Global } from '@/services/PluginGlobals';
|
import { Global } from '@/services/PluginGlobals';
|
||||||
|
|
||||||
var dndModule;
|
var dndModule;
|
||||||
@ -23,9 +23,12 @@ function Main(Api){
|
|||||||
|
|
||||||
let databaseWindow = Api.registerWindow('database', Api.createView('Database'));
|
let databaseWindow = Api.registerWindow('database', Api.createView('Database'));
|
||||||
let actorsWindow = Api.registerWindow('actors', Api.createView('Actors'));
|
let actorsWindow = Api.registerWindow('actors', Api.createView('Actors'));
|
||||||
|
let booksWindow = Api.registerWindow('books', Api.createView('Books'))
|
||||||
|
|
||||||
Global('dnd-5e').Data = {
|
Global('dnd-5e').Data = {
|
||||||
windows: {
|
windows: {
|
||||||
|
database: databaseWindow,
|
||||||
|
actors: actorsWindow,
|
||||||
character_sheet: Api.registerWindow('character_sheet', Api.createView('CharacterSheet')),
|
character_sheet: Api.registerWindow('character_sheet', Api.createView('CharacterSheet')),
|
||||||
item_sheet: Api.registerWindow('item_sheet', Api.createView('ItemSheet')),
|
item_sheet: Api.registerWindow('item_sheet', Api.createView('ItemSheet')),
|
||||||
create_item_prompt: Api.registerWindow('create_item_prompt', Api.createView('CreateItemPrompt'))
|
create_item_prompt: Api.registerWindow('create_item_prompt', Api.createView('CreateItemPrompt'))
|
||||||
@ -36,15 +39,27 @@ function Main(Api){
|
|||||||
right: [
|
right: [
|
||||||
{
|
{
|
||||||
id: 'database-button',
|
id: 'database-button',
|
||||||
icon: '/icons/iconoir/regular/bookmark-book.svg',
|
icon: '/icons/iconoir/regular/book.svg',
|
||||||
action: () => {
|
action: () => {
|
||||||
Api.createWindow(databaseWindow, {
|
Api.createWindow(databaseWindow, {
|
||||||
title: "Database",
|
title: "Campaign items",
|
||||||
id: databaseWindow,
|
id: 'campaign-items-window',
|
||||||
close: () => Api.clearWindow(databaseWindow)
|
close: () => Api.clearWindow("campaign-items-window")
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, {
|
},
|
||||||
|
{
|
||||||
|
id: 'database-button',
|
||||||
|
icon: '/icons/iconoir/regular/bookmark-book.svg',
|
||||||
|
action: () => {
|
||||||
|
Api.createWindow(booksWindow, {
|
||||||
|
title: "Books",
|
||||||
|
id: booksWindow,
|
||||||
|
close: () => Api.clearWindow(booksWindow)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
id: 'group-button',
|
id: 'group-button',
|
||||||
icon: '/icons/iconoir/regular/group.svg',
|
icon: '/icons/iconoir/regular/group.svg',
|
||||||
action: () => {
|
action: () => {
|
||||||
@ -64,7 +79,7 @@ function Main(Api){
|
|||||||
|
|
||||||
dndModule.onInit = () => {
|
dndModule.onInit = () => {
|
||||||
InitData();
|
InitData();
|
||||||
FetchData();
|
FetchConcepts();
|
||||||
}
|
}
|
||||||
|
|
||||||
Api.registerModule(dndModule);
|
Api.registerModule(dndModule);
|
||||||
|
82
plugins/dnd-5e/client/views/Books.vue
Normal file
82
plugins/dnd-5e/client/views/Books.vue
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<script setup>
|
||||||
|
import WindowHandle from '@/views/partials/WindowHandle.vue';
|
||||||
|
|
||||||
|
import { onMounted, ref, shallowRef } from 'vue';
|
||||||
|
import { ResetPosition, SetMinSize, SetResizable, SetSize, SetupHandle } from '@/services/Windows';
|
||||||
|
import ConceptList from '@/views/partials/ConceptList.vue';
|
||||||
|
import { Global } from '@/services/PluginGlobals';
|
||||||
|
|
||||||
|
const handle = ref(null);
|
||||||
|
|
||||||
|
const props = defineProps(['data']);
|
||||||
|
const data = props.data;
|
||||||
|
|
||||||
|
const Api = Global('dnd-5e').Api;
|
||||||
|
const PluginData = Global('dnd-5e').Data;
|
||||||
|
let dndModule = Global('dnd-5e').DndModule;
|
||||||
|
|
||||||
|
let id = data.id;
|
||||||
|
|
||||||
|
const books = shallowRef([]);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
SetupHandle(id, handle);
|
||||||
|
SetSize(id, {width: 400, height: 600});
|
||||||
|
ResetPosition(id, "center");
|
||||||
|
SetResizable(id, true);
|
||||||
|
SetMinSize(id, {width: 400, height: 300});
|
||||||
|
|
||||||
|
// Fetch book list
|
||||||
|
FetchBookList();
|
||||||
|
});
|
||||||
|
|
||||||
|
function FetchBookList(){
|
||||||
|
dndModule.getDatagen().then(response => {
|
||||||
|
books.value = response.data.datagens;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function OpenBook(){
|
||||||
|
console.log("Open book!");
|
||||||
|
}
|
||||||
|
|
||||||
|
function BookIcon(element){
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<div class="window-wrapper" :id="'window-wrapper-' + id">
|
||||||
|
<WindowHandle :window="id" ref="handle"></WindowHandle>
|
||||||
|
<div class="main-container">
|
||||||
|
<ConceptList
|
||||||
|
:elements="books"
|
||||||
|
:open="OpenBook"
|
||||||
|
:icon="BookIcon"
|
||||||
|
></ConceptList>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.main-container {
|
||||||
|
height: calc(100% - 24px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed-bottom-buttons {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
right: 10px;
|
||||||
|
z-index: 2;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.window-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
</style>
|
@ -1,7 +1,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import WindowHandle from '@/views/partials/WindowHandle.vue';
|
import WindowHandle from '@/views/partials/WindowHandle.vue';
|
||||||
|
|
||||||
import { GetConcept } from './../data.js';
|
import { GetItem } from './../data.js';
|
||||||
|
|
||||||
import { onMounted, ref, shallowRef } from 'vue';
|
import { onMounted, ref, shallowRef } from 'vue';
|
||||||
import { SetupHandle, SetSize, ResetPosition, SetMinSize, SetResizable } from '@/services/Windows';
|
import { SetupHandle, SetSize, ResetPosition, SetMinSize, SetResizable } from '@/services/Windows';
|
||||||
@ -153,8 +153,7 @@ if(data.item_create){
|
|||||||
|
|
||||||
}).catch(err => console.log(err));
|
}).catch(err => console.log(err));
|
||||||
} else {
|
} else {
|
||||||
// Get concept
|
GetItem(data.item_id).then(response => {
|
||||||
GetConcept(data.item_id).then(response => {
|
|
||||||
concept.value = response.data.data;
|
concept.value = response.data.data;
|
||||||
InitValues();
|
InitValues();
|
||||||
}).catch(err => console.log(err));
|
}).catch(err => console.log(err));
|
||||||
|
Loading…
Reference in New Issue
Block a user