Skip to content

Commit

Permalink
Merge pull request #581 from WycliffeAssociates/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
mXaln authored Oct 30, 2019
2 parents 109c355 + 1a06f64 commit 54f4f20
Show file tree
Hide file tree
Showing 19 changed files with 307 additions and 57 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# translationExchange
Manage and review development project. Started by the 8WoC 2017 internship team and continued by Wycliffe Associates.

Translation Exchange is a system for oral translators and narrators to securely store their audio files and to invite community checking and review. Translation Exchange is designed for the realities of the developing world: It works 100% off-line via local wifi network and can be run on low-power, low-cost computing devices such as Raspberry Pi. It maintains the same design philosophy as Translation Recorder: simple use, minimal text interface, and attention to audio quality.
BTT Exchanger is a system for oral translators and narrators to securely store their audio files and to invite community checking and review. BTT Exchanger is designed for the realities of the developing world: It works 100% off-line via local wifi network and can be run on low-power, low-cost computing devices such as Raspberry Pi. It maintains the same design philosophy as Translation Recorder: simple use, minimal text interface, and attention to audio quality.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "translationexchange",
"author": "mxaln",
"version": "1.1.7",
"description": "Translation Exchange",
"name": "bttexchanger",
"author": "WA",
"version": "1.1.8",
"description": "BTT Exchanger",
"private": true,
"homepage": ".",
"main": "src/start.js",
Expand Down Expand Up @@ -76,7 +76,7 @@
"redux-logger": "~3.0.6",
"redux-mock-store": "~1.3.0",
"redux-thunk": "~2.2.0",
"semantic-ui-css": "~2.2.11",
"semantic-ui-css-offline": "~1.0.1-2.3.2",
"semantic-ui-react": "~0.71.0",
"spark-md5": "~3.0.0",
"styled-components": "~3.2.1",
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>Translation eXchange</title>
<title>BTT Exchanger</title>
</head>
<body>

Expand Down
4 changes: 2 additions & 2 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sonar.projectKey=translationexchange
sonar.projectName=Translation Exchange
sonar.projectKey=bttexchanger
sonar.projectName=BTT Exchanger
sonar.projectVersion=1.0
sonar.sources=src
sonar.exclusions=src/js/*.js src/css src/config src/assets src/fonts src/languages src/views src/*.js src/*.css
Expand Down
16 changes: 10 additions & 6 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {ToastContainer} from 'react-toastify';
import NotFound from './js/pages/NotFound';
import axios from 'axios';
import Welcome from './js/pages/Login/LoginPage.js';
import Download from './js/pages/Download/DownloadPage.js';
import DownloadPage from './js/pages/Download/DownloadPage.js';
import SettingsPage from './js/pages/Settings/SettingsPage.js';
import AvailableUsers from './js/pages/Login/AvailableUsers.js';
import ErrorPage from './js/pages/ErrorPage/ErrorPage';
import CreateUserContainer from './js/pages/user/components/CreateUserContainer';
Expand All @@ -23,7 +24,11 @@ import config from './config/config';

// import and configure the raven client for sentry in order to track errors
import Raven from 'raven-js';
Raven.config(`http://9183fe1745da4049889061d44d154a4b@${config.domain}:9000/3`).install();
try {
Raven.config(`http://9183fe1745da4049889061d44d154a4b@${config.domain}:9000/3`).install();
} catch(error) {
console.log("Raven is not configured!");
}


class App extends Component {
Expand All @@ -33,7 +38,7 @@ class App extends Component {
//configuration for web requests
axios.defaults.timeout = 120000;

this.state ={
this.state = {
hasError: false,
};
}
Expand All @@ -43,8 +48,6 @@ class App extends Component {
Raven.captureException(error, {extra: info}); //send error to raven client
}



render() {
return (
/*
Expand All @@ -61,7 +64,8 @@ class App extends Component {
<Route exact path = "/users" component={AvailableUsers} />
<Route exact path = "/users/registration" component={CreateUserContainer} />
<Route path = "/welcome" component={Welcome} />
<Route path = "/download" component={Download} />
<Route path = "/download" component={DownloadPage} />
<Route path = "/settings" component={SettingsPage} />
<Route path = "/projects" component={ProjectsPage} />
<Route path = "/chapters" component={ChapterPage} />
<Route path = "/progress" component={TaskProgressPage} />
Expand Down
7 changes: 6 additions & 1 deletion src/__test__/unit_tests/pages/Login/LoginPage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {Welcome} from '../../../../js/pages/Login/LoginPage';
import {shallow} from 'enzyme';

const mockProps = {
history: [],
txt: {
loading: false,
availableUsers: 'availableUsers',
Expand All @@ -18,12 +19,16 @@ describe('LoginPage test suite', () => {
expect(wrapper.find('LoginPage').length).toBe(1);
expect(wrapper.find('Language').length).toBe(1);
expect(wrapper.find('LanguageContainer').length).toBe(1);

expect(wrapper.find('SettingsButton').length).toBe(1);
});

test('on Select function', () => {
wrapper.instance().onSelect('language');
expect(mockProps.updateLanguage.mock.calls.length).toEqual(1);
});

it('should navigate to settings', () => {
wrapper.instance().onSettingsClick();
expect(wrapper.instance().props.history.length).toEqual(1);
});
});
31 changes: 31 additions & 0 deletions src/__test__/unit_tests/pages/Settings/SettingsPage.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* global it describe expect jest*/
import React from 'react';
import {shallow} from 'enzyme';
import {SettingsPage} from '../../../../js/pages/Settings/SettingsPage';

