Commit cc6101aa authored by Matúš Žiak's avatar Matúš Žiak
Browse files

Mobile app - backend integration

parent ee1e38f3
......@@ -2,9 +2,10 @@ import React from "react";
import { Platform, StatusBar, StyleSheet, View } from "react-native";
import { AppLoading, Asset, Font, Icon } from "expo";
import AppNavigator from "./navigation/AppNavigator";
import { NOTIFICATIONS } from "./constants/Data";
// import { NOTIFICATIONS } from "./constants/Data";
import { API_URL } from "./constants/Api";
const API_CALL_TIMEOUT = 60000;
const API_CALL_TIMEOUT = 6000;
export default class App extends React.Component {
state = {
......@@ -24,20 +25,19 @@ export default class App extends React.Component {
}
getNotifications = () => {
// const notifications treba nahradit za fetch a setState spustit iba v pripade ze sa data zmenia
// pretoze by default to re-renderuje celu aplikaciu
if (this.state.notifications.length === 0) {
return this.setState({ notifications: NOTIFICATIONS });
}
// toto je len generator statickych novych notifikacii,, mozes zmazat ked bude fetch
let nextItem = NOTIFICATIONS[this.state.notifications.length - 4];
if (!nextItem) {
nextItem = NOTIFICATIONS[0];
}
// if (this.state.notifications.length === 0) {
const notifications = [...this.state.notifications, nextItem];
this.setState({ notifications });
fetch(API_URL + "robbery-event/all/10")
.then(response => response.json())
.then(data => {
return this.setState({ notifications: data });
})
.catch(error => {
console.log("Api call error" + error);
return () => {};
});
// }
};
render() {
......
......@@ -5,14 +5,19 @@ import MapView, { Marker } from "react-native-maps";
class BranchesMap extends PureComponent {
get markerLocation() {
const { branch } = this.props;
return { latitude: branch.lat, longitude: branch.long };
return {
latitude: parseFloat(branch.lat),
longitude: parseFloat(branch.lon)
};
}
get initialRegion() {
const { branch } = this.props;
console.log(branch);
return {
latitude: branch.lat,
longitude: branch.long,
latitude: parseFloat(branch.lat),
longitude: parseFloat(branch.lon),
latitudeDelta: 0.0922,
longitudeDelta: 0.0421
};
......
......@@ -8,7 +8,8 @@ export default class KeywordsWidget extends PureComponent {
_renderItem = ({ item }) => <KeywordsListItem item={item} />;
render() {
const { keywords } = this.props;
const keywords = this.props.keywords.split(" ");
if (!keywords) return null;
return (
......
......@@ -19,17 +19,17 @@ class NotificationListItem extends PureComponent {
return (
<ListItem
title={`${item.city}, ${item.address}`}
title={`${item.bank_branch.city}, ${item.bank_branch.address}`}
subtitle={
<NotificationAVMatch
audioMatch={item.audioMatch}
videoMatch={item.videoMatch}
audioMatch={item.audio_match}
videoMatch={item.video_match}
/>
}
rightTitle={
<NotificationDate
isPressable={isPressable}
timeStamp={item.timeStamp}
timeStamp={item.timestamp.substring(0, 19)}
/>
}
onPress={isPressable ? this._onPress : undefined}
......
export const API_URL = "http://192.168.1.105:8080/api/";
......@@ -30,10 +30,12 @@ export default class BranchInfoScreen extends Component {
componentDidMount() {
InteractionManager.runAfterInteractions(() => {
const branchID = this.state.branch.id;
console.log(this.props.screenProps);
this.setState({
isLoaded: true,
data: this.props.screenProps.notifications.filter(
item => item.branchId === branchID
item => item.bank_branch.id === branchID
)
});
});
......
import React, { Component } from "react";
import { StyleSheet, FlatList, View } from "react-native";
import BranchListItem from "../components/branches/BranchListItem";
import { BRANCHES } from "../constants/Data";
// import { BRANCHES } from "../constants/Data";
import { API_URL } from "../constants/Api";
export default class BranchesScreen extends Component {
static navigationOptions = {
......@@ -14,9 +15,15 @@ export default class BranchesScreen extends Component {
};
componentDidMount() {
// tu pojde request na branches....
// fetch(URL, blabla)
this.setState({ data: BRANCHES });
fetch(API_URL + "bank-branch/")
.then(response => response.json())
.then(data => {
this.setState({ data: data });
})
.catch(error => {
console.log("Api call error");
alert(error.message);
});
}
_keyExtractor = item => `branch-${item.id}`;
......
......@@ -59,7 +59,22 @@ export default class NotificationInfoScreen extends Component {
<KeywordsList keywords={data.keywords} />
</View>
<View style={[styles.containerInner, styles.buttonView]}>
<View
style={[styles.containerInner, styles.buttonView, styles.flexRow]}
>
<Button
icon={{
name: "bell",
type: "feather",
color: "white"
}}
onPress={this._onCallPressed}
containerStyle={styles.containerButton}
buttonStyle={styles.callButton}
titleStyle={styles.buttonTitle}
title="Alarm"
/>
<Button
icon={{
name: "phone",
......@@ -81,6 +96,11 @@ export default class NotificationInfoScreen extends Component {
const styles = StyleSheet.create({
container: { flex: 1 },
containerInner: { marginTop: 5, marginBottom: 10 },
flexRow: {
flexDirection: "row",
marginHorizontal: 5,
justifyContent: "space-around"
},
horizontalOffset: { paddingHorizontal: 15 },
buttonTabContainer: {},
videoStyle: { width: "100%", height: 230 },
......
CREATE DATABASE bank_robbery;
USE bank_robbery;
CREATE TABLE [data] (
CREATE TABLE [data]
(
id INT IDENTITY(1,1) NOT NULL,
timestamp DATETIME NULL DEFAULT GETDATE(),
phrase VARCHAR(64) NOT NULL,
bank_robbery DECIMAL(5,2) NULL,
PRIMARY KEY (id));
PRIMARY KEY (id)
);
CREATE TABLE [bank_branch] (
CREATE TABLE [bank_branch]
(
id INT IDENTITY(1,1) NOT NULL,
address VARCHAR(64) NOT NULL,
zip VARCHAR(64) NOT NULL,
city VARCHAR(64) NOT NULL,
lat VARCHAR(64) NOT NULL,
lon VARCHAR(64) NOT NULL,
PRIMARY KEY (id));
lat Decimal(9,6) NOT NULL,
lon Decimal(9,6) NOT NULL,
PRIMARY KEY (id)
);
INSERT INTO [bank_branch] (id, address, zip, city, lat, lon) VALUES ('1', 'Letná 9', '04001', 'Košice', '48.7304366', '21.2433415')
INSERT INTO [bank_branch]
(address, zip, city, lat, lon)
VALUES
('Letná 9', '04001', 'Košice', '48.7304366', '21.2433415')
CREATE TABLE [robbery_event] (
CREATE TABLE [robbery_event]
(
id INT IDENTITY(1,1) NOT NULL,
id_bank_branch INT NOT NULL,
timestamp DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
......
......@@ -3,10 +3,6 @@ chardet==3.0.4
Cython==0.29.7
idna==2.8
kaggle==1.5.3
mysql==0.0.2
mysql-connector==2.2.9
mysql-connector-python==8.0.15
mysqlclient==1.4.2.post1
nltk==3.4.1
numpy==1.16.3
paho-mqtt==1.4.0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment