From 8661fe1d3be0a9bd4cef01c4b8ff0f36c4f7e0a8 Mon Sep 17 00:00:00 2001 From: Scott Kuo Date: Mon, 6 Jul 2020 13:40:02 -0700 Subject: [PATCH] Initial commit --- .gitignore | 104 + LICENSE | 9 + content/css/style.css | 146 + content/css/style.min.css | 1 + content/css/style.scss | 133 + content/js/mainUI.js | 375 ++ index.html | 126 + main.js | 43 + models/atemController.js | 189 + models/atemSocketServer.js | 141 + package-lock.json | 2439 +++++++++ package.json | 35 + resources/icon.icns | Bin 0 -> 93943 bytes resources/icon.ico | Bin 0 -> 114954 bytes resources/icon.png | Bin 0 -> 29889 bytes routes/Tally.js | 9 + scripts/build.js | 43 + static/css/bootstrap.min.css | 9616 ++++++++++++++++++++++++++++++++++ static/css/style.min.css | 1 + static/js/socket.io.js | 9 + views/tally.pug | 119 + 21 files changed, 13538 insertions(+) create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 content/css/style.css create mode 100644 content/css/style.min.css create mode 100644 content/css/style.scss create mode 100644 content/js/mainUI.js create mode 100644 index.html create mode 100644 main.js create mode 100644 models/atemController.js create mode 100644 models/atemSocketServer.js create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 resources/icon.icns create mode 100644 resources/icon.ico create mode 100644 resources/icon.png create mode 100644 routes/Tally.js create mode 100644 scripts/build.js create mode 100644 static/css/bootstrap.min.css create mode 100644 static/css/style.min.css create mode 100644 static/js/socket.io.js create mode 100644 views/tally.pug diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6704566 --- /dev/null +++ b/.gitignore @@ -0,0 +1,104 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# Next.js build output +.next + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and *not* Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..fd277b5 --- /dev/null +++ b/LICENSE @@ -0,0 +1,9 @@ +The MIT License (MIT) +Copyright (c) 2020 Design Shift Consulting. All Rights Reserved. +https://designshift.ca + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/content/css/style.css b/content/css/style.css new file mode 100644 index 0000000..942cfd0 --- /dev/null +++ b/content/css/style.css @@ -0,0 +1,146 @@ +html, body { + background: #202427; + font-family: Arial, Helvetica, sans-serif; +} + +p, span, h1, h2 { + cursor: default; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.viewport-frame { + padding-top: 56px; + height: 100vh; + overflow: auto; + background: #202427; + color: #D8DCDF; +} + +.viewTitle { + margin-top: 2rem; +} + +input[type='color'] { + padding: 0; + background: rgba(0, 0, 0, 0); + border: none; +} + +input[type='color']:active { + background: rgba(0, 0, 0, 0); + border: none; +} + +.form-control:disabled { + background: #CCCCCC; + color: #999999; +} + +.view { + width: 100%; + height: 100%; +} + +#viewTallyError { + width: 100%; + height: 100%; +} + +#viewTallyError .errMsg { + position: absolute; + top: 50%; + left: 50%; + -webkit-transform: translateX(-50%); + transform: translateX(-50%); +} + +#viewTallyRenderer.viewSingleTally { + height: 100%; + width: 100%; +} + +#viewTallyRenderer.viewMultiTally { + display: -ms-grid; + display: grid; + grid-gap: 16px; + -ms-grid-columns: (minmax(10rem, 1fr))[auto-fill]; + grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); + grid-auto-rows: 1fr; + padding: 16px; +} + +#viewTallyRenderer.viewMultiTally::before { + content: ''; + -ms-grid-column: 1; + grid-column: 1 / 1; + -ms-grid-row: 1; + grid-row: 1 / 1; + padding-bottom: 100%; + width: 0; +} + +#viewTallyRenderer.viewMultiTally > *:first-child { + -ms-grid-column: 1; + grid-column: 1 / 1; + -ms-grid-row: 1; + grid-row: 1 / 1; +} + +#btn-group-voice button { + margin-left: 1em; +} + +.tally { + position: relative; + -webkit-transition: -webkit-box-shadow 0.5s ease-out; + transition: -webkit-box-shadow 0.5s ease-out; + transition: box-shadow 0.5s ease-out; + transition: box-shadow 0.5s ease-out, -webkit-box-shadow 0.5s ease-out; +} + +.tally[data-tally-state='preview'], .tally[data-tally-state='program'] { + -webkit-box-shadow: inset 0 0 40px 15px rgba(20, 20, 20, 0.3); + box-shadow: inset 0 0 40px 15px rgba(20, 20, 20, 0.3); +} + +.tally.tally-single { + height: 100%; + width: 100%; +} + +.tally.tally-multi { + border-radius: 5px; +} + +.tally .tallyCameraLabel { + background: rgba(0, 0, 0, 0.5); + border-radius: 16px; + text-align: center; + display: block; + font-weight: bold; + padding: 0.3em 0.5em; +} + +.tally .tallyCameraId { + color: black; + font-family: Arial, Helvetica, sans-serif; + font-size: 72px; + font-weight: bold; + left: 50%; + position: absolute; + text-shadow: 0px 3px 3px rgba(20, 20, 20, 0.3); + top: 50%; + -webkit-transform: translateX(-50%) translateY(-50%); + transform: translateX(-50%) translateY(-50%); +} + +.tally .tallyCameraLabel { + bottom: 5%; + left: 50%; + position: absolute; + -webkit-transform: translateX(-50%); + transform: translateX(-50%); +} diff --git a/content/css/style.min.css b/content/css/style.min.css new file mode 100644 index 0000000..8872724 --- /dev/null +++ b/content/css/style.min.css @@ -0,0 +1 @@ +html,body{background:#202427;font-family:Arial, Helvetica, sans-serif}p,span,h1,h2{cursor:default;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.viewport-frame{padding-top:56px;height:100vh;overflow:auto;background:#202427;color:#D8DCDF}.viewTitle{margin-top:2rem}input[type='color']{padding:0;background:rgba(0,0,0,0);border:none}input[type='color']:active{background:rgba(0,0,0,0);border:none}.form-control:disabled{background:#CCCCCC;color:#999999}.view{width:100%;height:100%}#viewTallyError{width:100%;height:100%}#viewTallyError .errMsg{position:absolute;top:50%;left:50%;-webkit-transform:translateX(-50%);transform:translateX(-50%)}#viewTallyRenderer.viewSingleTally{height:100%;width:100%}#viewTallyRenderer.viewMultiTally{display:-ms-grid;display:grid;grid-gap:16px;-ms-grid-columns:(minmax(10rem, 1fr))[auto-fill];grid-template-columns:repeat(auto-fill, minmax(10rem, 1fr));grid-auto-rows:1fr;padding:16px}#viewTallyRenderer.viewMultiTally::before{content:'';-ms-grid-column:1;grid-column:1 / 1;-ms-grid-row:1;grid-row:1 / 1;padding-bottom:100%;width:0}#viewTallyRenderer.viewMultiTally>*:first-child{-ms-grid-column:1;grid-column:1 / 1;-ms-grid-row:1;grid-row:1 / 1}#btn-group-voice button{margin-left:1em}.tally{position:relative;-webkit-transition:-webkit-box-shadow 0.5s ease-out;transition:-webkit-box-shadow 0.5s ease-out;transition:box-shadow 0.5s ease-out;transition:box-shadow 0.5s ease-out, -webkit-box-shadow 0.5s ease-out}.tally[data-tally-state='preview'],.tally[data-tally-state='program']{-webkit-box-shadow:inset 0 0 40px 15px rgba(20,20,20,0.3);box-shadow:inset 0 0 40px 15px rgba(20,20,20,0.3)}.tally.tally-single{height:100%;width:100%}.tally.tally-multi{border-radius:5px}.tally .tallyCameraLabel{background:rgba(0,0,0,0.5);border-radius:16px;text-align:center;display:block;font-weight:bold;padding:0.3em 0.5em}.tally .tallyCameraId{color:black;font-family:Arial, Helvetica, sans-serif;font-size:72px;font-weight:bold;left:50%;position:absolute;text-shadow:0px 3px 3px rgba(20,20,20,0.3);top:50%;-webkit-transform:translateX(-50%) translateY(-50%);transform:translateX(-50%) translateY(-50%)}.tally .tallyCameraLabel{bottom:5%;left:50%;position:absolute;-webkit-transform:translateX(-50%);transform:translateX(-50%)} diff --git a/content/css/style.scss b/content/css/style.scss new file mode 100644 index 0000000..5d1fa8b --- /dev/null +++ b/content/css/style.scss @@ -0,0 +1,133 @@ +html, body { + background: #202427; + font-family: Arial, Helvetica, sans-serif; +} + +p, span, h1, h2 { + cursor: default; + user-select: none; +} + +.viewport-frame { + padding-top: 56px; + height: 100vh; + overflow: auto; + background: #202427; + color: #D8DCDF; +} + +.viewTitle { + margin-top: 2rem; +} + +input[type='color'] { + padding: 0; + background: rgba(0, 0, 0, 0); + border: none; + &:active { + background: rgba(0, 0, 0, 0); + border: none; + } +} + +.form-control:disabled { + background: #CCCCCC; + color: #999999; +} + +.view { + width: 100%; + height: 100%; +} + +#viewTallyError { + width: 100%; + height: 100%; + .errMsg { + position: absolute; + top: 50%; + left: 50%; + transform: translateX(-50%); + } +} + +#viewTallyRenderer { + // min-height: 100%; + // height: 100%; + // overflow: auto; + &.viewSingleTally { + height: 100%; + width: 100%; + } + &.viewMultiTally { + display: grid; + grid-gap: 16px; + grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); + grid-auto-rows: 1fr; + padding: 16px; + &::before { + content: ''; + grid-column: 1 / 1; + grid-row: 1 / 1; + padding-bottom: 100%; + width: 0; + } + &>*:first-child { + grid-column: 1 / 1; + grid-row: 1 / 1; + } + } +} + +#btn-group-voice button { + margin-left: 1em; +} + +.tally { + position: relative; + transition: box-shadow 0.5s ease-out; + // &[data-tally-state='inactive'] { + // background: #333333; + // } + // &[data-tally-state='preview'] { + // background: #00FF00; + // } + // &[data-tally-state='program'] { + // background: #FF0000; + // } + &[data-tally-state='preview'], &[data-tally-state='program'] { + box-shadow: inset 0 0 40px 15px rgba(20, 20, 20, 0.3); + } + &.tally-single { + height: 100%; + width: 100%; + } + &.tally-multi { + border-radius: 5px; + } + .tallyCameraLabel { + background: rgba(0, 0, 0, 0.5); + border-radius: 16px; + text-align: center; + display: block; + font-weight: bold; + padding: 0.3em 0.5em; + } + .tallyCameraId { + color: black; + font-family: Arial, Helvetica, sans-serif; + font-size: 72px; + font-weight: bold; + left: 50%; + position: absolute; + text-shadow: 0px 3px 3px rgba(20, 20, 20, 0.3); + top: 50%; + transform: translateX(-50%) translateY(-50%); + } + .tallyCameraLabel { + bottom: 5%; + left: 50%; + position: absolute; + transform: translateX(-50%); + } +} \ No newline at end of file diff --git a/content/js/mainUI.js b/content/js/mainUI.js new file mode 100644 index 0000000..5b4c5b3 --- /dev/null +++ b/content/js/mainUI.js @@ -0,0 +1,375 @@ +const AtemController = require('./models/atemController'); +const Store = require('electron-store'); +const os = require('os'); +const ifaces = os.networkInterfaces(); +let atemController = new AtemController(); + +let store = new Store(); + +var programColor = "#FF0000"; +var previewColor = "#00FF00"; + +function updateTallyColor() { + $('.tally').css('background', '#333333'); // Reset all to black first + $(".tally[data-tally-state='preview']").css('background', previewColor); + $(".tally[data-tally-state='program']").css('background', programColor); +} + +function bindCameraButtons() { + $('.tally-multi').click(function(cam) { + var sid = $(this).data('sid'); + $('#cameraSelection').val(sid); + $('#cameraSelection').change(); + }); + $('.tally-single').click(function(cam) { + $('#cameraSelection').val("ALL"); + $('#cameraSelection').change(); + }); +} + +function updateTally() { + let renderer = $('#viewTallyRenderer'); + let errorRenderer = $('#viewTallyError'); + renderer.show(); + errorRenderer.hide(); + + renderer.removeClass('viewSingleTally viewMultiTally'); + + if ($('#cameraSelection').prop('disabled') || !atemController.availableCameras || atemController.availableCameras === []) { + errorRenderer.show(); + renderer.hide(); + errorRenderer.html('
Not connected
'); + } else { + let cameras = atemController.availableCameras; + let sid = ''; + let output = ''; + renderer.html(''); + + // console.log(cameras); + if ($('#cameraSelection').val() === "ALL") { + if (Object.keys(cameras).length > 0) { + renderer.addClass('viewMultiTally'); + $.each(Object.values(cameras), function(key, value) { + let state = 'inactive'; + + output = ''; + sid = Object.keys(cameras)[key].split('_')[1]; + + if (atemController.previewSourceId == sid) { + state = 'preview'; + } + + // Program overrides preview + if (atemController.programSourceId == sid) { + state = 'program'; + } + + renderer.append($('
', { + class: "tally tally-multi", + 'data-sid': Object.keys(cameras)[key], + 'data-cid': sid, + 'data-tally-state': state, + 'data-abbreviation': value.abbreviation, + 'data-name': value.name + })) + }); + $('.tally-multi').each(function(i, obj) { + $(obj).append('' + $(obj).attr('data-cid') + ''); + $(obj).append('' + $(obj).attr('data-abbreviation') + ''); + }); + } + } else { + renderer.addClass('viewSingleTally'); + fullsid = $('#cameraSelection').val(); + sid = fullsid.split('_')[1]; + + let state = 'inactive'; + + if (atemController.previewSourceId == sid) { + state = 'preview'; + } + + // Program overrides preview + if (atemController.programSourceId == sid) { + state = 'program'; + } + + renderer.append($('
', { + class: "tally tally-single", + 'data-sid': fullsid, + 'data-cid': sid, + 'data-tally-state': state, + 'data-abbreviation': atemController.availableCameras[fullsid].abbreviation, + 'data-name': atemController.availableCameras[fullsid].name + })) + + $('.tally-single').each(function(i, obj) { + $(obj).append('' + $(obj).attr('data-cid') + ''); + $(obj).append('' + $(obj).attr('data-abbreviation') + ''); + }); + + } + updateTallyColor(); + bindCameraButtons(); + } +} + +function setConnectedState() { + $('#btnConnectDevice').prop("disabled", true); + $('#btnDisconnectDevice').prop("disabled", false); + $('#connectionStatusLabel').text("Connected to " + atemController.activeip); +} + +function setDisconnectedState() { + $('#btnConnectDevice').prop("disabled", false); + $('#btnDisconnectDevice').prop("disabled", true); + $('#connectionStatusLabel').text("Disconnected"); +} + +function setInitialStates() { + showView(Views.Tally); + $("#inputManualIpaddress").hide(); + + // Check for tally color setting from store + if (store.get('programColor')) { + programColor = store.get('programColor'); + $('#btnProgramColor').val(programColor); + } + + if (store.get('previewColor')) { + previewColor = store.get('previewColor'); + $('#btnPreviewColor').val(previewColor); + } + + updateTally() + setDisconnectedState(); +} + +function hideMenu() { + $('#navbarMainToggler').addClass('collapsed'); + $('#navbarMainToggler').prop('aria-expanded', 'false'); + $('#navbarMain').removeClass('show'); +} + +Views = { + Tally: 'viewTally', + Settings: 'viewSettings', + Web: 'viewWeb', + About: 'viewAbout' +} + +function showView(viewname) { + hideMenu(); + if (viewname) { + document.getElementById("viewTally").style.display = (viewname == Views.Tally) ? 'block' : 'none'; + document.getElementById("viewSettings").style.display = (viewname == Views.Settings) ? 'block' : 'none'; + document.getElementById("viewWeb").style.display = (viewname == Views.Web) ? 'block' : 'none'; + document.getElementById("viewAbout").style.display = (viewname == Views.About) ? 'block' : 'none'; + } +} + +function updateCameras() { + let cameras = atemController.availableCameras; + + $('#cameraSelection').html(""); + if (Object.keys(cameras).length > 0) { + $('#cameraSelection').prop("disabled", false); + $('#cameraSelection').append($('