eco-helpers 2.0.16 → 2.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +125 -6
- data/eco-helpers.gemspec +10 -5
- data/lib/eco-helpers.rb +2 -0
- data/lib/eco/api/common/base_loader.rb +18 -0
- data/lib/eco/api/common/loaders/parser.rb +1 -0
- data/lib/eco/api/common/people/default_parsers.rb +1 -0
- data/lib/eco/api/common/people/default_parsers/date_parser.rb +11 -1
- data/lib/eco/api/common/people/default_parsers/login_providers_parser.rb +1 -1
- data/lib/eco/api/common/people/default_parsers/policy_groups_parser.rb +11 -11
- data/lib/eco/api/common/people/default_parsers/xls_parser.rb +53 -0
- data/lib/eco/api/common/people/entries.rb +1 -0
- data/lib/eco/api/common/people/entry_factory.rb +88 -23
- data/lib/eco/api/common/people/person_entry.rb +5 -2
- data/lib/eco/api/common/people/person_parser.rb +1 -1
- data/lib/eco/api/common/session.rb +1 -0
- data/lib/eco/api/common/session/base_session.rb +2 -0
- data/lib/eco/api/common/session/helpers.rb +30 -0
- data/lib/eco/api/common/session/helpers/prompt_user.rb +34 -0
- data/lib/eco/api/common/session/mailer.rb +0 -1
- data/lib/eco/api/common/session/s3_uploader.rb +0 -1
- data/lib/eco/api/common/session/sftp.rb +0 -1
- data/lib/eco/api/common/version_patches/ecoportal_api/external_person.rb +1 -1
- data/lib/eco/api/common/version_patches/ecoportal_api/internal_person.rb +7 -4
- data/lib/eco/api/common/version_patches/exception.rb +11 -4
- data/lib/eco/api/microcases.rb +3 -1
- data/lib/eco/api/microcases/append_usergroups.rb +0 -1
- data/lib/eco/api/microcases/people_cache.rb +2 -2
- data/lib/eco/api/microcases/people_load.rb +2 -2
- data/lib/eco/api/microcases/people_refresh.rb +2 -2
- data/lib/eco/api/microcases/people_search.rb +6 -6
- data/lib/eco/api/microcases/preserve_default_tag.rb +23 -0
- data/lib/eco/api/microcases/preserve_filter_tags.rb +28 -0
- data/lib/eco/api/microcases/preserve_policy_groups.rb +30 -0
- data/lib/eco/api/microcases/set_account.rb +0 -1
- data/lib/eco/api/microcases/with_each.rb +67 -6
- data/lib/eco/api/microcases/with_each_present.rb +4 -2
- data/lib/eco/api/microcases/with_each_starter.rb +4 -2
- data/lib/eco/api/organization.rb +1 -0
- data/lib/eco/api/organization/people.rb +98 -22
- data/lib/eco/api/organization/people_similarity.rb +272 -0
- data/lib/eco/api/organization/person_schemas.rb +5 -1
- data/lib/eco/api/organization/policy_groups.rb +5 -1
- data/lib/eco/api/organization/presets_factory.rb +22 -83
- data/lib/eco/api/organization/presets_integrity.json +6 -0
- data/lib/eco/api/organization/presets_values.json +5 -4
- data/lib/eco/api/organization/tag_tree.rb +33 -0
- data/lib/eco/api/policies/default_policies/99_user_access_policy.rb +0 -30
- data/lib/eco/api/session.rb +20 -28
- data/lib/eco/api/session/batch.rb +25 -7
- data/lib/eco/api/session/config.rb +0 -10
- data/lib/eco/api/session/config/apis.rb +80 -14
- data/lib/eco/api/session/config/people.rb +1 -17
- data/lib/eco/api/usecases.rb +2 -2
- data/lib/eco/api/usecases/base_case.rb +2 -2
- data/lib/eco/api/usecases/base_io.rb +17 -4
- data/lib/eco/api/usecases/default_cases.rb +2 -1
- data/lib/eco/api/usecases/default_cases/abstract_policygroup_abilities_case.rb +4 -4
- data/lib/eco/api/usecases/default_cases/analyse_people_case.rb +223 -0
- data/lib/eco/api/usecases/default_cases/clean_unknown_tags_case.rb +37 -0
- data/lib/eco/api/usecases/default_cases/codes_to_tags_case.rb +2 -3
- data/lib/eco/api/usecases/default_cases/reset_landing_page_case.rb +11 -1
- data/lib/eco/api/usecases/default_cases/restore_db_case.rb +1 -2
- data/lib/eco/api/usecases/default_cases/supers_cyclic_identify_case.rb +1 -1
- data/lib/eco/api/usecases/default_cases/supers_hierarchy_case.rb +1 -1
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +132 -29
- data/lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb +61 -36
- data/lib/eco/api/usecases/ooze_samples/ooze_update_case.rb +3 -2
- data/lib/eco/cli/config/default/input.rb +61 -8
- data/lib/eco/cli/config/default/options.rb +48 -17
- data/lib/eco/cli/config/default/people.rb +18 -24
- data/lib/eco/cli/config/default/people_filters.rb +3 -3
- data/lib/eco/cli/config/default/usecases.rb +97 -32
- data/lib/eco/cli/config/default/workflow.rb +22 -13
- data/lib/eco/cli/config/help.rb +1 -0
- data/lib/eco/cli/config/options_set.rb +106 -13
- data/lib/eco/cli/config/use_cases.rb +33 -33
- data/lib/eco/cli/scripting/args_helpers.rb +32 -5
- data/lib/eco/csv.rb +4 -2
- data/lib/eco/csv/table.rb +121 -21
- data/lib/eco/data.rb +1 -0
- data/lib/eco/data/crypto/encryption.rb +3 -3
- data/lib/eco/data/files/helpers.rb +6 -4
- data/lib/eco/data/fuzzy_match.rb +201 -0
- data/lib/eco/data/fuzzy_match/array_helpers.rb +75 -0
- data/lib/eco/data/fuzzy_match/chars_position_score.rb +38 -0
- data/lib/eco/data/fuzzy_match/ngrams_score.rb +82 -0
- data/lib/eco/data/fuzzy_match/pairing.rb +95 -0
- data/lib/eco/data/fuzzy_match/result.rb +87 -0
- data/lib/eco/data/fuzzy_match/results.rb +77 -0
- data/lib/eco/data/fuzzy_match/score.rb +49 -0
- data/lib/eco/data/fuzzy_match/stop_words.rb +35 -0
- data/lib/eco/data/fuzzy_match/string_helpers.rb +82 -0
- data/lib/eco/version.rb +1 -1
- metadata +147 -11
- data/lib/eco/api/microcases/refresh_abilities.rb +0 -19
- data/lib/eco/api/organization/presets_reference.json +0 -59
- data/lib/eco/api/usecases/default_cases/refresh_abilities_case.rb +0 -30
@@ -0,0 +1,37 @@
|
|
1
|
+
class Eco::API::UseCases::DefaultCases::CleanUnknownTags < Eco::API::Common::Loaders::UseCase
|
2
|
+
name "clean-unknown-tags"
|
3
|
+
type :transform
|
4
|
+
|
5
|
+
REGISTER_TAGS = [
|
6
|
+
"EVENT", "INJURY", "RISK", "CONTRACTOR", "PERMIT",
|
7
|
+
"AUDIT", "JSEA",
|
8
|
+
"TRAINING", "INDUCTION",
|
9
|
+
"MEETING", "PPE", "CHEMICAL",
|
10
|
+
"PLANT", "ASSET",
|
11
|
+
"POLICY", "IDEA", "REPORTS"
|
12
|
+
]
|
13
|
+
|
14
|
+
attr_reader :session, :options
|
15
|
+
|
16
|
+
def main(people, session, options, usecase)
|
17
|
+
@session = session; @options = options
|
18
|
+
|
19
|
+
update = session.new_job("main", "update", :update, usecase)
|
20
|
+
people.each do |person|
|
21
|
+
unknown_tags = person.filter_tags.select {|tag| !tag?(tag)}
|
22
|
+
person.filter_tags -= unknown_tags
|
23
|
+
update.add(person)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def tag?(value)
|
30
|
+
tagtree.tag?(value) || REGISTER_TAGS.any? {|reg| value == reg}
|
31
|
+
end
|
32
|
+
|
33
|
+
def tagtree
|
34
|
+
@tagtree ||= ASSETS.config.tagtree
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -16,10 +16,9 @@ class Eco::API::UseCases::DefaultCases::CodesToTagsCase < Eco::API::Common::Load
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def main(session, options, usecase)
|
19
|
-
|
20
|
-
@options = options
|
19
|
+
options[:end_get] = false
|
20
|
+
@session = session; @options = options
|
21
21
|
codes_to_tags
|
22
|
-
exit
|
23
22
|
end
|
24
23
|
|
25
24
|
private
|
@@ -2,13 +2,23 @@ class Eco::API::UseCases::DefaultCases::ResetLandingPageCase < Eco::API::Common:
|
|
2
2
|
name "reset-landing-page"
|
3
3
|
type :transform
|
4
4
|
|
5
|
+
attr_reader :session, :options
|
6
|
+
|
5
7
|
def main(people, session, options, usecase)
|
8
|
+
@session = session; @options = options
|
6
9
|
update = session.new_job("main", "update", :update, usecase, :core)
|
7
10
|
|
8
11
|
people.users.each do |user|
|
9
|
-
user.account.landing_page_id =
|
12
|
+
user.account.landing_page_id = page_id
|
10
13
|
update.add(user)
|
11
14
|
end
|
12
15
|
end
|
13
16
|
|
17
|
+
private
|
18
|
+
|
19
|
+
def page_id
|
20
|
+
options[:page_id]
|
21
|
+
end
|
22
|
+
|
23
|
+
|
14
24
|
end
|
@@ -59,7 +59,6 @@ class Eco::API::UseCases::DefaultCases::RestoreDBCase < Eco::API::Common::Loader
|
|
59
59
|
dst.policy_group_ids = src.policy_group_ids unless options.dig(:exclude, :policy_groups)
|
60
60
|
|
61
61
|
unless options.dig(:exclude, :abilities)
|
62
|
-
dst.permissions_preset = src.permissions_preset
|
63
62
|
dst.permissions_custom = src.permissions_custom
|
64
63
|
end
|
65
64
|
|
@@ -75,7 +74,7 @@ class Eco::API::UseCases::DefaultCases::RestoreDBCase < Eco::API::Common::Loader
|
|
75
74
|
dst.starred_ids = src.starred_ids
|
76
75
|
dst.landing_page_id = src.landing_page_id
|
77
76
|
end
|
78
|
-
|
77
|
+
|
79
78
|
dst&.send_invites = options[:send_invites] if options.key?(:send_invites)
|
80
79
|
end
|
81
80
|
end
|
@@ -5,10 +5,10 @@ class Eco::API::UseCases::DefaultCases::SupersCyclicIdentify < Eco::API::Common:
|
|
5
5
|
attr_reader :session, :people, :options
|
6
6
|
|
7
7
|
def main(people, session, options, usecase)
|
8
|
+
options[:end_get] = false
|
8
9
|
@session = session; @options = options; @people = people
|
9
10
|
|
10
11
|
save!(cyclic_sets)
|
11
|
-
exit(0)
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
@@ -5,10 +5,10 @@ class Eco::API::UseCases::DefaultCases::SupersHierarchy < Eco::API::Common::Load
|
|
5
5
|
attr_reader :session, :people, :options
|
6
6
|
|
7
7
|
def main(people, session, options, usecase)
|
8
|
+
options[:end_get] = false
|
8
9
|
@session = session; @options = options; @people = people
|
9
10
|
|
10
11
|
save!(hierarchy)
|
11
|
-
exit(0)
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
@@ -5,6 +5,7 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
5
5
|
attr_reader :session, :options, :people
|
6
6
|
|
7
7
|
def main(people, session, options, usecase)
|
8
|
+
options[:end_get] = false
|
8
9
|
@session = session; @options = options; @people = people
|
9
10
|
|
10
11
|
unless people && !people.empty?
|
@@ -12,25 +13,62 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
12
13
|
return false
|
13
14
|
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
if options.dig(:export, :options, :split_schemas)
|
17
|
+
by_schema.each do |id, people|
|
18
|
+
sch_name = schemas.to_name(id)
|
19
|
+
prefix = sch_name ? sch_name.gsub(" ", "_") : "No_Schema"
|
20
|
+
create_file!("#{prefix}_#{file}", people)
|
21
|
+
end
|
22
|
+
else
|
23
|
+
create_file!(file, people)
|
18
24
|
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
19
28
|
|
20
|
-
|
29
|
+
def create_file!(filename = file, data = people)
|
30
|
+
session.logger.info("going to create file: #{filename}")
|
21
31
|
|
22
|
-
CSV.open(
|
23
|
-
csv << spot_header
|
24
|
-
|
25
|
-
csv <<
|
32
|
+
CSV.open(filename, "w") do |csv|
|
33
|
+
csv << spot_header(data.first)
|
34
|
+
data.each do |person|
|
35
|
+
csv << to_row(person)
|
26
36
|
end
|
27
37
|
end
|
28
|
-
exit(0)
|
29
38
|
end
|
30
39
|
|
31
|
-
|
40
|
+
def to_row(person)
|
41
|
+
entry = to_entry_type(person)
|
42
|
+
entry.values_at(*keys(entry)).tap do |row|
|
43
|
+
row << schemas.to_name(person.details&.schema_id) || "No Schema"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def spot_header(person = people.first)
|
48
|
+
header = keys(to_entry_type(person))
|
49
|
+
header << "Schema"
|
50
|
+
header = yield(header) if block_given?
|
51
|
+
header = nice_header_names(header, schema: schema(person.details)) if nice_header_names?
|
52
|
+
header
|
53
|
+
end
|
54
|
+
|
55
|
+
def keys(entry)
|
56
|
+
entry.keys - ["freemium", "send_invites"]
|
57
|
+
end
|
58
|
+
|
59
|
+
def nice_header_names?
|
60
|
+
options.dig(:nice_header) || options.dig(:export, :options, :nice_header)
|
61
|
+
end
|
32
62
|
|
33
|
-
def
|
63
|
+
def nice_header_names(header, schema: nil)
|
64
|
+
schema ||= session.schema
|
65
|
+
name_maps = schema.fields_by_alt_id.each_with_object({}) do |(alt_id, fld), mappings|
|
66
|
+
mappings[alt_id] = fld.name
|
67
|
+
end.merge(nice_header_maps)
|
68
|
+
header.map {|name| name_maps[name] ? name_maps[name] : name}
|
69
|
+
end
|
70
|
+
|
71
|
+
def to_entry_type(person)
|
34
72
|
session.new_entry(person, dependencies: deps).yield_self do |person_entry|
|
35
73
|
options.dig(:export, :options, :internal_names) ? person_entry.mapped_entry : person_entry.external_entry
|
36
74
|
end
|
@@ -40,26 +78,91 @@ class Eco::API::UseCases::DefaultCases::ToCsvCase < Eco::API::Common::Loaders::U
|
|
40
78
|
@deps ||= {"supervisor_id" => {people: people}}
|
41
79
|
end
|
42
80
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
81
|
+
def file
|
82
|
+
@file ||= (options[:file] || options.dig(:export, :file, :name)).tap do |filename|
|
83
|
+
unless filename
|
84
|
+
session.logger.error("Destination file not specified")
|
85
|
+
return false
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def by_schema
|
91
|
+
people.group_by do |person|
|
92
|
+
if details = person.details
|
93
|
+
details.schema_id
|
94
|
+
end
|
95
|
+
end.transform_values do |persons|
|
96
|
+
people.newFrom persons
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def schema(value)
|
101
|
+
case value
|
102
|
+
when Ecoportal::API::V1::Person
|
103
|
+
schema(value.details&.schema_id)
|
104
|
+
when String
|
105
|
+
schemas[value]
|
106
|
+
when Ecoportal::API::V1::PersonDetails
|
107
|
+
schema(value.schema_id)
|
108
|
+
when Ecoportal::API::V1::PersonSchema
|
109
|
+
value
|
60
110
|
end
|
61
|
-
header
|
62
111
|
end
|
63
112
|
|
113
|
+
def schemas
|
114
|
+
session.schemas
|
115
|
+
end
|
116
|
+
|
117
|
+
def nice_header_maps
|
118
|
+
@nice_header_maps ||= {
|
119
|
+
"policy_group_ids" => "User Group(s)",
|
120
|
+
"email" => "Email",
|
121
|
+
"name" => "Name",
|
122
|
+
"supervisor_id" => "Manager ID",
|
123
|
+
"filter_tags" => "Locations",
|
124
|
+
"default_tag" => "Default Location",
|
125
|
+
"id" => "ecoPortal ID",
|
126
|
+
"external_id" => "Reference ID (ext_id)",
|
127
|
+
"login_provider_ids" => "Login Methods",
|
128
|
+
"landing_page_id" => "Landing Page ID",
|
129
|
+
"show_sidebar" => "(pref) Sidebar Open?",
|
130
|
+
"show_shortcuts" => "(pref) Link to Registers?",
|
131
|
+
"show_coming_soon" => "(pref) Coming Soon List?",
|
132
|
+
"show_recently_visited_forms" => "(pref) Recently Visited Forms List?",
|
133
|
+
"show_tasks" => "(pref) Tasks List?",
|
134
|
+
"show_task_bubbles" => "(pref) Task Count Bubbles",
|
135
|
+
"kiosk_enabled" => "Kiosk User?",
|
136
|
+
"freemium" => "Freemium User?",
|
137
|
+
"files" => "(able) on Files",
|
138
|
+
"reports" => "(able) on Report Structures",
|
139
|
+
"data" => "(able) on Data (hours, datasets)",
|
140
|
+
"organization" => "(able) on Organization Config",
|
141
|
+
"pages" => "(able) on Page/Entries",
|
142
|
+
"page_editor" => "(able) page Editor Level",
|
143
|
+
"registers" => "(able) on Registers",
|
144
|
+
"tasks" => "(able) on Tasks",
|
145
|
+
"person_core" => "(able) on People",
|
146
|
+
"person_core_create" => "(able) Create People?",
|
147
|
+
"person_core_edit" => "(able) Edit People?",
|
148
|
+
"person_details" => "(able) on People Schema Details",
|
149
|
+
"person_account" => "(able) on Users",
|
150
|
+
"person_abilities" => "(able) on Users' Abilities",
|
151
|
+
"custom_files" => "(min) on Files",
|
152
|
+
"custom_reports" => "(min) on Report Structures",
|
153
|
+
"custom_data" => "(min) on Data (hours, datasets)",
|
154
|
+
"custom_organization" => "(min) on Organization Config",
|
155
|
+
"custom_pages" => "(min) on Page/Entries",
|
156
|
+
"custom_page_editor" => "(min) page Editor Level",
|
157
|
+
"custom_registers" => "(min) on Registers",
|
158
|
+
"custom_tasks" => "(min) on Tasks",
|
159
|
+
"custom_person_core" => "(min) on People",
|
160
|
+
"custom_person_core_create" => "(min) Create People?",
|
161
|
+
"custom_person_core_edit" => "(min) Edit People?",
|
162
|
+
"custom_person_details" => "(min) on People Schema Details",
|
163
|
+
"custom_person_account" => "(min) on Users",
|
164
|
+
"custom_person_abilities" => "(min) on Users' Abilities"
|
165
|
+
}
|
166
|
+
end
|
64
167
|
|
65
168
|
end
|
@@ -1,53 +1,78 @@
|
|
1
|
-
class Eco::API::UseCases::DefaultCases::ToCsvDetailedCase < Eco::API::
|
1
|
+
class Eco::API::UseCases::DefaultCases::ToCsvDetailedCase < Eco::API::UseCases::DefaultCases::ToCsvCase
|
2
2
|
name "to-csv-detailed"
|
3
3
|
type :export
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
private
|
6
|
+
|
7
|
+
def to_row(person)
|
8
|
+
data = super(person)
|
9
|
+
data << person.subordinates
|
10
|
+
data << person_supervisor(person)
|
11
|
+
data += user_abilities(person)
|
12
|
+
data += user_permissions_custom(person) if options.dig(:export, :options, :permissions_custom)
|
13
|
+
account = person.account
|
14
|
+
data << account&.landing_page_id
|
15
|
+
data += user_preferences(person)
|
16
|
+
data
|
17
|
+
end
|
10
18
|
|
11
|
-
|
12
|
-
|
13
|
-
return
|
19
|
+
def person_supervisor(person)
|
20
|
+
session.micro.with_supervisor(person.supervisor_id, people) do |supervisor|
|
21
|
+
return supervisor ? supervisor.name : ""
|
14
22
|
end
|
23
|
+
end
|
15
24
|
|
16
|
-
|
17
|
-
|
25
|
+
def user_abilities(person)
|
26
|
+
account_abilities = (person.account && person.account.permissions_merged) || {}
|
27
|
+
abilities.map {|key| account_abilities[key] || "no access"}
|
28
|
+
end
|
18
29
|
|
19
|
-
|
20
|
-
|
21
|
-
|
30
|
+
def user_permissions_custom(person)
|
31
|
+
account_abilities = (person.account && person.account.permissions_custom) || {}
|
32
|
+
abilities.map {|key| account_abilities[key] || "no access"}
|
33
|
+
end
|
22
34
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
header += ["Supervisor Name"]
|
28
|
-
header += abilities
|
29
|
-
header += ["Landing Page"]
|
35
|
+
def user_preferences(person)
|
36
|
+
user_preferences = (person.account && person.account.preferences&.doc) || {}
|
37
|
+
preferences.map {|key| user_preferences[key] || false}
|
38
|
+
end
|
30
39
|
|
31
|
-
|
32
|
-
|
33
|
-
|
40
|
+
def spot_header(person = people.first)
|
41
|
+
super(person) do |header|
|
42
|
+
header << "Subordinates"
|
43
|
+
header << "Supervisor Name"
|
44
|
+
header += abilities_header
|
45
|
+
header += abilities_header("custom") if options.dig(:export, :options, :permissions_custom)
|
46
|
+
header << "Landing Page"
|
47
|
+
header += preferences
|
48
|
+
header
|
49
|
+
end
|
50
|
+
end
|
34
51
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
52
|
+
def keys(entry)
|
53
|
+
super(entry) + ["freemium"]
|
54
|
+
end
|
39
55
|
|
40
|
-
|
41
|
-
|
56
|
+
def login_providers
|
57
|
+
session.login_providers
|
58
|
+
end
|
42
59
|
|
43
|
-
|
44
|
-
|
45
|
-
|
60
|
+
def abilities
|
61
|
+
@abilities ||= session.presets_factory.keys
|
62
|
+
end
|
46
63
|
|
47
|
-
|
48
|
-
|
64
|
+
def abilities_header(prefix = nil)
|
65
|
+
abilities.map do |key|
|
66
|
+
prefix ? "#{prefix}_#{key}" : key
|
49
67
|
end
|
50
|
-
|
68
|
+
end
|
69
|
+
|
70
|
+
def preferences
|
71
|
+
@preferences ||= [
|
72
|
+
"show_sidebar", "show_shortcuts", "show_coming_soon", "show_recently_visited_forms",
|
73
|
+
"show_tasks", "show_task_bubbles",
|
74
|
+
"kiosk_enabled"
|
75
|
+
]
|
51
76
|
end
|
52
77
|
|
53
78
|
end
|
@@ -124,8 +124,9 @@ class Eco::API::UseCases::OozeSamples::OozeUpdateCase < Eco::API::Common::Loader
|
|
124
124
|
end
|
125
125
|
|
126
126
|
def prompt_to_confirm!
|
127
|
-
|
128
|
-
|
127
|
+
prompt_user("Do you want to proceed (y/N)?", default: "Y") do |response|
|
128
|
+
exit(1) unless response.upcase.start_with?("Y")
|
129
|
+
end
|
129
130
|
end
|
130
131
|
|
131
132
|
end
|
@@ -1,18 +1,71 @@
|
|
1
1
|
ASSETS.cli.config do |cnf|
|
2
|
+
formats = {
|
3
|
+
csv: {
|
4
|
+
option: ["-csv"],
|
5
|
+
extname: [".csv", ".txt"]
|
6
|
+
},
|
7
|
+
xml: {
|
8
|
+
option: ["-xml"],
|
9
|
+
extname: [".xml"]
|
10
|
+
},
|
11
|
+
xls: {
|
12
|
+
option: ["-xls", "-xlsx", "-excel"],
|
13
|
+
extname: [".xls", ".xlsx", ".xlsm"]
|
14
|
+
},
|
15
|
+
json: {
|
16
|
+
option: ["-json"],
|
17
|
+
extname: [".json"]
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
2
21
|
cnf.input(default_option: "-entries-from") do |session, str_opt, options|
|
3
22
|
input = []
|
4
23
|
if SCR.get_arg(str_opt)
|
5
24
|
file = SCR.get_file(str_opt, required: true)
|
25
|
+
|
26
|
+
# Command line check
|
27
|
+
format = formats.reduce(nil) do |matched, (format, selectors)|
|
28
|
+
used = selectors[:option].reduce(false) {|used, option| SCR.get_arg(option) || used}
|
29
|
+
next matched if matched
|
30
|
+
next format if used
|
31
|
+
end
|
32
|
+
|
33
|
+
# File/Folder check
|
34
|
+
file = File.expand_path(file)
|
35
|
+
if File.directory?(file)
|
36
|
+
folder = file
|
37
|
+
file = Dir.glob("#{file}/*").reject {|f| File.directory?(f)}
|
38
|
+
ext = (format && formats[format][:extname]) || [File.extname(file.first)]
|
39
|
+
file = file.select {|f| ext.any? {|e| File.extname(f) == e}}.tap do |files|
|
40
|
+
if files.empty?
|
41
|
+
session.logger.error("Could not find any file with extension: #{ext} in folder '#{folder}'")
|
42
|
+
exit(1)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
else
|
46
|
+
ext = File.extname(file)
|
47
|
+
end
|
48
|
+
|
49
|
+
format ||= formats.reduce(nil) do |matched, (format, selectors)|
|
50
|
+
next matched if matched
|
51
|
+
next format if selectors[:extname].any? {|e| ext == e}
|
52
|
+
end
|
53
|
+
format ||= :csv
|
54
|
+
|
6
55
|
options.deep_merge!(input: {file: {name: file}})
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
56
|
+
options.deep_merge!(input: {file: {format: format}})
|
57
|
+
|
58
|
+
case format
|
59
|
+
when :xml
|
60
|
+
[file].flatten.each {|f| session.config.files.validate(:xml, f)}
|
61
|
+
input = session.entries(file: file, format: format)
|
62
|
+
when :xls
|
63
|
+
input = session.entries(file: file, format: format)
|
64
|
+
when :json
|
65
|
+
input = [file].flatten.reduce(Eco::API::Organization::People.new([])) do |people, file|
|
66
|
+
people.merge(JSON.parse(File.read(file)))
|
67
|
+
end
|
14
68
|
else
|
15
|
-
options.deep_merge!(input: {file: {format: :csv}})
|
16
69
|
input = session.csv_entries(file)
|
17
70
|
end
|
18
71
|
end
|