navilocal 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/application/lib/common_functions.rb +56 -0
- data/application/models/settings.rb +85 -0
- data/application/ui/navi/account_configuration.rb +67 -0
- data/application/ui/navi/agreement.rb +55 -0
- data/application/ui/navi/application.rb +42 -0
- data/application/ui/navi/destination_select.rb +47 -0
- data/application/ui/navi/install_summary.rb +120 -0
- data/application/ui/navi/installer_assistant.rb +174 -0
- data/application/ui/navi/main_runner.rb +224 -0
- data/application/ui/navi/navi_install.rb +230 -0
- data/application/ui/navi/splash.rb +115 -0
- data/bin/navilocal +12 -8
- data/gresource.bin +0 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63013a4268bf0f72217ed82bea6c171986343c42
|
4
|
+
data.tar.gz: a11148916ac42fe7034b5587881b689e8dd261ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64caf8ecc662ab8f626231a24c481b0e28739191aaf76c48dbf325cb9955631d0aba9e2d2224eda02b719793d657b8b870cedb5924fb2a2e7cb1c195224ed671
|
7
|
+
data.tar.gz: e186941a3b4b7fe4de3c153dba7a868ebdb8cd0b8076aa8e9b143bd7aed2c14b78bb6c91b7449cd9b02ce59ac5d36b0102f4f4b6079d3dee7012ee085c16905a
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module CommonFunctions
|
2
|
+
|
3
|
+
def create_tags(buffer)
|
4
|
+
buffer.create_tag("double_spaced_line",
|
5
|
+
"pixels_inside_wrap" => 2)
|
6
|
+
buffer.create_tag("large_spaced_line",
|
7
|
+
"pixels_inside_wrap" => 8)
|
8
|
+
buffer.create_tag("wide_margins",
|
9
|
+
"left_margin" => 18,
|
10
|
+
"right_margin" => 18)
|
11
|
+
buffer.create_tag("bold",
|
12
|
+
"weight" => :bold)
|
13
|
+
|
14
|
+
buffer.create_tag("big",
|
15
|
+
# points times the PANGO_SCALE factor
|
16
|
+
"size" => 20 * Pango::SCALE)
|
17
|
+
|
18
|
+
buffer.create_tag("large-size",
|
19
|
+
"size" => 18 * Pango::SCALE)
|
20
|
+
|
21
|
+
buffer.create_tag("large",
|
22
|
+
"size" => 14 * Pango::SCALE)
|
23
|
+
|
24
|
+
buffer.create_tag("normal-size",
|
25
|
+
"size" => 12 * Pango::SCALE)
|
26
|
+
|
27
|
+
buffer.create_tag("xx-small",
|
28
|
+
"scale" => :xx_small)
|
29
|
+
|
30
|
+
buffer.create_tag("x-large",
|
31
|
+
"scale" => :x_large)
|
32
|
+
|
33
|
+
buffer.create_tag("monospace", "family" => "monospace")
|
34
|
+
|
35
|
+
buffer.create_tag("grey_foreground", "foreground" => "#7a7a7a")
|
36
|
+
|
37
|
+
buffer.create_tag("cyan_foreground", "foreground" => "#4093D3")
|
38
|
+
|
39
|
+
buffer.create_tag("red_background", "background" => "red")
|
40
|
+
|
41
|
+
buffer.create_tag("big_gap_before_line",
|
42
|
+
"pixels_above_lines" => 30)
|
43
|
+
|
44
|
+
buffer.create_tag("big_gap_after_line",
|
45
|
+
"pixels_below_lines" => 30)
|
46
|
+
end
|
47
|
+
|
48
|
+
def apply_css(widget, provider)
|
49
|
+
widget.style_context.add_provider(provider, Gtk::StyleProvider::PRIORITY_USER)
|
50
|
+
if widget.is_a?(Gtk::Container)
|
51
|
+
widget.each_all do |child|
|
52
|
+
apply_css(child, provider)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module NaviClientInstaller
|
5
|
+
class Settings
|
6
|
+
PROPERTIES = [:provider, :username, :password, :agreement, :location, :creation_datetime, :last_modified, :download_path, :install, :hash, :client_log_file, :training_data_file, :ai_log_file].freeze
|
7
|
+
|
8
|
+
PRIORITIES = ['high', 'medium', 'normal', 'low'].freeze
|
9
|
+
|
10
|
+
DEFAULT_STORAGE = File.expand_path File.join('~', '.navi')
|
11
|
+
|
12
|
+
attr_accessor *PROPERTIES
|
13
|
+
|
14
|
+
def initialize(options = {})
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
# if user_data_path = options[:user_data_path]
|
19
|
+
# # New item. When saved, it will be placed under the :user_data_path value
|
20
|
+
# @id = SecureRandom.uuid
|
21
|
+
# @creation_datetime = Time.now.to_s
|
22
|
+
# @filename = "#{user_data_path}/#{id}.json"
|
23
|
+
# elsif filename = options[:filename]
|
24
|
+
# # Load an existing item
|
25
|
+
# load_from_file filename
|
26
|
+
# else
|
27
|
+
# raise ArgumentError, 'Please specify the :user_data_path for new item or the :filename to load existing'
|
28
|
+
# end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Loads an item from a file
|
32
|
+
def load_from_file_json(filename)
|
33
|
+
properties = JSON.parse(File.read(filename))
|
34
|
+
|
35
|
+
# Assign the properties
|
36
|
+
PROPERTIES.each do |property|
|
37
|
+
self.send "#{property}=", properties[property.to_s]
|
38
|
+
end
|
39
|
+
rescue => e
|
40
|
+
raise ArgumentError, "Failed to load existing item: #{e.message}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def load_from_file_yaml(filename)
|
44
|
+
properties = YAML.load_file(filename)
|
45
|
+
# Assign the properties
|
46
|
+
PROPERTIES.each do |property|
|
47
|
+
self.send "#{property}=", properties[property.to_s]
|
48
|
+
end
|
49
|
+
rescue => e
|
50
|
+
# raise ArgumentError, "Failed to load existing item: #{e.message}"
|
51
|
+
end
|
52
|
+
|
53
|
+
# Resolves if an item is new
|
54
|
+
def is_new?
|
55
|
+
!File.exists? @filename
|
56
|
+
end
|
57
|
+
|
58
|
+
# Saves an item to its `filename` location
|
59
|
+
def save!
|
60
|
+
File.open(@filename, 'w') do |file|
|
61
|
+
file.write self.to_json
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def save_settings location = NaviClientInstaller::Settings::DEFAULT_STORAGE + '/config.yml'
|
66
|
+
File.open(location, 'w') { |f| YAML.dump(self.to_props, f) }
|
67
|
+
end
|
68
|
+
|
69
|
+
# Deletes an item
|
70
|
+
def delete!
|
71
|
+
raise 'Item is not saved!' if is_new?
|
72
|
+
|
73
|
+
File.delete(@filename)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Produces a json string for the item
|
77
|
+
def to_props
|
78
|
+
result = {}
|
79
|
+
PROPERTIES.each do |prop|
|
80
|
+
result[prop.to_s] = self.send prop
|
81
|
+
end
|
82
|
+
result
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative '../../lib/common_functions'
|
2
|
+
module NaviClientInstaller
|
3
|
+
class AccountConfiguration
|
4
|
+
attr_accessor :window_ui
|
5
|
+
include CommonFunctions
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
def initialize(settings, next_btn)
|
10
|
+
builder = Gtk::Builder.new(:resource => '/com/navi/navi-client/ui/account_configuration.ui')
|
11
|
+
css_provider = Gtk::CssProvider.new
|
12
|
+
css_provider.load(:resource_path => '/com/navi/navi-client/css/main.css')
|
13
|
+
|
14
|
+
@window_ui = builder.get_object("box_ac_container")
|
15
|
+
label_top = builder.get_object("label_ac_title")
|
16
|
+
@combo_text_provider = builder.get_object("combo_text_ac_provider")
|
17
|
+
@entry_email = builder.get_object("entry_email")
|
18
|
+
@entry_password = builder.get_object("entry_password")
|
19
|
+
# @settings = settings
|
20
|
+
#
|
21
|
+
@entry_email.set_text settings.username unless settings.username.nil?
|
22
|
+
@entry_password.set_text settings.password unless settings.password.nil?
|
23
|
+
|
24
|
+
item = @combo_text_provider.model.iter_first
|
25
|
+
while ( @combo_text_provider.model.iter_next(item) )
|
26
|
+
@combo_text_provider.set_active item.path.to_s.to_i if (item.get_value 1) == settings.provider
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
view_info = builder.get_object("view_info")
|
31
|
+
|
32
|
+
|
33
|
+
view_info.buffer.insert(view_info.buffer.get_iter_at(:offset => 0), "Please enter your email address which you want to associate with NAVI")
|
34
|
+
|
35
|
+
|
36
|
+
@combo_text_provider.signal_connect "changed" do |widget|
|
37
|
+
settings.provider = widget.active_iter.get_value(1)
|
38
|
+
prepare_ui next_btn
|
39
|
+
end
|
40
|
+
|
41
|
+
@entry_password.signal_connect "changed" do |widget|
|
42
|
+
settings.password= widget.text
|
43
|
+
prepare_ui next_btn
|
44
|
+
end
|
45
|
+
|
46
|
+
@entry_email.signal_connect "changed" do |widget|
|
47
|
+
settings.username = widget.text
|
48
|
+
prepare_ui next_btn
|
49
|
+
end
|
50
|
+
|
51
|
+
white = Gdk::RGBA::new(1, 1, 1, 1.0)
|
52
|
+
@window_ui.override_background_color(:normal, white)
|
53
|
+
|
54
|
+
apply_css @combo_text_provider, css_provider
|
55
|
+
|
56
|
+
label_top.style_context.add_provider(css_provider, Gtk::StyleProvider::PRIORITY_USER)
|
57
|
+
@window_ui.style_context.add_provider(css_provider, Gtk::StyleProvider::PRIORITY_USER)
|
58
|
+
#
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
def prepare_ui(nxt_btn, prev_btn = nil)
|
63
|
+
valid = !@entry_email.text.empty? && !@entry_password.text.empty? && !@combo_text_provider.active_iter.get_value(1).nil?
|
64
|
+
nxt_btn.set_sensitive valid
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require_relative '../../lib/common_functions'
|
2
|
+
module NaviClientInstaller
|
3
|
+
class AgreementWindow
|
4
|
+
|
5
|
+
attr_accessor :window_ui
|
6
|
+
|
7
|
+
include CommonFunctions
|
8
|
+
|
9
|
+
def initialize(values, btn_next = nil)
|
10
|
+
builder = Gtk::Builder.new(:resource => '/com/navi/navi-client/ui/agreement.ui')
|
11
|
+
agreementTextContent = Gio::Resources.lookup_data("/com/navi/navi-client/texts/agreement_main_content.html", 0)
|
12
|
+
css_provider = Gtk::CssProvider.new
|
13
|
+
css_provider.load(:resource_path => '/com/navi/navi-client/css/main.css')
|
14
|
+
|
15
|
+
@window_ui = builder.get_object("box_agreement_container")
|
16
|
+
id_agreement_label = builder.get_object("id_agreement_label")
|
17
|
+
box_agreement_container = builder.get_object("box_agreement_container")
|
18
|
+
view_info = builder.get_object("view_info")
|
19
|
+
tv_agreement_main_content = builder.get_object("tv_agreement_main_content")
|
20
|
+
@rb_ac_agree = builder.get_object("rb_ac_agree")
|
21
|
+
rb_ac_disagree = builder.get_object("rb_ac_disagree")
|
22
|
+
white = Gdk::RGBA::new(1, 1, 1, 1.0)
|
23
|
+
|
24
|
+
@rb_ac_agree.set_active(values.agreement == true)
|
25
|
+
|
26
|
+
@rb_ac_agree.signal_connect("toggled") {|button|
|
27
|
+
btn_next.set_sensitive(button.active?)
|
28
|
+
values.agreement = button.active?
|
29
|
+
}
|
30
|
+
|
31
|
+
agreementTextContent = Gio::Resources.lookup_data("/com/navi/navi-client/texts/agreement_main_content.html", 0)
|
32
|
+
|
33
|
+
|
34
|
+
apply_css tv_agreement_main_content, css_provider
|
35
|
+
|
36
|
+
box_agreement_container.override_background_color(:normal, white)
|
37
|
+
create_tags(view_info.buffer)
|
38
|
+
create_tags(tv_agreement_main_content.buffer)
|
39
|
+
view_info.buffer.insert(view_info.buffer.get_iter_at(:offset => 0), "Please take a moment to read the license agreement now. If you accept the terms below click 'I agree' then 'Next', otherwise 'Cancel'.",
|
40
|
+
:tags => %w(double_spaced_line wide_margins normal-size))
|
41
|
+
|
42
|
+
tv_agreement_main_content.buffer.insert_markup(tv_agreement_main_content.buffer.get_iter_at(:offset => 0), agreementTextContent)
|
43
|
+
id_agreement_label.style_context.add_provider(css_provider, Gtk::StyleProvider::PRIORITY_USER)
|
44
|
+
@rb_ac_agree.style_context.add_provider(css_provider, Gtk::StyleProvider::PRIORITY_USER)
|
45
|
+
rb_ac_disagree.style_context.add_provider(css_provider, Gtk::StyleProvider::PRIORITY_USER)
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
def prepare_ui(nxt_btn, prev_btn=nil)
|
50
|
+
nxt_btn.set_sensitive @rb_ac_agree.active?
|
51
|
+
prev_btn.set_opacity 0
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module NaviClientInstaller
|
2
|
+
class Application < Gtk::Application
|
3
|
+
|
4
|
+
attr_reader :user_data_path
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super 'com.local.desktop-app', Gio::ApplicationFlags::FLAGS_NONE
|
8
|
+
|
9
|
+
@user_data_path = File.expand_path('~/.navi')
|
10
|
+
unless File.file?(@user_data_path + '/config.yml')
|
11
|
+
FileUtils.mkdir_p(@user_data_path)
|
12
|
+
File.write(@user_data_path + '/config.yml', '')
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
signal_connect :activate do |application|
|
17
|
+
|
18
|
+
window = NaviClientInstaller::InstallerMain.new(application)
|
19
|
+
window.set_size_request(400, 0)
|
20
|
+
window.set_title 'Navi'
|
21
|
+
window.set_window_position Gtk::WindowPosition::CENTER
|
22
|
+
window.present
|
23
|
+
|
24
|
+
window.signal_connect("destroy") {|button|
|
25
|
+
|
26
|
+
# kill naviai process
|
27
|
+
navi_path = File.join NaviClientInstaller::Settings::DEFAULT_STORAGE , 'bin', 'naviai_pid.tmp'
|
28
|
+
begin
|
29
|
+
Process.kill('QUIT', File.read(navi_path).to_i) if File.file? navi_path
|
30
|
+
rescue Errno::ESRCH
|
31
|
+
# process exited normally
|
32
|
+
rescue
|
33
|
+
ensure
|
34
|
+
FileUtils.rm_f navi_path
|
35
|
+
end
|
36
|
+
}
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require_relative '../../lib/common_functions'
|
2
|
+
|
3
|
+
module NaviClientInstaller
|
4
|
+
class DestinationSelect
|
5
|
+
|
6
|
+
attr_accessor :window_ui
|
7
|
+
|
8
|
+
include CommonFunctions
|
9
|
+
|
10
|
+
def initialize(settings, next_btn)
|
11
|
+
builder = Gtk::Builder.new(:resource => '/com/navi/navi-client/ui/destination_select.ui')
|
12
|
+
css_provider = Gtk::CssProvider.new
|
13
|
+
css_provider.load(:resource_path => '/com/navi/navi-client/css/main.css')
|
14
|
+
|
15
|
+
@window_ui = builder.get_object("box_ds_container")
|
16
|
+
file_chooser = builder.get_object("fc_ds_destination")
|
17
|
+
rb_ds_custom = builder.get_object("rb_ds_custom")
|
18
|
+
file_chooser.filename = NaviClientInstaller::Settings::DEFAULT_STORAGE
|
19
|
+
settings.location = NaviClientInstaller::Settings::DEFAULT_STORAGE
|
20
|
+
|
21
|
+
file_chooser.signal_connect "file-set" do |widget|
|
22
|
+
settings.location = widget.filename
|
23
|
+
end
|
24
|
+
|
25
|
+
view_info = builder.get_object("view_ds_note")
|
26
|
+
view_info.buffer.insert(view_info.buffer.get_iter_at(:offset => 0), "Please choose your location, where do you want to install NAVI.")
|
27
|
+
white = Gdk::RGBA::new(1, 1, 1, 1.0)
|
28
|
+
@window_ui.override_background_color(:normal, white)
|
29
|
+
|
30
|
+
rb_ds_custom.signal_connect("toggled") {|button|
|
31
|
+
if(!button.active?)
|
32
|
+
file_chooser.filename = NaviClientInstaller::Settings::DEFAULT_STORAGE
|
33
|
+
settings.location = file_chooser.filename
|
34
|
+
end
|
35
|
+
file_chooser.set_sensitive(button.active?)
|
36
|
+
}
|
37
|
+
|
38
|
+
apply_css @window_ui, css_provider
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
def prepare_ui(nxt_btn, prev_btn = nil)
|
43
|
+
nxt_btn.set_sensitive true
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
require_relative '../../lib/common_functions'
|
2
|
+
|
3
|
+
module NaviClientInstaller
|
4
|
+
class NaviInstallSummary
|
5
|
+
|
6
|
+
attr_accessor :window_ui
|
7
|
+
|
8
|
+
include CommonFunctions
|
9
|
+
|
10
|
+
@replace_string = false
|
11
|
+
|
12
|
+
|
13
|
+
def initialize(settings, next_btn)
|
14
|
+
builder = Gtk::Builder.new(:resource => '/com/navi/navi-client/ui/install_summary.ui')
|
15
|
+
css_provider = Gtk::CssProvider.new
|
16
|
+
css_provider.load(:resource_path => '/com/navi/navi-client/css/main.css')
|
17
|
+
|
18
|
+
@window_ui = builder.get_object("box_summary_container")
|
19
|
+
|
20
|
+
view_summary = builder.get_object("view_summary_note")
|
21
|
+
|
22
|
+
@hand_cursor = Gdk::Cursor.new(Gdk::CursorType::HAND2, :display => view_summary.display)
|
23
|
+
@regular_cursor = Gdk::Cursor.new(Gdk::CursorType::XTERM, :display => view_summary.display)
|
24
|
+
|
25
|
+
create_tags( view_summary.buffer)
|
26
|
+
iter = view_summary.buffer.get_iter_at(:offset => 0)
|
27
|
+
view_summary.buffer.insert(iter, "The Software was installed. You'll be prompted when NAVI app updates are available. Always install updates to get the latest information and security improvements.",
|
28
|
+
:tags => %w(large_spaced_line large-size grey_foreground))
|
29
|
+
view_summary.buffer.insert(iter, " Learn More.",
|
30
|
+
:tags => %w(large_spaced_line large-size cyan_foreground), :page =>1)
|
31
|
+
|
32
|
+
# grey_foregroundview_summary.buffer.insert_markup(view_summary.buffer.get_iter_at(:offset => 0), "<span rise='10000' color='#7a7a7a' size='large'>The Software was installed. You'll be prompted when NAVI app updates are available. Always install updates to get the latest information and security improvements. <a href='google.com'>Learn more.</a></span>")
|
33
|
+
#
|
34
|
+
#
|
35
|
+
|
36
|
+
|
37
|
+
view_summary.signal_connect "motion-notify-event" do |widget, event|
|
38
|
+
x, y = widget.window_to_buffer_coords(:widget, event.x, event.y)
|
39
|
+
set_cursor_if_appropriate(widget, x, y)
|
40
|
+
widget.window.pointer
|
41
|
+
false
|
42
|
+
end
|
43
|
+
|
44
|
+
view_summary.signal_connect "key-press-event" do |_widget, event|
|
45
|
+
|
46
|
+
case event.keyval
|
47
|
+
when Gdk::Keyval::KEY_Return, Gdk::Keyval::KEY_KP_Enter
|
48
|
+
iter = view_summary.buffer.get_iter_at_mark(view_summary.buffer.get_mark("insert"))
|
49
|
+
follow_if_link(iter) if iter
|
50
|
+
end
|
51
|
+
false
|
52
|
+
end
|
53
|
+
|
54
|
+
# Links can also be activated by clicking or tapping.
|
55
|
+
view_summary.signal_connect "event-after" do |widget, event|
|
56
|
+
if event.is_a?(Gdk::EventButton) && event.button == 1
|
57
|
+
buffer = widget.buffer
|
58
|
+
# we shouldn't follow a link if the user has selected something
|
59
|
+
range = buffer.selection_bounds
|
60
|
+
# || range[0].offset != range[1].offset
|
61
|
+
|
62
|
+
if range.nil?
|
63
|
+
x, y = widget.window_to_buffer_coords(:widget, event.x, event.y)
|
64
|
+
iter = widget.get_iter_at_location(x, y)
|
65
|
+
follow_if_link(iter) if iter
|
66
|
+
end
|
67
|
+
false
|
68
|
+
else
|
69
|
+
false
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
apply_css @window_ui, css_provider
|
74
|
+
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
def prepare_ui(nxt_btn, prev_btn = nil)
|
81
|
+
# btn.set_sensitive true
|
82
|
+
prev_btn.set_opacity 0
|
83
|
+
prev_btn.set_sensitive false
|
84
|
+
nxt_btn.set_sensitive true
|
85
|
+
nxt_btn.set_label "Open Navi"
|
86
|
+
end
|
87
|
+
|
88
|
+
def follow_if_link(iter)
|
89
|
+
tags = iter.tags
|
90
|
+
tags.each do |tag|
|
91
|
+
if tag.name == 'cyan_foreground'
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
break
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def set_cursor_if_appropriate(text_view, x, y)
|
101
|
+
iter = text_view.get_iter_at_location(x, y)
|
102
|
+
return unless iter
|
103
|
+
hovering = false
|
104
|
+
tags = iter.tags
|
105
|
+
tags.each do |tag|
|
106
|
+
if tag.name == 'cyan_foreground'
|
107
|
+
hovering = true
|
108
|
+
break
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
if hovering != @hovering
|
113
|
+
@hovering = hovering
|
114
|
+
window = text_view.get_window(:text)
|
115
|
+
window.cursor = @hovering ? @hand_cursor : @regular_cursor
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,174 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require_relative '../../lib/common_functions'
|
3
|
+
|
4
|
+
module NaviClientInstaller
|
5
|
+
class InstallerMain < Gtk::ApplicationWindow
|
6
|
+
|
7
|
+
include CommonFunctions
|
8
|
+
|
9
|
+
type_register
|
10
|
+
|
11
|
+
class << self
|
12
|
+
def init
|
13
|
+
# Set the template from the resources binary
|
14
|
+
set_template resource: '/com/navi/navi-client/ui/installer_main.ui'
|
15
|
+
bind_template_child 'main_stack'
|
16
|
+
bind_template_child 'bbox_navigation'
|
17
|
+
bind_template_child 'btn_next'
|
18
|
+
bind_template_child 'btn_back'
|
19
|
+
bind_template_child 'btn_cancel'
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def initialize(application)
|
25
|
+
super application: application
|
26
|
+
|
27
|
+
css_provider = Gtk::CssProvider.new
|
28
|
+
css_provider.load(:resource_path => '/com/navi/navi-client/css/main.css')
|
29
|
+
|
30
|
+
@settings = NaviClientInstaller::Settings.new
|
31
|
+
@settings.load_from_file_yaml(NaviClientInstaller::Settings::DEFAULT_STORAGE + '/config.yml')
|
32
|
+
@settings.creation_datetime = Time.now.to_s if @settings.creation_datetime.nil?
|
33
|
+
|
34
|
+
@splash = NaviClientInstaller::SplashWindow.new @settings
|
35
|
+
main_stack.add_named(@splash.window_ui, "splash")
|
36
|
+
|
37
|
+
# setupMainApp
|
38
|
+
initiate_splash
|
39
|
+
|
40
|
+
|
41
|
+
apply_css bbox_navigation, css_provider
|
42
|
+
end
|
43
|
+
|
44
|
+
def initiate_splash
|
45
|
+
bbox_navigation.set_visible false
|
46
|
+
main_stack.set_visible_child(@splash.window_ui)
|
47
|
+
|
48
|
+
if @settings.install
|
49
|
+
setupMainApp
|
50
|
+
else
|
51
|
+
setupInstallerSteps
|
52
|
+
endSplash
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def endSplash()
|
59
|
+
|
60
|
+
Thread.new do
|
61
|
+
# duration for the splash screen
|
62
|
+
sleep 3
|
63
|
+
# your code here
|
64
|
+
main_stack.set_transition_type(Gtk::Stack::TransitionType::SLIDE_RIGHT)
|
65
|
+
@current_window.prepare_ui btn_next, btn_back
|
66
|
+
main_stack.set_visible_child(@current_window.window_ui)
|
67
|
+
|
68
|
+
bbox_navigation.set_visible !@settings.install
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
def setupMainApp()
|
75
|
+
|
76
|
+
@runner_window = NaviClientInstaller::NaviRunner.new @settings
|
77
|
+
main_stack.add_named(@runner_window.window_ui, "signup")
|
78
|
+
|
79
|
+
resp = @splash.validate_email( @settings.username, @settings.hash)
|
80
|
+
|
81
|
+
if(@settings.hash && resp.code == 200)
|
82
|
+
@current_window = @runner_window
|
83
|
+
@runner_window.set_token resp["access_token"]
|
84
|
+
@runner_window.start
|
85
|
+
endSplash
|
86
|
+
# main_stack.set_visible_child(@splash.window_ui)
|
87
|
+
|
88
|
+
else
|
89
|
+
Thread.new do
|
90
|
+
# duration for the splash screen
|
91
|
+
gaussian = Proc.new do |dist, *args|
|
92
|
+
# @current_window.prepare_ui btn_next, btn_back
|
93
|
+
@current_window = @runner_window
|
94
|
+
@runner_window.set_token args.first
|
95
|
+
main_stack.set_transition_type(Gtk::Stack::TransitionType::SLIDE_RIGHT)
|
96
|
+
main_stack.set_visible_child(@current_window.window_ui)
|
97
|
+
@runner_window.start
|
98
|
+
end
|
99
|
+
sleep 3
|
100
|
+
@splash.initiate_signup gaussian
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
def setupInstallerSteps()
|
107
|
+
@step_licence_agreement = NaviClientInstaller::AgreementWindow.new @settings, btn_next
|
108
|
+
@step_account_configuration = NaviClientInstaller::AccountConfiguration.new @settings, btn_next
|
109
|
+
@step_destination_select = NaviClientInstaller::DestinationSelect.new @settings, btn_next
|
110
|
+
@step_navi_install = NaviClientInstaller::NaviInstall.new @settings, btn_next
|
111
|
+
@step_navi_install_summary = NaviClientInstaller::NaviInstallSummary.new @settings, btn_next
|
112
|
+
|
113
|
+
|
114
|
+
@current_window = recover_state
|
115
|
+
|
116
|
+
@steps = [ @step_licence_agreement, @step_account_configuration, @step_destination_select, @step_navi_install, @step_navi_install_summary]
|
117
|
+
|
118
|
+
|
119
|
+
# main_stack.add_named(@splash.window_ui, "splash")
|
120
|
+
main_stack.add_named(@step_licence_agreement.window_ui, "agreement")
|
121
|
+
main_stack.add_named(@step_account_configuration.window_ui, "account_configuration")
|
122
|
+
main_stack.add_named(@step_destination_select.window_ui, "destination_select")
|
123
|
+
main_stack.add_named(@step_navi_install.window_ui, "navi_install")
|
124
|
+
main_stack.add_named(@step_navi_install_summary.window_ui, "navi_install_summary")
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
btn_next.signal_connect 'clicked' do |button|
|
129
|
+
renderSteps 1, Gtk::Stack::TransitionType::SLIDE_RIGHT
|
130
|
+
end
|
131
|
+
|
132
|
+
btn_cancel.signal_connect 'clicked' do |button|
|
133
|
+
close
|
134
|
+
end
|
135
|
+
|
136
|
+
btn_back.signal_connect 'clicked' do |button|
|
137
|
+
renderSteps -1, Gtk::Stack::TransitionType::SLIDE_LEFT
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def renderSteps(factor, transistion_type)
|
142
|
+
index = @steps.find_index(@current_window)
|
143
|
+
index+=factor
|
144
|
+
|
145
|
+
if index == @steps.length
|
146
|
+
initiate_splash
|
147
|
+
elsif index < @steps.length && index > -1
|
148
|
+
main_stack.set_transition_type(transistion_type)
|
149
|
+
@current_window = @steps[index]
|
150
|
+
|
151
|
+
@settings.save_settings if factor == 1
|
152
|
+
|
153
|
+
btn_back.set_opacity 1
|
154
|
+
btn_back.set_sensitive true
|
155
|
+
@current_window.prepare_ui btn_next, btn_back
|
156
|
+
main_stack.set_visible_child(@current_window.window_ui)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def recover_state
|
161
|
+
if @settings.agreement != true
|
162
|
+
@step_licence_agreement
|
163
|
+
elsif @settings.username.nil? || @settings.password.nil? || @settings.provider.nil?
|
164
|
+
@step_account_configuration
|
165
|
+
elsif @settings.location.nil? || @settings.download_path.nil?
|
166
|
+
@step_destination_select
|
167
|
+
else
|
168
|
+
@step_navi_install
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
@@ -0,0 +1,224 @@
|
|
1
|
+
require_relative '../../lib/common_functions'
|
2
|
+
require 'navi_client'
|
3
|
+
require 'httparty'
|
4
|
+
|
5
|
+
module NaviClientInstaller
|
6
|
+
class NaviRunner
|
7
|
+
|
8
|
+
attr_accessor :window_ui
|
9
|
+
|
10
|
+
include CommonFunctions
|
11
|
+
|
12
|
+
def initialize(settings, token=nil)
|
13
|
+
builder = Gtk::Builder.new(:resource => '/com/navi/navi-client/ui/main/main_runner.ui')
|
14
|
+
css_provider = Gtk::CssProvider.new
|
15
|
+
css_provider.load(:resource_path => '/com/navi/navi-client/css/main.css')
|
16
|
+
@window_ui = builder.get_object("box_main_container")
|
17
|
+
@log_display = builder.get_object("tv_runner_logs")
|
18
|
+
@scroll_control = builder.get_object("scrollview_runner_logs")
|
19
|
+
@notifier = builder.get_object("label_progress_notifier")
|
20
|
+
@email_indicator = builder.get_object("label-email-indicator")
|
21
|
+
|
22
|
+
image = builder.get_object("app_logo")
|
23
|
+
image.set_from_resource('/com/navi/navi-client/images/navi-logo-small.png')
|
24
|
+
|
25
|
+
stack = builder.get_object("app_stack")
|
26
|
+
|
27
|
+
@settings = settings
|
28
|
+
@token = token
|
29
|
+
apply_css @window_ui, css_provider
|
30
|
+
|
31
|
+
@iter_log = @log_display.buffer.get_iter_at(:offset => 0)
|
32
|
+
|
33
|
+
@log_display.signal_connect 'size-allocate' do |button|
|
34
|
+
adj = @scroll_control.vadjustment
|
35
|
+
adj.set_value( adj.upper - adj.page_size )
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
def watch_for(file,pattern)
|
47
|
+
f = File.open(file,"r")
|
48
|
+
|
49
|
+
# Since this file exists and is growing, seek to the end of the most recent entry
|
50
|
+
f.seek(0,IO::SEEK_END)
|
51
|
+
|
52
|
+
|
53
|
+
while true
|
54
|
+
select([f])
|
55
|
+
puts "Found it!" unless f.gets.nil?
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def start
|
60
|
+
Thread.new do
|
61
|
+
starts
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def starts
|
68
|
+
|
69
|
+
env = "development"
|
70
|
+
@client = NaviClient::Local.new("http://localhost:3008", "local", "https://api2.navihq.com/v2/generate_csv_input", true, env)
|
71
|
+
@client.set_token "Token: #{@token}##{@settings.username}"
|
72
|
+
@logger = CustomLogger.new @log_display.buffer, @iter_log, @client.logger
|
73
|
+
@client.override_logger @logger
|
74
|
+
|
75
|
+
#logging to loggly
|
76
|
+
logToLoggly = false
|
77
|
+
if logToLoggly
|
78
|
+
@client.setupLoggly("navi-client")
|
79
|
+
end
|
80
|
+
|
81
|
+
@logger.debug "Running the process.. #{@token}"
|
82
|
+
@logger.debug "Connecting to imap server with your local config."
|
83
|
+
|
84
|
+
@notifier.label = "Configuring the system.."
|
85
|
+
imap = @client.imap_connection(@settings.provider, @settings.username, @settings.password, false)
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
if @client.errors.nil?
|
91
|
+
|
92
|
+
@logger.debug "Complete. OK..."
|
93
|
+
|
94
|
+
filenames = []
|
95
|
+
dateStarted = DateTime.now
|
96
|
+
@logger.debug "Syncing started at #{dateStarted}"
|
97
|
+
@client.logToLoggly({event:"EMAIL_SYNC_STARTED", env: env, storage: "local", email: @settings.username})
|
98
|
+
|
99
|
+
sendEmailCompletedEvent = true
|
100
|
+
folder = "Test"
|
101
|
+
|
102
|
+
|
103
|
+
#this block of code is repeated. Need to change in navi_client gem for that
|
104
|
+
imap.examine folder
|
105
|
+
total = imap.uid_search(['ALL']).size
|
106
|
+
downloaded = @client.getMessageUUIds("#{@settings.download_path}#{@settings.username}/meta/").size
|
107
|
+
downloaded = downloaded - 2 if downloaded > 1
|
108
|
+
|
109
|
+
@email_indicator.label = "#{downloaded}/#{total}"
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
begin
|
114
|
+
start_naviai
|
115
|
+
@notifier.label = "Checking for previous failures.."
|
116
|
+
|
117
|
+
@client.parse_prev_failed_emails
|
118
|
+
@notifier.label = "Fetching emails..."
|
119
|
+
@client.retrieve_emails(imap, ['ALL'], folder) do |mail, index, isLast, id|
|
120
|
+
|
121
|
+
@logger.debug "processing email##{index + 1} with id #{mail.__id__.to_s} and uuid #{id}"
|
122
|
+
|
123
|
+
filenames << @client.process_email(mail, id)
|
124
|
+
downloaded+=1
|
125
|
+
@email_indicator.label = "#{downloaded}/#{total}"
|
126
|
+
|
127
|
+
@logger.debug "Processing Complete. OK..."
|
128
|
+
|
129
|
+
if filenames.size == 10 || isLast
|
130
|
+
sendEmailCompletedEvent = !sendEmailCompletedEvent
|
131
|
+
|
132
|
+
@logger.debug "Sending Bulk Request for #{isLast ? filenames.size : 10} emails to Navi AI."
|
133
|
+
@notifier.label = "Parsing the emails..."
|
134
|
+
|
135
|
+
@client.send_request(filenames)
|
136
|
+
|
137
|
+
@logger.debug "Complete Ok... continue email sync"
|
138
|
+
@notifier.label = "Fetching emails..."
|
139
|
+
# verify
|
140
|
+
filenames = []
|
141
|
+
if sendEmailCompletedEvent && !isLast
|
142
|
+
@client.logToLoggly({event:"EMAIL_SYNC_IN_PROGRESS", env: env, storage: "local", email: @settings.username, emailCount: index + 1})
|
143
|
+
# exit
|
144
|
+
elsif isLast
|
145
|
+
|
146
|
+
dateEnded = DateTime.now
|
147
|
+
totalTimeInSecs = (dateEnded - dateStarted) * 24 * 60 * 60
|
148
|
+
|
149
|
+
@client.logToLoggly({event:"EMAIL_SYNC_FINISHED", env: env, storage: "local", email: @settings.username, emailCount: index + 1, time_elapsed: totalTimeInSecs.to_f.round(2)})
|
150
|
+
@logger.debug "#{index + 1} emails from the #{folder} has been downloaded. OK"
|
151
|
+
@logger.debug "started: #{dateStarted.to_s} , ended: #{dateEnded.to_s}, Total time: #{totalTimeInSecs.to_f.round(2)} secs"
|
152
|
+
end
|
153
|
+
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
|
158
|
+
|
159
|
+
@logger.debug "All emails sync and parse completed."
|
160
|
+
|
161
|
+
@notifier.label = "Finalizing..."
|
162
|
+
|
163
|
+
@client.initate_csv_generation(@settings.username)
|
164
|
+
|
165
|
+
@notifier.label = "Waiting for the new emails.."
|
166
|
+
@client.idle_loop(imap, ['UNSEEN'], folder, @settings.provider, @settings.username, @settings.password)
|
167
|
+
|
168
|
+
imap.logout
|
169
|
+
imap.disconnect
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
rescue => e
|
174
|
+
@logger.debug "#{e.message}"
|
175
|
+
end
|
176
|
+
|
177
|
+
|
178
|
+
else
|
179
|
+
@logger.debug "Failed to connect with your email. Please recheck the configuration."
|
180
|
+
end
|
181
|
+
|
182
|
+
end
|
183
|
+
|
184
|
+
|
185
|
+
def prepare_ui btn_next, btn_back
|
186
|
+
|
187
|
+
end
|
188
|
+
|
189
|
+
def set_token token
|
190
|
+
@token = token
|
191
|
+
end
|
192
|
+
|
193
|
+
def start_naviai
|
194
|
+
navi_path = NaviClientInstaller::Settings::DEFAULT_STORAGE
|
195
|
+
|
196
|
+
pid = spawn("#{navi_path}/bin/naviai", :out => "#{navi_path}/bin/test.out", :err => "#{navi_path}/bin/test.err")
|
197
|
+
|
198
|
+
File.open("#{navi_path}/bin/naviai_pid.tmp", 'w') { |file| file.write(pid) }
|
199
|
+
|
200
|
+
Process.detach(pid)
|
201
|
+
end
|
202
|
+
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
class CustomLogger
|
207
|
+
def initialize buffer, iterator, logger = nil
|
208
|
+
@logger_custom = logger
|
209
|
+
@buffer = buffer
|
210
|
+
@iter = iterator
|
211
|
+
end
|
212
|
+
|
213
|
+
def info msg
|
214
|
+
p msg
|
215
|
+
@buffer.insert_markup(@iter, "#{msg}\n")
|
216
|
+
@logger_custom.info msg
|
217
|
+
end
|
218
|
+
|
219
|
+
def debug msg
|
220
|
+
p msg
|
221
|
+
@buffer.insert_markup(@iter, "#{msg}\n")
|
222
|
+
@logger_custom.debug msg
|
223
|
+
end
|
224
|
+
end
|
@@ -0,0 +1,230 @@
|
|
1
|
+
require_relative '../../lib/common_functions'
|
2
|
+
|
3
|
+
module NaviClientInstaller
|
4
|
+
class NaviInstall
|
5
|
+
|
6
|
+
attr_accessor :window_ui
|
7
|
+
|
8
|
+
include CommonFunctions
|
9
|
+
|
10
|
+
@replace_string = false
|
11
|
+
|
12
|
+
|
13
|
+
def initialize(settings, next_btn)
|
14
|
+
builder = Gtk::Builder.new(:resource => '/com/navi/navi-client/ui/navi_install.ui')
|
15
|
+
css_provider = Gtk::CssProvider.new
|
16
|
+
css_provider.load(:resource_path => '/com/navi/navi-client/css/main.css')
|
17
|
+
@log_storage = NaviClientInstaller::Settings::DEFAULT_STORAGE + '/screen.log'
|
18
|
+
@settings = settings
|
19
|
+
@no_steps = 3
|
20
|
+
@fraction = 1/3.to_f
|
21
|
+
@install = false
|
22
|
+
|
23
|
+
@limit_progress = 0
|
24
|
+
|
25
|
+
@window_ui = builder.get_object("box_ni_container")
|
26
|
+
|
27
|
+
@view_info = builder.get_object("view_ni_note")
|
28
|
+
@log_display = builder.get_object("tv_ni_log_display")
|
29
|
+
@text_display = builder.get_object("view_ni_update_info")
|
30
|
+
@scroll_control = builder.get_object("scrollview_ni_log")
|
31
|
+
@hide_control = builder.get_object("btn_ni_show")
|
32
|
+
@progress_indicator = builder.get_object("pbar_ni_indicator")
|
33
|
+
@view_info.buffer.insert(@view_info.buffer.get_iter_at(:offset => 0), "Installing navi components, this may take a while....")
|
34
|
+
|
35
|
+
@log_display.signal_connect 'size-allocate' do |button|
|
36
|
+
new_logs_update
|
37
|
+
end
|
38
|
+
|
39
|
+
@hide_control.signal_connect 'clicked' do |button|
|
40
|
+
|
41
|
+
@scroll_control.set_visible !@scroll_control.visible?
|
42
|
+
@hide_control.label = @scroll_control.visible? ? 'Hide Details' : 'Show Details'
|
43
|
+
end
|
44
|
+
|
45
|
+
@iter_log = @log_display.buffer.get_iter_at(:offset => 0)
|
46
|
+
|
47
|
+
@log_display.buffer.insert_markup(@iter_log, "Starting the process...\n")
|
48
|
+
|
49
|
+
|
50
|
+
apply_css @window_ui, css_provider
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def prepare_ui(nxt_btn, prev_btn = nil)
|
55
|
+
# btn.set_sensitive true
|
56
|
+
@next = nxt_btn
|
57
|
+
@settings.download_path = File.join(@settings.location, 'downloads', '')
|
58
|
+
@settings.client_log_file = File.join(NaviClientInstaller::Settings::DEFAULT_STORAGE, 'logs', 'client.log')
|
59
|
+
@settings.ai_log_file = File.join(NaviClientInstaller::Settings::DEFAULT_STORAGE, 'logs', 'ai.log')
|
60
|
+
@settings.training_data_file = File.join(NaviClientInstaller::Settings::DEFAULT_STORAGE, 'WIKI-models', '')
|
61
|
+
@settings.save_settings
|
62
|
+
prev_btn.set_opacity 0
|
63
|
+
prev_btn.set_sensitive false
|
64
|
+
nxt_btn.set_sensitive false
|
65
|
+
download
|
66
|
+
end
|
67
|
+
|
68
|
+
def download
|
69
|
+
|
70
|
+
#need to force stop this thread if it is closed suddenly by the user
|
71
|
+
Thread.new do
|
72
|
+
read_logs
|
73
|
+
configure_ai
|
74
|
+
install_mitie
|
75
|
+
download_wiki_models
|
76
|
+
finalize
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
def configure_ai
|
82
|
+
@limit_progress = @progress_indicator.fraction + @fraction
|
83
|
+
@text_display.set_text "Configuring naviai..."
|
84
|
+
@log_display.buffer.insert_markup(@iter_log, "Configuring ai..\n")
|
85
|
+
|
86
|
+
unless File.file?(File.expand_path File.join(NaviClientInstaller::Settings::DEFAULT_STORAGE,'bin', 'naviai'))
|
87
|
+
%x(rm -rf #{NaviClientInstaller::Settings::DEFAULT_STORAGE}/bin/naviai*)
|
88
|
+
|
89
|
+
|
90
|
+
url= %x(uname).gsub(/\s+/, "") == 'Darwin' ? "https://s3.amazonaws.com/locallockbox/naviaiDarwin.zip" : "https://s3.amazonaws.com/locallockbox/naviai.zip"
|
91
|
+
FileUtils.mkdir_p(NaviClientInstaller::Settings::DEFAULT_STORAGE + '/bin')
|
92
|
+
# @replace_string = true
|
93
|
+
%x(curl -o #{NaviClientInstaller::Settings::DEFAULT_STORAGE}/bin/naviai.zip #{url} 2>&1 | tee #{@log_storage})
|
94
|
+
# @replace_string = false
|
95
|
+
|
96
|
+
%x(unzip -a #{NaviClientInstaller::Settings::DEFAULT_STORAGE}/bin/naviai.zip -d #{NaviClientInstaller::Settings::DEFAULT_STORAGE}/bin/ 2>&1 | tee #{@log_storage})
|
97
|
+
%x(chmod 777 #{NaviClientInstaller::Settings::DEFAULT_STORAGE}/bin/naviai)
|
98
|
+
%x(rm -rf #{NaviClientInstaller::Settings::DEFAULT_STORAGE}/bin/naviai.zip 2>&1 | tee #{@log_storage})
|
99
|
+
|
100
|
+
@log_display.buffer.insert_markup(@iter_log, "Done Configuring ai..\n")
|
101
|
+
else
|
102
|
+
@log_display.buffer.insert_markup(@iter_log, "Ai already installed...forwarding to the next step\n")
|
103
|
+
end
|
104
|
+
@progress_indicator.fraction = @limit_progress
|
105
|
+
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
def install_mitie()
|
110
|
+
@text_display.set_text "Installing mitie..."
|
111
|
+
@limit_progress = @progress_indicator.fraction + @fraction
|
112
|
+
if %x(uname).gsub(/\s+/, "") == 'Darwin'
|
113
|
+
@log_display.buffer.insert_markup(@iter_log, "Installing mitie...\n")
|
114
|
+
%x(brew install mitie 2>&1 | tee #{@log_storage})
|
115
|
+
# sleep 3
|
116
|
+
append_logs
|
117
|
+
|
118
|
+
@log_display.buffer.insert_markup(@iter_log, "Finished Updating Home brew...\n")
|
119
|
+
|
120
|
+
else
|
121
|
+
@log_display.buffer.insert_markup(@iter_log, "Mitie not installed. Install it manually...\n")
|
122
|
+
end
|
123
|
+
@progress_indicator.fraction = @limit_progress
|
124
|
+
end
|
125
|
+
|
126
|
+
def download_wiki_models
|
127
|
+
@text_display.set_text "Downloading wiki models.."
|
128
|
+
@limit_progress = @progress_indicator.fraction + @fraction
|
129
|
+
@log_display.buffer.insert_markup(@iter_log, "Downloading wiki models\n")
|
130
|
+
|
131
|
+
models_storage = File.expand_path File.join(NaviClientInstaller::Settings::DEFAULT_STORAGE,'WIKI-models')
|
132
|
+
|
133
|
+
unless File.directory?(models_storage)
|
134
|
+
wiki_url = "https://s3.amazonaws.com/locallockbox/naviaiDarwin.zip"
|
135
|
+
# wiki_url = "https://s3.amazonaws.com/locallockbox/WIKI-models.zip"
|
136
|
+
#
|
137
|
+
%x(rm -rf #{models_storage}*)
|
138
|
+
|
139
|
+
%x(curl -o #{models_storage}.zip #{wiki_url} 2>&1 | tee #{@log_storage})
|
140
|
+
%x(unzip -a #{models_storage}.zip -d #{NaviClientInstaller::Settings::DEFAULT_STORAGE} 2>&1 | tee #{@log_storage})
|
141
|
+
%x(rm -rf #{models_storage}.zip 2>&1 | tee #{@log_storage})
|
142
|
+
else
|
143
|
+
@log_display.buffer.insert_markup(@iter_log, "Wiki models already downloaded.\n")
|
144
|
+
end
|
145
|
+
|
146
|
+
|
147
|
+
@progress_indicator.fraction = @limit_progress
|
148
|
+
@text_display.set_text "Installation Complete..."
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
def new_logs_update
|
154
|
+
adj = @scroll_control.vadjustment
|
155
|
+
adj.set_value( adj.upper - adj.page_size )
|
156
|
+
end
|
157
|
+
|
158
|
+
def read_logs
|
159
|
+
Thread.new do
|
160
|
+
loop do
|
161
|
+
Thread.exit if @window_ui.destroyed? || @install
|
162
|
+
append_logs
|
163
|
+
# sleep 0.1
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
def append_logs
|
170
|
+
File.open(@log_storage, 'a+') { |file|
|
171
|
+
contents = file.read
|
172
|
+
|
173
|
+
if contents.gsub(/\s+/, "") != ""
|
174
|
+
file.truncate(0)
|
175
|
+
if @replace_string
|
176
|
+
|
177
|
+
if !@last.nil?
|
178
|
+
itercpy = @iter_log.copy
|
179
|
+
itercpy.set_line(@last)
|
180
|
+
@log_display.buffer.delete(itercpy, @iter_log)
|
181
|
+
end
|
182
|
+
@last = @iter_log.line
|
183
|
+
else
|
184
|
+
@last = nil
|
185
|
+
end
|
186
|
+
|
187
|
+
if(@progress_indicator.fraction < @limit_progress*0.8 )
|
188
|
+
@progress_indicator.fraction+=0.001
|
189
|
+
end
|
190
|
+
@log_display.buffer.insert_markup(@iter_log, contents.gsub("\u0000", '') + "\n")
|
191
|
+
|
192
|
+
end
|
193
|
+
}
|
194
|
+
end
|
195
|
+
|
196
|
+
def finalize
|
197
|
+
setup_navi_path
|
198
|
+
@next.set_sensitive true
|
199
|
+
@next.set_label "Finish"
|
200
|
+
@install = true
|
201
|
+
@settings.install = true
|
202
|
+
@settings.save_settings
|
203
|
+
|
204
|
+
@view_info.buffer.set_text ""
|
205
|
+
end
|
206
|
+
|
207
|
+
def setup_navi_path
|
208
|
+
|
209
|
+
if %x(echo $SHELL ).strip == "/bin/zsh"
|
210
|
+
loc = %x(zsh -c 'source $HOME/.zshrc; ${=alias=echo $NAVI_PATH}')
|
211
|
+
if loc.strip.length == 0
|
212
|
+
%x(echo "export NAVI_PATH=$HOME/.navi" >> $HOME/.zshrc)
|
213
|
+
%x(echo "export NAVI_ENV=local" >> $HOME/.zshrc)
|
214
|
+
system("source $HOME/.zshrc")
|
215
|
+
end
|
216
|
+
else
|
217
|
+
if %x(echo $NAVI_PATH).strip.length == 0
|
218
|
+
%x(echo "export NAVI_PATH=$HOME/.navi" >> ~/.bashrc)
|
219
|
+
%x(echo "export NAVI_ENV=local" >> ~/.bashrc)
|
220
|
+
system("source ~/.bashrc")
|
221
|
+
end
|
222
|
+
|
223
|
+
end
|
224
|
+
|
225
|
+
end
|
226
|
+
|
227
|
+
@last
|
228
|
+
|
229
|
+
end
|
230
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require_relative '../../lib/common_functions'
|
2
|
+
require 'httparty'
|
3
|
+
module NaviClientInstaller
|
4
|
+
class SplashWindow
|
5
|
+
|
6
|
+
attr_accessor :window_ui
|
7
|
+
|
8
|
+
include CommonFunctions
|
9
|
+
|
10
|
+
def initialize(settings=nil)
|
11
|
+
@builder = Gtk::Builder.new(:resource => '/com/navi/navi-client/ui/splash.ui')
|
12
|
+
css_provider = Gtk::CssProvider.new
|
13
|
+
css_provider.load(:resource_path => '/com/navi/navi-client/css/main.css')
|
14
|
+
@settings = settings
|
15
|
+
|
16
|
+
@window_ui = @builder.get_object("box_splash")
|
17
|
+
|
18
|
+
splash_image = @builder.get_object("splash_image")
|
19
|
+
splash_image.set_from_resource('/com/navi/navi-client/images/navi-logo.png')
|
20
|
+
|
21
|
+
@count =1
|
22
|
+
@timeout = GLib::Timeout.add(690) do
|
23
|
+
|
24
|
+
screen = @builder.get_object("spash_revealer")
|
25
|
+
screen.reveal_child = true
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
apply_css @window_ui, css_provider
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
def validate_email(email, pass)
|
35
|
+
response = HTTParty.post("http://localhost:3008/oauth/token",
|
36
|
+
body: {
|
37
|
+
email: email, # get from sso_web application
|
38
|
+
password: pass,
|
39
|
+
grant_type: "password"
|
40
|
+
}
|
41
|
+
)
|
42
|
+
response
|
43
|
+
end
|
44
|
+
|
45
|
+
def initiate_signup callback
|
46
|
+
|
47
|
+
login_info = @builder.get_object("view_splash_info")
|
48
|
+
@spinner = @builder.get_object("spinner_splash_loader")
|
49
|
+
@error_label = @builder.get_object("label_splash_error")
|
50
|
+
# @spinner.active = true
|
51
|
+
|
52
|
+
email_entry = @builder.get_object("entry_splash_email")
|
53
|
+
@password_entry = @builder.get_object("entry_splash_pass")
|
54
|
+
@signup_control = @builder.get_object("box_splash_login")
|
55
|
+
email_entry.set_text @settings.username
|
56
|
+
|
57
|
+
@password_entry.signal_connect("activate") {|widget|
|
58
|
+
unless widget.text.empty?
|
59
|
+
@spinner.active = true
|
60
|
+
@password_entry.sensitive = false
|
61
|
+
|
62
|
+
|
63
|
+
response = validate_email @settings.username, widget.text
|
64
|
+
|
65
|
+
@spinner.active = false
|
66
|
+
@password_entry.sensitive = true
|
67
|
+
|
68
|
+
if response.code != 200
|
69
|
+
@error_label.set_opacity 1
|
70
|
+
else
|
71
|
+
@error_label.set_opacity 0
|
72
|
+
@settings.hash = widget.text
|
73
|
+
@settings.save_settings
|
74
|
+
callback.call response["access_token"]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
}
|
78
|
+
|
79
|
+
create_tags(login_info.buffer)
|
80
|
+
login_info.buffer.insert(login_info.buffer.get_iter_at(:offset => 0), "We need you to connect to our app. Please sign in. If you donot have the account already, please sign up first.",
|
81
|
+
:tags => %w(double_spaced_line large))
|
82
|
+
|
83
|
+
@signup_control.visible = true
|
84
|
+
end
|
85
|
+
|
86
|
+
def add_timeout
|
87
|
+
@timeout = GLib::Timeout.add(690) do
|
88
|
+
name = "revealer#{@count}"
|
89
|
+
|
90
|
+
revealer = @builder[name]
|
91
|
+
revealer.reveal_child = true
|
92
|
+
|
93
|
+
revealer.signal_connect "notify::child-revealed" do |widget|
|
94
|
+
if widget.mapped?
|
95
|
+
revealed = widget.child_revealed?
|
96
|
+
widget.reveal_child = !revealed
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
@count += 1
|
101
|
+
if @count >= 9
|
102
|
+
@timeout = nil
|
103
|
+
false
|
104
|
+
else
|
105
|
+
true
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
|
data/bin/navilocal
CHANGED
@@ -5,27 +5,31 @@ require 'fileutils'
|
|
5
5
|
|
6
6
|
|
7
7
|
# Require all ruby files in the application folder recursively
|
8
|
-
application_root_path = File.expand_path(
|
8
|
+
application_root_path = File.expand_path(__dir__).gsub("/bin", "")
|
9
9
|
Dir[File.join(application_root_path, '**', 'ui/navi/*.rb')].each { |file| require file }
|
10
10
|
Dir[File.join(application_root_path, '**', 'application/models/settings.rb')].each { |file| require file }
|
11
11
|
|
12
12
|
|
13
13
|
# Define the source & target files of the glib-compile-resources command
|
14
|
-
|
14
|
+
|
15
15
|
resource_bin = File.join(application_root_path, 'gresource.bin')
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
17
|
+
|
18
|
+
# resource_xml = File.join(application_root_path, 'resources', 'gresources.xml')
|
19
|
+
# # Build the binary
|
20
|
+
# system("glib-compile-resources",
|
21
|
+
# "--target", resource_bin,
|
22
|
+
# "--sourcedir", File.dirname(resource_xml),
|
23
|
+
# resource_xml)
|
24
|
+
|
25
|
+
|
22
26
|
|
23
27
|
resource = Gio::Resource.load(resource_bin)
|
24
28
|
Gio::Resources.register(resource)
|
25
29
|
|
26
30
|
at_exit do
|
27
31
|
# Before existing, please remove the binary we prodNced, thanks.
|
28
|
-
FileUtils.rm_f(resource_bin)
|
32
|
+
# FileUtils.rm_f(resource_bin)
|
29
33
|
end
|
30
34
|
|
31
35
|
|
data/gresource.bin
ADDED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: navilocal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Msanjib
|
@@ -73,7 +73,19 @@ executables:
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
+
- application/lib/common_functions.rb
|
77
|
+
- application/models/settings.rb
|
78
|
+
- application/ui/navi/account_configuration.rb
|
79
|
+
- application/ui/navi/agreement.rb
|
80
|
+
- application/ui/navi/application.rb
|
81
|
+
- application/ui/navi/destination_select.rb
|
82
|
+
- application/ui/navi/install_summary.rb
|
83
|
+
- application/ui/navi/installer_assistant.rb
|
84
|
+
- application/ui/navi/main_runner.rb
|
85
|
+
- application/ui/navi/navi_install.rb
|
86
|
+
- application/ui/navi/splash.rb
|
76
87
|
- bin/navilocal
|
88
|
+
- gresource.bin
|
77
89
|
homepage: http://rubygems.org/gems/navilocal
|
78
90
|
licenses:
|
79
91
|
- MIT
|
@@ -81,7 +93,7 @@ metadata: {}
|
|
81
93
|
post_install_message:
|
82
94
|
rdoc_options: []
|
83
95
|
require_paths:
|
84
|
-
-
|
96
|
+
- "."
|
85
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
86
98
|
requirements:
|
87
99
|
- - ">="
|