1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-12-08 23:07:32 +02:00

Mobile: Added status info to view active alarms

This commit is contained in:
Laurent Cozic
2017-11-28 20:31:14 +00:00
parent ddb73c8642
commit d1a83d065a
6 changed files with 40 additions and 22 deletions

View File

@@ -286,11 +286,16 @@ class ScreenHeaderComponent extends Component {
if (!this.props.noteSelectionEnabled) { if (!this.props.noteSelectionEnabled) {
for (let i = 0; i < this.props.menuOptions.length; i++) { for (let i = 0; i < this.props.menuOptions.length; i++) {
let o = this.props.menuOptions[i]; let o = this.props.menuOptions[i];
if (o.isDivider) {
menuOptionComponents.push(<View key={'menuOption_' + key++} style={this.styles().divider}/>);
} else {
menuOptionComponents.push( menuOptionComponents.push(
<MenuOption value={o.onPress} key={'menuOption_' + key++} style={this.styles().contextMenuItem}> <MenuOption value={o.onPress} key={'menuOption_' + key++} style={this.styles().contextMenuItem}>
<Text style={this.styles().contextMenuItemText}>{o.title}</Text> <Text style={this.styles().contextMenuItemText}>{o.title}</Text>
</MenuOption>); </MenuOption>);
} }
}
if (this.props.showAdvancedOptions) { if (this.props.showAdvancedOptions) {
if (menuOptionComponents.length) { if (menuOptionComponents.length) {

View File

@@ -384,18 +384,21 @@ class NoteScreenComponent extends BaseScreenComponent {
let canAttachPicture = true; let canAttachPicture = true;
if (Platform.OS === 'android' && Platform.Version < 21) canAttachPicture = false; if (Platform.OS === 'android' && Platform.Version < 21) canAttachPicture = false;
if (canAttachPicture) { if (canAttachPicture) {
output.push({ title: _('Attach image'), onPress: () => { this.attachImage_onPress(); } }); output.push({ title: _('Attach photo'), onPress: () => { this.attachImage_onPress(); } });
output.push({ title: _('Attach any other file'), onPress: () => { this.attachFile_onPress(); } }); output.push({ title: _('Attach any file'), onPress: () => { this.attachFile_onPress(); } });
output.push({ isDivider: true });
} }
if (isTodo) { if (isTodo) {
output.push({ title: _('Set or clear alarm'), onPress: () => { this.setState({ alarmDialogShown: true }) }});; output.push({ title: _('Set alarm'), onPress: () => { this.setState({ alarmDialogShown: true }) }});;
} }
output.push({ title: _('Delete note'), onPress: () => { this.deleteNote_onPress(); } }); output.push({ title: isTodo ? _('Convert to note') : _('Convert to todo'), onPress: () => { this.toggleIsTodo_onPress(); } });
output.push({ title: isTodo ? _('Convert to regular note') : _('Convert to todo'), onPress: () => { this.toggleIsTodo_onPress(); } }); output.push({ isDivider: true });
if (this.props.showAdvancedOptions) output.push({ title: this.state.showNoteMetadata ? _('Hide metadata') : _('Show metadata'), onPress: () => { this.showMetadata_onPress(); } }); if (this.props.showAdvancedOptions) output.push({ title: this.state.showNoteMetadata ? _('Hide metadata') : _('Show metadata'), onPress: () => { this.showMetadata_onPress(); } });
output.push({ title: _('View location on map'), onPress: () => { this.showOnMap_onPress(); } }); output.push({ title: _('View on map'), onPress: () => { this.showOnMap_onPress(); } });
output.push({ isDivider: true });
output.push({ title: _('Delete'), onPress: () => { this.deleteNote_onPress(); } });
return output; return output;
} }

View File

@@ -39,6 +39,10 @@ class Alarm extends BaseModel {
return output; return output;
} }
static async allDue() {
return this.modelSelectAll('SELECT * FROM alarms WHERE trigger_time >= ?', [Date.now()]);
}
} }
module.exports = Alarm; module.exports = Alarm;

View File

@@ -115,9 +115,6 @@ class AlarmService {
} }
} }
// TODO: inner notifications (when app is active)
// TODO: status to view active notifications
} }
module.exports = AlarmService; module.exports = AlarmService;

View File

@@ -1,5 +1,6 @@
const { time } = require('lib/time-utils'); const { time } = require('lib/time-utils');
const { BaseItem } = require('lib/models/base-item.js'); const { BaseItem } = require('lib/models/base-item.js');
const Alarm = require('lib/models/Alarm');
const { Folder } = require('lib/models/folder.js'); const { Folder } = require('lib/models/folder.js');
const { Note } = require('lib/models/note.js'); const { Note } = require('lib/models/note.js');
const { _ } = require('lib/locale.js'); const { _ } = require('lib/locale.js');
@@ -108,10 +109,8 @@ class ReportService {
async status(syncTarget) { async status(syncTarget) {
let r = await this.syncStatus(syncTarget); let r = await this.syncStatus(syncTarget);
let sections = []; let sections = [];
let section = {};
section.title = _('Sync status (synced items / total items)'); let section = { title: _('Sync status (synced items / total items)'), body: [] };
section.body = [];
for (let n in r.items) { for (let n in r.items) {
if (!r.items.hasOwnProperty(n)) continue; if (!r.items.hasOwnProperty(n)) continue;
@@ -125,22 +124,31 @@ class ReportService {
sections.push(section); sections.push(section);
section = {}; section = { title: _('Folders'), body: [] };
section.title = _('Folders');
section.body = [];
let folders = await Folder.all({ const folders = await Folder.all({
order: { by: 'title', dir: 'ASC' }, order: { by: 'title', dir: 'ASC' },
caseInsensitive: true, caseInsensitive: true,
}); });
for (let i = 0; i < folders.length; i++) { for (let i = 0; i < folders.length; i++) {
let folder = folders[i]; const folder = folders[i];
section.body.push(_('%s: %d notes', folders[i].title, await Folder.noteCount(folders[i].id))); section.body.push(_('%s: %d notes', folders[i].title, await Folder.noteCount(folders[i].id)));
} }
sections.push(section); sections.push(section);
section = { title: _('Coming alarms'), body: [] };
const alarms = await Alarm.allDue();
for (let i = 0; i < alarms.length; i++) {
const alarm = alarms[i];
const note = await Note.load(alarm.note_id);
section.body.push(_('On %s: %s', time.formatMsToLocal(alarm.trigger_time), note.title));
}
sections.push(section);
return sections; return sections;
} }

View File

@@ -55,7 +55,8 @@ class Time {
return moment.unix(ms / 1000).format('DD/MM/YYYY HH:mm'); return moment.unix(ms / 1000).format('DD/MM/YYYY HH:mm');
} }
formatMsToLocal(ms, format) { formatMsToLocal(ms, format = null) {
if (format === null) format = this.dateTimeFormat();
return moment(ms).format(format); return moment(ms).format(format);
} }