Skip to content

Commit

Permalink
Fix filter syntax error and track usage
Browse files Browse the repository at this point in the history
  • Loading branch information
piascikj committed Apr 16, 2018
1 parent 814aee6 commit 147887b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .imdone/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
{
"name": "DOING",
"hidden": true
"hidden": false
},
{
"name": "CHANGED",
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.4.17
- Fix filter syntax error

## 2.4.16
- Provide data-key and data-value in metadata rows for plugins or custom css. e.g. `tr.meta-data-row[data-key=gh]`
- When filtering only show lists with tasks and ignored lists
Expand Down
4 changes: 2 additions & 2 deletions lib/services/imdoneio-client.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ class ImdoneioClient extends Emitter

onAuthSuccess: (user, cb) ->
return cb null, user if @authenticated
@authenticated = true
@getPlan (err, @plan) =>
@authenticated = true
@authRetryCount = 0
@emit 'authenticated'
@emit 'authenticated', user
@saveCredentials (err) =>
@storageAuthFailed = false
cb(null, user)
Expand Down
2 changes: 1 addition & 1 deletion lib/services/imdoneio-store.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ module.exports = (repo) ->

plugins = []

client.on 'authenticated', -> repo.emit 'authenticated'
client.on 'authenticated', (user) -> repo.emit 'authenticated', user
client.on 'unauthenticated', -> repo.emit 'unauthenticated'
client.on 'authentication-failed', ({status, retries}) -> repo.emit 'authentication-failed', ({status, retries})
client.on 'unavailable', -> repo.emit 'unavailable'
Expand Down
22 changes: 22 additions & 0 deletions lib/services/track.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
var KeenTracking = require('keen-tracking');

// Configure a client instance
var client = new KeenTracking({
projectId: '5ad4b047c9e77c0001a03747',
writeKey: '114ADADE7BD4883071292ECA509E032E3241BB7D62C5EFDD34AE1C6525C4A7B91328F514BA46376CCA7A59C85172B32940C8A062DBC99795B7A67EC052F23792D0C386E27184D4AA22B771A6085C5B7B55D28B1C6BEBCA7A81CCF816D524E5FC'
});

var user;

var send = function(name, data) {
if (name === 'authenticated') user = data
else if (user) data.user = {email: user.email, id: user.id}
debugger
client.recordEvent(name, data);
}
module.exports = {
send,
click: function (e) {
console.log('*********************************',e)
}
}
15 changes: 9 additions & 6 deletions lib/views/imdone-atom-view.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{$, $$, $$$, ScrollView} = require 'atom-space-pen-views'
$el = require 'laconic'
track = require '../services/track'
moment = require 'moment'
{Emitter} = require 'atom'
fs = require 'fs'
Expand Down Expand Up @@ -148,7 +149,9 @@ class ImdoneAtomView extends ScrollView
@hideMask() if status == "unavailable" && retries
#console.log "auth-failed" if status == "failed"

@emitter.on 'authenticated', => pluginManager.init()
@emitter.on 'authenticated', (user) =>
track.send 'authenticated', user
pluginManager.init()

@emitter.on 'unavailable', =>
@hideMask()
Expand Down Expand Up @@ -189,6 +192,7 @@ class ImdoneAtomView extends ScrollView
@boardWrapper.toggleClass 'shift'

@emitter.on 'filter', (text) =>
track.send 'filter', {text}
@filter text

@emitter.on 'filter.clear', =>
Expand All @@ -202,6 +206,7 @@ class ImdoneAtomView extends ScrollView
fullPath = @imdoneRepo.getFullPath file
paths[fullPath] = task.line

track.send 'openVisible', paths
numFiles = _.keys(paths).length
if numFiles < 5 || window.confirm "imdone is about to open #{numFiles} files. Continue?"
for fpath, line of paths
Expand Down Expand Up @@ -239,6 +244,7 @@ class ImdoneAtomView extends ScrollView

@on 'click', '.source-link', (e) =>
link = e.target
track.send 'source-link', {uri: link.dataset.uri, line: link.dataset.line}
@openPath link.dataset.uri, link.dataset.line

if config.getSettings().showNotifications && !$(link).hasClass('info-link')
Expand Down Expand Up @@ -390,7 +396,8 @@ class ImdoneAtomView extends ScrollView
else
@board.find('.task').hide()
@board.find('.task a[href^="#filter/"]').removeClass('inline-block highlight-info')
@board.find(".task a[href='#filter/#{text}']").addClass('inline-block highlight-info')
try @board.find(".task a[href='#filter/#{text}']").addClass('inline-block highlight-info')
catch e then console.error(e)
tasks = @imdoneRepo.query text
lists = _.uniq(tasks.map (task) -> task.list).sort()
if JSON.stringify(@shownLists) is JSON.stringify(lists)
Expand All @@ -402,10 +409,6 @@ class ImdoneAtomView extends ScrollView
list.hidden = !lists.includes(list.name) && !list.ignore
@imdoneRepo.saveConfig()

filterByPath: (text) -> @board.find(util.format('.task:attrContainsRegex(data-path,%s)', text)).each -> $(this).show().attr('id')

filterByContent: (text) -> @board.find(util.format('.task-full-text:containsRegex("%s")', text)).each -> $(this).closest('.task').show().attr('id')

visibleTasks: (listName) ->
return [] unless @imdoneRepo
@imdoneRepo.visibleTasks listName
Expand Down
16 changes: 8 additions & 8 deletions lib/views/menu-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ class MenuView extends View
# @div click: "toggleMenu", outlet:"$menuButton", class: "imdone-menu-toggle imdone-toolbar-button", title: "Lists and filter", =>
# @a href: "#", class: "icon #{menuClosedClass}"
# @div class: "menu-sep-space-2x"
@div click: "deleteTasks", class: "delete-tasks imdone-toolbar-button", title: "Delete visible tasks", =>
@a href: "#", =>
@i class: "icon icon-trashcan toolbar-icon"
@span class:'tool-text', 'Delete visible tasks'
@div click: "openReadme", class: "readme-open imdone-toolbar-button", title: "Gimme some README", =>
@a href: "#", =>
@i class: "icon icon-book toolbar-icon"
@span class:'tool-text', 'README.md'
# @div click: "deleteTasks", class: "delete-tasks imdone-toolbar-button", title: "Delete visible tasks", =>
# @a href: "#", =>
# @i class: "icon icon-trashcan toolbar-icon"
# @span class:'tool-text', 'Delete visible tasks'
# @div click: "openReadme", class: "readme-open imdone-toolbar-button", title: "Gimme some README", =>
# @a href: "#", =>
# @i class: "icon icon-book toolbar-icon"
# @span class:'tool-text', 'README.md'
@div click: "newList", class: "new-list-open imdone-toolbar-button", title: "I need another list", =>
@a href: "#", =>
@i class: "icon icon-plus toolbar-icon"
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"ignore": "^3.3.7",
"imdone-core": "1.4.7",
"json-editor": "^0.7.28",
"keen-tracking": "^1.4.0",
"laconic": "^0.2.2",
"lodash": "^4.12.0",
"loophole": "^1.1.0",
Expand Down

0 comments on commit 147887b

Please sign in to comment.