Doc update
This commit is contained in:
parent
b0b0be833a
commit
708c0aa354
@ -133,6 +133,7 @@ class BackendModule {
|
|||||||
return this.#_router;
|
return this.#_router;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Creates a model for the Module
|
||||||
createModel(name, schema){
|
createModel(name, schema){
|
||||||
return new BackendModel(name, `${this.#_plugin.package}/${this.#_id}`, schema);
|
return new BackendModel(name, `${this.#_plugin.package}/${this.#_id}`, schema);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ class ClientApi {
|
|||||||
return `${this.#_plugin.package}/${name}`;
|
return `${this.#_plugin.package}/${name}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
createWindow(type, data){
|
createWindow(type, data = {id: type}){
|
||||||
_Windows.CreateWindow(type, data);
|
_Windows.CreateWindow(type, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,18 +30,18 @@ export default defineUserConfig({
|
|||||||
text: "Plugin",
|
text: "Plugin",
|
||||||
prefix: "plugin/",
|
prefix: "plugin/",
|
||||||
collapsable: true,
|
collapsable: true,
|
||||||
children: ['/client/test']
|
children: ['/plugin/plugin.json']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "Client API",
|
text: "Client API",
|
||||||
prefix: "client/",
|
prefix: "client/",
|
||||||
collapsable: true,
|
collapsable: true,
|
||||||
children: ['/client/test']
|
children: ['/client/api']
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: "Server API",
|
text: "Server API",
|
||||||
prefix: "server/",
|
prefix: "server/",
|
||||||
children: ['/server/test']
|
children: ['/server/api']
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
155
documentation/docs/client/api.md
Normal file
155
documentation/docs/client/api.md
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
# Client Api
|
||||||
|
|
||||||
|
## ClientApi
|
||||||
|
|
||||||
|
The ClientApi object is used for interacting with everything related to the Dragonroll client. It is passed to the `Main` function at the entrypoint defined in the [plugin.json](/plugin/plugin.json) file
|
||||||
|
|
||||||
|
|
||||||
|
### createView
|
||||||
|
|
||||||
|
Creates a [ClientView](#clientview) object from a Vue view defined inside the `client/views` folder
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Property | Type | Required | Description |
|
||||||
|
| -------- | ---- | -------- | ----------- |
|
||||||
|
| ``path`` | String | yes | The path relative from `client/views` to the Vue view without the `.vue` extension |
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
|
||||||
|
| Type | Description |
|
||||||
|
| ---- | ----------- |
|
||||||
|
| [ClientView](#clientview) | The new created view |
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Supposing that we have /your-plugin-root/client/views/Calculator.vue
|
||||||
|
let calculatorView = Api.createView('Calculator');
|
||||||
|
```
|
||||||
|
|
||||||
|
### createModule
|
||||||
|
|
||||||
|
Creates a [ClientModule](#clientmodule). The module needs to be later registered with the [registerModule](#registermodule) method to be loaded by Dragonroll. See [creating a module]()
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Property | Type | Required | Description |
|
||||||
|
| -------- | ---- | -------- | ----------- |
|
||||||
|
| ``id`` | String | yes | The identifier of the new module |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
| Type | Description |
|
||||||
|
| ---- | ----------- |
|
||||||
|
| [ClientModule](#clientmodule) | The new ClientModule |
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
let dndModule = Api.createModule('dnd-5e');
|
||||||
|
dndModule.title = "Dungeons & Dragons 5e";
|
||||||
|
dndModule.description = "Dungeons & Dragons Fifth edition module";
|
||||||
|
dndModule.version = "1.0";
|
||||||
|
dndModule.color = "#e92026";
|
||||||
|
dndModule.icon = "icon.png";
|
||||||
|
```
|
||||||
|
|
||||||
|
### createWindow
|
||||||
|
|
||||||
|
This method instances a new window from an already registered one. You can also pass custom parameters inside this method and then read them from your view.
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Property | Type | Required | Description |
|
||||||
|
| -------- | ---- | -------- | ----------- |
|
||||||
|
| ``type`` | String ([WindowType]()) | yes | The type of the new window |
|
||||||
|
| ``data`` | Object ([WindowData]()) | no | Aditional data for the created window |
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
let databaseWindow = Api.registerWindow('database', Api.createView('Database'));
|
||||||
|
|
||||||
|
// Opens the database window
|
||||||
|
Api.createWindow(databaseWindow, {
|
||||||
|
id: 'my-database-window',
|
||||||
|
title: "My Database",
|
||||||
|
custom: [
|
||||||
|
{
|
||||||
|
data: "This is custom data"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
### clearWindow
|
||||||
|
|
||||||
|
Clears the window with the specified id
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Property | Type | Required | Description |
|
||||||
|
| -------- | ---- | -------- | ----------- |
|
||||||
|
| ``id`` | String | yes | The id of the window to clear |
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
Api.createWindow(databaseWindow, {
|
||||||
|
id: 'my-database-window',
|
||||||
|
title: "My Database",
|
||||||
|
close: () => {
|
||||||
|
// When the close button is pressed, clear the window
|
||||||
|
Api.clearWindow('my-database-window');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### registerModule
|
||||||
|
|
||||||
|
Registers an already created [module](#clientmodule) to Dragonroll
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Property | Type | Required | Description |
|
||||||
|
| -------- | ---- | -------- | ----------- |
|
||||||
|
| ``module`` | [ClientModule](#clientmodule) | yes | The module to register |
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
let dndModule = Api.createModule('dnd-5e');
|
||||||
|
...
|
||||||
|
api.registerModule(dndModule);
|
||||||
|
```
|
||||||
|
|
||||||
|
### registerWindow
|
||||||
|
|
||||||
|
Registers a new window to Dragonroll and returns the registered id
|
||||||
|
|
||||||
|
#### Parameters
|
||||||
|
|
||||||
|
| Property | Type | Required | Description |
|
||||||
|
| -------- | ---- | -------- | ----------- |
|
||||||
|
| ``name`` | String | yes | The name of the new window |
|
||||||
|
| ``view`` | [ClientView](#clientview) | yes | The view that contains the window |
|
||||||
|
|
||||||
|
#### Returns
|
||||||
|
|
||||||
|
| Type | Description |
|
||||||
|
| ---- | ----------- |
|
||||||
|
| String ([WindowType](#windowpath)) | The registered type of window |
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
|
||||||
|
```js
|
||||||
|
let databaseWindow = Api.registerWindow('database', Api.createView('Database'));
|
||||||
|
```
|
||||||
|
|
||||||
|
### router
|
||||||
|
|
||||||
|
### socket
|
||||||
|
|
||||||
|
## ClientModule
|
@ -1,41 +0,0 @@
|
|||||||
# Updating a resource
|
|
||||||
|
|
||||||
## Request
|
|
||||||
|
|
||||||
- HTTP Method: `PUT`
|
|
||||||
- Content Type: `application/json`
|
|
||||||
- URL: `http://example.com/users/{id}`
|
|
||||||
|
|
||||||
## Parameters
|
|
||||||
|
|
||||||
| Property | Type | Required | Description |
|
|
||||||
| -------- | ---- | -------- | ----------- |
|
|
||||||
| ``name`` | String | false | The name of the user. |
|
|
||||||
| ``age`` | Number | false | The age of the user. |
|
|
||||||
|
|
||||||
## Request example
|
|
||||||
|
|
||||||
``` js
|
|
||||||
fetch('http://example.com/users/1', {
|
|
||||||
method: 'PUT',
|
|
||||||
body: JSON.stringify({
|
|
||||||
name: 'John Doe',
|
|
||||||
age: 27,
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
'Content-type': 'application/json',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((json) => console.log(json));
|
|
||||||
```
|
|
||||||
|
|
||||||
## Response example
|
|
||||||
|
|
||||||
``` JSON
|
|
||||||
{
|
|
||||||
"id": 1,
|
|
||||||
"name": "John Doe",
|
|
||||||
"age": 27
|
|
||||||
}
|
|
||||||
```
|
|
1
documentation/docs/plugin/plugin.json.md
Normal file
1
documentation/docs/plugin/plugin.json.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# plugin.json
|
1
documentation/docs/server/api.md
Normal file
1
documentation/docs/server/api.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
# ServerApi
|
@ -1 +0,0 @@
|
|||||||
# Server test
|
|
Loading…
Reference in New Issue
Block a user