Skip to content

Commit

Permalink
Merge branch 'master' into is2757/gc-as-a-service-implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
pcrespov authored Mar 15, 2022
2 parents 20ebf05 + 64f0631 commit 75e1b77
Show file tree
Hide file tree
Showing 27 changed files with 1,344 additions and 344 deletions.
27 changes: 27 additions & 0 deletions api/specs/common/schemas/project-v0.0.1-converted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,33 @@ properties:
currentNodeId:
type: string
format: uuid
annotations:
type: object
x-patternProperties:
^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?4[0-9a-fA-F]{3}-?[89abAB][0-9a-fA-F]{3}-?[0-9a-fA-F]{12}$:
type: object
additionalProperties: false
required:
- type
- color
- attributes
properties:
type:
type: string
description: Annotation type
example:
- rect
- text
color:
type: string
description: Annotation's color
example:
- '#FF0000'
- '#0000FF'
attributes:
type: object
description: svg attributes
additionalProperties: true
tags:
type: array
items:
Expand Down
36 changes: 36 additions & 0 deletions api/specs/common/schemas/project-v0.0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,42 @@
"currentNodeId": {
"type": "string",
"format": "uuid"
},
"annotations": {
"type": "object",
"patternProperties": {
"^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?4[0-9a-fA-F]{3}-?[89abAB][0-9a-fA-F]{3}-?[0-9a-fA-F]{12}$": {
"type": "object",
"additionalProperties": false,
"required": [
"type",
"color",
"attributes"
],
"properties": {
"type": {
"type": "string",
"description": "Annotation type",
"examples": [
"rect",
"text"
]
},
"color": {
"type": "string",
"description": "Annotation's color",
"examples": [
"#FF0000",
"#0000FF"
]
},
"attributes": {
"type": "object",
"description": "svg attributes"
}
}
}
}
}
}
},
Expand Down
33 changes: 29 additions & 4 deletions packages/models-library/src/models_library/projects_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
Models Front-end UI
"""

from typing import Dict, Optional
from typing import Dict, Literal, Optional

from pydantic import BaseModel, Extra, Field
from pydantic.color import Color

from .projects_nodes_io import NodeID, NodeIDStr
from .projects_nodes_ui import Position
Expand All @@ -24,10 +25,34 @@ class Config:
extra = Extra.forbid


class Annotation(BaseModel):
type: Literal["rect", "text"] = Field(...)
color: Color = Field(...)
attributes: Dict = Field(..., description="svg attributes")

class Config:
extra = Extra.forbid
schema_extra = {
"examples": [
{
"type": "rect",
"color": "#FF0000",
"attributes": {"x": 415, "y": 100, "width": 117, "height": 26},
},
{
"type": "text",
"color": "#0000FF",
"attributes": {"x": 415, "y": 100, "text": "Hey!"},
},
]
}


class StudyUI(BaseModel):
workbench: Optional[Dict[NodeIDStr, WorkbenchUI]] = Field(None)
slideshow: Optional[Dict[NodeIDStr, Slideshow]]
current_node_id: Optional[NodeID] = Field(alias="currentNodeId")
workbench: Optional[Dict[NodeIDStr, WorkbenchUI]] = None
slideshow: Optional[Dict[NodeIDStr, Slideshow]] = None
current_node_id: Optional[NodeID] = Field(None, alias="currentNodeId")
annotations: Optional[Dict[NodeIDStr, Annotation]] = None

class Config:
extra = Extra.allow
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def create_new_project_for_job(
},
slideshow={},
currentNodeId=solver_id,
annotations={},
),
# FIXME: these should be unnecessary
prjOwner="[email protected]",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,42 @@
"currentNodeId": {
"type": "string",
"format": "uuid"
},
"annotations": {
"type": "object",
"patternProperties": {
"^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?4[0-9a-fA-F]{3}-?[89abAB][0-9a-fA-F]{3}-?[0-9a-fA-F]{12}$": {
"type": "object",
"additionalProperties": false,
"required": [
"type",
"color",
"attributes"
],
"properties": {
"type": {
"type": "string",
"description": "Annotation type",
"examples": [
"rect",
"text"
]
},
"color": {
"type": "string",
"description": "Annotation's color",
"examples": [
"#FF0000",
"#0000FF"
]
},
"attributes": {
"type": "object",
"description": "svg attributes"
}
}
}
}
}
}
},
Expand Down
27 changes: 27 additions & 0 deletions services/storage/src/simcore_service_storage/api/v0/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,33 @@ components:
currentNodeId:
type: string
format: uuid
annotations:
type: object
x-patternProperties:
'^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?4[0-9a-fA-F]{3}-?[89abAB][0-9a-fA-F]{3}-?[0-9a-fA-F]{12}$':
type: object
additionalProperties: false
required:
- type
- color
- attributes
properties:
type:
type: string
description: Annotation type
example:
- rect
- text
color:
type: string
description: Annotation's color
example:
- '#FF0000'
- '#0000FF'
attributes:
type: object
description: svg attributes
additionalProperties: true
tags:
type: array
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,42 @@
"currentNodeId": {
"type": "string",
"format": "uuid"
},
"annotations": {
"type": "object",
"patternProperties": {
"^[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?4[0-9a-fA-F]{3}-?[89abAB][0-9a-fA-F]{3}-?[0-9a-fA-F]{12}$": {
"type": "object",
"additionalProperties": false,
"required": [
"type",
"color",
"attributes"
],
"properties": {
"type": {
"type": "string",
"description": "Annotation type",
"examples": [
"rect",
"text"
]
},
"color": {
"type": "string",
"description": "Annotation's color",
"examples": [
"#FF0000",
"#0000FF"
]
},
"attributes": {
"type": "object",
"description": "svg attributes"
}
}
}
}
}
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/* ************************************************************************
osparc - the simcore frontend
https://osparc.io
Copyright:
2022 IT'IS Foundation, https://itis.swiss
License:
MIT: https://opensource.org/licenses/MIT
Authors:
* Odei Maiz (odeimaiz)
************************************************************************ */

qx.Class.define("osparc.component.editor.AnnotationEditor", {
extend: qx.ui.core.Widget,

construct: function(annotation) {
this.base(arguments);

const layout = new qx.ui.layout.Grid(5, 5);
layout.setColumnAlign(0, "right", "middle");
layout.setColumnAlign(1, "left", "middle");
this._setLayout(layout);

this.set({
padding: 10
});

if (annotation) {
this.setAnnotation(annotation);
}
},

properties: {
annotation: {
check: "osparc.component.workbench.Annotation",
apply: "__applyAnnotation"
}
},

members: {
__applyAnnotation: function(annotation) {
this._removeAll();

let row = 0;
this._add(new qx.ui.basic.Label(this.tr("Color")), {
row,
column: 0
});
const colorPicker = new osparc.component.form.ColorPicker();
annotation.bind("color", colorPicker, "color");
colorPicker.bind("color", annotation, "color");
this._add(colorPicker, {
row,
column: 1
});
row++;

if (annotation.getType() === "text") {
this._add(new qx.ui.basic.Label(this.tr("Text")), {
row,
column: 0
});
const textField = new qx.ui.form.TextField(annotation.getAttributes().text);
textField.addListener("changeValue", e => annotation.setText(e.getData()));
this._add(textField, {
row,
column: 1
});
}
}
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* oSPARC - The SIMCORE frontend - https://osparc.io
* Copyright: 2022 IT'IS Foundation - https://itis.swiss
* License: MIT - https://opensource.org/licenses/MIT
* Authors: Ignacio Pascual (ignapas)
* Odei Maiz (odeimaiz)
*/

qx.Class.define("osparc.component.form.ColorPicker", {
extend: qx.ui.core.Widget,

construct: function() {
this.base(arguments);

this._setLayout(new qx.ui.layout.HBox());

this._add(this.getChildControl("color-button"));
this._add(this.getChildControl("color-input"));
},

properties: {
color: {
check: "Color",
event: "changeColor",
init: "#303030"
}
},

members: {
_createChildControlImpl: function(id) {
let control;
switch (id) {
case "color-button":
control = new qx.ui.form.Button(null, "@FontAwesome5Solid/sync-alt/12");
control.addListener("execute", () => this.setColor(osparc.utils.Utils.getRandomColor()), this);
this.bind("color", control, "backgroundColor");
this.bind("color", control, "textColor", {
converter: value => osparc.utils.Utils.getContrastedTextColor(qx.theme.manager.Color.getInstance().resolve(value))
});
break;
case "color-input":
control = new qx.ui.form.TextField().set({
width: 60,
required: true
});
this.bind("color", control, "value");
control.addListener("changeValue", e => {
const newColor = e.getData();
if (osparc.utils.Validators.hexColor(newColor, control)) {
this.setColor(newColor);
}
});
break;
}
return control || this.base(arguments, id);
}
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ qx.Class.define("osparc.component.widget.Renamer", {

// Create a text field in which to edit the data
const labelEditor = new qx.ui.form.TextField(oldLabel).set({
placeholder: this.tr("Type text"),
allowGrowX: true,
minWidth: labelWidth
});
Expand Down
Loading

0 comments on commit 75e1b77

Please sign in to comment.