Skip to content

Commit

Permalink
OP-159-API-Payment-widget
Browse files Browse the repository at this point in the history
  • Loading branch information
vadim-siamro committed Aug 3, 2018
1 parent 3ee38df commit 2d778fd
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .gitlab-ci.yml
Expand Up @@ -237,6 +237,7 @@ certificates-development:
DEPLOY_HOST: $DEPLOY_HOST_DEV
DEPLOY_KEY: $DEPLOY_KEY_DEV
SERVER_NAME: "api.open-platform.zensoft.io"
WIDGET_HOST: "https://api.open-platform.zensoft.io"
before_script: *prepare_key
script: *update_certificates
only:
Expand All @@ -250,6 +251,7 @@ certificates-production:
DEPLOY_HOST: $DEPLOY_HOST_PROD
DEPLOY_KEY: $DEPLOY_KEY_PROD
SERVER_NAME: "api.openfuture.io"
WIDGET_HOST: "https://api.openfuture.io"
before_script: *prepare_key
script: *update_certificates
only:
Expand Down
@@ -0,0 +1,13 @@
package io.openfuture.api.config.propety

import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.stereotype.Component
import org.springframework.validation.annotation.Validated
import javax.validation.constraints.NotBlank

@ConfigurationProperties(prefix = "widget")
@Validated
@Component
class WidgetProperties(
@field:NotBlank var host: String? = null
)
@@ -1,6 +1,7 @@
package io.openfuture.api.controller.base

import io.openfuture.api.config.propety.AuthorizationProperties
import io.openfuture.api.config.propety.WidgetProperties
import org.springframework.stereotype.Controller
import org.springframework.ui.ModelMap
import org.springframework.web.bind.annotation.GetMapping
Expand All @@ -10,7 +11,8 @@ import javax.servlet.http.HttpServletResponse

@Controller
class MainController(
private val properties: AuthorizationProperties
private val properties: AuthorizationProperties,
private val widgetProperties: WidgetProperties
) {

@GetMapping("/logout")
Expand All @@ -26,6 +28,7 @@ class MainController(
@GetMapping("/widget/{address}")
fun widget(@PathVariable address: String, model: ModelMap): String {
model["address"] = address
model["host"] = widgetProperties.host
return "widget"
}

Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/application.properties
Expand Up @@ -18,4 +18,7 @@ ethereum.open-token-address=${OPEN_TOKEN_ADDRESS}
ethereum.event-subscription=${EVENT_SUBSCRIPTION}

# AUTH
auth.cookie-name=open_key
auth.cookie-name=open_key

# WIDGET
widget.host=${WIDGET_HOST}
4 changes: 2 additions & 2 deletions widget/build/index.html
Expand Up @@ -7,7 +7,7 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title></title>
</head>
<body data-address="${address}">
<script src="https://api.openfuture.io/js/open-widget.js"></script>
<body data-address="${address}" data-host="${host}">
<script src="${host}/static/js/open-widget.js"></script>
</body>
</html>
6 changes: 3 additions & 3 deletions widget/src/index.js
@@ -1,7 +1,6 @@
import * as internalWeb3 from 'web3';
import * as style from './style.css';

const _web3 = new internalWeb3(internalWeb3.givenProvider || 'http://localhost:8545');
const _web3 = new internalWeb3(internalWeb3.givenProvider);
let windgetData;
let userInputData = [];
let currentNetwork;
Expand Down Expand Up @@ -107,7 +106,8 @@ function validateForm(){

async function openWidget(){
const scaffoldAddress = await document.body.dataset.address;
const OPEN_URL = `https://api.openfuture.io/widget/scaffolds/${scaffoldAddress}`;
const host = await document.body.dataset.host;
const OPEN_URL = `${host}/widget/scaffolds/${scaffoldAddress}`;
windgetData = await getContractData(OPEN_URL);

let widgetEl = document.createElement('div');
Expand Down
2 changes: 1 addition & 1 deletion widget/webpack.config.js
Expand Up @@ -7,7 +7,7 @@ module.exports = {
entry: './src/index.js',
output: {
filename: 'open-widget.js',
path: path.resolve(`${__dirname}`, 'build/js')
path: path.resolve(`${__dirname}`, 'build/static/js')
},
performance: {
maxEntrypointSize: 512000,
Expand Down

0 comments on commit 2d778fd

Please sign in to comment.