v1.2
HTTPS support
This commit is contained in:
parent
0d57ed9a93
commit
9246e26bfc
5 changed files with 22 additions and 7 deletions
10
BMDevice.js
10
BMDevice.js
|
|
@ -22,6 +22,9 @@ class BMDevice {
|
||||||
hostname;
|
hostname;
|
||||||
APIAddress;
|
APIAddress;
|
||||||
|
|
||||||
|
// Are we using HTTPS?
|
||||||
|
useHTTPS;
|
||||||
|
|
||||||
// WebSocket items
|
// WebSocket items
|
||||||
ws;
|
ws;
|
||||||
availableProperties;
|
availableProperties;
|
||||||
|
|
@ -39,10 +42,13 @@ class BMDevice {
|
||||||
updateUI() {};
|
updateUI() {};
|
||||||
|
|
||||||
// ============= CONSTRUCTOR ================
|
// ============= CONSTRUCTOR ================
|
||||||
constructor(hostname) {
|
constructor(hostname, secure=false) {
|
||||||
|
// Set Security
|
||||||
|
this.useHTTPS = secure;
|
||||||
|
|
||||||
// Set name properties
|
// Set name properties
|
||||||
this.hostname = hostname;
|
this.hostname = hostname;
|
||||||
this.APIAddress = "http://"+hostname+"/control/api/v1";
|
this.APIAddress = (this.useHTTPS ? "https://" : "http://")+hostname+"/control/api/v1";
|
||||||
this.name = this.hostname.replace(".local","").replaceAll("-"," ");
|
this.name = this.hostname.replace(".local","").replaceAll("-"," ");
|
||||||
|
|
||||||
// Initialize WebSocket
|
// Initialize WebSocket
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,8 @@ If your camera does not have an ethernet port, use a USB-C to ethernet adapter.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
> If you're using the GitHub Pages site, the API must be accessed with HTTPS rather than HTTP. You can enable this on the camera in **Blackmagic Camera Setup** by clicking the "Generate Certificate" button.
|
||||||
|
|
||||||
## Launching the App
|
## Launching the App
|
||||||
The app is a self-contained, offline web page. (No installation, dependencies, or servers to worry about!) Simply open the `index.html` file in your browser of choice, enter the hostname of your camera, and press "Connect".
|
The app is a self-contained, offline web page. (No installation, dependencies, or servers to worry about!) Simply open the `index.html` file in your browser of choice, enter the hostname of your camera, and press "Connect".
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,8 @@
|
||||||
<td>
|
<td>
|
||||||
<input type="text" placeholder="Studio-Camera-6K-Pro.local" id="hostnameInput">
|
<input type="text" placeholder="Studio-Camera-6K-Pro.local" id="hostnameInput">
|
||||||
<button onclick="initCamera()">Connect</button>
|
<button onclick="initCamera()">Connect</button>
|
||||||
|
<input type="checkbox" id="secureCheckbox">
|
||||||
|
<span id="secureCheckboxLabel">Use HTTPS</span>
|
||||||
<span id="connectionErrorSpan"></span>
|
<span id="connectionErrorSpan"></span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -331,7 +333,7 @@
|
||||||
<!-- Footer Div -->
|
<!-- Footer Div -->
|
||||||
<div class="flexContainerH" id="footerContainer">
|
<div class="flexContainerH" id="footerContainer">
|
||||||
<div id="footerLeft">
|
<div id="footerLeft">
|
||||||
<span class="">(v 1.1)</span>
|
<span class="">(v 1.2)</span>
|
||||||
<span id="activeElementSpan"></span>
|
<span id="activeElementSpan"></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="footerLinks">
|
<div id="footerLinks">
|
||||||
|
|
|
||||||
|
|
@ -131,6 +131,10 @@ input[type=file]:focus {
|
||||||
border: 1px solid rgb(150, 58, 0);
|
border: 1px solid rgb(150, 58, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#secureCheckboxLabel {
|
||||||
|
margin-right: 1vw;
|
||||||
|
}
|
||||||
|
|
||||||
/* Horizontal Container Styles */
|
/* Horizontal Container Styles */
|
||||||
#headerContainer {
|
#headerContainer {
|
||||||
background: #181818;
|
background: #181818;
|
||||||
|
|
|
||||||
|
|
@ -26,14 +26,15 @@ function bodyOnLoad() {
|
||||||
function initCamera() {
|
function initCamera() {
|
||||||
// Get hostname from Hostname text field
|
// Get hostname from Hostname text field
|
||||||
let hostname = document.getElementById("hostnameInput").value;
|
let hostname = document.getElementById("hostnameInput").value;
|
||||||
|
let security = document.getElementById("secureCheckbox").checked;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Check if the hostname is valid
|
// Check if the hostname is valid
|
||||||
let response = sendRequest("GET", "http://"+hostname+"/control/api/v1/system","");
|
let response = sendRequest("GET", (security ? "https://" : "http://")+hostname+"/control/api/v1/system","");
|
||||||
|
|
||||||
if (response.status < 300) {
|
if (response.status < 300) {
|
||||||
// Success, make a new camera, get all relevant info, and populate the UI
|
// Success, make a new camera, get all relevant info, and populate the UI
|
||||||
cameras[ci] = new BMCamera(hostname);
|
cameras[ci] = new BMCamera(hostname, security);
|
||||||
|
|
||||||
cameras[ci].updateUI = updateUIAll;
|
cameras[ci].updateUI = updateUIAll;
|
||||||
|
|
||||||
|
|
@ -286,8 +287,8 @@ function updateUIAll() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ============ Footer Links ===============
|
// ============ Footer Links ===============
|
||||||
document.getElementById("documentationLink").href = "http://"+cameras[ci].hostname+"/control/documentation.html";
|
document.getElementById("documentationLink").href = (cameras[ci].useHTTPS ? "https://" : "http://")+cameras[ci].hostname+"/control/documentation.html";
|
||||||
document.getElementById("mediaManagerLink").href = "http://"+cameras[ci].hostname;
|
document.getElementById("mediaManagerLink").href = (cameras[ci].useHTTPS ? "https://" : "http://")+cameras[ci].hostname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue