2017-07-10 21:16:59 +02:00
|
|
|
import React, { Component } from 'react';
|
2017-07-22 00:42:24 +02:00
|
|
|
import { ListView, StyleSheet, View, Text, Button } from 'react-native';
|
2017-07-16 18:06:05 +02:00
|
|
|
import { Setting } from 'lib/models/setting.js';
|
2017-07-10 21:16:59 +02:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
import { Log } from 'lib/log.js'
|
|
|
|
import { reg } from 'lib/registry.js'
|
|
|
|
import { ScreenHeader } from 'lib/components/screen-header.js';
|
|
|
|
import { time } from 'lib/time-utils'
|
|
|
|
import { Logger } from 'lib/logger.js';
|
|
|
|
import { BaseItem } from 'lib/models/base-item.js';
|
2017-07-16 18:06:05 +02:00
|
|
|
import { Database } from 'lib/database.js';
|
2017-07-13 00:32:08 +02:00
|
|
|
import { Folder } from 'lib/models/folder.js';
|
2017-07-13 20:09:47 +02:00
|
|
|
import { ReportService } from 'lib/services/report.js';
|
2017-07-10 21:16:59 +02:00
|
|
|
import { _ } from 'lib/locale.js';
|
2017-07-14 20:49:14 +02:00
|
|
|
import { BaseScreenComponent } from 'lib/components/base-screen.js';
|
2017-07-22 00:42:24 +02:00
|
|
|
import { globalStyle } from 'lib/components/global-style.js';
|
|
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
|
body: {
|
|
|
|
flex: 1,
|
|
|
|
margin: globalStyle.margin,
|
|
|
|
},
|
|
|
|
});
|
2017-07-10 21:16:59 +02:00
|
|
|
|
2017-07-14 20:49:14 +02:00
|
|
|
class StatusScreenComponent extends BaseScreenComponent {
|
2017-07-10 21:16:59 +02:00
|
|
|
|
|
|
|
static navigationOptions(options) {
|
|
|
|
return { header: null };
|
|
|
|
}
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.state = {
|
2017-07-13 20:09:47 +02:00
|
|
|
report: [],
|
2017-07-10 21:16:59 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
componentWillMount() {
|
|
|
|
this.resfreshScreen();
|
|
|
|
}
|
|
|
|
|
2017-07-13 00:32:08 +02:00
|
|
|
async resfreshScreen() {
|
2017-07-13 20:09:47 +02:00
|
|
|
let service = new ReportService();
|
2017-07-24 20:58:11 +02:00
|
|
|
let report = await service.status(Setting.value('sync.target'));
|
2017-07-13 20:09:47 +02:00
|
|
|
this.setState({ report: report });
|
2017-07-13 00:32:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-07-13 20:09:47 +02:00
|
|
|
function renderBody(report) {
|
|
|
|
let output = [];
|
|
|
|
let baseStyle = {
|
|
|
|
paddingLeft: 6,
|
|
|
|
paddingRight: 6,
|
|
|
|
paddingTop: 0,
|
|
|
|
paddingBottom: 0,
|
|
|
|
flex: 0,
|
2017-07-30 23:04:26 +02:00
|
|
|
fontSize: globalStyle.fontSize,
|
2017-07-13 20:09:47 +02:00
|
|
|
};
|
|
|
|
for (let i = 0; i < report.length; i++) {
|
|
|
|
let section = report[i];
|
|
|
|
|
|
|
|
let style = Object.assign({}, baseStyle);
|
|
|
|
style.fontWeight = 'bold';
|
|
|
|
if (i > 0) style.paddingTop = 20;
|
|
|
|
output.push(<Text key={'sectiontitle_' + i} style={style}>{section.title}</Text>);
|
|
|
|
|
|
|
|
for (let n in section.body) {
|
|
|
|
if (!section.body.hasOwnProperty(n)) continue;
|
|
|
|
style = Object.assign({}, baseStyle);
|
|
|
|
output.push(<Text key={'line_' + i + '_' + n} style={style}>{section.body[n]}</Text>);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
|
|
|
let body = renderBody(this.state.report);
|
2017-07-10 21:16:59 +02:00
|
|
|
|
|
|
|
return (
|
2017-07-14 20:49:14 +02:00
|
|
|
<View style={this.styles().screen}>
|
2017-07-24 23:58:14 +02:00
|
|
|
<ScreenHeader title={_('Status')}/>
|
2017-07-22 00:42:24 +02:00
|
|
|
<View style={styles.body}>
|
2017-07-13 20:09:47 +02:00
|
|
|
{ body }
|
|
|
|
</View>
|
2017-07-27 19:34:43 +02:00
|
|
|
<Button title={_("Refresh")} onPress={() => this.resfreshScreen()}/>
|
2017-07-10 21:16:59 +02:00
|
|
|
</View>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const StatusScreen = connect(
|
|
|
|
(state) => {
|
|
|
|
return {};
|
|
|
|
}
|
|
|
|
)(StatusScreenComponent)
|
|
|
|
|
|
|
|
export { StatusScreen };
|