From 4fedbce692a3add5686bad634d6fb42c78f071b8 Mon Sep 17 00:00:00 2001 From: waridrox Date: Fri, 6 Aug 2021 13:02:51 +0530 Subject: [PATCH 1/7] Added function for downloading spectrum img --- examples/capture/capture.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/examples/capture/capture.js b/examples/capture/capture.js index 07134dd4..3b2e13eb 100644 --- a/examples/capture/capture.js +++ b/examples/capture/capture.js @@ -161,6 +161,27 @@ $W = { this_.getRecentCalibrations("#calibration_id"); }, + downloadSpectrum: function() { + function getFormattedTime() { + let current_date = new Date(); + let year = current_date.getFullYear(); + let month = current_date.getMonth() + 1; + let day = current_date.getDate(); + let hours = current_date.getHours(); + let minutes = current_date.getMinutes(); + let seconds = current_date.getSeconds(); + return (year + '-' + month + '-' + day + '-' + hours + '-' + minutes + '-' + seconds); + } + + let base64_imgdata = $('#dataurl').val($W.canvas.toDataURL())[0].defaultValue; + console.log(base64_imgdata); + + let a = document.createElement('a'); + a.href = base64_imgdata; + a.download = ('spectrum_img-' + getFormattedTime() + '.png'); + a.click(); + }, + getRecentCalibrations: function(selector) { $.ajax({ url: "/capture/recent_calibrations.json?calibration_id=" + $W.calibration_id, From 4368655038ea28932ad13fc3bdabbd70e8fa7ae1 Mon Sep 17 00:00:00 2001 From: waridrox Date: Sat, 21 Aug 2021 18:43:25 +0530 Subject: [PATCH 2/7] Adding dropdown for camera switching --- examples/capture/capture.js | 13 +------------ examples/capture/index.html | 6 +++++- examples/new-capture/index.html | 11 ++++++++++- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/examples/capture/capture.js b/examples/capture/capture.js index 3b2e13eb..8b7778a7 100644 --- a/examples/capture/capture.js +++ b/examples/capture/capture.js @@ -162,23 +162,12 @@ $W = { }, downloadSpectrum: function() { - function getFormattedTime() { - let current_date = new Date(); - let year = current_date.getFullYear(); - let month = current_date.getMonth() + 1; - let day = current_date.getDate(); - let hours = current_date.getHours(); - let minutes = current_date.getMinutes(); - let seconds = current_date.getSeconds(); - return (year + '-' + month + '-' + day + '-' + hours + '-' + minutes + '-' + seconds); - } - let base64_imgdata = $('#dataurl').val($W.canvas.toDataURL())[0].defaultValue; console.log(base64_imgdata); let a = document.createElement('a'); a.href = base64_imgdata; - a.download = ('spectrum_img-' + getFormattedTime() + '.png'); + a.download = ('spectrum_img.png'); a.click(); }, diff --git a/examples/capture/index.html b/examples/capture/index.html index 82f8b22f..7585e0d6 100644 --- a/examples/capture/index.html +++ b/examples/capture/index.html @@ -174,7 +174,11 @@ - + +
+ +
+

TOOLS

diff --git a/examples/new-capture/index.html b/examples/new-capture/index.html index 62a2e766..8bcb45f5 100644 --- a/examples/new-capture/index.html +++ b/examples/new-capture/index.html @@ -170,8 +170,12 @@

Auto-select Sample Row Flip image Rotate -

+ +
+ +
+

Help selecting a camera

@@ -242,9 +246,14 @@

+ +

Once you save the capture, you cannot go back here.

+ + + From 7650ccfa2d4f503a93a41b5e7a08722c37d33412 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Tue, 21 Sep 2021 12:39:48 -0400 Subject: [PATCH 3/7] download file and check length --- .../spectral-workbench-demo.spec.js | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/cypress/integration/spectral-workbench-demo.spec.js b/cypress/integration/spectral-workbench-demo.spec.js index 363a1c49..545573b8 100644 --- a/cypress/integration/spectral-workbench-demo.spec.js +++ b/cypress/integration/spectral-workbench-demo.spec.js @@ -6,7 +6,6 @@ context('Actions', () => { cy.visit('http://127.0.0.1:8080/examples/new-capture/') }) - it('It reach the default landing page', () => { cy.get('#landing-page-content').contains('Spectral WorkBench'); cy.get('#landing-page-content').contains('What is Spectral Workbench?'); @@ -28,5 +27,21 @@ context('Actions', () => { cy.get('.bs-stepper-header>div').eq(6).not('have.class', 'active') }); - -}) \ No newline at end of file + it('can be clicked through to begin capturing', () => { + cy.get('#landing-page-next').click() + cy.get('#setting-page-next').click() + cy.get('#download-spectrum').click() + + cy.log('**read downloaded file**') + + // file path is relative to the working folder + const filename = path.join(downloadsFolder, 'spectrum_img.png') + + // browser might take a while to download the file, + // so use "cy.readFile" to retry until the file exists + // and has length - and we assume that it has finished downloading then + cy.readFile(filename, { timeout: 15000 }) + .should('have.length.gt', 50) + }); + +}) From 692c7b23308e56deb94b01184be14e103ba6cbc3 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Tue, 21 Sep 2021 12:54:41 -0400 Subject: [PATCH 4/7] Update spectral-workbench-demo.spec.js --- cypress/integration/spectral-workbench-demo.spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/cypress/integration/spectral-workbench-demo.spec.js b/cypress/integration/spectral-workbench-demo.spec.js index 545573b8..a1ede552 100644 --- a/cypress/integration/spectral-workbench-demo.spec.js +++ b/cypress/integration/spectral-workbench-demo.spec.js @@ -1,4 +1,5 @@ /// +const path = require('path') context('Actions', () => { From 24d7062ad842e7d77f3063518bbaa9037782a555 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Tue, 21 Sep 2021 17:37:34 -0400 Subject: [PATCH 5/7] Update spectral-workbench-demo.spec.js --- cypress/integration/spectral-workbench-demo.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cypress/integration/spectral-workbench-demo.spec.js b/cypress/integration/spectral-workbench-demo.spec.js index a1ede552..934653b8 100644 --- a/cypress/integration/spectral-workbench-demo.spec.js +++ b/cypress/integration/spectral-workbench-demo.spec.js @@ -28,6 +28,8 @@ context('Actions', () => { cy.get('.bs-stepper-header>div').eq(6).not('have.class', 'active') }); + const downloadsFolder = Cypress.config('downloadsFolder') + it('can be clicked through to begin capturing', () => { cy.get('#landing-page-next').click() cy.get('#setting-page-next').click() From 1962fa23f1b1b23e227acf9f2f0c92415af85dd3 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Tue, 21 Sep 2021 17:40:20 -0400 Subject: [PATCH 6/7] Update spectral-workbench-demo.spec.js --- cypress/integration/spectral-workbench-demo.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/spectral-workbench-demo.spec.js b/cypress/integration/spectral-workbench-demo.spec.js index 934653b8..2e32e44d 100644 --- a/cypress/integration/spectral-workbench-demo.spec.js +++ b/cypress/integration/spectral-workbench-demo.spec.js @@ -44,7 +44,7 @@ context('Actions', () => { // so use "cy.readFile" to retry until the file exists // and has length - and we assume that it has finished downloading then cy.readFile(filename, { timeout: 15000 }) - .should('have.length.gt', 50) + .should('have.length.gt', 5000000000) }); }) From d7834a78828e86131e289701653400fbaf139b5b Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Tue, 21 Sep 2021 17:52:38 -0400 Subject: [PATCH 7/7] increase file length test for downloaded image --- cypress/integration/spectral-workbench-demo.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cypress/integration/spectral-workbench-demo.spec.js b/cypress/integration/spectral-workbench-demo.spec.js index 2e32e44d..934653b8 100644 --- a/cypress/integration/spectral-workbench-demo.spec.js +++ b/cypress/integration/spectral-workbench-demo.spec.js @@ -44,7 +44,7 @@ context('Actions', () => { // so use "cy.readFile" to retry until the file exists // and has length - and we assume that it has finished downloading then cy.readFile(filename, { timeout: 15000 }) - .should('have.length.gt', 5000000000) + .should('have.length.gt', 50) }); })