Skip to content

Commit

Permalink
Handle issues
Browse files Browse the repository at this point in the history
  • Loading branch information
KristjanESPERANTO committed Nov 6, 2024
1 parent d08fe8c commit 440cf3d
Show file tree
Hide file tree
Showing 33 changed files with 2,040 additions and 2,100 deletions.
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/Bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ body:
Also, you accept that, if this issue it's invalid in any way, will be discarded without receiving any response about it.
If you're not sure if it's a bug, please [ask here](https://github.com/Jopyth/MMM-Remote-Control/discussions).
Thanks for taking the time to help Remote Control get better every day!
- type: input
attributes:
Expand All @@ -26,7 +26,7 @@ body:
description: |
example:
- NodeJS: 14.17.5
placeholder: '14.17.5'
placeholder: "14.17.5"
validations:
required: true
- type: input
Expand All @@ -35,7 +35,7 @@ body:
description: |
example:
- MM: 2.16.0
placeholder: '2.16.0'
placeholder: "2.16.0"
validations:
required: true
- type: input
Expand All @@ -44,15 +44,15 @@ body:
description: |
example:
- Remote Control: 2.3.6
placeholder: '2.3.6'
placeholder: "2.3.6"
validations:
required: true
- type: checkboxes
attributes:
label: Did you try using just Remote Control alone with MM?
options:
- label: I have and the error still happening
required: true
- label: I have and the error still happening
required: true
- type: textarea
attributes:
label: Description
Expand Down Expand Up @@ -115,4 +115,4 @@ body:
label: Additional info
description: Everything else that you think could be useful for us. ;D
validations:
required: false
required: false
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/Feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ body:
label: Additional info
description: Everything else that you think could be useful for us. ;D
validations:
required: false
required: false
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ blank_issues_enabled: false
contact_links:
- name: Discussions
url: https://github.com/Jopyth/MMM-Remote-Control/discussions
about: Don't know how to do it? Ask the community!
about: Don't know how to do it? Ask the community!
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ You can click them in preview mode!
If clicking those links let you with the same description, just erase everything above and tell us what's your PR about!
-->
-->
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE/Bug_fixes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ Fixes #

### Additional info

<!-- Everything else that you think could be useful for us. ;D -->
<!-- Everything else that you think could be useful for us. ;D -->
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE/Feature_addition.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ You can now erase this warning, and complete the steps below. Cheers :D

### Additional info

<!-- Everything else that you think could be useful for us. ;D -->
<!-- Everything else that you think could be useful for us. ;D -->
12 changes: 6 additions & 6 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'Close stale issues and PRs'
name: "Close stale issues and PRs"
on:
schedule: [{cron: "0 12 * * *"},{cron: "0 0 * * *"}]
schedule: [{ cron: "0 12 * * *" }, { cron: "0 0 * * *" }]

jobs:
stale:
Expand All @@ -23,8 +23,8 @@ jobs:
days-before-pr-stale: 30
days-before-issue-close: 7
days-before-pr-close: 7
stale-issue-label: 'stale'
exempt-issue-labels: 'working,help wanted,PR Welcome!'
stale-pr-label: 'stale'
exempt-pr-labels: 'working,help wanted'
stale-issue-label: "stale"
exempt-issue-labels: "working,help wanted,PR Welcome!"
stale-pr-label: "stale"
exempt-pr-labels: "working,help wanted"
exempt-all-milestones: true
116 changes: 58 additions & 58 deletions API/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Introduction

The MMM-Remote-Control Module for MagicMirror² implements a RESTful(-ish) API to control the MagicMirror² using the existing functionality built-in to MMM-Remote-Control, as well as the notifications commands built into most modules. In addition, the API creates a basic framework which allows for each module to expand or customize their own API by a simple notification.
The MMM-Remote-Control Module for MagicMirror² implements a RESTful(-ish) API to control the MagicMirror² using the existing functionality built-in to MMM-Remote-Control, as well as the notifications commands built into most modules. In addition, the API creates a basic framework which allows for each module to expand or customize their own API by a simple notification.

This expansion was developed by [shbatm](https://github.com/shbatm) using [juzim's MMM-Api](https://github.com/juzim/MMM-Api) and of-course, [jopyth's MMM-Remote-Control](https://github.com/jopyth/MMM-Remote-Control).

Expand Down Expand Up @@ -83,7 +83,7 @@ $ curl -X POST http://magicmirrorip:8080/api/module/alert/showalert \
}'
```

***For convenience, the remainder of the examples omit the API Key***
**_For convenience, the remainder of the examples omit the API Key_**

## Secure Endpoints

Expand All @@ -106,13 +106,13 @@ Setting secureEndpoints to false allow every endpoint to be reachable externally

There are three general categories of API commands:

**1. MMM-Remote-Control Internal Commands** -- these are used to call the existing commands that MMM-Remote-Control already exposes. For example, to turn off the monitor ("MONITOROFF"):
**1. MMM-Remote-Control Internal Commands** -- these are used to call the existing commands that MMM-Remote-Control already exposes. For example, to turn off the monitor ("MONITOROFF"):

```bash
curl -X GET http://magicmirrorip:8080/api/monitor/off
```

**2. External APIs (Guessed)** -- when this module first loads, it parses all of the installed modules' source code and checks for any custom notifications that are used. From this basic search, it tries to "guess" notification actions that may be valid, without them being explicitly defined anywhere else. For example, the "alert" command examples above are not defined within this module, the 'alert' module just looks for a notification, "SHOW_ALERT"--this is exposed as a `/module/alert/showalert` action in the External API processor. Full credit to this idea goes to `juzim` from the MMM-Api module.
**2. External APIs (Guessed)** -- when this module first loads, it parses all of the installed modules' source code and checks for any custom notifications that are used. From this basic search, it tries to "guess" notification actions that may be valid, without them being explicitly defined anywhere else. For example, the "alert" command examples above are not defined within this module, the 'alert' module just looks for a notification, "SHOW_ALERT"--this is exposed as a `/module/alert/showalert` action in the External API processor. Full credit to this idea goes to `juzim` from the MMM-Api module.

**3. External APIs (Explicit)** -- these commands are developed when a module loads and sends a "REGISTER_API" notification with command details to this module. These commands will overwrite any "guessed" commands and can provide a way for a module to define its own API, but still use the same routes already in place.

Expand All @@ -128,12 +128,12 @@ Or check it in your own installation using <http://ip-of-your-mirror:8080/api/do

As discussed above, these methods are guessed based on your currently installed modules. To see what actions are available on your particular installation:

| Method | URL | Description |
| ------ | --- | ------- |
| GET | /api/module | Return a list of all external API actions registered.
| GET | /api/module/:moduleName | Returns registered API actions for a given module<br>`:moduleName`: Name or Identifier for an installed & activated module.
| Method | URL | Description |
| ------ | ----------------------- | --------------------------------------------------------------------------------------------------------------------------- |
| GET | /api/module | Return a list of all external API actions registered. |
| GET | /api/module/:moduleName | Returns registered API actions for a given module<br>`:moduleName`: Name or Identifier for an installed & activated module. |

- *NOTE:* Just because an action appears in this list, does not necessarily mean it is valid and the related module will do what you want. Consult each modules' README for details on what notifications can be used and how.
- _NOTE:_ Just because an action appears in this list, does not necessarily mean it is valid and the related module will do what you want. Consult each modules' README for details on what notifications can be used and how.

#### Example

Expand All @@ -145,43 +145,43 @@ curl -X GET http://magicmirrorip:8080/api/module/newsfeed

```json
{
"success": true,
"module": "newsfeed",
"path": "newsfeed",
"actions": {
"newsitems": {
"notification": "NEWS_ITEMS"
},
"articlenext": {
"notification": "ARTICLE_NEXT"
},
"articleprevious": {
"notification": "ARTICLE_PREVIOUS"
},
"articlemoredetails": {
"notification": "ARTICLE_MORE_DETAILS"
},
"articlescrollup": {
"notification": "ARTICLE_SCROLL_UP"
},
"articlelessdetails": {
"notification": "ARTICLE_LESS_DETAILS"
},
"articletogglefull": {
"notification": "ARTICLE_TOGGLE_FULL"
}
"success": true,
"module": "newsfeed",
"path": "newsfeed",
"actions": {
"newsitems": {
"notification": "NEWS_ITEMS"
},
"guessed": true
"articlenext": {
"notification": "ARTICLE_NEXT"
},
"articleprevious": {
"notification": "ARTICLE_PREVIOUS"
},
"articlemoredetails": {
"notification": "ARTICLE_MORE_DETAILS"
},
"articlescrollup": {
"notification": "ARTICLE_SCROLL_UP"
},
"articlelessdetails": {
"notification": "ARTICLE_LESS_DETAILS"
},
"articletogglefull": {
"notification": "ARTICLE_TOGGLE_FULL"
}
},
"guessed": true
}
```

| Parameter | Description |
| :-: | -- |
| `"success"` | Result of the GET call
| `"module"` | Module name
| `"path"` | API path to use. All lower case, with "MMM-" and "-"s removed (e.g. MMM-Remote-Control's path if it had one would be `/api/module/remotecontrol/`). Can be customized for explicit External APIs.
| `"actions"` | The list of actions registered, along with the respective notifications that they will call.<br>For example, `GET /api/module/newsfeed/articlenext` will send a `"ARTICLE_NEXT"` notification to the `newsfeed` module
| `"guessed"` | Whether or not the API actions were guessed (not all are reliable) or if they were explicitly provided by the module.
| Parameter | Description |
| :---------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `"success"` | Result of the GET call |
| `"module"` | Module name |
| `"path"` | API path to use. All lower case, with "MMM-" and "-"s removed (e.g. MMM-Remote-Control's path if it had one would be `/api/module/remotecontrol/`). Can be customized for explicit External APIs. |
| `"actions"` | The list of actions registered, along with the respective notifications that they will call.<br>For example, `GET /api/module/newsfeed/articlenext` will send a `"ARTICLE_NEXT"` notification to the `newsfeed` module |
| `"guessed"` | Whether or not the API actions were guessed (not all are reliable) or if they were explicitly provided by the module. |

### 3. External APIs (Explicit) - Extending Another Module with this API

Expand All @@ -195,30 +195,30 @@ let payload = {
path: "mymodulename",
actions: {
actionName: {
method: "GET",
notification: "NOTIFICATION_TO_SEND",
payload: ObjectToSend,
prettyName: "Action Name"
method: "GET",
notification: "NOTIFICATION_TO_SEND",
payload: ObjectToSend,
prettyName: "Action Name"
},
anotherActionName: {
method: "POST",
notification: "NOTIFICATION_TO_SEND"
method: "POST",
notification: "NOTIFICATION_TO_SEND"
}
}
};
this.sendNotification("REGISTER_API", payload);
```

| Parameter | Description |
| :-: | - |
| `module` | Actual Name of your Module (e.g. "MMM-Your-Module-Name, or just use `this.name`)
| `path` | Path to use in the API (e.g. `path: "mymodulename"`) translates to `/api/module/mymodulename`
| `actions` | An `Object` defining the actions you want to expose. See below for details.
| `actionName` | The name for your action (e.g. called from `/api/module/mymodulename/actionName`).
| `method` | *Optional:* The HTTP Method to use.<br>Valid options are: `"GET"` or `"POST"`. If `method` is not provided in an action, then both `"GET"` or `"POST"` methods will be treated as valid.
| `notification` | The notification to send to your module. When the API receives a valid action, it passes a Module Notification to your module. It is your responsibility to do something with that notification to make the action work.
| `prettyName` | *Optional:* You can specify a Formatted Name to use in dynamic menus, like the MMM-Remote-Control Module Control menu, otherwise one will be guessed based on the Notification text.
| `payload` | *Optional:* If you always want the module to send the same `payload`, you can provide an `Object` here. It will be merged into the `payload` sent with the notification, which will also include:<br>1. URL Parameter, if used. See notes on `payload` Object below.<br>2. Query String, if used. API key will be removed.<br>3. Request body, if `POST` method is used and a body sent.<br>4. Finally, this parameter.
| Parameter | Description |
| :------------: | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `module` | Actual Name of your Module (e.g. "MMM-Your-Module-Name, or just use `this.name`) |
| `path` | Path to use in the API (e.g. `path: "mymodulename"`) translates to `/api/module/mymodulename` |
| `actions` | An `Object` defining the actions you want to expose. See below for details. |
| `actionName` | The name for your action (e.g. called from `/api/module/mymodulename/actionName`). |
| `method` | _Optional:_ The HTTP Method to use.<br>Valid options are: `"GET"` or `"POST"`. If `method` is not provided in an action, then both `"GET"` or `"POST"` methods will be treated as valid. |
| `notification` | The notification to send to your module. When the API receives a valid action, it passes a Module Notification to your module. It is your responsibility to do something with that notification to make the action work. |
| `prettyName` | _Optional:_ You can specify a Formatted Name to use in dynamic menus, like the MMM-Remote-Control Module Control menu, otherwise one will be guessed based on the Notification text. |
| `payload` | _Optional:_ If you always want the module to send the same `payload`, you can provide an `Object` here. It will be merged into the `payload` sent with the notification, which will also include:<br>1. URL Parameter, if used. See notes on `payload` Object below.<br>2. Query String, if used. API key will be removed.<br>3. Request body, if `POST` method is used and a body sent.<br>4. Finally, this parameter. |

#### About the `payload` object

Expand Down
Loading

0 comments on commit 440cf3d

Please sign in to comment.