const mockProps = {
txt: {
serverName: 'Server name',
settings: 'settings',
goBack: 'go back',
},
onServerNameChange: jest.fn(),
};

describe('Settings Page test suite', () => {

const wrapper = shallow(<SettingsPage {...mockProps} />);

it('should render the component correctly', () => {
expect(wrapper.find('Container').length).toBe(1);
expect(wrapper.find('BackLink').length).toBe(1);
expect(wrapper.find('Header').length).toBe(1);
expect(wrapper.find('SettingsContainer').length).toBe(1);
expect(wrapper.find('ButtonsContainer').length).toBe(1);
expect(wrapper.find('SettingsItem').length).toBeGreaterThan(0);
expect(wrapper.find('SettingsTitle').length).toBeGreaterThan(0);
expect(wrapper.find('SettingsValue').length).toBeGreaterThan(0);
expect(wrapper.find('SettingsInput').length).toBeGreaterThan(0);
});

});
29 changes: 6 additions & 23 deletions src/config/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,13 @@
Then you can access the settings as "config.apiUrl", "config.streamingUrl", etc
*/

// var config = {
// apiUrl: "http://172.19.145.91/api/",
// streamingUrl: "http://172.19.145.91/"
// };
//
// var config = {
// apiUrl: "http://127.0.0.1:8000/api/",
// streamingUrl: "http://127.0.0.1/"
// };
const uploadServer = localStorage.getItem("uploadServer") || "opentranslationtools.org";




// const config = { // local development
// apiUrl: 'http://localhost/api/',
// streamingUrl: 'http://localhost/',
// redirectUri: 'http://localhost:3000',
// };

