Skip to content

Commit 6027950

Browse files
jywarrendependabot-preview[bot]waridroxdependabot[bot]
authored
Merge latest main to gh-pages (#264)
* Update README.md * Update README.md * Bump jasmine from 3.6.1 to 3.7.0 (#216) Bumps [jasmine](https://github.com/jasmine/jasmine-npm) from 3.6.1 to 3.7.0. - [Release notes](https://github.com/jasmine/jasmine-npm/releases) - [Commits](jasmine/jasmine-npm@v3.6.1...v3.7.0) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Bump tape from 5.2.0 to 5.2.2 (#211) Bumps [tape](https://github.com/substack/tape) from 5.2.0 to 5.2.2. - [Release notes](https://github.com/substack/tape/releases) - [Commits](tape-testing/tape@v5.2.0...v5.2.2) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * [Security] Bump ini from 1.3.5 to 1.3.8 (#198) Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8. **This update includes a security fix.** - [Release notes](https://github.com/isaacs/ini/releases) - [Commits](npm/ini@v1.3.5...v1.3.8) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * bump to v0.2.0 (#238) * Camera switching in a dropdown list (#247) * Added camera switching in a dropdown * Added dropdown element for camera switching on old and new interface Added dropdown element on old interface * bump to v0.2.1 * Bump moment from 2.10.6 to 2.19.3 (#230) Bumps [moment](https://github.com/moment/moment) from 2.10.6 to 2.19.3. - [Release notes](https://github.com/moment/moment/releases) - [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) - [Commits](moment/moment@2.10.6...2.19.3) Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jquery from 3.5.1 to 3.6.0 (#232) Bumps [jquery](https://github.com/jquery/jquery) from 3.5.1 to 3.6.0. - [Release notes](https://github.com/jquery/jquery/releases) - [Commits](jquery/jquery@3.5.1...3.6.0) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Bump grunt-cli from 1.3.2 to 1.4.3 (#234) Bumps [grunt-cli](https://github.com/gruntjs/grunt-cli) from 1.3.2 to 1.4.3. - [Release notes](https://github.com/gruntjs/grunt-cli/releases) - [Changelog](https://github.com/gruntjs/grunt-cli/blob/main/CHANGELOG.md) - [Commits](gruntjs/grunt-cli@v1.3.2...v1.4.3) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Bump cypress from 5.1.0 to 8.1.0 (#244) Bumps [cypress](https://github.com/cypress-io/cypress) from 5.1.0 to 8.1.0. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js) - [Commits](https://github.com/cypress-io/cypress/compare/@cypress/react-v5.1.0...v8.1.0) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Bump path-parse from 1.0.6 to 1.0.7 (#246) Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7. - [Release notes](https://github.com/jbgutierrez/path-parse/releases) - [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7) --- updated-dependencies: - dependency-name: path-parse dependency-type: indirect ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Upgrade to GitHub-native Dependabot (#226) Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Bump cypress from 8.1.0 to 8.3.0 (#253) Bumps [cypress](https://github.com/cypress-io/cypress) from 8.1.0 to 8.3.0. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js) - [Commits](cypress-io/cypress@v8.1.0...v8.3.0) --- updated-dependencies: - dependency-name: cypress dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump grunt from 1.3.0 to 1.4.1 (#252) Bumps [grunt](https://github.com/gruntjs/grunt) from 1.3.0 to 1.4.1. - [Release notes](https://github.com/gruntjs/grunt/releases) - [Changelog](https://github.com/gruntjs/grunt/blob/main/CHANGELOG) - [Commits](gruntjs/grunt@v1.3.0...v1.4.1) --- updated-dependencies: - dependency-name: grunt dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jquery.steps from 1.1.1 to 1.1.2 (#250) Bumps [jquery.steps](https://github.com/oguzhanoya/jquery-steps) from 1.1.1 to 1.1.2. - [Release notes](https://github.com/oguzhanoya/jquery-steps/releases) - [Commits](oguzhanoya/jquery-steps@v1.1.1...v1.1.2) --- updated-dependencies: - dependency-name: jquery.steps dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump tape from 5.2.2 to 5.3.1 (#249) Bumps [tape](https://github.com/substack/tape) from 5.2.2 to 5.3.1. - [Release notes](https://github.com/substack/tape/releases) - [Commits](tape-testing/tape@v5.2.2...v5.3.1) --- updated-dependencies: - dependency-name: tape dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump jasmine from 3.7.0 to 3.9.0 (#248) Bumps [jasmine](https://github.com/jasmine/jasmine-npm) from 3.7.0 to 3.9.0. - [Release notes](https://github.com/jasmine/jasmine-npm/releases) - [Commits](jasmine/jasmine-npm@v3.7.0...v3.9.0) --- updated-dependencies: - dependency-name: jasmine dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump moment from 2.19.3 to 2.29.1 (#257) Bumps [moment](https://github.com/moment/moment) from 2.19.3 to 2.29.1. - [Release notes](https://github.com/moment/moment/releases) - [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md) - [Commits](moment/moment@2.19.3...2.29.1) --- updated-dependencies: - dependency-name: moment dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump cypress from 8.3.0 to 8.3.1 (#259) Bumps [cypress](https://github.com/cypress-io/cypress) from 8.3.0 to 8.3.1. - [Release notes](https://github.com/cypress-io/cypress/releases) - [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js) - [Commits](cypress-io/cypress@v8.3.0...v8.3.1) --- updated-dependencies: - dependency-name: cypress dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump http-server from 0.12.3 to 13.0.1 (#258) Bumps [http-server](https://github.com/http-party/http-server) from 0.12.3 to 13.0.1. - [Release notes](https://github.com/http-party/http-server/releases) - [Commits](http-party/http-server@v0.12.3...v13.0.1) --- updated-dependencies: - dependency-name: http-server dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Added functionality for downloading spectrum image (#245) * Added function for downloading spectrum img * Adding dropdown for camera switching * download file and check length * Update spectral-workbench-demo.spec.js * Update spectral-workbench-demo.spec.js * Update spectral-workbench-demo.spec.js * increase file length test for downloaded image Co-authored-by: Jeffrey Warren <[email protected]> * Bump http-server from 13.0.1 to 13.0.2 (#260) Bumps [http-server](https://github.com/http-party/http-server) from 13.0.1 to 13.0.2. - [Release notes](https://github.com/http-party/http-server/releases) - [Commits](http-party/http-server@v13.0.1...v13.0.2) --- updated-dependencies: - dependency-name: http-server dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Mohammad Warid <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent 29c52a2 commit 6027950

File tree

9 files changed

+969
-1034
lines changed

9 files changed

+969
-1034
lines changed

.github/dependabot.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
open-pull-requests-limit: 10
8+
ignore:
9+
- dependency-name: cypress
10+
versions:
11+
- 6.3.0
12+
- 6.4.0
13+
- 6.5.0
14+
- 6.6.0
15+
- 6.7.1
16+
- 6.8.0
17+
- 7.0.0
18+
- 7.0.1
19+
- 7.1.0
20+
- dependency-name: d3
21+
versions:
22+
- 6.5.0
23+
- 6.6.0
24+
- 6.6.1
25+
- 6.6.2
26+
- dependency-name: tape
27+
versions:
28+
- 5.1.1
29+
- 5.2.1
30+
- dependency-name: jasmine
31+
versions:
32+
- 3.6.4
33+
- dependency-name: flot
34+
versions:
35+
- 4.2.1

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Try a demo of the newly rewritten capture interface here: https://publiclab.gith
2121

2222
****
2323

24+
![screenshot](https://publiclab.org/i/42828.png)
25+
2426

2527
## Installation
2628

cypress/integration/spectral-workbench-demo.spec.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/// <reference types="cypress" />
2+
const path = require('path')
23

34
context('Actions', () => {
45

56
beforeEach(() => {
67
cy.visit('http://127.0.0.1:8080/examples/new-capture/')
78
})
89

9-
1010
it('It reach the default landing page', () => {
1111
cy.get('#landing-page-content').contains('Spectral WorkBench');
1212
cy.get('#landing-page-content').contains('What is Spectral Workbench?');
@@ -28,5 +28,23 @@ context('Actions', () => {
2828
cy.get('.bs-stepper-header>div').eq(6).not('have.class', 'active')
2929
});
3030

31-
32-
})
31+
const downloadsFolder = Cypress.config('downloadsFolder')
32+
33+
it('can be clicked through to begin capturing', () => {
34+
cy.get('#landing-page-next').click()
35+
cy.get('#setting-page-next').click()
36+
cy.get('#download-spectrum').click()
37+
38+
cy.log('**read downloaded file**')
39+
40+
// file path is relative to the working folder
41+
const filename = path.join(downloadsFolder, 'spectrum_img.png')
42+
43+
// browser might take a while to download the file,
44+
// so use "cy.readFile" to retry until the file exists
45+
// and has length - and we assume that it has finished downloading then
46+
cy.readFile(filename, { timeout: 15000 })
47+
.should('have.length.gt', 50)
48+
});
49+
50+
})

dist/capture.dist.js

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,20 +265,98 @@ $W.getUserMedia = function(options) {
265265
container.appendChild(video);
266266
video.autoplay = true;
267267
video.id = 'webcam-video'
268+
269+
var videoElement = document.getElementById('webcam-video');
270+
var videoSelect = document.querySelector('select#videoSource');
271+
var selectors = [videoSelect];
268272

269-
const successCallback = stream => {
273+
successCallback = stream => {
270274
$('#heightIndicator').show()
271275
$('#webcam-msg').hide()
272-
attachMediaStream(video, stream)
276+
277+
window.stream = stream;
278+
videoElement = attachMediaStream(videoElement, stream)
273279
if ($W.flipped == true) {
274280
$W.flipped = false; // <= turn it false because f_h() will toggle it. messy.
275281
$W.flip_horizontal();
276282
}
283+
return getVidDevices();
277284
};
278285

279286
const errorCallback = () => console.warn(error);
280287

281288
getUserMedia($W.defaultConstraints, successCallback, errorCallback);
289+
290+
gotVidDevices = (deviceInfos) => {
291+
let values = selectors.map(function(select) {
292+
return select.value;
293+
});
294+
295+
selectors.forEach(function(select) {
296+
while (select.firstChild) {
297+
select.removeChild(select.firstChild);
298+
}
299+
});
300+
for (let i = 0; i !== deviceInfos.length; ++i) {
301+
let deviceInfo = deviceInfos[i];
302+
let option = document.createElement('option');
303+
option.value = (deviceInfo.id || deviceInfo.deviceId);
304+
if (deviceInfo.kind === 'videoinput' || deviceInfo.kind === 'video') {
305+
console.log(deviceInfo.label);
306+
option.text = deviceInfo.label || 'camera ' + (videoSelect.length + 1);
307+
videoSelect.appendChild(option);
308+
}
309+
}
310+
311+
selectors.forEach(function(select, selectorIndex) {
312+
if (Array.prototype.slice.call(select.childNodes).some(function(n) {
313+
return n.value === values[selectorIndex];
314+
})) {
315+
select.value = values[selectorIndex];
316+
}
317+
});
318+
}
319+
320+
getVidDevices = () => {
321+
if (typeof Promise === 'undefined') {
322+
return MediaStreamTrack.getSources(gotVidDevices);
323+
} else {
324+
return navigator.mediaDevices.enumerateDevices()
325+
.then(gotVidDevices)
326+
.catch((error) => {
327+
console.error(error);
328+
});
329+
}
330+
}
331+
332+
getVidDevices();
333+
334+
start = () => {
335+
if (window.stream) {
336+
window.stream.getTracks().forEach(function(track) {
337+
track.stop(); //stopping the current video stream
338+
});
339+
}
340+
341+
var videoSource = videoSelect.value;
342+
var constraints = {
343+
video: {
344+
deviceId: videoSource ? {exact: videoSource} : undefined //Taking device ids as the video source
345+
}
346+
};
347+
348+
if (typeof Promise === 'undefined') {
349+
navigator.getUserMedia(constraints, successCallback, function(){});
350+
}
351+
else {
352+
navigator.mediaDevices.getUserMedia(constraints)
353+
.then(successCallback);
354+
}
355+
}
356+
357+
videoSelect.onchange = start; //repeating the process for source change
358+
359+
start();
282360
});
283361
};
284362

examples/capture/capture.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,16 @@ $W = {
161161
this_.getRecentCalibrations("#calibration_id");
162162
},
163163

164+
downloadSpectrum: function() {
165+
let base64_imgdata = $('#dataurl').val($W.canvas.toDataURL())[0].defaultValue;
166+
console.log(base64_imgdata);
167+
168+
let a = document.createElement('a');
169+
a.href = base64_imgdata;
170+
a.download = ('spectrum_img.png');
171+
a.click();
172+
},
173+
164174
getRecentCalibrations: function(selector) {
165175
$.ajax({
166176
url: "/capture/recent_calibrations.json?calibration_id=" + $W.calibration_id,

examples/capture/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,10 @@
174174
<a rel="tooltip" title="Flip video horizontally" class="btn btn-default btn-flip" onClick="$W.flip_horizontal()"><i class="fa fa-white fa-arrows-h"></i></a>
175175
<a rel="tooltip" title="Scale video" class="btn btn-default" onClick="$W.scale_h = parseFloat(prompt('Enter a horizontal scaling factor (default is 1):'))"><i class="fa fa-white fa-expand"></i></a>
176176
</div>
177+
178+
<div class="select" style="padding-top:5px;">
179+
<label for="videoSource">Camera source: </label><select id="videoSource"></select>
180+
</div>
177181

178182
<p><small><b>TOOLS</b></small></p>
179183
<div class="btn-group toolbar" style="margin-bottom:5px;">

examples/new-capture/index.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,12 @@ <h1>
170170
<a rel="tooltip" title="" class="btn btn-default" onclick="$W.auto_detect_sample_row()" data-original-title="Auto select sample row"><i class="fa fa-white fa-arrows-v"></i> Auto-select Sample Row</a>
171171
<a rel="tooltip" title="Flip video horizontally" class="btn btn-default btn-flip" onClick="$W.flip_horizontal()"><i class="fa fa-white fa-arrows-h"></i> Flip image</a>
172172
<a rel="tooltip" title="Rotate video 90 &deg;" class="btn btn-default btn-rotate" onClick="$W.toggle_rotation()"><i class="fa fa-white fa-rotate-right"></i> Rotate</a>
173-
174173
</p>
174+
175+
<div class="select" style="padding-top:5px;">
176+
<label for="videoSource">Camera source: </label><select id="videoSource"></select>
177+
</div>
178+
175179
<p style="padding-top:5px;">
176180
Help <a href="http://publiclab.org/wiki/spectral-workbench-usage#Webcam+selection">selecting a camera</a>
177181
</p>
@@ -242,9 +246,14 @@ <h1>
242246
</div>
243247
</div>
244248

249+
<input name="dataurl" type="hidden" id="dataurl" />
250+
245251
<button class="demo-button next" id="capture-page-next">Save Capture</button>
246252
<p style="margin-top: 0.5em">Once you save the capture, you cannot go back here.</p>
247253
<img style="display:none;background:#333;" id="spectrum-preview" />
254+
255+
<button class="demo-button next" id="download-spectrum" onClick="$W.downloadSpectrum();">Download</button>
256+
248257
</div>
249258

250259

0 commit comments

Comments
 (0)