Skip to content

Commit

Permalink
Mobile: Added status info to view active alarms
Browse files Browse the repository at this point in the history
  • Loading branch information
laurent22 committed Nov 28, 2017
1 parent ddb73c8 commit d1a83d0
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 22 deletions.
13 changes: 9 additions & 4 deletions ReactNativeClient/lib/components/screen-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,15 @@ class ScreenHeaderComponent extends Component {
if (!this.props.noteSelectionEnabled) {
for (let i = 0; i < this.props.menuOptions.length; i++) {
let o = this.props.menuOptions[i];
menuOptionComponents.push(
<MenuOption value={o.onPress} key={'menuOption_' + key++} style={this.styles().contextMenuItem}>
<Text style={this.styles().contextMenuItemText}>{o.title}</Text>
</MenuOption>);

if (o.isDivider) {
menuOptionComponents.push(<View key={'menuOption_' + key++} style={this.styles().divider}/>);
} else {
menuOptionComponents.push(
<MenuOption value={o.onPress} key={'menuOption_' + key++} style={this.styles().contextMenuItem}>
<Text style={this.styles().contextMenuItemText}>{o.title}</Text>
</MenuOption>);
}
}

if (this.props.showAdvancedOptions) {
Expand Down
15 changes: 9 additions & 6 deletions ReactNativeClient/lib/components/screens/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,18 +384,21 @@ class NoteScreenComponent extends BaseScreenComponent {
let canAttachPicture = true;
if (Platform.OS === 'android' && Platform.Version < 21) canAttachPicture = false;
if (canAttachPicture) {
output.push({ title: _('Attach image'), onPress: () => { this.attachImage_onPress(); } });
output.push({ title: _('Attach any other file'), onPress: () => { this.attachFile_onPress(); } });
output.push({ title: _('Attach photo'), onPress: () => { this.attachImage_onPress(); } });
output.push({ title: _('Attach any file'), onPress: () => { this.attachFile_onPress(); } });
output.push({ isDivider: true });
}

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 regular note') : _('Convert to todo'), onPress: () => { this.toggleIsTodo_onPress(); } });
output.push({ title: isTodo ? _('Convert to 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(); } });
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;
}
Expand Down
4 changes: 4 additions & 0 deletions ReactNativeClient/lib/models/Alarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class Alarm extends BaseModel {
return output;
}

static async allDue() {
return this.modelSelectAll('SELECT * FROM alarms WHERE trigger_time >= ?', [Date.now()]);
}

}

module.exports = Alarm;
3 changes: 0 additions & 3 deletions ReactNativeClient/lib/services/AlarmService.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,6 @@ class AlarmService {
}
}

// TODO: inner notifications (when app is active)
// TODO: status to view active notifications

}

module.exports = AlarmService;
24 changes: 16 additions & 8 deletions ReactNativeClient/lib/services/report.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const { time } = require('lib/time-utils');
const { BaseItem } = require('lib/models/base-item.js');
const Alarm = require('lib/models/Alarm');
const { Folder } = require('lib/models/folder.js');
const { Note } = require('lib/models/note.js');
const { _ } = require('lib/locale.js');
Expand Down Expand Up @@ -108,10 +109,8 @@ class ReportService {
async status(syncTarget) {
let r = await this.syncStatus(syncTarget);
let sections = [];
let section = {};

section.title = _('Sync status (synced items / total items)');
section.body = [];
let section = { title: _('Sync status (synced items / total items)'), body: [] };

for (let n in r.items) {
if (!r.items.hasOwnProperty(n)) continue;
Expand All @@ -125,22 +124,31 @@ class ReportService {

sections.push(section);

section = {};
section.title = _('Folders');
section.body = [];
section = { title: _('Folders'), body: [] };

let folders = await Folder.all({
const folders = await Folder.all({
order: { by: 'title', dir: 'ASC' },
caseInsensitive: true,
});

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)));
}

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;
}

Expand Down
3 changes: 2 additions & 1 deletion ReactNativeClient/lib/time-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class Time {
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);
}

Expand Down

0 comments on commit d1a83d0

Please sign in to comment.