Skip to content

Commit

Permalink
v0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
komplexb committed Apr 17, 2017
1 parent 6feae8e commit 4d1a64b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ This project was generated from [electron-vue](https://github.com/SimulatedGREG/
[Notifications Collection]: https://thenounproject.com/dergraph/collection/notifications
[OneNote Account]: http://onenote.com
[Download Notifyer]: https://github.com/komplexb/notifyer-electron/releases
[Chance]: http://chancejs.com
[Chance]: http://chancejs.com
80 changes: 59 additions & 21 deletions app/src/components/Note.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
<div v-bind:style='{ backgroundImage: `url(${imgUrl})`}' class="medium ui image">
</div>
<div class="content">
<div @click='openOneNoteClient' :title='title' class="ui blue large header">
{{title}}
<div class="title-area">
<div @click='openOneNoteClient' :title='title' class="ui blue large header">
{{title}}
</div>
<div class="ui toggle checkbox">
<input v-model="sticky" type="checkbox" name="sticky" :title="stickyTooltip" @change='handleSticky'>
<label></label>
</div>
</div>

<div class="description">
<template v-if='loading'>
<div class="ui active inverted dimmer">
Expand Down Expand Up @@ -39,6 +44,7 @@
import $ from 'jquery'
const { ipcRenderer: ipc, shell } = require('electron')
const path = require('path')
const storage = require('../main/store')
const { getRandomNote } = require('../main/onenote')
const { URLS } = require('../../app.config')
const {app} = require('electron').remote
Expand All @@ -53,7 +59,9 @@
body: '',
imgUrl: '',
noteLinks: {},
loading: false
loading: false,
sticky: false,
stickyTooltip: 'Make this quote sticky.'
}
},
Expand All @@ -62,6 +70,9 @@
},
methods: {
handleSticky () {
this.stickyTooltip = this.sticky ? "This quote won't change until you restart the app or uncheck this toggle." : 'Make this quote sticky.'
},
showSettings: function () {
$('#settings').modal('show')
},
Expand All @@ -71,26 +82,31 @@
// get a random note update the UI, conditionally push a notification
handleRandomNote: function (withNotification = true) {
this.loading = true // show loading overlay
getRandomNote()
.then((note) => {
const { title, noteLinks, preview: {previewText, links} } = note
this.title = title
this.body = previewText
this.imgUrl = (links.previewImageUrl.href === null) ? URLS.THUMBNAIL : links.previewImageUrl.href
this.noteLinks = noteLinks
this.loading = false // hide loading overlay
// if sticky use the last set note
if (this.sticky === true) {
const currentNote = storage.getItem('current_note')
this.setNote(currentNote)
if (withNotification) {
this.renderNotification(note)
this.renderNotification(currentNote)
}
})
.catch((err) => {
this.title = 'Ooops!'
this.body = `Can't seem to find any notes here. Please check if you created a section called '${storeSettings.getItemSync('sectionName')}', add some notes, or try re-signing into the app (sign-out + sign-in).`
this.imgUrl = URLS.ERROR
this.loading = false
console.log(err)
})
} else {
getRandomNote()
.then((note) => {
storage.setItem('current_note', note)
this.setNote(note)
if (withNotification) {
this.renderNotification(note)
}
})
.catch((err) => {
this.title = 'Ooops!'
this.body = `Can't seem to find any notes here. Please check if you created a section called '${storeSettings.getItemSync('sectionName')}', add some notes, or try re-signing into the app (sign-out + sign-in).`
this.imgUrl = URLS.ERROR
this.loading = false
console.log(err)
})
}
},
renderNotification: function (note) {
const { title, preview: {previewText, links} } = note
Expand All @@ -108,6 +124,14 @@
openOneNoteClient: function () {
const { oneNoteClientUrl, oneNoteWebUrl } = this.noteLinks
shell.openExternal((storeSettings.getItemSync('openWith') === 'OneNote') ? oneNoteClientUrl.href : oneNoteWebUrl.href)
},
setNote (note) {
const { title, noteLinks, preview: {previewText, links} } = note
this.title = title
this.body = previewText
this.imgUrl = (links.previewImageUrl.href === null) ? URLS.THUMBNAIL : links.previewImageUrl.href
this.noteLinks = noteLinks
this.loading = false // hide loading overlay
}
}
}
Expand All @@ -131,6 +155,7 @@
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
flex: 1;
}
#note .ui.card > .content {
Expand All @@ -155,4 +180,17 @@
flex-direction: column;
/*justify-content: center;*/
}
.title-area {
display: flex;
}
.title-area .checkbox {
align-content: flex-end;
padding-top: 3px;
}
.title-area .ui.toggle.checkbox label {
padding-left: 3.5rem;
}
</style>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Notifyer",
"productName": "Notifyer",
"version": "0.0.5",
"version": "0.0.6",
"description": "Notifyer Desktop",
"scripts": {
"build": "node tasks/release.js",
Expand Down

0 comments on commit 4d1a64b

Please sign in to comment.