This is an automated email from the ASF dual-hosted git repository. marat pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-karavan.git
The following commit(s) were added to refs/heads/main by this push: new 0337a46 Fix #45 (#47) 0337a46 is described below commit 0337a4654282d6abac12f01bbdc7842042d62426 Author: Marat Gubaidullin <marat.gubaidul...@gmail.com> AuthorDate: Wed Oct 27 10:40:14 2021 -0400 Fix #45 (#47) --- karavan-designer/public/components/activemq.json | 1 + karavan-designer/public/components/docker.json | 402 +++++++++++++++++++++ .../public/kamelets/timer-source.kamelet.yaml | 69 ++++ karavan-designer/src/App.tsx | 3 + karavan-designer/src/designer/ui/DslProperties.tsx | 78 +--- 5 files changed, 491 insertions(+), 62 deletions(-) diff --git a/karavan-designer/public/components/activemq.json b/karavan-designer/public/components/activemq.json new file mode 100644 index 0000000..56e28c2 --- /dev/null +++ b/karavan-designer/public/components/activemq.json @@ -0,0 +1 @@ +{"component":{"kind":"component","name":"activemq","title":"ActiveMQ","description":"Send messages to (or consume from) Apache ActiveMQ. This component extends the Camel JMS component.","deprecated":false,"firstVersion":"1.0.0","label":"messaging","javaType":"org.apache.camel.component.activemq.ActiveMQComponent","supportLevel":"Stable","groupId":"org.apache.camel","artifactId":"camel-activemq","version":"3.11.1-SNAPSHOT","scheme":"activemq","extendsScheme":"jms","syntax":"activemq:desti [...] \ No newline at end of file diff --git a/karavan-designer/public/components/docker.json b/karavan-designer/public/components/docker.json new file mode 100644 index 0000000..d099510 --- /dev/null +++ b/karavan-designer/public/components/docker.json @@ -0,0 +1,402 @@ +{ + "component": { + "kind": "component", + "name": "docker", + "title": "Docker", + "description": "Manage Docker containers.", + "deprecated": false, + "firstVersion": "2.15.0", + "label": "cloud,container,paas", + "javaType": "org.apache.camel.component.docker.DockerComponent", + "supportLevel": "Stable", + "groupId": "org.apache.camel", + "artifactId": "camel-docker", + "version": "3.11.1-SNAPSHOT", + "scheme": "docker", + "extendsScheme": "", + "syntax": "docker:operation", + "async": false, + "api": false, + "consumerOnly": false, + "producerOnly": false, + "lenientProperties": true + }, + "properties": { + "operation": { + "kind": "path", + "displayName": "Operation", + "group": "common", + "label": "", + "required": true, + "type": "object", + "javaType": "org.apache.camel.component.docker.DockerOperation", + "enum": [ + "events", + "stats", + "auth", + "info", + "ping", + "version", + "imagebuild", + "imagecreate", + "imageinspect", + "imagelist", + "imagepull", + "imagepushimageremove", + "imagesearch", + "imagetag", + "containerattach", + "containercommit", + "containercopyfile", + "containercreate", + "containerdiffinspectcontainer", + "containerkill", + "containerlist", + "containerlog", + "containerpause", + "containerrestart", + "containerremove", + "containerstartcontainerstop", + "containertop", + "containerunpause", + "containerwait", + "execcreate", + "execstart" + ], + "deprecated": false, + "deprecationNote": "", + "autowired": false, + "secret": false, + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Which operation to use" + }, + "email": { + "kind": "parameter", + "displayName": "Email", + "group": "common", + "label": "", + "required": false, + "type": "string", + "javaType": "java.lang.String", + "deprecated": false, + "autowired": false, + "secret": false, + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Email address associated with the user" + }, + "host": { + "kind": "parameter", + "displayName": "Host", + "group": "common", + "label": "", + "required": true, + "type": "string", + "javaType": "java.lang.String", + "deprecated": false, + "deprecationNote": "", + "autowired": false, + "secret": false, + "defaultValue": "localhost", + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Docker host" + }, + "port": { + "kind": "parameter", + "displayName": "Port", + "group": "common", + "label": "", + "required": false, + "type": "integer", + "javaType": "java.lang.Integer", + "deprecated": false, + "autowired": false, + "secret": false, + "defaultValue": "2375", + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Docker port" + }, + "requestTimeout": { + "kind": "parameter", + "displayName": "Request Timeout", + "group": "common", + "label": "", + "required": false, + "type": "integer", + "javaType": "java.lang.Integer", + "deprecated": false, + "autowired": false, + "secret": false, + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Request timeout for response (in seconds)" + }, + "bridgeErrorHandler": { + "kind": "parameter", + "displayName": "Bridge Error Handler", + "group": "consumer", + "label": "consumer", + "required": false, + "type": "boolean", + "javaType": "boolean", + "deprecated": false, + "autowired": false, + "secret": false, + "defaultValue": false, + "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored." + }, + "exceptionHandler": { + "kind": "parameter", + "displayName": "Exception Handler", + "group": "consumer (advanced)", + "label": "consumer,advanced", + "required": false, + "type": "object", + "javaType": "org.apache.camel.spi.ExceptionHandler", + "optionalPrefix": "consumer.", + "deprecated": false, + "autowired": false, + "secret": false, + "description": "To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this option is not in use. By default the consumer will deal with exceptions, that will be logged at WARN or ERROR level and ignored." + }, + "exchangePattern": { + "kind": "parameter", + "displayName": "Exchange Pattern", + "group": "consumer (advanced)", + "label": "consumer,advanced", + "required": false, + "type": "object", + "javaType": "org.apache.camel.ExchangePattern", + "enum": [ + "InOnly", + "InOut", + "InOptionalOut" + ], + "deprecated": false, + "autowired": false, + "secret": false, + "description": "Sets the exchange pattern when the consumer creates an exchange." + }, + "lazyStartProducer": { + "kind": "parameter", + "displayName": "Lazy Start Producer", + "group": "producer", + "label": "producer", + "required": false, + "type": "boolean", + "javaType": "boolean", + "deprecated": false, + "autowired": false, + "secret": false, + "defaultValue": false, + "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and starting the [...] + }, + "cmdExecFactory": { + "kind": "parameter", + "displayName": "Cmd Exec Factory", + "group": "advanced", + "label": "advanced", + "required": false, + "type": "string", + "javaType": "java.lang.String", + "deprecated": false, + "autowired": false, + "secret": false, + "defaultValue": "com.github.dockerjava.netty.NettyDockerCmdExecFactory", + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "The fully qualified class name of the DockerCmdExecFactory implementation to use" + }, + "followRedirectFilter": { + "kind": "parameter", + "displayName": "Follow Redirect Filter", + "group": "advanced", + "label": "advanced", + "required": false, + "type": "boolean", + "javaType": "boolean", + "deprecated": false, + "autowired": false, + "secret": false, + "defaultValue": false, + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Whether to follow redirect filter" + }, + "loggingFilter": { + "kind": "parameter", + "displayName": "Logging Filter", + "group": "advanced", + "label": "advanced", + "required": false, + "type": "boolean", + "javaType": "boolean", + "deprecated": false, + "autowired": false, + "secret": false, + "defaultValue": false, + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Whether to use logging filter" + }, + "maxPerRouteConnections": { + "kind": "parameter", + "displayName": "Max Per Route Connections", + "group": "advanced", + "label": "advanced", + "required": false, + "type": "integer", + "javaType": "java.lang.Integer", + "deprecated": false, + "autowired": false, + "secret": false, + "defaultValue": "100", + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Maximum route connections" + }, + "maxTotalConnections": { + "kind": "parameter", + "displayName": "Max Total Connections", + "group": "advanced", + "label": "advanced", + "required": false, + "type": "integer", + "javaType": "java.lang.Integer", + "deprecated": false, + "autowired": false, + "secret": false, + "defaultValue": "100", + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Maximum total connections" + }, + "parameters": { + "kind": "parameter", + "displayName": "Parameters", + "group": "advanced", + "label": "advanced", + "required": false, + "type": "object", + "javaType": "java.util.Map<java.lang.String, java.lang.Object>", + "deprecated": false, + "autowired": false, + "secret": false, + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Additional configuration parameters as key/value pairs" + }, + "serverAddress": { + "kind": "parameter", + "displayName": "Server Address", + "group": "advanced", + "label": "advanced", + "required": false, + "type": "string", + "javaType": "java.lang.String", + "deprecated": false, + "autowired": false, + "secret": false, + "defaultValue": "https://index.docker.io/v1/", + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Server address for docker registry." + }, + "socket": { + "kind": "parameter", + "displayName": "Socket", + "group": "advanced", + "label": "advanced", + "required": false, + "type": "boolean", + "javaType": "boolean", + "deprecated": false, + "autowired": false, + "secret": false, + "defaultValue": true, + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Socket connection mode" + }, + "certPath": { + "kind": "parameter", + "displayName": "Cert Path", + "group": "security", + "label": "security", + "required": false, + "type": "string", + "javaType": "java.lang.String", + "deprecated": false, + "autowired": false, + "secret": false, + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Location containing the SSL certificate chain" + }, + "password": { + "kind": "parameter", + "displayName": "Password", + "group": "security", + "label": "security", + "required": false, + "type": "string", + "javaType": "java.lang.String", + "deprecated": false, + "autowired": false, + "secret": true, + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Password to authenticate with" + }, + "secure": { + "kind": "parameter", + "displayName": "Secure", + "group": "security", + "label": "security", + "required": false, + "type": "boolean", + "javaType": "boolean", + "deprecated": false, + "autowired": false, + "secret": false, + "defaultValue": false, + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Use HTTPS communication" + }, + "tlsVerify": { + "kind": "parameter", + "displayName": "Tls Verify", + "group": "security", + "label": "security", + "required": false, + "type": "boolean", + "javaType": "boolean", + "deprecated": false, + "autowired": false, + "secret": false, + "defaultValue": false, + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "Check TLS" + }, + "username": { + "kind": "parameter", + "displayName": "Username", + "group": "security", + "label": "security", + "required": false, + "type": "string", + "javaType": "java.lang.String", + "deprecated": false, + "autowired": false, + "secret": true, + "configurationClass": "org.apache.camel.component.docker.DockerConfiguration", + "configurationField": "configuration", + "description": "User name to authenticate with" + } + } +} \ No newline at end of file diff --git a/karavan-designer/public/kamelets/timer-source.kamelet.yaml b/karavan-designer/public/kamelets/timer-source.kamelet.yaml new file mode 100644 index 0000000..ff37896 --- /dev/null +++ b/karavan-designer/public/kamelets/timer-source.kamelet.yaml @@ -0,0 +1,69 @@ +# --------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# --------------------------------------------------------------------------- + +apiVersion: camel.apache.org/v1alpha1 +kind: Kamelet +metadata: + name: timer-source + annotations: + camel.apache.org/kamelet.support.level: "Preview" + camel.apache.org/catalog.version: "0.4.0" + camel.apache.org/kamelet.icon: data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gU3ZnIFZlY3RvciBJY29ucyA6IGh0dHA6Ly93d3cub25saW5ld2ViZm9udHMuY29tL2ljb24gLS0+DQo8IURPQ1RZUEUgc3ZnIFBVQkxJQyAiLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4iICJodHRwOi8vd3d3LnczLm9yZy9HcmFwaGljcy9TVkcvMS4xL0RURC9zdmcxMS5kdGQiPg0KPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4IiB2aWV3Qm9 [...] + camel.apache.org/provider: "Apache Software Foundation" + camel.apache.org/kamelet.group: "Timer" + labels: + camel.apache.org/kamelet.type: source + camel.apache.org/kamelet.verified: "true" +spec: + definition: + title: Timer Source + description: Produces periodic events with a custom payload. + required: + - message + type: object + properties: + period: + title: Period + description: The interval between two events in milliseconds + type: integer + default: 1000 + message: + title: Message + description: The message to generate + type: string + example: hello world + contentType: + title: Content Type + description: The content type of the message being generated + type: string + default: text/plain + dependencies: + - "camel:core" + - "camel:timer" + - "camel:kamelet" + flow: + from: + uri: timer:tick + parameters: + period: "{{period}}" + steps: + - set-body: + constant: "{{message}}" + - set-header: + name: "Content-Type" + constant: "{{contentType}}" + - to: kamelet:sink diff --git a/karavan-designer/src/App.tsx b/karavan-designer/src/App.tsx index 5d1bb93..ac076f0 100644 --- a/karavan-designer/src/App.tsx +++ b/karavan-designer/src/App.tsx @@ -43,6 +43,7 @@ class App extends React.Component<Props, State> { componentDidMount() { ["http-secured-sink.kamelet.yaml", + "timer-source.kamelet.yaml", "http-secured-source.kamelet.yaml", "http-sink.kamelet.yaml", "http-source.kamelet.yaml", @@ -58,6 +59,8 @@ class App extends React.Component<Props, State> { ["bonita.json", + "activemq.json", + "docker.json", "netty-http.json", "jms.json", "sql.json", diff --git a/karavan-designer/src/designer/ui/DslProperties.tsx b/karavan-designer/src/designer/ui/DslProperties.tsx index 2c5600f..82883a6 100644 --- a/karavan-designer/src/designer/ui/DslProperties.tsx +++ b/karavan-designer/src/designer/ui/DslProperties.tsx @@ -95,7 +95,7 @@ export class DslProperties extends React.Component<Props, State> { e.language = language; e[language] = value; const exp: any = new Expression(e); - if (this.state.element?.dslName === 'when'){ + if (this.state.element?.dslName === 'when') { (clone as any).expression = exp; } else { (clone as any)[this.state.element?.dslName].expression = exp; @@ -106,8 +106,9 @@ export class DslProperties extends React.Component<Props, State> { } parametersChanged = (parameter: string, value: string | number | boolean | any, pathParameter?: boolean) => { + console.log(value) if (this.state.step && this.state.element) { - if (pathParameter){ + if (pathParameter) { const uri = ComponentApi.buildComponentUri((this.state.element as any).uri, parameter, value); this.propertyChanged("uri", uri); } else { @@ -119,7 +120,6 @@ export class DslProperties extends React.Component<Props, State> { this.props.onPropertyUpdate?.call(this, clone, this.state.step.uuid); } } - }; componentDidUpdate = (prevProps: Readonly<Props>, prevState: Readonly<State>, snapshot?: any) => { @@ -198,12 +198,12 @@ export class DslProperties extends React.Component<Props, State> { </button> </Popover> }> - {property.type === 'string' && <TextInput + {['string', 'integer', 'int', 'number'].includes(property.type) && <TextInput className="text-field" isRequired - type={property.format === 'password' ? "password" : "text"} + type={['integer', 'int', 'number'].includes(property.type) ? 'number' : ( property.format ? "password" : "text")} id={id} name={id} - value={value?.toString()} - onChange={e => this.parametersChanged(property.id, e)}/> + value={value} + onChange={e => this.parametersChanged(property.id, ['integer', 'int', 'number'].includes(property.type) ? Number(e) : e)}/> } {property.type === 'boolean' && <Switch id={id} name={id} @@ -212,22 +212,6 @@ export class DslProperties extends React.Component<Props, State> { isChecked={Boolean(value) === true} onChange={e => this.parametersChanged(property.id, !Boolean(value))}/> } - {['integer', 'int', 'number'].includes(property.type) && <div className="number"> - <NumberInput - className="number-property" - id={id} name={id} - value={typeof value === 'number' ? value : undefined} - inputName={id} - onMinus={() => this.parametersChanged(property.id, typeof value === 'number' ? value - 1 : -1)} - onPlus={() => this.parametersChanged(property.id, typeof value === 'number' ? value + 1 : 1)} - onChange={(e: any) => this.parametersChanged(property.id, Number(e.target.value))}/> - <Button - className="clear-button" - variant="tertiary" - isSmall icon={<UndoIcon/>} - onClick={e => this.parametersChanged(property.id, undefined)}/> - </div> - } </FormGroup> ) } @@ -259,12 +243,13 @@ export class DslProperties extends React.Component<Props, State> { </button> </Popover> }> - {['string', 'duration'].includes(property.type) && property.enum === undefined && <TextInput + {['string', 'duration', 'integer', 'int', 'number'].includes(property.type) && property.enum === undefined && + <TextInput className="text-field" isRequired - type={property.secret ? "password" : "text"} + type={['integer', 'int', 'number'].includes(property.type) ? 'number' : ( property.secret ? "password" : "text")} id={id} name={id} - value={value?.toString()} - onChange={e => this.parametersChanged(property.name, e, property.kind === 'path')}/> + value={value} + onChange={e => this.parametersChanged(property.name, ['integer', 'int', 'number'].includes(property.type) ? Number(e) : e, property.kind === 'path')}/> } {property.type === 'string' && property.enum && <Select variant={SelectVariant.single} @@ -288,22 +273,6 @@ export class DslProperties extends React.Component<Props, State> { isChecked={Boolean(value) === true} onChange={e => this.parametersChanged(property.name, !Boolean(value))}/> } - {['integer', 'int', 'number'].includes(property.type) && <div className="number"> - <NumberInput - className="number-property" - id={id} name={id} - value={value !== undefined ? (typeof value === 'number' ? value : Number(value)) : property.defaultValue} - inputName={id} - onMinus={() => this.parametersChanged(property.name, typeof value === 'number' ? value - 1 : Number(value) -1, property.kind === 'path')} - onPlus={() => this.parametersChanged(property.name, typeof value === 'number' ? value + 1 : Number(value) + 1, property.kind === 'path')} - onChange={(e: any) => this.parametersChanged(property.name, Number(e.target.value), property.kind === 'path')}/> - <Button - className="clear-button" - variant="tertiary" - isSmall icon={<UndoIcon/>} - onClick={e => this.parametersChanged(property.name, undefined,property.kind === 'path')}/> - </div> - } </FormGroup> ) } @@ -394,13 +363,14 @@ export class DslProperties extends React.Component<Props, State> { </button> </Popover> : <div></div> }> - {['string', 'duration'].includes(property.type) && !property.enumVals && <TextInput + {['string', 'duration', 'integer', 'number'].includes(property.type) && !property.enumVals && + <TextInput isReadOnly={property.name === 'uri'} className="text-field" isRequired - type={property.secret ? "password" : "text"} + type={['integer', 'number'].includes(property.type)? 'number' : (property.secret ? "password" : "text")} id={property.name} name={property.name} value={value?.toString()} - onChange={e => this.propertyChanged(property.name, e)}/> + onChange={e => this.propertyChanged(property.name, ['integer', 'number'].includes(property.type) ? Number(e) : e)}/> } {property.type === 'boolean' && <Switch id={property.name} name={property.name} @@ -426,22 +396,6 @@ export class DslProperties extends React.Component<Props, State> { {selectOptions} </Select> } - {property.type === 'integer' && <div className="number"> - <NumberInput - className="number-property" - id={property.name} name={property.name} - value={typeof value === 'number' ? value : undefined} - inputName={property.name} - onMinus={() => this.propertyChanged(property.name, typeof value === 'number' ? value - 1 : -1)} - onPlus={() => this.propertyChanged(property.name, typeof value === 'number' ? value + 1 : 1)} - onChange={(e: any) => this.propertyChanged(property.name, Number(e.target.value))}/> - <Button - className="clear-button" - variant="tertiary" - isSmall icon={<UndoIcon/>} - onClick={e => this.propertyChanged(property.name, undefined)}/> - </div> - } <div className="expression"> {property.name === 'expression' && property.type === "Expression" && this.createExpressionProperty(property)}