More docs and better module data params
This commit is contained in:
parent
708c0aa354
commit
2753bb4331
@ -16,6 +16,7 @@ import { socket } from '@/services/Socket';
|
|||||||
class ClientApi {
|
class ClientApi {
|
||||||
#_plugin
|
#_plugin
|
||||||
#_router
|
#_router
|
||||||
|
#_baseRouter
|
||||||
#_windows
|
#_windows
|
||||||
#_socket
|
#_socket
|
||||||
|
|
||||||
@ -25,6 +26,7 @@ class ClientApi {
|
|||||||
constructor(plugin){
|
constructor(plugin){
|
||||||
this.#_plugin = plugin
|
this.#_plugin = plugin
|
||||||
this.#_router = new ClientRouter(`/plugin/${plugin.package}`)
|
this.#_router = new ClientRouter(`/plugin/${plugin.package}`)
|
||||||
|
this.#_baseRouter = new ClientRouter("")
|
||||||
this.#_windows = new ClientWindows(plugin.package)
|
this.#_windows = new ClientWindows(plugin.package)
|
||||||
this.#_socket = new ClientSocket(plugin.package)
|
this.#_socket = new ClientSocket(plugin.package)
|
||||||
}
|
}
|
||||||
@ -82,6 +84,10 @@ class ClientApi {
|
|||||||
return this.#_router;
|
return this.#_router;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get baseRouter(){
|
||||||
|
return this.#_baseRouter;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the windows object
|
* Returns the windows object
|
||||||
* @type {ClientWindows}
|
* @type {ClientWindows}
|
||||||
@ -152,6 +158,7 @@ class ClientModule {
|
|||||||
#_color;
|
#_color;
|
||||||
#_icon;
|
#_icon;
|
||||||
#_buttons;
|
#_buttons;
|
||||||
|
#_previewData;
|
||||||
#_init;
|
#_init;
|
||||||
#_exit;
|
#_exit;
|
||||||
|
|
||||||
@ -163,39 +170,13 @@ class ClientModule {
|
|||||||
this.#_router = new ClientRouter(`/module/${plugin.package}/${id}`);
|
this.#_router = new ClientRouter(`/module/${plugin.package}/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
setData(data){
|
||||||
* The title of the module
|
this.#_previewData = data;
|
||||||
* @type {string}
|
}
|
||||||
*/
|
|
||||||
set title(title) { this.#_title = title; }
|
|
||||||
|
|
||||||
/**
|
set onInit(init){ this.#_init = init; }
|
||||||
* The description of the module
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
set description(description){ this.#_description = description; }
|
|
||||||
|
|
||||||
/**
|
set onExit(exit){ this.#_exit = exit; }
|
||||||
* The version of the module
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
set version(version){ this.#_version = version; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The accent color of the module. This will be displayed for example
|
|
||||||
* in the background title inside the campaign preview
|
|
||||||
* @type {string}
|
|
||||||
*/
|
|
||||||
set color(color){ this.#_color = color; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the icon for the module. It must be placed inside the public folder of the plugin
|
|
||||||
*/
|
|
||||||
set icon(icon){ this.#_icon = icon; }
|
|
||||||
|
|
||||||
set init(init){ this.#_init = init; }
|
|
||||||
|
|
||||||
set exit(exit){ this.#_exit = exit; }
|
|
||||||
|
|
||||||
setButtons(buttons){
|
setButtons(buttons){
|
||||||
this.#_buttons = buttons;
|
this.#_buttons = buttons;
|
||||||
@ -212,11 +193,7 @@ class ClientModule {
|
|||||||
get info(){
|
get info(){
|
||||||
return {
|
return {
|
||||||
id: this.#_id,
|
id: this.#_id,
|
||||||
title: this.#_title,
|
previewData: this.#_previewData,
|
||||||
description: this.#_description,
|
|
||||||
version: this.#_version,
|
|
||||||
color: this.#_color,
|
|
||||||
icon: this.#_icon,
|
|
||||||
init: this.#_init,
|
init: this.#_init,
|
||||||
exit: () => {},
|
exit: () => {},
|
||||||
buttons: this.#_buttons
|
buttons: this.#_buttons
|
||||||
|
@ -19,6 +19,8 @@ let GetModules = () => modules;
|
|||||||
// let GetModulesToLoad = () => modulesToLoad;
|
// let GetModulesToLoad = () => modulesToLoad;
|
||||||
|
|
||||||
function GetModule(id){
|
function GetModule(id){
|
||||||
|
console.log(modules);
|
||||||
|
console.log(modules[id])
|
||||||
return modules[id];
|
return modules[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ function Select(){
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
title.value = data.title;
|
title.value = data.previewData.title;
|
||||||
image.value.src = `plugins/${data.id}/${data.icon}`;
|
image.value.src = `plugins/${data.id}/${data.previewData.icon}`;
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -75,7 +75,7 @@ onMounted(() => {
|
|||||||
|
|
||||||
AddSound(container.value)
|
AddSound(container.value)
|
||||||
|
|
||||||
campaign_title.value.style.backgroundColor = GetModule(data.campaign.system).color ? GetModule(data.campaign.system).color : "#1f1f1f";
|
campaign_title.value.style.backgroundColor = GetModule(data.campaign.system).previewData.color ? GetModule(data.campaign.system).color : "#1f1f1f";
|
||||||
|
|
||||||
AddTooltip(copy_code_button.value, `<p>${t('campaigns.preview.copy-explain')}</p>`, {max_width: 300})
|
AddTooltip(copy_code_button.value, `<p>${t('campaigns.preview.copy-explain')}</p>`, {max_width: 300})
|
||||||
});
|
});
|
||||||
|
@ -150,6 +150,102 @@ let databaseWindow = Api.registerWindow('database', Api.createView('Database'));
|
|||||||
|
|
||||||
### router
|
### router
|
||||||
|
|
||||||
|
Gets the router object associated with the API. It has no prefix and can make all kinds of calls to the Dragonroll backend
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
| Type | Description |
|
||||||
|
| ---- | ----------- |
|
||||||
|
| [ClientRouter](#clientrouter) | The client router |
|
||||||
|
|
||||||
|
### baseRouter
|
||||||
|
|
||||||
|
Gets the royter object associated with the API. It has no prefix and can make all kinds of calls to the Dragonroll backend.
|
||||||
|
|
||||||
|
| Type | Description |
|
||||||
|
| ---- | ----------- |
|
||||||
|
| [ClientRouter](#clientrouter) | The client router from root |
|
||||||
|
|
||||||
### socket
|
### socket
|
||||||
|
|
||||||
## ClientModule
|
Gets the socket object associated with the Plugin.
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
| Type | Description |
|
||||||
|
| ---- | ----------- |
|
||||||
|
| [ClientSocket](#clientsocket) | The client socket |
|
||||||
|
|
||||||
|
## ClientModule
|
||||||
|
|
||||||
|
### setData
|
||||||
|
|
||||||
|
Sets the information data displayed in Dragonroll of the current module
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
This method accepts an Object type with the following properties:
|
||||||
|
|
||||||
|
| Property | Type | Required | Description |
|
||||||
|
| -------- | ---- | -------- | ----------- |
|
||||||
|
| ``title`` | String | yes | The display name of the module |
|
||||||
|
| ``description`` | String | yes | The description of the module |
|
||||||
|
| ``version`` | String | yes | The version of the module |
|
||||||
|
| ``color`` | String | yes | The display color for the module |
|
||||||
|
| ``authors`` | [Author] | no | The authors of the module |
|
||||||
|
| ``icon`` | String | yes | The icon to be displayed with the module. Relative to the `public` folder |
|
||||||
|
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
dndModule.setData({
|
||||||
|
title: "Dungeons & Dragons 5e",
|
||||||
|
description: "Dungeons & Dragons Fifth edition game system support",
|
||||||
|
version: "0.1",
|
||||||
|
color: "#e92026",
|
||||||
|
authors: [{
|
||||||
|
name: "Aran Roig",
|
||||||
|
webpage: "aranroig.com"
|
||||||
|
}],
|
||||||
|
icon: "icon.png"
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
### onInit
|
||||||
|
|
||||||
|
### onExit
|
||||||
|
|
||||||
|
### setButtons
|
||||||
|
|
||||||
|
### router
|
||||||
|
|
||||||
|
## ClientRouter
|
||||||
|
|
||||||
|
### get
|
||||||
|
|
||||||
|
### post
|
||||||
|
|
||||||
|
### put
|
||||||
|
|
||||||
|
### delete
|
||||||
|
|
||||||
|
### baseGet
|
||||||
|
|
||||||
|
### basePost
|
||||||
|
|
||||||
|
### basePut
|
||||||
|
|
||||||
|
### baseDelete
|
||||||
|
|
||||||
|
## ClientSocket
|
||||||
|
|
||||||
|
### on
|
||||||
|
|
||||||
|
## ClientView
|
||||||
|
|
||||||
|
### path
|
||||||
|
|
||||||
|
## WindowType
|
||||||
|
|
||||||
|
## WindowData
|
@ -1 +1,43 @@
|
|||||||
# ServerApi
|
# ServerApi
|
||||||
|
|
||||||
|
## BakcendApi
|
||||||
|
|
||||||
|
The BackendApi object is used for interacting with everything related to the Dragonroll backend. It is passed to the `Main` function at the entrypoint defined in the [plugin.json](/plugin/plugin.json) file
|
||||||
|
|
||||||
|
### router
|
||||||
|
|
||||||
|
### createModel
|
||||||
|
|
||||||
|
### createModule
|
||||||
|
|
||||||
|
## BackendRouter
|
||||||
|
|
||||||
|
### get
|
||||||
|
|
||||||
|
### post
|
||||||
|
|
||||||
|
### put
|
||||||
|
|
||||||
|
### delete
|
||||||
|
|
||||||
|
### createModelRoutes
|
||||||
|
|
||||||
|
## BackendModule
|
||||||
|
|
||||||
|
### router
|
||||||
|
|
||||||
|
### createModel
|
||||||
|
|
||||||
|
## BackendModel
|
||||||
|
|
||||||
|
### find
|
||||||
|
|
||||||
|
### findOne
|
||||||
|
|
||||||
|
### findById
|
||||||
|
|
||||||
|
### create
|
||||||
|
|
||||||
|
### updateOne
|
||||||
|
|
||||||
|
### updateMany
|
@ -14,6 +14,7 @@ function InitData(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function FetchConcepts(){
|
function FetchConcepts(){
|
||||||
|
|
||||||
Server().get('/concept/list?campaign=' + GetCampaign()._id).then(response => {
|
Server().get('/concept/list?campaign=' + GetCampaign()._id).then(response => {
|
||||||
data.value.concepts = response.data.data;
|
data.value.concepts = response.data.data;
|
||||||
}).catch((err) => console.log(err));
|
}).catch((err) => console.log(err));
|
||||||
@ -22,7 +23,7 @@ function FetchConcepts(){
|
|||||||
function FetchData(){
|
function FetchData(){
|
||||||
FetchConcepts();
|
FetchConcepts();
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
Api.socket.on('update-concepts', () => {
|
Api.socket.on('update-concepts', () => {
|
||||||
FetchConcepts();
|
FetchConcepts();
|
||||||
});
|
});
|
||||||
|
@ -2,19 +2,26 @@ import { FetchData, InitData } from "./data";
|
|||||||
|
|
||||||
// Entrypoint
|
// Entrypoint
|
||||||
let Api;
|
let Api;
|
||||||
|
let dndModule;
|
||||||
|
|
||||||
function Main(api){
|
function Main(api){
|
||||||
Api = api
|
Api = api
|
||||||
|
|
||||||
console.log("Hello World!");
|
|
||||||
|
console.log("Module registered!");
|
||||||
|
dndModule = Api.createModule('dnd-5e');
|
||||||
|
|
||||||
let dndModule = Api.createModule('dnd-5e');
|
dndModule.setData({
|
||||||
|
title: "Dungeons & Dragons 5e",
|
||||||
dndModule.title = "Dungeons & Dragons 5e";
|
description: "Dungeons & Dragons Fifth edition game system support",
|
||||||
dndModule.description = "Dungeons & Dragons Fifth edition game system support";
|
version: "0.1",
|
||||||
dndModule.version = "0.1";
|
color: "#e92026",
|
||||||
dndModule.color = "#e92026";
|
authors: [{
|
||||||
dndModule.icon = "icon.png";
|
name: "Aran Roig",
|
||||||
|
webpage: "aranroig.com"
|
||||||
|
}],
|
||||||
|
icon: "icon.png"
|
||||||
|
});
|
||||||
|
|
||||||
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'));
|
||||||
@ -58,12 +65,18 @@ function Main(api){
|
|||||||
// Api.windows.registerWindow('item_sheet', Api.createView('ItemSheet'));
|
// Api.windows.registerWindow('item_sheet', Api.createView('ItemSheet'));
|
||||||
// Api.windows.registerWindow('create_item_prompt', Api.createView('CreateItemPrompt'));
|
// Api.windows.registerWindow('create_item_prompt', Api.createView('CreateItemPrompt'));
|
||||||
|
|
||||||
dndModule.init = () => {
|
dndModule.onInit = () => {
|
||||||
InitData();
|
InitData();
|
||||||
FetchData();
|
FetchData();
|
||||||
}
|
}
|
||||||
|
|
||||||
Api.registerModule(dndModule);
|
Api.registerModule(dndModule);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Main, Api };
|
export {
|
||||||
|
Main,
|
||||||
|
Api,
|
||||||
|
dndModule
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user