You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	Status screen
This commit is contained in:
		| @@ -90,8 +90,8 @@ android { | ||||
| 		applicationId "net.cozic.joplin" | ||||
| 		minSdkVersion 16 | ||||
| 		targetSdkVersion 22 | ||||
| 		versionCode 3 | ||||
| 		versionName "0.8.1" | ||||
| 		versionCode 4 | ||||
| 		versionName "0.8.2" | ||||
| 		ndk { | ||||
| 			abiFilters "armeabi-v7a", "x86" | ||||
| 		} | ||||
|   | ||||
| @@ -3,4 +3,5 @@ rmdir /s/q android\app\build | ||||
| rmdir /s/q android\build | ||||
| rmdir /s/q android\.gradle | ||||
| rmdir /s/q node_modules | ||||
| npm install | ||||
| npm install | ||||
| start_server.bat | ||||
| @@ -41,6 +41,13 @@ class ScreenHeaderComponent extends Component { | ||||
| 		});	 | ||||
| 	} | ||||
|  | ||||
| 	status_press() { | ||||
| 		this.props.dispatch({ | ||||
| 			type: 'Navigation/NAVIGATE', | ||||
| 			routeName: 'Status', | ||||
| 		});	 | ||||
| 	} | ||||
|  | ||||
| 	render() { | ||||
| 		let key = 0; | ||||
| 		let menuOptionComponents = []; | ||||
| @@ -61,6 +68,11 @@ class ScreenHeaderComponent extends Component { | ||||
| 				<Text>{_('Log')}</Text> | ||||
| 			</MenuOption>); | ||||
|  | ||||
| 		menuOptionComponents.push( | ||||
| 			<MenuOption value={() => this.status_press()} key={'menuOption_' + key++}> | ||||
| 				<Text>{_('Status')}</Text> | ||||
| 			</MenuOption>); | ||||
|  | ||||
| 		let title = 'title' in this.props && this.props.title !== null ? this.props.title : _(this.props.navState.routeName); | ||||
|  | ||||
| 		return ( | ||||
|   | ||||
							
								
								
									
										66
									
								
								ReactNativeClient/lib/components/screens/status.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										66
									
								
								ReactNativeClient/lib/components/screens/status.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,66 @@ | ||||
| import React, { Component } from 'react'; | ||||
| import { ListView, View, Text, Button } from 'react-native'; | ||||
| 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'; | ||||
| import { _ } from 'lib/locale.js'; | ||||
|  | ||||
| class StatusScreenComponent extends React.Component { | ||||
| 	 | ||||
| 	static navigationOptions(options) { | ||||
| 		return { header: null }; | ||||
| 	} | ||||
|  | ||||
| 	constructor() { | ||||
| 		super(); | ||||
| 		this.state = { | ||||
| 			report: {}, | ||||
| 		}; | ||||
| 	} | ||||
|  | ||||
| 	componentWillMount() { | ||||
| 		this.resfreshScreen(); | ||||
| 	} | ||||
|  | ||||
| 	resfreshScreen() { | ||||
| 		return BaseItem.stats().then((report) => { | ||||
| 			this.setState({ report: report }); | ||||
| 		}); | ||||
| 	} | ||||
|  | ||||
| 	render() { | ||||
| 		let reportLines = []; | ||||
| 		const r = this.state.report; | ||||
|  | ||||
| 		for (let n in r.items) { | ||||
| 			if (!r.items.hasOwnProperty(n)) continue; | ||||
| 			reportLines.push(_('%s: %d/%d', n, r.items[n].synced, r.items[n].total)); | ||||
| 		} | ||||
|  | ||||
| 		if (r.total) reportLines.push(_('Total: %d/%d', r.total.synced, r.total.total)); | ||||
| 		if (r.toDelete) reportLines.push(_('To delete: %d', r.toDelete.total)); | ||||
|  | ||||
| 		reportLines = reportLines.join("\n"); | ||||
|  | ||||
| 		return ( | ||||
| 			<View style={{flex: 1}}> | ||||
| 				<ScreenHeader navState={this.props.navigation.state} /> | ||||
| 				<Text style={{padding: 6, flex: 1, textAlignVertical: 'top'}} multiline={true}>{reportLines}</Text> | ||||
| 				<Button title="Refresh" onPress={() => this.resfreshScreen()}/> | ||||
| 			</View> | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| } | ||||
|  | ||||
| const StatusScreen = connect( | ||||
| 	(state) => { | ||||
| 		return {}; | ||||
| 	} | ||||
| )(StatusScreenComponent) | ||||
|  | ||||
| export { StatusScreen }; | ||||
| @@ -56,12 +56,16 @@ class BaseItem extends BaseModel { | ||||
| 			synced: syncedCount, | ||||
| 		}; | ||||
|  | ||||
| 		output.toDelete = { | ||||
| 			total: await this.deletedItemCount(), | ||||
| 		}; | ||||
|  | ||||
| 		return output; | ||||
| 	} | ||||
|  | ||||
| 	static async syncedCount() { | ||||
| 		const ItemClass = this.itemClass(this.modelType()); | ||||
| 		const r = await this.db().selectOne('SELECT count(*) as total FROM `' + ItemClass.tableName() + '` WHERE updated_time > sync_time'); | ||||
| 		const r = await this.db().selectOne('SELECT count(*) as total FROM `' + ItemClass.tableName() + '` WHERE updated_time <= sync_time'); | ||||
| 		return r.total; | ||||
| 	} | ||||
|  | ||||
| @@ -143,6 +147,11 @@ class BaseItem extends BaseModel { | ||||
| 		return this.db().selectAll('SELECT * FROM deleted_items'); | ||||
| 	} | ||||
|  | ||||
| 	static async deletedItemCount() { | ||||
| 		let r = await this.db().selectOne('SELECT count(*) as total FROM deleted_items'); | ||||
| 		return r['total']; | ||||
| 	} | ||||
|  | ||||
| 	static remoteDeletedItem(itemId) { | ||||
| 		return this.db().exec('DELETE FROM deleted_items WHERE item_id = ?', [itemId]); | ||||
| 	} | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import { shim } from 'lib/shim.js'; | ||||
| import { GeolocationReact } from 'lib/geolocation-react.js'; | ||||
| import RNFetchBlob from 'react-native-fetch-blob'; | ||||
|  | ||||
| function shimInit() { | ||||
| 	shim.Geolocation = GeolocationReact; | ||||
|   | ||||
| @@ -25,6 +25,7 @@ import { NoteScreen } from 'lib/components/screens/note.js' | ||||
| import { FolderScreen } from 'lib/components/screens/folder.js' | ||||
| import { FoldersScreen } from 'lib/components/screens/folders.js' | ||||
| import { LogScreen } from 'lib/components/screens/log.js' | ||||
| import { StatusScreen } from 'lib/components/screens/status.js' | ||||
| import { LoadingScreen } from 'lib/components/screens/loading.js' | ||||
| import { OneDriveLoginScreen } from 'lib/components/screens/onedrive-login.js' | ||||
| import { Setting } from 'lib/models/setting.js' | ||||
| @@ -218,6 +219,7 @@ const AppNavigator = StackNavigator({ | ||||
| 	Loading: { screen: LoadingScreen }, | ||||
| 	OneDriveLogin: { screen: OneDriveLoginScreen }, | ||||
| 	Log: { screen: LogScreen }, | ||||
| 	Status: { screen: StatusScreen }, | ||||
| }); | ||||
|  | ||||
| let initializationState_ = 'waiting'; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user