Skip to content

Commit

Permalink
Major changes
Browse files Browse the repository at this point in the history
  • Loading branch information
albertogcatalan committed Dec 16, 2020
1 parent 0a7b203 commit b5225c2
Show file tree
Hide file tree
Showing 25 changed files with 3,665 additions and 0 deletions.
Binary file added Sources/.DS_Store
Binary file not shown.
Binary file added Sources/DistributionTool
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 94 additions & 0 deletions Sources/com.streamtools.webhooks.sdPlugin/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/* global $CC, Utils, $SD */

/**
* Here are a couple of wrappers we created to help ypu quickly setup
* your plugin and subscribe to events sent by Stream Deck to your plugin.
*/

/**
* The 'connected' event is sent to your plugin, after the plugin's instance
* is registered with Stream Deck software. It carries the current websocket
* and other information about the current environmet in a JSON object
* You can use it to subscribe to events you want to use in your plugin.
*/

$SD.on('connected', (jsonObj) => connected(jsonObj));

function connected(jsn) {
/** subscribe to the willAppear and other events */
$SD.on('com.streamtools.webhooks.action.willAppear', (jsonObj) => action.onWillAppear(jsonObj));
$SD.on('com.streamtools.webhooks.action.keyUp', (jsonObj) => action.onKeyUp(jsonObj));
$SD.on('com.streamtools.webhooks.action.sendToPlugin', (jsonObj) => action.onSendToPlugin(jsonObj));
$SD.on('com.streamtools.webhooks.action.didReceiveSettings', (jsonObj) => action.onDidReceiveSettings(jsonObj));
$SD.on('com.streamtools.webhooks.action.propertyInspectorDidAppear', (jsonObj) => {
console.log('%c%s', 'color: white; background: black; font-size: 13px;', '[app.js]propertyInspectorDidAppear:');
});
$SD.on('com.streamtools.webhooks.action.propertyInspectorDidDisappear', (jsonObj) => {
console.log('%c%s', 'color: white; background: red; font-size: 13px;', '[app.js]propertyInspectorDidDisappear:');
});
};

/** ACTIONS */

const action = {
settings:{},
onDidReceiveSettings: function(jsonObj) {
console.log(`[onDidReceiveMessage] ${JSON.stringify(jsonObj)}`);
},

/**
* The 'willAppear' event is the first event a key will receive, right before it gets
* showed on your Stream Deck and/or in Stream Deck software.
* This event is a good place to setup your plugin and look at current settings (if any),
* which are embedded in the events payload.
*/

onWillAppear: function (jsonObj) {
$SD.api.sendToPropertyInspector(jsonObj.context, Utils.getProp(jsonObj, "payload.settings", {}), jsonObj.action);
},

onKeyUp: function (jsonObj) {
if (!jsonObj.payload.settings || !jsonObj.payload.settings.streamtoolsapikey || !jsonObj.payload.settings.widgetid) {
$SD.api.showAlert(jsonObj.context);
return;
}
let url = 'http://streamtools.local.com/webhook/'+jsonObj.payload.settings.widgettype+'/'+jsonObj.payload.settings.widgetid;
fetch(url, {
"method": 'POST',
"headers": {
"content-type": "application/json",
'X-API-KEY': jsonObj.payload.settings.streamtoolsapikey
},
"body": {'action': jsonObj.payload.settings.webhookpayload}
}).then(result => $SD.api.showOk(jsonObj.context), error => $SD.api.showAlert(jsonObj.context));
},

onSendToPlugin: function (jsonObj) {
/**
* this is a message sent directly from the Property Inspector
* (e.g. some value, which is not saved to settings)
* You can send this event from Property Inspector (see there for an example)
*/

if(jsonObj.payload) {
$SD.api.setSettings(jsonObj.context, jsonObj.payload);
}
},

/**
* This snippet shows, how you could save settings persistantly to Stream Deck software
* It is not used in this example plugin.
*/

saveSettings: function (jsn, sdpi_collection) {
console.log('saveSettings:', jsn);
if (sdpi_collection.hasOwnProperty('key') && sdpi_collection.key != '') {
if (sdpi_collection.value && sdpi_collection.value !== undefined) {
this.settings[sdpi_collection.key] = sdpi_collection.value;
console.log('setSettings....', this.settings);
$SD.api.setSettings(jsn.context, this.settings);
}
}
},
};

15 changes: 15 additions & 0 deletions Sources/com.streamtools.webhooks.sdPlugin/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Description": "Send an action request to a Streamtools widget with remote webhook API",
"Name": "Streamtools Webhook",
"Category": "Templates",
"com.streamtools.webhooks.action": {
"Name": "Send action",
"Tooltip": "Send an action request to a Streamtools widget with remote webhook API"
},
"Localization": {
"More info": "More info",
"Message": "Message",
"Click Me": "Click Me",
"Button": "Button"
}
}
15 changes: 15 additions & 0 deletions Sources/com.streamtools.webhooks.sdPlugin/es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Description": "Envia una solicitud de acción a un widget de Streamtools con la API",
"Name": "Streamtools Webhook",
"Category": "Templates",
"com.streamtools.webhooks.action": {
"Name": "Enviar acción",
"Tooltip": "Envia una solicitud de acción a un widget de Streamtools con la API"
},
"Localization": {
"More info": "Más info",
"Message": "Mensaje",
"Click Me": "Haz click",
"Button": "Botón"
}
}
19 changes: 19 additions & 0 deletions Sources/com.streamtools.webhooks.sdPlugin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE HTML>
<html>

<head>
<title>Streamtools Webhook</title>
<meta charset="utf-8" />
<style>
canvas {
background-color:transparent;
}
</style>
</head>

<body>
<script src="propertyinspector/js/common.js"></script>
<script src="app.js"></script>
</body>

</html>
41 changes: 41 additions & 0 deletions Sources/com.streamtools.webhooks.sdPlugin/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"Actions": [
{
"Icon": "action/images/actionimage",
"Name": "Webhooks",
"States": [
{
"Image": "action/images/action",
"TitleAlignment": "bottom",
"FontSize": "10"
}
],
"SupportedInMultiActions": true,
"Tooltip": "Send an action request to a Streamtools widget with remote webhook API",
"UUID": "com.streamtools.webhooks.action"
}
],
"SDKVersion": 2,
"Author": "Alberto González Catalán",
"CodePath": "index.html",
"PropertyInspectorPath": "propertyinspector/index.html",
"Description": "Send an action request to a Streamtools widget with remote webhook API",
"Name": "Streamtools Webhook",
"Icon": "action/images/action",
"URL": "https://streamtools.com",
"Version": "1.0.0",
"OS": [
{
"Platform": "mac",
"MinimumVersion" : "10.11"
},
{
"Platform": "windows",
"MinimumVersion" : "10"
}
],
"Software":
{
"MinimumVersion" : "4.1"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b5225c2

Please sign in to comment.