Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PlayWallCompanion
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PlayWall
PlayWallCompanion
Commits
7cb0bdfb
Commit
7cb0bdfb
authored
1 year ago
by
Tobias Ullerich
Browse files
Options
Downloads
Patches
Plain Diff
#187 - Add feedback for pad status
parent
3502e7b1
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
feedbacks.js
+16
-16
16 additions, 16 deletions
feedbacks.js
main.js
+3
-1
3 additions, 1 deletion
main.js
project.js
+31
-1
31 additions, 1 deletion
project.js
receive/pad_status_update.js
+11
-0
11 additions, 0 deletions
receive/pad_status_update.js
with
61 additions
and
18 deletions
feedbacks.js
+
16
−
16
View file @
7cb0bdfb
...
@@ -2,30 +2,30 @@ const { combineRgb } = require('@companion-module/base')
...
@@ -2,30 +2,30 @@ const { combineRgb } = require('@companion-module/base')
module
.
exports
=
async
function
(
self
)
{
module
.
exports
=
async
function
(
self
)
{
self
.
setFeedbackDefinitions
({
self
.
setFeedbackDefinitions
({
Channel
Stat
e
:
{
Pad
Stat
us
:
{
name
:
'
Example Feedback
'
,
name
:
'
Pad Status
'
,
type
:
'
boolean
'
,
type
:
'
boolean
'
,
label
:
'
Channel
Stat
e
'
,
label
:
'
Pad
Stat
us
'
,
defaultStyle
:
{
defaultStyle
:
{
bgcolor
:
combineRgb
(
255
,
0
,
0
),
bgcolor
:
combineRgb
(
255
,
0
,
0
),
color
:
combineRgb
(
0
,
0
,
0
),
color
:
combineRgb
(
0
,
0
,
0
),
},
},
options
:
[
options
:
[
{
{
id
:
'
num
'
,
id
:
'
name
'
,
type
:
'
number
'
,
type
:
'
textinput
'
,
label
:
'
Test
'
,
label
:
'
Pad Name
'
,
default
:
5
,
default
:
''
,
min
:
0
,
max
:
10
,
},
},
],
],
callback
:
(
feedback
)
=>
{
callback
:
(
feedback
,
context
)
=>
{
console
.
log
(
'
Hello world!
'
,
feedback
.
options
.
num
)
self
.
log
(
'
debug
'
,
`Update feedback for pad name
${
feedback
.
options
.
name
}
`
);
if
(
feedback
.
options
.
num
>
5
)
{
const
pad
=
self
.
currentProject
.
findPadByName
(
feedback
.
options
.
name
);
return
true
if
(
pad
!=
null
)
{
self
.
log
(
'
debug
'
,
`Update feedback for pad id
${
pad
.
id
}
with status
${
pad
.
status
}
`
);
return
pad
.
status
===
'
PLAY
'
;
}
else
{
}
else
{
return
false
return
false
;
}
}
},
},
},
},
...
...
This diff is collapsed.
Click to expand it.
main.js
+
3
−
1
View file @
7cb0bdfb
...
@@ -7,6 +7,7 @@ const WebSocket = require('ws')
...
@@ -7,6 +7,7 @@ const WebSocket = require('ws')
const
ProjectUpdate
=
require
(
"
./receive/project_update
"
);
const
ProjectUpdate
=
require
(
"
./receive/project_update
"
);
const
Project
=
require
(
"
./project
"
);
const
Project
=
require
(
"
./project
"
);
const
PadNameUpdate
=
require
(
"
./receive/pad_name_update
"
);
const
PadNameUpdate
=
require
(
"
./receive/pad_name_update
"
);
const
PadStatusUpdate
=
require
(
"
./receive/pad_status_update
"
);
const
uuid
=
require
(
'
uuid
'
);
const
uuid
=
require
(
'
uuid
'
);
class
ModuleInstance
extends
InstanceBase
{
class
ModuleInstance
extends
InstanceBase
{
...
@@ -16,7 +17,8 @@ class ModuleInstance extends InstanceBase {
...
@@ -16,7 +17,8 @@ class ModuleInstance extends InstanceBase {
messageHandlers
=
{
messageHandlers
=
{
'
project-current
'
:
new
ProjectUpdate
(),
'
project-current
'
:
new
ProjectUpdate
(),
'
pad-name-changed
'
:
new
PadNameUpdate
()
'
pad-name-changed
'
:
new
PadNameUpdate
(),
'
pad-status-changed
'
:
new
PadStatusUpdate
()
};
};
currentProject
=
new
Project
({});
currentProject
=
new
Project
({});
...
...
This diff is collapsed.
Click to expand it.
project.js
+
31
−
1
View file @
7cb0bdfb
module
.
exports
=
class
Project
{
module
.
exports
=
class
Project
{
constructor
(
data
)
{
constructor
(
data
)
{
this
.
data
=
data
this
.
padCache
=
{}
this
.
padCache
=
{}
// Prefill with current project
// Prefill with current project
...
@@ -29,7 +28,38 @@ module.exports = class Project {
...
@@ -29,7 +28,38 @@ module.exports = class Project {
delete
this
.
padCache
[
oldName
];
delete
this
.
padCache
[
oldName
];
}
}
/**
*
* @param {string} padId
* @param {string} newStatus
*/
updatePadStatus
(
padId
,
newStatus
)
{
const
pad
=
this
.
findPadById
(
padId
);
if
(
pad
!=
null
)
{
pad
.
status
=
newStatus
;
}
}
/**
*
* @param {string} name
* @returns {*}
*/
findPadByName
(
name
)
{
findPadByName
(
name
)
{
return
this
.
padCache
[
name
];
return
this
.
padCache
[
name
];
}
}
/**
*
* @param {string} padId
*/
findPadById
(
padId
)
{
for
(
const
id
in
this
.
padCache
)
{
const
pad
=
this
.
padCache
[
id
];
if
(
pad
.
id
===
padId
)
{
return
pad
}
}
return
null
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
receive/pad_status_update.js
0 → 100644
+
11
−
0
View file @
7cb0bdfb
const
MessageExecutable
=
require
(
"
./message_executable
"
);
module
.
exports
=
class
PadStatusUpdate
extends
MessageExecutable
{
handleMessage
(
plugin
,
message
)
{
plugin
.
currentProject
.
updatePadStatus
(
message
.
pad
,
message
.
status
);
plugin
.
checkFeedbacks
();
}
}
// {"pad":"8b7ef494-d735-45f9-ab84-c95e299298a6","status":"PLAY","updateType":"pad-status-changed"}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment