Skip to content

Commit

Permalink
using the uppercase service + button to change title in uppercase
Browse files Browse the repository at this point in the history
  • Loading branch information
sunix committed Nov 24, 2020
1 parent 032f4c4 commit 24049a6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
14 changes: 14 additions & 0 deletions devfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ projects:

components:

- type: dockerimage
image: sebi2706/uppercase-sg-service
memoryLimit: 32M
env:
- value: '8082'
name: QUARKUS_HTTP_PORT
endpoints:
- name: uppercase-sg-service
port: 8082
attributes:
path: /touppercase?p=uppercase%20service



- alias: quarkus-backend-dev
type: dockerimage
image: quay.io/quarkus/centos-quarkus-maven:20.1.0-java11
Expand Down
16 changes: 15 additions & 1 deletion node-frontend/src/components/Post.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Post extends React.Component {
timestamp: this.props.timestamp,
}
this.deletePost = this.deletePost.bind(this);
this.toUppercase = this.toUppercase.bind(this);
}

render() {
Expand All @@ -38,7 +39,10 @@ class Post extends React.Component {
<Col className="delete-post-button" sm={1}>
<Button variant="danger" type="submit" onClick={this.deletePost}>
Delete
</Button>
</Button>
<Button variant="primary" onClick={this.toUppercase}>
toUppercase
</Button>
</Col>
</Row>
</Container>
Expand All @@ -63,6 +67,16 @@ class Post extends React.Component {
window.location.reload();
}

toUppercase() {
fetch(`touppercase?p=${encodeURI(this.state.title)}`, {
method: 'GET'
})
.then(response => response.text())
.then(data => {
this.state.title = data;
this.setState(this.state);
})
}
}

export default Post
19 changes: 19 additions & 0 deletions node-frontend/src/setupProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,24 @@ module.exports = function (app) {
})
);


var uppercase_quarkus_host = 'localhost';
var uppercase_quarkus_port = '8082';

if (process.env.COMPONENT_QUARKUS_UPPERCASE_HOST) {
uppercase_quarkus_host = process.env.COMPONENT_QUARKUS_UPPERCASE_HOST;
}

if (process.env.COMPONENT_QUARKUS_UPPERCASE_PORT) {
uppercase_quarkus_port = process.env.COMPONENT_QUARKUS_UPPERCASE_PORT;
}

app.use(
'/touppercase',
createProxyMiddleware({
target: `http://${uppercase_quarkus_host}:${uppercase_quarkus_port}`,
changeOrigin: true
})
);
};

0 comments on commit 24049a6

Please sign in to comment.