You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-07-03 23:50:33 +02:00
.github
Assets
CliClient
Clipper
ElectronClient
ReactNativeClient
android
ios
lib
MdToHtml
components
screens
NoteTagsDialog.js
config.js
dropbox-login.js
encryption-config.js
folder.js
log.js
note.js
notes.js
onedrive-login.js
search.js
status.js
tag.js
tags.js
welcome.js
shared
CameraView.js
Dropdown.js
ItemList.js
ModalDialog.js
SaveIcon.png
action-button.js
app-nav.js
base-screen.js
checkbox.js
global-style.js
note-body-viewer.js
note-item.js
note-list.js
screen-header.js
select-date-time-dialog.js
side-menu-content.js
side-menu.js
images
migrations
models
services
vendor
ArrayUtils.js
BaseApplication.js
BaseModel.js
BaseSyncTarget.js
Cache.js
ClipperServer.js
DropboxApi.js
EventDispatcher.js
HtmlToMd.js
JoplinError.js
MdToHtml.js
ModelCache.js
ObjectUtils.js
SyncTargetDropbox.js
SyncTargetFilesystem.js
SyncTargetMemory.js
SyncTargetNextcloud.js
SyncTargetOneDrive.js
SyncTargetOneDriveDev.js
SyncTargetRegistry.js
SyncTargetWebDAV.js
TaskQueue.js
WebDavApi.js
WelcomeUtils.js
database-driver-node.js
database-driver-react-native.js
database.js
dialogs.js
file-api-driver-dropbox.js
file-api-driver-local.js
file-api-driver-memory.js
file-api-driver-onedrive.js
file-api-driver-webdav.js
file-api.js
folders-screen-utils.js
fs-driver-base.js
fs-driver-dummy.js
fs-driver-node.js
fs-driver-rn.js
geolocation-node.js
geolocation-react.js
import-enex-md-gen.js
import-enex.js
joplin-database.js
layout-utils.js
locale.js
logger.js
markJsUtils.js
markdownUtils.js
mime-utils.js
net-utils.js
onedrive-api.js
package.json
parameters.js
parseUri.js
path-utils.js
poor-man-intervals.js
promise-utils.js
randomClipperPort.js
react-logger.js
reducer.js
registry.js
shim-init-node.js
shim-init-react.js
shim.js
string-utils-common.js
string-utils.js
synchronizer.js
time-utils.js
urlUtils.js
uuid.js
welcomeAssets.js
locales
.babelrc
.buckconfig
.flowconfig
.gitattributes
.gitignore
.watchmanconfig
App.js
app.json
build_android.bat
build_android_prod.bat
clean_build.bat
debug_log.bat
debug_log.sh
index.android.js
index.ios.js
index.js
main.js
package-lock.json
package.json
root.js
start_emulator.bat
start_server.bat
start_server.sh
Tools
docs
readme
.gitignore
.travis.yml
BUILD.md
CONTRIBUTING.md
Joplin_install_and_update.sh
LICENSE
README.md
_config.yml
appveyor.yml
joplin.sublime-project
linkToLocal.sh
130 lines
3.7 KiB
JavaScript
130 lines
3.7 KiB
JavaScript
const React = require('react'); const Component = React.Component;
|
|
const { ListView, View, Text, Button, StyleSheet, Platform } = require('react-native');
|
|
const { connect } = require('react-redux');
|
|
const { reg } = require('lib/registry.js');
|
|
const { ScreenHeader } = require('lib/components/screen-header.js');
|
|
const { time } = require('lib/time-utils');
|
|
const { themeStyle } = require('lib/components/global-style.js');
|
|
const { Logger } = require('lib/logger.js');
|
|
const { BaseScreenComponent } = require('lib/components/base-screen.js');
|
|
const { _ } = require('lib/locale.js');
|
|
|
|
class LogScreenComponent extends BaseScreenComponent {
|
|
|
|
static navigationOptions(options) {
|
|
return { header: null };
|
|
}
|
|
|
|
constructor() {
|
|
super();
|
|
const ds = new ListView.DataSource({
|
|
rowHasChanged: (r1, r2) => { return r1 !== r2; }
|
|
});
|
|
this.state = {
|
|
dataSource: ds,
|
|
showErrorsOnly: false,
|
|
};
|
|
this.styles_ = {};
|
|
}
|
|
|
|
styles() {
|
|
const theme = themeStyle(this.props.theme);
|
|
|
|
if (this.styles_[this.props.theme]) return this.styles_[this.props.theme];
|
|
this.styles_ = {};
|
|
|
|
let styles = {
|
|
row: {
|
|
flexDirection: 'row',
|
|
paddingLeft: 1,
|
|
paddingRight: 1,
|
|
paddingTop:0,
|
|
paddingBottom:0,
|
|
},
|
|
rowText: {
|
|
fontSize: 10,
|
|
color: theme.color,
|
|
},
|
|
};
|
|
|
|
if (Platform.OS !== 'ios') { // Crashes on iOS with error "Unrecognized font family 'monospace'"
|
|
styles.rowText.fontFamily = 'monospace';
|
|
}
|
|
|
|
styles.rowTextError = Object.assign({}, styles.rowText);
|
|
styles.rowTextError.color = theme.colorError;
|
|
|
|
styles.rowTextWarn = Object.assign({}, styles.rowText);
|
|
styles.rowTextWarn.color = theme.colorWarn;
|
|
|
|
this.styles_[this.props.theme] = StyleSheet.create(styles);
|
|
return this.styles_[this.props.theme];
|
|
}
|
|
|
|
UNSAFE_componentWillMount() {
|
|
this.resfreshLogEntries();
|
|
}
|
|
|
|
resfreshLogEntries(showErrorsOnly = null) {
|
|
if (showErrorsOnly === null) showErrorsOnly = this.state.showErrorsOnly;
|
|
|
|
let levels = [Logger.LEVEL_DEBUG, Logger.LEVEL_INFO, Logger.LEVEL_WARN, Logger.LEVEL_ERROR];
|
|
if (showErrorsOnly) levels = [Logger.LEVEL_WARN, Logger.LEVEL_ERROR]
|
|
|
|
reg.logger().lastEntries(1000, { levels: levels }).then((entries) => {
|
|
const newDataSource = this.state.dataSource.cloneWithRows(entries);
|
|
this.setState({ dataSource: newDataSource });
|
|
});
|
|
}
|
|
|
|
toggleErrorsOnly() {
|
|
const showErrorsOnly = !this.state.showErrorsOnly;
|
|
this.setState({ showErrorsOnly: showErrorsOnly });
|
|
this.resfreshLogEntries(showErrorsOnly);
|
|
}
|
|
|
|
render() {
|
|
let renderRow = (item) => {
|
|
let textStyle = this.styles().rowText;
|
|
if (item.level == Logger.LEVEL_WARN) textStyle = this.styles().rowTextWarn;
|
|
if (item.level == Logger.LEVEL_ERROR) textStyle = this.styles().rowTextError;
|
|
|
|
return (
|
|
<View style={this.styles().row}>
|
|
<Text style={textStyle}>{time.formatMsToLocal(item.timestamp, 'MM-DDTHH:mm:ss') + ': ' + item.message}</Text>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
// `enableEmptySections` is to fix this warning: https://github.com/FaridSafi/react-native-gifted-listview/issues/39
|
|
return (
|
|
<View style={this.rootStyle(this.props.theme).root}>
|
|
<ScreenHeader title={_('Log')}/>
|
|
<ListView
|
|
dataSource={this.state.dataSource}
|
|
renderRow={renderRow}
|
|
enableEmptySections={true}
|
|
/>
|
|
<View style={{flexDirection: 'row'}}>
|
|
<View style={{flex:1, marginRight: 5 }}>
|
|
<Button title={_("Refresh")} onPress={() => { this.resfreshLogEntries(); }}/>
|
|
</View>
|
|
<View style={{flex:1}}>
|
|
<Button title={this.state.showErrorsOnly ? _("Show all") : _("Errors only")} onPress={() => { this.toggleErrorsOnly(); }}/>
|
|
</View>
|
|
</View>
|
|
</View>
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
const LogScreen = connect(
|
|
(state) => {
|
|
return {
|
|
theme: state.settings.theme,
|
|
};
|
|
}
|
|
)(LogScreenComponent)
|
|
|
|
module.exports = { LogScreen }; |