Skip to content

Commit

Permalink
Feature/implement payee simulator (#119)
Browse files Browse the repository at this point in the history
* Added payeeapp simulator

* Some improvements

* Added payee mobile simulator wrapper and notification style

* Added brand icon to payee sim

* Bumped up the version and postponed audits
  • Loading branch information
vijayg10 committed Sep 9, 2021
1 parent b6fa54f commit 923619a
Show file tree
Hide file tree
Showing 16 changed files with 7,004 additions and 6,315 deletions.
12,630 changes: 6,321 additions & 6,309 deletions audit-resolve.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ services:
environment:
- API_BASE_URL=http://localhost:5050
- AUTH_ENABLED=FALSE
# - PAYEE_SIM_BRAND_ICON=some_image
command:
- sh
- /usr/share/nginx/start.sh
3 changes: 3 additions & 0 deletions nginx/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ fi
if [[ ! -z "${AUTH_ENABLED}" ]]; then
find /usr/share/nginx/html -type f -name "*.*" -exec sed -i -e "s|TTK_AUTH_ENABLED|$AUTH_ENABLED|g" {} \;
fi
if [[ ! -z "${PAYEE_SIM_BRAND_ICON}" ]]; then
find /usr/share/nginx/html -type f -name "*.*" -exec sed -i -e "s|TTK_PAYEE_SIM_BRAND_ICON|$PAYEE_SIM_BRAND_ICON|g" {} \;
fi
nginx -g "daemon off;"
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ml-testing-toolkit-ui",
"version": "13.4.1",
"version": "13.5.0",
"description": "Mojaloop Testing Toolkit Web User Interface",
"main": "index.js",
"repository": {
Expand Down
Binary file added src/assets/img/mobile_plain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import 'antd/dist/antd.css';

import Login from './views/login/Login.jsx';
import MobileSimulator from "./views/demos/MobileSimulator/MobileSimulator.jsx";
import PayeeAppSimulator from "./views/demos/PayeeAppSimulator/PayeeApp";
import PayeeMobileSimulator from "./views/demos/PayeeAppSimulator/PayeeMobile";
import DemoTestRunner from "./views/demos/DemoTestRunner/DemoTestRunner.jsx";


Expand Down Expand Up @@ -98,6 +100,8 @@ function App() {
<Switch>
<Route path="/admin" render={props => <AdminLayout {...props} handleLogout={handleLogout} />} />
<Route exact path='/mobilesimulator' render={props => <MobileSimulator {...props} />} />
<Route exact path='/payeeapp' render={props => <PayeeAppSimulator {...props} />} />
<Route exact path='/payeemobile' render={props => <PayeeMobileSimulator {...props} />} />
<Route exact path='/demotestrunner' render={props => <DemoTestRunner {...props} />} />
<Redirect from='/' to='/admin/index' />
</Switch>
Expand Down
62 changes: 62 additions & 0 deletions src/services/demos/PayeeAppSimulator/payeeNotifications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*****
License
--------------
Copyright © 2017 Bill & Melinda Gates Foundation
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files 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, the Mojaloop files are 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.
Contributors
--------------
This is the official list of the Mojaloop project contributors for this file.
Names of the original copyright holders (individuals or organizations)
should be listed with a '*' in the first column. People who have
contributed from an organization can be listed under the organization
that actually holds the copyright for their contributions (see the
Gates Foundation organization for an example). Those individuals should have
their names indented and be marked with a '-'. Email address can be added
optionally within square brackets <email>.
* Gates Foundation
* ModusBox
* Vijaya Kumar Guthi <vijaya.guthi@modusbox.com> (Original Author)
--------------
******/

import socketIOClient from "socket.io-client";
import { getConfig } from '../../../utils/getConfig'

class NotificationService {

notificationEventFunction = () => {}

setNotificationEventListener (notificationEventFunction) {
this.notificationEventFunction = notificationEventFunction
}

apiBaseUrl = ''
sessionId = ''
socket = null
socketTopic = 'pushMessage'

constructor (sessionId = null) {
const { apiBaseUrl } = getConfig()
this.apiBaseUrl = apiBaseUrl
this.sessionId = sessionId

this.socket = socketIOClient(this.apiBaseUrl)
this.socket.on(this.socketTopic + (this.sessionId ? '/' + this.sessionId : ''), message => {
this.notificationEventFunction(message)
})
}

getSessionId () {
return this.sessionId
}

disconnect () {
this.socket.disconnect()
}

}

export default NotificationService
11 changes: 10 additions & 1 deletion src/utils/getConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,16 @@ export const getConfig = () => {
// const AUTH_ENABLED = 'TRUE'
const isAuthEnabled = AUTH_ENABLED ? AUTH_ENABLED.toUpperCase() === 'TRUE' : false

return { apiBaseUrl, isAuthEnabled }
// Payee Sim Branding
const payeeAppSimulatorBrandConfig = {
icon: 'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAIQAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJDAAABoAAAAChnVFJDAAABoAAAAChiVFJDAAABoAAAACh3dHB0AAAByAAAABRjcHJ0AAAB3AAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAFgAAAAcAHMAUgBHAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF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ig }
}

export const getServerConfig = async () => {
Expand Down
110 changes: 110 additions & 0 deletions src/views/common/ArrayInputValues.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*****
License
--------------
Copyright © 2017 Bill & Melinda Gates Foundation
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files 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, the Mojaloop files are 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.
Contributors
--------------
This is the official list of the Mojaloop project contributors for this file.
Names of the original copyright holders (individuals or organizations)
should be listed with a '*' in the first column. People who have
contributed from an organization can be listed under the organization
that actually holds the copyright for their contributions (see the
Gates Foundation organization for an example). Those individuals should have
their names indented and be marked with a '-'. Email address can be added
optionally within square brackets <email>.
* Gates Foundation
* ModusBox
* Vijaya Kumar Guthi <vijaya.guthi@modusbox.com> (Original Author)
--------------
******/

import React from "react";
import { Input, Row, Col, Button, Card } from 'antd';
import { DeleteTwoTone } from '@ant-design/icons';
import 'antd/dist/antd.css';

class ArrayInputValues extends React.Component {

state = {
values: []
};

componentDidMount = async () => {
if (!this.props.values || !Array.isArray(this.props.values)) {
this.props.onChange([])
} else {
this.setState({values: this.props.values})
}
}

handleDeleteClick = (itemIndex) => {
this.state.values.splice(itemIndex,1)
this.props.onChange(this.state.values)
}

getInputItems = () => {
let inputItems = []
for (let i = 0; i < this.state.values.length; i++) {
inputItems.push(
<Row className='mb-2' key={i}>
<Col span={24}>
<Row gutter={8}>
<Col span={23}>
<Input
value={this.state.values[i]}
onChange={(e) => {
this.state.values[i] = e.target.value
this.props.onChange(this.state.values)
}}
/>
</Col>
<Col span={1}>
<DeleteTwoTone key={i} type="delete" theme="filled"
onClick={() => this.handleDeleteClick(i)}
/>
</Col>
</Row>
</Col>
</Row>
)
}
return inputItems
}

handleAddInputValue = () => {
this.state.values.push('')
this.props.onChange(this.state.values)
}

render() {
return (
<>
<Row gutter={16}>
<Col span={24}>
<Card size='small'>
<Row className='mb-2'>
<Col span={24}>
<Button
className="text-right float-right"
color="primary"
size="sm"
onClick={this.handleAddInputValue}
>
Add
</Button>
</Col>
</Row>
{this.getInputItems()}
</Card>
</Col>
</Row>
</>
)
}
}

export default ArrayInputValues;
14 changes: 14 additions & 0 deletions src/views/demos/Demos.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ class Demos extends React.Component {
</ul>
</Col>
</Row>
<Row className='my-4'>
<Col span={24}>
<ul>
<li>
<a
href="/payeemobile"
target="_blank"
>
Payee App Simulator
</a>
</li>
</ul>
</Col>
</Row>
<Row className='my-4'>
<Col span={24}>
<ul>
Expand Down
59 changes: 59 additions & 0 deletions src/views/demos/PayeeAppSimulator/BrandIcon.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*****
License
--------------
Copyright © 2017 Bill & Melinda Gates Foundation
The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files 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, the Mojaloop files are 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.
Contributors
--------------
This is the official list of the Mojaloop project contributors for this file.
Names of the original copyright holders (individuals or organizations)
should be listed with a '*' in the first column. People who have
contributed from an organization can be listed under the organization
that actually holds the copyright for their contributions (see the
Gates Foundation organization for an example). Those individuals should have
their names indented and be marked with a '-'. Email address can be added
optionally within square brackets <email>.
* Gates Foundation
* ModusBox
* Vijaya Kumar Guthi <vijaya.guthi@modusbox.com> (Original Author)
--------------
******/
import React from "react";
import { Image } from 'antd';
import { getConfig } from '../../../utils/getConfig'


class BrandIcon extends React.Component {

state = {
image: null
}

constructor () {
super()
const { payeeAppSimulatorBrandConfig } = getConfig()
this.state.image = payeeAppSimulatorBrandConfig.icon
}

render() {
return (
<>
{
this.state.image
? (
<Image
width={this.props.width || '150px'}
src={this.state.image}
/>
)
: null
}
</>
);
}
}

export default BrandIcon
Loading

0 comments on commit 923619a

Please sign in to comment.