const config = { //production
apiUrl: 'http://opentranslationtools.org/api/',
streamingUrl: 'http://opentranslationtools.org/',
redirectUri: 'http://opentranslationtools.org/',
domain: 'opentranslationtools.org'
const config = {
apiUrl: 'http://' + uploadServer + '/api/',
streamingUrl: 'http://' + uploadServer + '/',
redirectUri: 'http://' + uploadServer + '/',
domain: '' + uploadServer + ''
};

export default config;
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ReactDOM from 'react-dom';
import { HashRouter } from 'react-router-dom';

import App from './App';
import 'semantic-ui-css/semantic.min.css';
import 'semantic-ui-css-offline/semantic.min.css';
import './index.css';
import { Provider } from 'react-redux';
import store from './js/store';
Expand Down
3 changes: 2 additions & 1 deletion src/js/actions/ProjectsPageActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@ export const fetchAllProjects = (query, redirect) => {
dispatch(dispatchAllProjectsFailed(err));
localStorage.removeItem('token');

if(err.response.status == 401) {
if(err.response != undefined && err.response.status == 401) {
redirect.push('/welcome');
} else {
console.log("ERROR: ", config.apiUrl, query);
redirect.push('/errorPage');
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/js/actions/UserActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ return (dispatch) => {
dispatch(fetchUserSuccess(response.data));
})
.catch(error => {
console.log(error); //TODO handle error
console.log("ERROR: ", config.apiUrl); //TODO handle error
redirect.push('./ErrorPage');
});
};
Expand Down
6 changes: 5 additions & 1 deletion src/js/components/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class NavBar extends Component {
if (key === '2') {
this.props.history.push('./download');
}
if (key === '3') {
this.props.history.push('./settings');
}
}

onSelect({key, item}) {
Expand Down Expand Up @@ -91,6 +94,7 @@ class NavBar extends Component {
<MenuItem style={{cursor: 'pointer', color: '#fff', backgroundColor: '#000' }} key={0}>{txt.logOut}</MenuItem>
<MenuItem style={{cursor: 'pointer', color: '#fff', backgroundColor: '#000' }} key={1}>{txt.progressPage}</MenuItem>
<MenuItem style={{cursor: 'pointer', color: '#fff', backgroundColor: '#000' }} key={2}>{txt.downloadClients}</MenuItem>
<MenuItem style={{cursor: 'pointer', color: '#fff', backgroundColor: '#000' }} key={3}>{txt.settings}</MenuItem>
</Menu>
);

Expand Down Expand Up @@ -139,7 +143,7 @@ class NavBar extends Component {
return (
<Container>
<TextContainer>
<Title>Translation Exchange </Title>
<Title>BTT Exchanger</Title>
</TextContainer>

<IconsContainer>
Expand Down
25 changes: 21 additions & 4 deletions src/js/pages/Login/AvailableUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class AvailableUsers extends React.Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
this.sortedUsers = this.sortedUsers.bind(this);
}

handleClick(clickSrc) {
Expand All @@ -30,12 +31,28 @@ export class AvailableUsers extends React.Component {
if (language) {
updateLanguage(language);
}
}

sortedUsers() {
const {users} = this.props;

users.forEach((element) => {
element["timestamp"] = localStorage.getItem("login:" + element.icon_hash);
});

users.sort((a, b) => {
if(a.timestamp == null) return 1;
if(b.timestamp == null) return -1;

return b.timestamp - a.timestamp;
});

return users;
}

render() {

const {users, txt} = this.props;
const {txt} = this.props;

return (
<Container className="pageBackground">
Expand All @@ -60,13 +77,13 @@ export class AvailableUsers extends React.Component {
</Grid.Column >

{
users.length>0? users.map((user,index) => {
this.sortedUsers().length > 0? this.sortedUsers().map((user,index) => {
return (
user.is_social? '' :
<Grid.Column width={3} key={user.id}>
<UserCard id={index} user={user} {...this.props} />
<UserCard id={index} user={user} {...this.props} />
</Grid.Column>
);}) : ''
);}) : ''

}
</Grid>
Expand Down
26 changes: 24 additions & 2 deletions src/js/pages/Login/LoginPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,35 @@ export class Welcome extends React.Component {
}

onSelect({key}) {
const language =key;
const language = key;
this.props.updateLanguage(language);
localStorage.setItem('language', language);
}

onSettingsClick() {
this.props.history.push ({
pathname: '/settings',
});
}


render() {
const menu = (
<Menu onSelect={ ky=> this.onSelect(ky)}>
{Object.keys(Languages).map(lng => <MenuItem style={{cursor: 'pointer', color: '#fff', backgroundColor: '#000' }} key={lng}> {lng} </MenuItem> )}
{Object.keys(Languages).map(lng =>
<MenuItem style={{cursor: 'pointer', color: '#fff', backgroundColor: '#000' }} key={lng}>
{lng}
</MenuItem>
)}
</Menu>
);

return (
<LoginPage className="pageBackground">
<LanguageContainer>
<SettingsButton onClick={this.onSettingsClick.bind(this)}>
{this.props.txt.settings} <i className="material-icons">settings</i>
</SettingsButton>
<Dropdown
trigger={['click']}
overlay={menu}
Expand Down Expand Up @@ -81,6 +93,16 @@ const LanguageContainer = styled.div`
`;
LanguageContainer.displayName = 'LanguageContainer';

const SettingsButton = styled.a`
margin-right: 1vh;
color: white;
cursor: pointer;
:hover {
color: white;
}
`;
SettingsButton.displayName = 'SettingsButton';

const mapDispatchToProps = dispatch => {
return bindActionCreators(
Expand Down
5 changes: 4 additions & 1 deletion src/js/pages/Login/components/UserCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export default class UserCard extends React.Component {
}

identLogin(hash) {
this.props.identiconLogin(hash, ()=>this.props.history.push('/projects'));
this.props.identiconLogin(hash, ()=>{
localStorage.setItem("login:" + hash, Date.now());
this.props.history.push('/projects');
});
}

play() {
Expand Down
2 changes: 1 addition & 1 deletion src/js/pages/Login/components/WelcomeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class WelcomeComponent extends React.Component {

<WelcomePage>

<h2 className="welcomeh2"> translation Exchange </h2>
<h2 className="welcomeh2"> BTT Exchanger </h2>
<Icon src={welcomeImg} />

<ButtonsContainer>
Expand Down
Loading

0 comments on commit 54f4f20

Please sign in to comment.