Skip to content

Commit

Permalink
Fix html for settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Toxblh committed Jul 21, 2021
1 parent 51ef8ff commit 301114e
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 63 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/ncu.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
name: Update Dependencies
on:
schedule:
- cron: '0 10 * * *'
- cron: "0 10 * * *"
jobs:
update-dep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '12.x'
node-version: "12.x"
- name: Update dependencies
run: |
npx -p npm-check-updates ncu -u
npm install
npm upgrade
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.PAT }}
commit-message: Update dependencies
title: Update dependencies
body: |
- Dependency updates
Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
branch: update-dependencies
labels: automerge
token: ${{ secrets.PAT }}
commit-message: Update dependencies
title: Update dependencies
body: |
- Dependency updates
Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
branch: update-dependencies
labels: automerge
23 changes: 11 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,21 @@ on: [push]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x]

steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: yarn install, build and test
run: |
yarn install --frozen-lockfile
yarn test
env:
CI: true
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: yarn install, build and test
run: |
yarn install --frozen-lockfile
yarn test
env:
CI: true
20 changes: 10 additions & 10 deletions __tests__/samsung_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ describe('Samsung-tv Node', function () {

it.each`
type
${'samsung-tv-send'}
${'samsung-tv-sendchannel'}
${'samsung-tv-isalive'}
${'samsung-tv-isaliveping'}
${'samsung-tv-token'}
${'samsung-tv-turnon'}
${'samsung-tv-openapp'}
${'samsung-tv-getapps'}
`('should be loaded $type', function({ type }, done) {
${'samsung-tv-send'}
${'samsung-tv-sendchannel'}
${'samsung-tv-isalive'}
${'samsung-tv-isaliveping'}
${'samsung-tv-token'}
${'samsung-tv-turnon'}
${'samsung-tv-openapp'}
${'samsung-tv-getapps'}
`('should be loaded $type', function ({ type }, done) {
var flow = [{ id: 'n1', type, name: 'test name' }]
helper.load(samsung, flow, function() {
helper.load(samsung, flow, function () {
var n1 = helper.getNode('n1')
expect(n1).toHaveProperty('name', 'test name')
done()
Expand Down
2 changes: 1 addition & 1 deletion lib/apps.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { APPS } = require('samsung-tv-control/lib/apps')

function provideApps(RED) {
RED.httpAdmin.get('/samsungtv/apps', function(req, res, next) {
RED.httpAdmin.get('/samsungtv/apps', function (req, res, next) {
res.send(JSON.stringify(APPS))
next()
})
Expand Down
2 changes: 1 addition & 1 deletion lib/keys.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { KEYS } = require('samsung-tv-control/lib/keys')

function provideKeys(RED) {
RED.httpAdmin.get('/samsungtv/keys', function(req, res, next) {
RED.httpAdmin.get('/samsungtv/keys', function (req, res, next) {
res.send(JSON.stringify(KEYS))
next()
})
Expand Down
14 changes: 7 additions & 7 deletions lib/samsung.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@
</div>
<div class="form-row">
<label for="node-input-key"><i class="fa fa-tasks"></i> Key</label>
<input type="text" id="node-input-key" style="!important" />
<input type="text" id="node-input-key" />
</div>
<div class="form-tips" id="node-input-key" style="margin-top:5px margin-bottom:5px">
<div class="form-tips" id="node-input-key" style="margin-top:5px;margin-bottom:5px">
<div>
Select a reference node to write the payload to.
</div>
Expand Down Expand Up @@ -204,9 +204,9 @@
</div>
<div class="form-row">
<label for="node-input-keys"><i class="fa fa-tasks"></i> Keys</label>
<input type="text" id="node-input-keys" style="!important" />
<input type="text" id="node-input-keys" />
</div>
<div class="form-tips" id="node-input-keys" style="margin-top:5px margin-bottom:5px">
<div class="form-tips" id="node-input-keys" style="margin-top:5px;margin-bottom:5px">
<div>
Write which channel need to open like 25
</div>
Expand Down Expand Up @@ -419,9 +419,9 @@
</div>
<div class="form-row">
<label for="node-input-appid"><i class="fa fa-tasks"></i> AppId</label>
<input type="text" id="node-input-appid" style="!important" />
<input type="text" id="node-input-appid" />
</div>
<div class="form-tips" id="node-input-appid" style="margin-top:5px margin-bottom:5px">
<div class="form-tips" id="node-input-appid" style="margin-top:5px;margin-bottom:5px">
<div>
Select a reference node to write the payload to.
</div>
Expand Down Expand Up @@ -515,4 +515,4 @@

<script type="text/html" data-help-name="samsung-tv-getapps">
<p>Returns list of apps installed on your TV</p>
</script>
</script>
37 changes: 18 additions & 19 deletions lib/samsung.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function registerNodes(RED) {
token: config.token,
ip: config.ip,
port: Number(config.model) || 8002,
mac: config.mac
mac: config.mac,
}

RED.nodes.createNode(this, config)
Expand All @@ -22,12 +22,12 @@ function registerNodes(RED) {

const node = this

node.on('input', function(msg) {
node.on('input', function (msg) {
const device = RED.nodes.getNode(config.device)
device.remote
.isAvaliable()
.then(() => node.send([msg, null]))
.catch(e => node.send([null, msg]))
.catch((e) => node.send([null, msg]))
})
}

Expand All @@ -36,19 +36,19 @@ function registerNodes(RED) {

const node = this

node.on('input', function(msg) {
node.on('input', function (msg) {
const device = RED.nodes.getNode(config.device)
device.remote
.isAvaliablePing()
.then(() => node.send([msg, null]))
.catch(e => node.send([null, msg]))
.catch((e) => node.send([null, msg]))
})
}

function sendNode(config) {
RED.nodes.createNode(this, config)

this.on('input', function(msg) {
this.on('input', function (msg) {
const device = RED.nodes.getNode(config.device)
var key = config.key ? config.key : msg.payload

Expand All @@ -59,7 +59,7 @@ function registerNodes(RED) {

const node = this

device.remote.sendKey(String(key), function(err, res) {
device.remote.sendKey(String(key), function (err, res) {
if (err) {
node.warn(err)
} else {
Expand All @@ -69,11 +69,10 @@ function registerNodes(RED) {
})
}


function sendChannel(config) {
RED.nodes.createNode(this, config)

this.on('input', async function(msg) {
this.on('input', async function (msg) {
const device = RED.nodes.getNode(config.device)
var keys = config.keys ? String(config.keys) : String(msg.payload)

Expand All @@ -87,9 +86,9 @@ function registerNodes(RED) {
try {
for (var i = 0; i < keys.length; i++) {
await device.remote.sendKeyPromise('KEY_' + keys.charAt(i))
await new Promise(r => setTimeout(r, 300));
await new Promise((r) => setTimeout(r, 300))
}
await new Promise(r => setTimeout(r, 500));
await new Promise((r) => setTimeout(r, 500))
await device.remote.sendKeyPromise('KEY_ENTER')

node.send(msg)
Expand All @@ -104,10 +103,10 @@ function registerNodes(RED) {

const node = this

node.on('input', function(msg) {
node.on('input', function (msg) {
const device = RED.nodes.getNode(config.device)

device.remote.getToken(function(token) {
device.remote.getToken(function (token) {
msg.payload = token
node.send(msg)
})
Expand All @@ -119,10 +118,10 @@ function registerNodes(RED) {

const node = this

node.on('input', function(msg) {
node.on('input', function (msg) {
const device = RED.nodes.getNode(config.device)

device.remote.turnOn(function() {
device.remote.turnOn(function () {
node.send(msg)
})
})
Expand All @@ -131,7 +130,7 @@ function registerNodes(RED) {
function openApp(config) {
RED.nodes.createNode(this, config)

this.on('input', function(msg) {
this.on('input', function (msg) {
const device = RED.nodes.getNode(config.device)
var appId = config.appid ? config.appid : msg.payload

Expand All @@ -142,7 +141,7 @@ function registerNodes(RED) {

const node = this

device.remote.openApp(String(appId), function(err, res) {
device.remote.openApp(String(appId), function (err, res) {
if (err) {
node.warn(err)
} else {
Expand All @@ -157,10 +156,10 @@ function registerNodes(RED) {

const node = this

node.on('input', function(msg) {
node.on('input', function (msg) {
const device = RED.nodes.getNode(config.device)

device.remote.getAppsFromTV(function(err, res) {
device.remote.getAppsFromTV(function (err, res) {
if (err || res.data.data === undefined) {
node.warn(err)
}
Expand Down

0 comments on commit 301114e

Please sign in to comment.