openall_time_applet 0.0.25 → 0.0.26
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +22 -18
- data/VERSION +1 -1
- data/gui/trayicon.rb +3 -5
- data/gui/win_main.rb +3 -2
- data/gui/win_preferences.rb +3 -2
- data/gui/win_worktime_overview.rb +1 -0
- data/lib/openall_time_applet.rb +17 -1
- data/models/timelog.rb +16 -14
- data/openall_time_applet.gemspec +5 -3
- data/spec/openall_time_applet_spec.rb +9 -0
- data/spec/sync_spec.rb +52 -0
- data/spec/tray_timelogs_spec.rb +31 -0
- metadata +5 -3
data/Gemfile.lock
CHANGED
@@ -1,40 +1,44 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
atk (1.1.
|
5
|
-
glib2 (>= 1.1.
|
4
|
+
atk (1.1.4)
|
5
|
+
glib2 (>= 1.1.4)
|
6
6
|
cairo (1.12.2)
|
7
7
|
pkg-config
|
8
|
-
datet (0.0.
|
8
|
+
datet (0.0.14)
|
9
9
|
diff-lcs (1.1.3)
|
10
|
-
gdk_pixbuf2 (1.1.
|
11
|
-
glib2 (>= 1.1.
|
10
|
+
gdk_pixbuf2 (1.1.4)
|
11
|
+
glib2 (>= 1.1.4)
|
12
12
|
gettext (2.2.1)
|
13
13
|
locale
|
14
14
|
git (1.2.5)
|
15
|
-
glib2 (1.1.
|
15
|
+
glib2 (1.1.4)
|
16
16
|
pkg-config
|
17
|
-
gtk2 (1.1.
|
18
|
-
atk (>= 1.1.
|
19
|
-
gdk_pixbuf2 (>= 1.1.
|
20
|
-
pango (>= 1.1.
|
21
|
-
http2 (0.0.
|
17
|
+
gtk2 (1.1.4)
|
18
|
+
atk (>= 1.1.4)
|
19
|
+
gdk_pixbuf2 (>= 1.1.4)
|
20
|
+
pango (>= 1.1.4)
|
21
|
+
http2 (0.0.5)
|
22
22
|
jeweler (1.8.4)
|
23
23
|
bundler (~> 1.0)
|
24
24
|
git (>= 1.2.5)
|
25
25
|
rake
|
26
26
|
rdoc
|
27
|
-
json (1.7.
|
28
|
-
knjrbfw (0.0.
|
27
|
+
json (1.7.4)
|
28
|
+
knjrbfw (0.0.78)
|
29
29
|
datet
|
30
30
|
http2
|
31
|
+
php4r
|
31
32
|
tsafe
|
32
33
|
wref
|
33
34
|
locale (2.0.5)
|
34
|
-
pango (1.1.
|
35
|
+
pango (1.1.4)
|
35
36
|
cairo (>= 1.10.0)
|
36
|
-
glib2 (>= 1.1.
|
37
|
-
|
37
|
+
glib2 (>= 1.1.4)
|
38
|
+
php4r (0.0.2)
|
39
|
+
datet
|
40
|
+
http2
|
41
|
+
pkg-config (1.1.4)
|
38
42
|
rake (0.9.2.2)
|
39
43
|
rdoc (3.12)
|
40
44
|
json (~> 1.4)
|
@@ -48,8 +52,8 @@ GEM
|
|
48
52
|
diff-lcs (~> 1.1.2)
|
49
53
|
rspec-mocks (2.8.0)
|
50
54
|
sqlite3 (1.3.6)
|
51
|
-
tsafe (0.0.
|
52
|
-
wref (0.0.
|
55
|
+
tsafe (0.0.11)
|
56
|
+
wref (0.0.5)
|
53
57
|
|
54
58
|
PLATFORMS
|
55
59
|
ruby
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.26
|
data/gui/trayicon.rb
CHANGED
@@ -60,10 +60,10 @@ class Openall_time_applet::Gui::Trayicon
|
|
60
60
|
|
61
61
|
#Generate image.
|
62
62
|
require "RMagick"
|
63
|
-
canvas = Magick::Image.new(53, 53)
|
63
|
+
canvas = Magick::Image.new(53, 53) do
|
64
64
|
self.background_color = "transparent"
|
65
65
|
self.format = "png"
|
66
|
-
|
66
|
+
end
|
67
67
|
|
68
68
|
color = "#a1a80a" if color == "green_casalogic"
|
69
69
|
|
@@ -86,9 +86,7 @@ class Openall_time_applet::Gui::Trayicon
|
|
86
86
|
|
87
87
|
def on_statusicon_rightclick(tray, button, time)
|
88
88
|
menu = Gtk::Menu.new
|
89
|
-
|
90
|
-
#Make a list of all timelogs in the menu.
|
91
|
-
@args[:oata].ob.list(:Timelog, "parent_timelog_id" => 0, "orderby" => "id") do |timelog|
|
89
|
+
@args[:oata].trayicon_timelogs do |timelog|
|
92
90
|
label = timelog.descr_short
|
93
91
|
|
94
92
|
#If this is the active timelog, make the label bold, by getting the label-child and using HTML-markup on it.
|
data/gui/win_main.rb
CHANGED
@@ -7,6 +7,7 @@ class Openall_time_applet::Gui::Win_main
|
|
7
7
|
@gui = Gtk::Builder.new.add("#{File.dirname(__FILE__)}/../glade/win_main.glade")
|
8
8
|
@gui.translate
|
9
9
|
@gui.connect_signals{|h| method(h)}
|
10
|
+
@gui["window"].icon = "#{File.dirname(__FILE__)}/../gfx/icon_time_black.png"
|
10
11
|
|
11
12
|
|
12
13
|
#Generate list-store containing tasks for the task-column.
|
@@ -299,7 +300,7 @@ class Openall_time_applet::Gui::Win_main
|
|
299
300
|
@gui["tvTimelogsPrepareTransfer"].model.clear
|
300
301
|
@timelogs_sync_count = 0
|
301
302
|
|
302
|
-
@args[:oata].ob.list(:Timelog,
|
303
|
+
@args[:oata].ob.list(:Timelog, "sync_need" => 1, "task_id_not" => ["", 0], "orderby" => "timestamp") do |timelog|
|
303
304
|
#Read time and transport from timelog.
|
304
305
|
time = timelog[:time].to_i
|
305
306
|
transport = timelog[:time_transport].to_i
|
@@ -400,7 +401,7 @@ class Openall_time_applet::Gui::Win_main
|
|
400
401
|
def reload_timelogs
|
401
402
|
return nil if @dont_reload or @gui["tvTimelogs"].destroyed?
|
402
403
|
@gui["tvTimelogs"].model.clear
|
403
|
-
@args[:oata].ob.list(:Timelog, "orderby" => [
|
404
|
+
@args[:oata].ob.list(:Timelog, "orderby" => ["task_id", "descr", "timestamp"]) do |timelog|
|
404
405
|
begin
|
405
406
|
tstamp_str = timelog.timestamp_str
|
406
407
|
rescue => e
|
data/gui/win_preferences.rb
CHANGED
@@ -7,6 +7,7 @@ class Openall_time_applet::Gui::Win_preferences
|
|
7
7
|
@gui = Gtk::Builder.new.add("../glade/win_preferences.glade")
|
8
8
|
@gui.translate
|
9
9
|
@gui.connect_signals{|h| method(h)}
|
10
|
+
@gui["window"].icon = "#{File.dirname(__FILE__)}/../gfx/icon_time_black.png"
|
10
11
|
|
11
12
|
self.load_values
|
12
13
|
|
@@ -47,7 +48,7 @@ class Openall_time_applet::Gui::Win_preferences
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def on_btnReminderSave_clicked
|
50
|
-
if !
|
51
|
+
if !(Float(@gui["txtReminderEveryMinute"].text) rescue false)
|
51
52
|
Knj::Gtk2.msgbox(_("Reminder-minute was not numeric."))
|
52
53
|
return nil
|
53
54
|
end
|
@@ -106,7 +107,7 @@ class Openall_time_applet::Gui::Win_preferences
|
|
106
107
|
|
107
108
|
def on_btnAutoSyncSave_clicked
|
108
109
|
interval = @gui["txtAutoSyncInterval"].text
|
109
|
-
if !
|
110
|
+
if !(Float(interval) rescue false)
|
110
111
|
Knj::Gtk2.msgbox(_("The interval was not numeric."))
|
111
112
|
return false
|
112
113
|
end
|
@@ -8,6 +8,7 @@ class Openall_time_applet::Gui::Win_worktime_overview
|
|
8
8
|
@gui = Gtk::Builder.new.add("../glade/win_worktime_overview.glade")
|
9
9
|
@gui.translate
|
10
10
|
@gui.connect_signals{|h| method(h)}
|
11
|
+
@gui["window"].icon = "#{File.dirname(__FILE__)}/../gfx/icon_time_black.png"
|
11
12
|
|
12
13
|
@date = Datet.new
|
13
14
|
self.build_week
|
data/lib/openall_time_applet.rb
CHANGED
@@ -283,7 +283,7 @@ class Openall_time_applet
|
|
283
283
|
end
|
284
284
|
|
285
285
|
#Synchronizes organisations, tasks and worktimes.
|
286
|
-
def sync_static(args =
|
286
|
+
def sync_static(args = {})
|
287
287
|
sw = Knj::Gtk2::StatusWindow.new("transient_for" => args["transient_for"])
|
288
288
|
|
289
289
|
return Knj::Thread.new do
|
@@ -469,6 +469,22 @@ class Openall_time_applet
|
|
469
469
|
win_main.gui["statusbar"].push(0, newstatus)
|
470
470
|
end
|
471
471
|
end
|
472
|
+
|
473
|
+
def trayicon_timelogs
|
474
|
+
yielded_titles = {}
|
475
|
+
|
476
|
+
#Make a list of all timelogs in the menu.
|
477
|
+
@ob.list(:Timelog, "parent_timelog_id" => 0, "orderby" => "descr") do |timelog|
|
478
|
+
task_id = timelog[:task_id].to_i
|
479
|
+
yielded_titles[task_id] = {} if !yielded_titles.key?(task_id)
|
480
|
+
|
481
|
+
title = timelog.descr_short.strip.downcase
|
482
|
+
next if yielded_titles[task_id].key?(title)
|
483
|
+
yielded_titles[task_id][title] = true
|
484
|
+
|
485
|
+
yield(timelog)
|
486
|
+
end
|
487
|
+
end
|
472
488
|
end
|
473
489
|
|
474
490
|
#Gettext support.
|
data/models/timelog.rb
CHANGED
@@ -28,26 +28,28 @@ class Openall_time_applet::Models::Timelog < Knj::Datarow
|
|
28
28
|
def self.push_time_updates(d, args)
|
29
29
|
args[:oata].oa_conn do |conn|
|
30
30
|
#Go through timelogs that needs syncing and has a task set.
|
31
|
-
self.ob.list(:Timelog,
|
31
|
+
self.ob.list(:Timelog, "sync_need" => 1, "task_id_not" => ["", 0]) do |timelog|
|
32
32
|
secs_sum = timelog[:time_sync].to_i + timelog[:time_transport].to_i
|
33
33
|
next if secs_sum <= 0 or !timelog.task
|
34
34
|
|
35
|
+
post_hash = {
|
36
|
+
:task_uid => timelog.task[:openall_uid].to_i,
|
37
|
+
:comment => timelog[:descr],
|
38
|
+
:worktime => Knj::Strings.secs_to_human_time_str(timelog[:time_sync]),
|
39
|
+
:workinternal => timelog[:workinternal],
|
40
|
+
:timestamp => timelog[:timestamp],
|
41
|
+
:timetype => timelog[:timetype],
|
42
|
+
:transporttime => Knj::Strings.secs_to_human_time_str(timelog[:time_transport]),
|
43
|
+
:transportlength => timelog[:transportlength].to_i,
|
44
|
+
:transportcosts => timelog[:transportcosts].to_i,
|
45
|
+
:transportdescription => timelog[:transportdescription],
|
46
|
+
:travelfixed => timelog[:travelfixed]
|
47
|
+
}
|
48
|
+
|
35
49
|
#The timelog has not yet been created in OpenAll - create it!
|
36
50
|
res = conn.request(
|
37
51
|
:method => :createWorktime,
|
38
|
-
:post =>
|
39
|
-
:task_uid => timelog.task[:openall_uid].to_i,
|
40
|
-
:comment => timelog[:descr],
|
41
|
-
:worktime => Knj::Strings.secs_to_human_time_str(timelog[:time]),
|
42
|
-
:workinternal => timelog[:workinternal],
|
43
|
-
:timestamp => timelog[:timestamp],
|
44
|
-
:timetype => timelog[:timetype],
|
45
|
-
:transporttime => Knj::Strings.secs_to_human_time_str(timelog[:time_transport]),
|
46
|
-
:transportlength => timelog[:transportlength].to_i,
|
47
|
-
:transportcosts => timelog[:transportcosts].to_i,
|
48
|
-
:transportdescription => timelog[:transportdescription],
|
49
|
-
:travelfixed => timelog[:travelfixed]
|
50
|
-
}
|
52
|
+
:post => post_hash
|
51
53
|
)
|
52
54
|
|
53
55
|
parent_timelog = timelog.parent_timelog
|
data/openall_time_applet.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{openall_time_applet}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.26"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kasper Johansen"]
|
12
|
-
s.date = %q{2012-
|
12
|
+
s.date = %q{2012-08-04}
|
13
13
|
s.description = %q{Off-line time-tracking for OpenAll with syncing when online.}
|
14
14
|
s.email = %q{k@spernj.org}
|
15
15
|
s.executables = ["OpenAll Timelogging", "openall_time_applet.rb"]
|
@@ -54,7 +54,9 @@ Gem::Specification.new do |s|
|
|
54
54
|
"models/worktime.rb",
|
55
55
|
"openall_time_applet.gemspec",
|
56
56
|
"spec/openall_time_applet_spec.rb",
|
57
|
-
"spec/spec_helper.rb"
|
57
|
+
"spec/spec_helper.rb",
|
58
|
+
"spec/sync_spec.rb",
|
59
|
+
"spec/tray_timelogs_spec.rb"
|
58
60
|
]
|
59
61
|
s.homepage = %q{http://github.com/kaspernj/openall_time_applet}
|
60
62
|
s.licenses = ["MIT"]
|
@@ -102,6 +102,15 @@ describe "OpenallTimeApplet" do
|
|
102
102
|
raise "Timelog was not deleted." if !timelog.deleted?
|
103
103
|
end
|
104
104
|
|
105
|
+
it "should only return a specific amount of timelogs for tray-icon" do
|
106
|
+
count = 0
|
107
|
+
$oata.trayicon_timelogs do |timelog|
|
108
|
+
count += 1
|
109
|
+
end
|
110
|
+
|
111
|
+
print "Count: #{count}\n"
|
112
|
+
end
|
113
|
+
|
105
114
|
it "should remove the temp db" do
|
106
115
|
File.unlink($tmp_path) if File.exists?($tmp_path)
|
107
116
|
end
|
data/spec/sync_spec.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "OpenallTimeApplet" do
|
4
|
+
it "should be able to start" do
|
5
|
+
begin
|
6
|
+
$tmp_path = "/tmp/openall_spec.sqlite3"
|
7
|
+
File.unlink($tmp_path) if File.exists?($tmp_path)
|
8
|
+
Openall_time_applet::CONFIG[:db_path] = $tmp_path
|
9
|
+
$oata = Openall_time_applet.new
|
10
|
+
|
11
|
+
Knj::Opts.set("openall_host", "192.168.56.54")
|
12
|
+
Knj::Opts.set("openall_port", 80)
|
13
|
+
Knj::Opts.set("openall_username", "kaspernj")
|
14
|
+
Knj::Opts.set("openall_password", Base64.strict_encode64("123"))
|
15
|
+
Knj::Opts.set("openall_ssl", 0)
|
16
|
+
rescue Exception => e
|
17
|
+
STDOUT.print Knj::Errors.error_str(e)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should only return a specific amount of timelogs for tray-icon" do
|
22
|
+
$oata.sync_static
|
23
|
+
sleep 1
|
24
|
+
raise "A new message box was shown: '#{Knj::Gtk2::Msgbox.cur_label}'." if Knj::Gtk2::Msgbox.shown?
|
25
|
+
|
26
|
+
task = $oata.ob.get_by(:Task, "openall_uid_not" => ["", 0])
|
27
|
+
raise "No task could be found?" if !task
|
28
|
+
|
29
|
+
idstr = Digest::MD5.hexdigest(Time.now.to_f.to_s)
|
30
|
+
titlestr = "Tlog test #{idstr}"
|
31
|
+
|
32
|
+
tlog = $oata.ob.add(:Timelog,
|
33
|
+
:descr => titlestr,
|
34
|
+
:sync_need => 1,
|
35
|
+
:task_id => task.id,
|
36
|
+
:time => Knj::Strings.human_time_str_to_secs("01:30:15"),
|
37
|
+
:time_sync => Knj::Strings.human_time_str_to_secs("01:30:30")
|
38
|
+
)
|
39
|
+
|
40
|
+
$oata.sync_real
|
41
|
+
$oata.sync_static
|
42
|
+
sleep 1
|
43
|
+
|
44
|
+
worktime = $oata.ob.get_by(:Worktime, "comment" => titlestr)
|
45
|
+
raise "Could not find synced worktime." if !worktime
|
46
|
+
raise "Expected synced worktime to be '5430' but it was '#{worktime[:worktime]}'." if worktime[:worktime].to_i != 5430
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should remove the temp db" do
|
50
|
+
File.unlink($tmp_path) if File.exists?($tmp_path)
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "OpenallTimeApplet" do
|
4
|
+
it "should be able to start" do
|
5
|
+
$tmp_path = "/tmp/openall_spec.sqlite3"
|
6
|
+
File.unlink($tmp_path) if File.exists?($tmp_path)
|
7
|
+
Openall_time_applet::CONFIG[:db_path] = $tmp_path
|
8
|
+
$oata = Openall_time_applet.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should only return a specific amount of timelogs for tray-icon" do
|
12
|
+
task1 = $oata.ob.add(:Task, :title => "Task 1")
|
13
|
+
task2 = $oata.ob.add(:Task, :title => "Task 2")
|
14
|
+
|
15
|
+
tlog1 = $oata.ob.add(:Timelog, :descr => "Tlog 1", :task_id => task1.id)
|
16
|
+
tlog2 = $oata.ob.add(:Timelog, :descr => "Tlog 1", :task_id => task1.id)
|
17
|
+
tlog3 = $oata.ob.add(:Timelog, :descr => "Tlog 1", :task_id => task2.id)
|
18
|
+
tlog4 = $oata.ob.add(:Timelog, :descr => "Tlog 4", :task_id => task2.id)
|
19
|
+
|
20
|
+
count = 0
|
21
|
+
$oata.trayicon_timelogs do |timelog|
|
22
|
+
count += 1
|
23
|
+
end
|
24
|
+
|
25
|
+
raise "Expected count 3 but got #{count}." if count != 3
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should remove the temp db" do
|
29
|
+
File.unlink($tmp_path) if File.exists?($tmp_path)
|
30
|
+
end
|
31
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: openall_time_applet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.26
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kasper Johansen
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-08-04 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -193,6 +193,8 @@ files:
|
|
193
193
|
- openall_time_applet.gemspec
|
194
194
|
- spec/openall_time_applet_spec.rb
|
195
195
|
- spec/spec_helper.rb
|
196
|
+
- spec/sync_spec.rb
|
197
|
+
- spec/tray_timelogs_spec.rb
|
196
198
|
has_rdoc: true
|
197
199
|
homepage: http://github.com/kaspernj/openall_time_applet
|
198
200
|
licenses:
|
@@ -207,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
207
209
|
requirements:
|
208
210
|
- - ">="
|
209
211
|
- !ruby/object:Gem::Version
|
210
|
-
hash: -
|
212
|
+
hash: -1135881411050114948
|
211
213
|
segments:
|
212
214
|
- 0
|
213
215
|
version: "0"
|