ecoportal-api-oozes 0.6.1 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +86 -0
- data/ecoportal-api-oozes.gemspec +6 -6
- data/lib/ecoportal/api/common/content/collection_model.rb +25 -3
- data/lib/ecoportal/api/common/content/double_model.rb +27 -12
- data/lib/ecoportal/api/common/content/hash_diff_patch.rb +8 -1
- data/lib/ecoportal/api/v2.rb +27 -2
- data/lib/ecoportal/api/v2/page.rb +3 -3
- data/lib/ecoportal/api/v2/page/component.rb +11 -2
- data/lib/ecoportal/api/v2/page/component/action.rb +14 -3
- data/lib/ecoportal/api/v2/page/component/action_field.rb +40 -2
- data/lib/ecoportal/api/v2/page/component/chart_field.rb +54 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/frequency.rb +29 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/heatmap.rb +27 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/indicator.rb +26 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/multiseries.rb +31 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/sankey.rb +27 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/serie.rb +26 -0
- data/lib/ecoportal/api/v2/page/component/chart_field/series_config.rb +23 -0
- data/lib/ecoportal/api/v2/page/component/chart_fr_field.rb +32 -0
- data/lib/ecoportal/api/v2/page/component/checklist_field.rb +35 -2
- data/lib/ecoportal/api/v2/page/component/checklist_item.rb +10 -0
- data/lib/ecoportal/api/v2/page/component/date_field.rb +21 -0
- data/lib/ecoportal/api/v2/page/component/files_field.rb +1 -2
- data/lib/ecoportal/api/v2/page/component/gauge_field.rb +24 -1
- data/lib/ecoportal/api/v2/page/component/gauge_stop.rb +88 -0
- data/lib/ecoportal/api/v2/page/component/images_field.rb +1 -2
- data/lib/ecoportal/api/v2/page/component/people_field.rb +8 -1
- data/lib/ecoportal/api/v2/page/component/plain_text_field.rb +2 -0
- data/lib/ecoportal/api/v2/page/component/reference_field.rb +4 -0
- data/lib/ecoportal/api/v2/page/component/selection_field.rb +4 -5
- data/lib/ecoportal/api/v2/page/component/selection_option.rb +1 -0
- data/lib/ecoportal/api/v2/page/component/signature_field.rb +1 -1
- data/lib/ecoportal/api/v2/page/component/tag_field.rb +2 -0
- data/lib/ecoportal/api/v2/page/components.rb +2 -2
- data/lib/ecoportal/api/v2/page/section.rb +1 -0
- data/lib/ecoportal/api/v2/page/sections.rb +1 -1
- data/lib/ecoportal/api/v2/version.rb +1 -1
- metadata +60 -32
@@ -0,0 +1,54 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ChartField < Page::Component
|
7
|
+
passthrough :mode
|
8
|
+
passthrough :relative, :relstart, :relbound
|
9
|
+
passthrough :bounded, :ubound, :lbound
|
10
|
+
passthrough :filter_date_input
|
11
|
+
passthrough :user_id, :lock_chart_user
|
12
|
+
|
13
|
+
embeds_one :series_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::SeriesConfig"
|
14
|
+
embeds_one :frequency_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Frequency"
|
15
|
+
embeds_one :heatmap_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Heatmap"
|
16
|
+
embeds_one :sankey_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Sankey"
|
17
|
+
embeds_one :indicator_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Indicator"
|
18
|
+
embeds_one :faceted_series_config, klass: "Ecoportal::API::V2::Page::Component::ChartField::Multiseries"
|
19
|
+
|
20
|
+
embeds_many :series, klass: "Ecoportal::API::V2::Page::Component::ChartField::Serie"
|
21
|
+
|
22
|
+
MODES = ["frequency", "series", "heatmap", "sankey", "indicator", "faceted_series"]
|
23
|
+
|
24
|
+
def config
|
25
|
+
case mode
|
26
|
+
when "frequency"
|
27
|
+
frequency_config
|
28
|
+
when "series"
|
29
|
+
series_config
|
30
|
+
when "heatmap"
|
31
|
+
heatmap_config
|
32
|
+
when "sankey"
|
33
|
+
sankey_config
|
34
|
+
when "indicator"
|
35
|
+
indicator_config
|
36
|
+
when "faceted_series"
|
37
|
+
faceted_series_config
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
require 'ecoportal/api/v2/page/component/chart_field/frequency'
|
49
|
+
require 'ecoportal/api/v2/page/component/chart_field/series_config'
|
50
|
+
require 'ecoportal/api/v2/page/component/chart_field/serie'
|
51
|
+
require 'ecoportal/api/v2/page/component/chart_field/heatmap'
|
52
|
+
require 'ecoportal/api/v2/page/component/chart_field/sankey'
|
53
|
+
require 'ecoportal/api/v2/page/component/chart_field/indicator'
|
54
|
+
require 'ecoportal/api/v2/page/component/chart_field/multiseries'
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ChartField
|
7
|
+
class Frequency < Common::Content::DoubleModel
|
8
|
+
passkey :id
|
9
|
+
passthrough :patch_ver
|
10
|
+
passthrough :register_id, :source_type
|
11
|
+
|
12
|
+
passthrough :mode, :input
|
13
|
+
passarray :tags
|
14
|
+
passthrough :secondary
|
15
|
+
|
16
|
+
passthrough :output, :bar_mode
|
17
|
+
passthrough :series_size, :skip_zeroes
|
18
|
+
|
19
|
+
passarray :filters, :people_filters, :task_filters
|
20
|
+
|
21
|
+
passthrough :color
|
22
|
+
passarray :color_map
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ChartField
|
7
|
+
class Heatmap < Common::Content::DoubleModel
|
8
|
+
passkey :id
|
9
|
+
passthrough :patch_ver
|
10
|
+
passthrough :register_id, :source_type
|
11
|
+
|
12
|
+
passthrough :xinput, :xmode
|
13
|
+
passthrough :yinput, :ymode
|
14
|
+
passarray :xtags, :ytags
|
15
|
+
|
16
|
+
passthrough :bucket_type
|
17
|
+
|
18
|
+
passarray :filters, :people_filters, :task_filters
|
19
|
+
|
20
|
+
passthrough :color
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ChartField
|
7
|
+
class Indicator < Common::Content::DoubleModel
|
8
|
+
passkey :id
|
9
|
+
passthrough :patch_ver
|
10
|
+
passthrough :register_id, :source_type
|
11
|
+
|
12
|
+
passthrough :date_input, :secondary
|
13
|
+
passthrough :duration, :math_mode, :currency
|
14
|
+
|
15
|
+
passthrough :display_previous, :change_format, :invert_colors
|
16
|
+
|
17
|
+
passarray :filters, :people_filters, :task_filters
|
18
|
+
|
19
|
+
passthrough :color
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ChartField
|
7
|
+
class Multiseries < Common::Content::DoubleModel
|
8
|
+
passkey :id
|
9
|
+
passthrough :patch_ver
|
10
|
+
passthrough :register_id, :source_type
|
11
|
+
|
12
|
+
passthrough :xinput, :xlabel
|
13
|
+
passthrough :interval, :calc_mode
|
14
|
+
|
15
|
+
passthrough :yinput, :ylabel
|
16
|
+
passthrough :facet_by_discrete, :discrete_facet
|
17
|
+
passthrough :facet_by_tags
|
18
|
+
passarray :facet_tags
|
19
|
+
|
20
|
+
passarray :filters, :people_filters, :task_filters
|
21
|
+
|
22
|
+
passthrough :display_mode, :display_type
|
23
|
+
passthrough :color
|
24
|
+
passarray :color_map
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ChartField
|
7
|
+
class Sankey < Common::Content::DoubleModel
|
8
|
+
passkey :id
|
9
|
+
passthrough :patch_ver
|
10
|
+
passthrough :register_id, :source_type
|
11
|
+
|
12
|
+
passthrough :xinput, :xmode
|
13
|
+
passthrough :yinput, :ymode
|
14
|
+
passthrough :zinput, :zmode
|
15
|
+
passarray :xtags, :ytags, :ztags
|
16
|
+
|
17
|
+
passarray :filters, :people_filters, :task_filters
|
18
|
+
|
19
|
+
passthrough :color
|
20
|
+
passarray :color_map
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ChartField
|
7
|
+
class Serie < Common::Content::DoubleModel
|
8
|
+
passkey :id
|
9
|
+
passthrough :patch_ver
|
10
|
+
passthrough :register_id
|
11
|
+
|
12
|
+
passthrough :input, :type
|
13
|
+
passarray :y_axes
|
14
|
+
|
15
|
+
passthrough :visual, :stacked
|
16
|
+
|
17
|
+
passarray :filters, :people_filters, :task_filters
|
18
|
+
|
19
|
+
passthrough :color
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ChartField
|
7
|
+
class SeriesConfig < Common::Content::DoubleModel
|
8
|
+
passkey :id
|
9
|
+
passthrough :patch_ver
|
10
|
+
|
11
|
+
passthrough :xlabel, :xtype
|
12
|
+
passthrough :interval, :calc_mode, :comparative_year
|
13
|
+
passthrough :ylabel
|
14
|
+
|
15
|
+
passthrough :filled_up_with_zeros, :zero_y, :bounds_rigid
|
16
|
+
passthrough :stack_all
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class ChartFrField < Page::Component
|
7
|
+
passthrough :register_id, :date_input
|
8
|
+
passthrough :filter
|
9
|
+
|
10
|
+
passthrough :facet_by_tags, :facet_by_select
|
11
|
+
passthrough :select_input, :select_mapping
|
12
|
+
passarray :facet_tags
|
13
|
+
|
14
|
+
passthrough :relative, :relstart, :relbound
|
15
|
+
passthrough :bounded, :ubound, :lbound
|
16
|
+
|
17
|
+
passthrough :display_mode, :display_type
|
18
|
+
passarray :guidelines
|
19
|
+
passthrough :cumulative, :cumulative_mode, :cumulative_start
|
20
|
+
passthrough :multiplier, :granularity
|
21
|
+
|
22
|
+
passthrough :color
|
23
|
+
passarray :color_map
|
24
|
+
|
25
|
+
passthrough :chart_user
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -4,8 +4,41 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class ChecklistField < Page::Component
|
7
|
-
|
8
|
-
|
7
|
+
embeds_many :items, klass: "Ecoportal::API::V2::Page::Component::ChecklistItem", order_key: :weight
|
8
|
+
|
9
|
+
def add_item(label:, pos: NOT_USED, before: NOT_USED, after: NOT_USED)
|
10
|
+
itm_doc = items.stops.items_class.new_doc
|
11
|
+
items.upsert!(itm_doc, pos: pos, before: before, after: after) do |item|
|
12
|
+
item.label = label
|
13
|
+
if prev = previous_item(item)
|
14
|
+
item.weight = prev.weight
|
15
|
+
end
|
16
|
+
yield(item) if block_given?
|
17
|
+
fix_item_weights!
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def ordered_items
|
22
|
+
items.each_with_index.sort_by do |item, index|
|
23
|
+
(item.weight >= 9999) ? [index, index] : [item.weight, index]
|
24
|
+
end.map(&:first)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def fix_item_weights!
|
30
|
+
ordered_items.each_with_index do |item, index|
|
31
|
+
item.weight = index
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def previous_item(value)
|
36
|
+
itms = ordered_items
|
37
|
+
pos = itms.index(value) - 1
|
38
|
+
return if pos < 0
|
39
|
+
itms[pos]
|
40
|
+
end
|
41
|
+
|
9
42
|
end
|
10
43
|
end
|
11
44
|
end
|
@@ -4,6 +4,16 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class ChecklistItem < Common::Content::DoubleModel
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def new_doc
|
10
|
+
{
|
11
|
+
"id" => new_uuid,
|
12
|
+
"weight" => 9999
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
7
17
|
passkey :id
|
8
18
|
passthrough :patch_ver, :label
|
9
19
|
passthrough :weight, :checked
|
@@ -5,6 +5,27 @@ module Ecoportal
|
|
5
5
|
class Component
|
6
6
|
class DateField < Page::Component
|
7
7
|
passthrough :value
|
8
|
+
passthrough :show_time, :today_button, :past_only
|
9
|
+
passthrough :create_event, :remind_me_in
|
10
|
+
passthrough :renews, :renews_every, :renews_unit, :renews_until
|
11
|
+
|
12
|
+
ISO8601 = "%Y-%m-%dT%H:%M:00Z" # "%Y-%m-%dT%H:%M:00.00Z"
|
13
|
+
|
14
|
+
def value=(val)
|
15
|
+
doc["value"] = self.class.to_time(val).yield_self do |datetime|
|
16
|
+
datetime = datetime.utc.strftime(ISO8601) if datetime
|
17
|
+
datetime
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def value
|
22
|
+
if val = doc["value"]
|
23
|
+
(Time.parse(val) rescue nil).yield_self do |datetime|
|
24
|
+
datetime.localtime if datetime
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
8
29
|
end
|
9
30
|
end
|
10
31
|
end
|
@@ -4,8 +4,7 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class FilesField < Page::Component
|
7
|
-
|
8
|
-
embeds_multiple :items, klass: "Ecoportal::API::V2::Page::File", order_key: :position
|
7
|
+
embeds_many :items, klass: "Ecoportal::API::V2::Page::File", order_key: :position
|
9
8
|
end
|
10
9
|
end
|
11
10
|
end
|
@@ -4,10 +4,33 @@ module Ecoportal
|
|
4
4
|
class Page
|
5
5
|
class Component
|
6
6
|
class GaugeField < Page::Component
|
7
|
-
passthrough :value
|
7
|
+
passthrough :value, :max
|
8
|
+
passthrough :active_color
|
9
|
+
|
10
|
+
embeds_many :stops, klass: "Ecoportal::API::V2::Page::Component::GaugeStop", order_key: :threshold
|
11
|
+
|
12
|
+
# Adds a stop at `threshold` with `color`
|
13
|
+
# @return [Ecoportal::API::V2::Page::Component::GaugeStop]
|
14
|
+
def add_stop (threshold: 0.0, color: '#e256d1')
|
15
|
+
stop_doc = stops.items_class.new_doc
|
16
|
+
stops.upsert!(stop_doc) do |stop|
|
17
|
+
stop.threshold = threshold
|
18
|
+
stop.color = color
|
19
|
+
yield(stop) if block_given?
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def ordered_stops
|
24
|
+
stops.each_with_index.sort_by do |stop, index|
|
25
|
+
(stop.threshold >= 9999) ? [index, index] : [stop.threshold, index]
|
26
|
+
end.map(&:first)
|
27
|
+
end
|
28
|
+
|
8
29
|
end
|
9
30
|
end
|
10
31
|
end
|
11
32
|
end
|
12
33
|
end
|
13
34
|
end
|
35
|
+
|
36
|
+
require 'ecoportal/api/v2/page/component/gauge_stop'
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Ecoportal
|
2
|
+
module API
|
3
|
+
class V2
|
4
|
+
class Page
|
5
|
+
class Component
|
6
|
+
class GaugeStop < Common::Content::DoubleModel
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def new_doc
|
10
|
+
{
|
11
|
+
"id" => new_uuid,
|
12
|
+
"threshold" => nil,
|
13
|
+
"color" => nil
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
passkey :id
|
19
|
+
passthrough :patch_ver, :threshold
|
20
|
+
passthrough :color
|
21
|
+
|
22
|
+
# Assign the color to the stop.
|
23
|
+
# @note These are the available colors:
|
24
|
+
# - :blue, :blue_greyed, :blue_light
|
25
|
+
# - :turquoise, :jade, :green, :pistachio, :avocado
|
26
|
+
# - :yellow, :orange, :pumpkin, :red, :magenta, :fuchsia, :purple, :violet
|
27
|
+
# @param value [String, Symbol] you can use a `symbol` to specify a color
|
28
|
+
def color=(value)
|
29
|
+
value = to_color(value) if value.is_a?(Symbol)
|
30
|
+
doc["color"] = value
|
31
|
+
end
|
32
|
+
|
33
|
+
# @return [Symbol] to get the `color` sym code
|
34
|
+
def color_sym
|
35
|
+
color_maps.each do |k, v|
|
36
|
+
return k if color == v
|
37
|
+
end
|
38
|
+
:undefined
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def to_color(value)
|
44
|
+
return nil unless valid_color?(value)
|
45
|
+
return value if value.is_a?(String)
|
46
|
+
color_maps[value]
|
47
|
+
end
|
48
|
+
|
49
|
+
def valid_color?(value)
|
50
|
+
return true if value.is_a?(String) && colors.any? {|c| c == value}
|
51
|
+
return true if value.is_a?(Symbol) && color_syms.any? {|s| s == value}
|
52
|
+
end
|
53
|
+
|
54
|
+
def color_syms
|
55
|
+
@color_syms ||= color_maps.keys
|
56
|
+
end
|
57
|
+
|
58
|
+
def colors
|
59
|
+
@colors ||= color_maps.values
|
60
|
+
end
|
61
|
+
|
62
|
+
def color_maps
|
63
|
+
@color_maps ||= [
|
64
|
+
[:blue, "#5656e2"],
|
65
|
+
[:blue_greyed, "#568be2"],
|
66
|
+
[:blue_light, "#56c0e2"],
|
67
|
+
[:turquoise, "#56e2cf"],
|
68
|
+
[:jade, "#56e29b"],
|
69
|
+
[:green, "#56e267"],
|
70
|
+
[:pistachio, "#79e256"],
|
71
|
+
[:avocado, "#aee256"],
|
72
|
+
[:yellow, "#e2e156"],
|
73
|
+
[:orange, "#e2ad56"],
|
74
|
+
[:pumpkin, "#e27956"],
|
75
|
+
[:red, "#e25667"],
|
76
|
+
[:magenta, "#e2569c"],
|
77
|
+
[:fuchsia, "#e256d1"],
|
78
|
+
[:purple, "#be56e2"],
|
79
|
+
[:violet, "#8a56e2"]
|
80
|
+
].to_h
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|