diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/TokensPage.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/TokensPage.js index 428df069ba4..2067f393ea8 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/TokensPage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/TokensPage.js @@ -73,12 +73,17 @@ qx.Class.define("osparc.desktop.preferences.pages.TokensPage", { } const createAPIKeyWindow = new osparc.desktop.preferences.window.CreateAPIKey(); - createAPIKeyWindow.addListener("finished", keyLabel => { + createAPIKeyWindow.addListener("finished", e => { + const formData = e.getData(); const params = { data: { - "display_name": keyLabel.getData() + "display_name": formData["name"] } }; + if (formData["expiration"]) { + const seconds = parseInt((new Date(formData["expiration"]).getTime() - new Date().getTime()) / 1000); + params.data["expiration"] = seconds + } createAPIKeyWindow.close(); this.__requestAPIKeyBtn.setFetching(true); osparc.data.Resources.fetch("apiKeys", "post", params) diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/window/CreateAPIKey.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/window/CreateAPIKey.js index 334d0f65709..a1fff213357 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/window/CreateAPIKey.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/window/CreateAPIKey.js @@ -29,30 +29,47 @@ qx.Class.define("osparc.desktop.preferences.window.CreateAPIKey", { }, members: { + __form: null, + __populateWindow: function() { - const hBox1 = new qx.ui.container.Composite(new qx.ui.layout.HBox(10)); - const sTitle = new qx.ui.basic.Label(this.tr("API Key")).set({ - width: 50, - alignY: "middle" - }); - hBox1.add(sTitle); - const labelEditor = new qx.ui.form.TextField(); - this.add(labelEditor, { - flex: 1 + const form = this.__form = new qx.ui.form.Form(); + + const keyName = new qx.ui.form.TextField().set({ + required: true }); - hBox1.add(labelEditor, { - flex: 1 + form.add(keyName, this.tr("Key Name"), null, "name"); + this.addListener("appear", () => keyName.focus()); + + const dateFormat = new qx.util.format.DateFormat("dd/MM/yyyy-HH:mm:ss"); + const expirationDate = new qx.ui.form.DateField(); + form.add(expirationDate, this.tr("Expiration Date"), null, "expiration"); + expirationDate.addListener("changeValue", e => { + const date = e.getData(); + if (date) { + // allow only today and future dates + if (new Date(date).getDate() < new Date().getDate()) { + const msg = this.tr("Choose a future date"); + osparc.FlashMessenger.getInstance().logAs(msg, "WARNING"); + expirationDate.resetValue(); + } else { + expirationDate.setDateFormat(dateFormat); + } + } }); - this.add(hBox1); + + const formRenderer = new qx.ui.form.renderer.Single(form); + this.add(formRenderer); const hBox2 = new qx.ui.container.Composite(new qx.ui.layout.HBox(10)); hBox2.add(new qx.ui.core.Spacer(), { flex: 1 }); const confirmBtn = new qx.ui.form.Button(this.tr("Confirm")); - confirmBtn.addListener("execute", e => { - const keyLabel = labelEditor.getValue(); - this.fireDataEvent("finished", keyLabel); + confirmBtn.addListener("execute", () => { + this.fireDataEvent("finished", { + name: form.getItem("name").getValue(), + expiration: form.getItem("expiration").getValue() + }); }, this); hBox2.add(confirmBtn); diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/window/ShowAPIKey.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/window/ShowAPIKey.js index b70cf8b982b..4c63579a70f 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/window/ShowAPIKey.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/window/ShowAPIKey.js @@ -69,9 +69,11 @@ qx.Class.define("osparc.desktop.preferences.window.ShowAPIKey", { width: 40 }); hBox.add(sTitle); - const sLabel = new qx.ui.basic.Label(label).set({ - selectable: true - }); + const sLabel = new qx.ui.basic.Label(); + if (label) { + // partially hide the key and secret + sLabel.setValue(label.substring(1, 8) + "****") + } hBox.add(sLabel); return hBox; } diff --git a/tests/e2e-playwright/tests/ti_plan.py b/tests/e2e-playwright/tests/ti_plan.py index 461b1cbf3cd..1d6a6a01a09 100644 --- a/tests/e2e-playwright/tests/ti_plan.py +++ b/tests/e2e-playwright/tests/ti_plan.py @@ -8,7 +8,7 @@ import re from http import HTTPStatus -from playwright.sync_api import APIRequestContext, Page, WebSocket +from playwright.sync_api import APIRequestContext, Page, WebSocket, expect from pydantic import AnyUrl from pytest_simcore.playwright_utils import SocketIOOsparcMessagePrinter from tenacity import Retrying @@ -58,7 +58,12 @@ def test_tip( # Electrode Selector es_page = page.frame_locator(f'[osparc-test-id="iframe_{node_ids[0]}"]') - es_page.get_by_test_id("TargetStructure_Selector").click(timeout=300000) + expect(es_page.get_by_test_id("TargetStructure_Selector")).to_be_visible( + timeout=300000 + ) + # Sometimes this iframe flicks and shows a white page. This wait will avoid it + page.wait_for_timeout(5000) + es_page.get_by_test_id("TargetStructure_Selector").click() es_page.get_by_test_id( "TargetStructure_Target_(Targets_combined) Hypothalamus" ).click() @@ -94,7 +99,10 @@ def test_tip( # Optimal Configuration Identification ti_page = page.frame_locator(f'[osparc-test-id="iframe_{node_ids[1]}"]') - ti_page.get_by_role("button", name="Run Optimization").click(timeout=300000) + expect(ti_page.get_by_role("button", name="Run Optimization")).to_be_visible( + timeout=300000 + ) + ti_page.get_by_role("button", name="Run Optimization").click() page.wait_for_timeout(20000) ti_page.get_by_role("button", name="Load Analysis").click() page.wait_for_timeout(20000) @@ -125,8 +133,11 @@ def test_tip( # Sim4Life PostPro s4l_postpro_page = page.frame_locator(f'[osparc-test-id="iframe_{node_ids[2]}"]') - # click on the mode button - s4l_postpro_page.get_by_test_id("mode-button-postro").click(timeout=300000) + expect(s4l_postpro_page.get_by_test_id("mode-button-postro")).to_be_visible( + timeout=300000 + ) + # click on the postpro mode button + s4l_postpro_page.get_by_test_id("mode-button-postro").click() # click on the surface viewer s4l_postpro_page.get_by_test_id("tree-item-ti_field.cache").click() s4l_postpro_page.get_by_test_id("tree-item-SurfaceViewer").click()