|
1 | 1 | class GttConfigurationController < ApplicationController
|
2 | 2 |
|
3 |
| - before_action :find_optional_project_and_authorize |
| 3 | + before_action :find_optional_project_and_authorize |
4 | 4 |
|
5 |
| - accept_api_auth :default_setting_configuration |
| 5 | + accept_api_auth :default_setting_configuration |
6 | 6 |
|
7 |
| - def default_setting_configuration |
8 |
| - gtt_map_config = build_default_setting_config |
9 |
| - respond_to do |format| |
10 |
| - format.api { render json: build_default_setting_config} |
11 |
| - end |
| 7 | + def default_setting_configuration |
| 8 | + gtt_map_config = build_default_setting_config |
| 9 | + respond_to do |format| |
| 10 | + format.api { render json: build_default_setting_config} |
12 | 11 | end
|
| 12 | + end |
13 | 13 |
|
14 |
| - def build_default_setting_config |
15 |
| - default_tracker_icon = [] |
16 |
| - default_status_color = [] |
17 |
| - gtt_tile_source = [] |
| 14 | + def build_default_setting_config |
| 15 | + default_tracker_icon = [] |
| 16 | + default_status_color = [] |
| 17 | + gtt_map_layer = [] |
18 | 18 |
|
19 |
| - Tracker.all.sort.each {|tracker| |
20 |
| - default_tracker_icon.append({ |
21 |
| - trackerID: tracker.id, |
22 |
| - trackerName: tracker.name, |
23 |
| - icon: Setting.plugin_redmine_gtt['tracker_'+tracker.id.to_s] |
24 |
| - }) |
25 |
| - } |
26 |
| - IssueStatus.all.sort.each {|status| |
27 |
| - default_status_color.append({ |
28 |
| - statusID: status.id, |
29 |
| - statusName: status.name, |
30 |
| - color: Setting.plugin_redmine_gtt['status_'+status.id.to_s] |
31 |
| - }) |
32 |
| - } |
33 |
| - GttTileSource.where(global: true).sort.each {|tileSource| |
34 |
| - gtt_tile_source.append({ |
35 |
| - id: tileSource.id, |
36 |
| - name: tileSource.name, |
37 |
| - type: tileSource.type, |
38 |
| - options: tileSource.options |
39 |
| - }) |
40 |
| - } |
| 19 | + Tracker.all.sort.each {|tracker| |
| 20 | + default_tracker_icon.append({ |
| 21 | + trackerID: tracker.id, |
| 22 | + trackerName: tracker.name, |
| 23 | + icon: Setting.plugin_redmine_gtt['tracker_'+tracker.id.to_s] |
| 24 | + }) |
| 25 | + } |
41 | 26 |
|
42 |
| - mapConfig = { |
43 |
| - gttDefaultSetting: { |
44 |
| - defaultTrackerIcon: default_tracker_icon, |
45 |
| - defaultStatusColor: default_status_color, |
46 |
| - defaultMapSetting: { |
47 |
| - centerLng: Setting.plugin_redmine_gtt['default_map_center_longitude'], |
48 |
| - centerLat: Setting.plugin_redmine_gtt['default_map_center_latitude'] |
49 |
| - }, |
50 |
| - geometrySetting: { |
51 |
| - geometryTypes: Setting.plugin_redmine_gtt['editable_geometry_types_on_issue_map'], |
52 |
| - GeoJsonUpload: (Setting.plugin_redmine_gtt['enable_geojson_upload_on_issue_map'] == 'true'), |
53 |
| - }, |
54 |
| - geocoderSetting: { |
55 |
| - enableGeocodingOnMap: (Setting.plugin_redmine_gtt['enable_geocoding_on_map'] == 'true'), |
56 |
| - geocoderOptions: Setting.plugin_redmine_gtt['default_geocoder_options'] |
57 |
| - }, |
58 |
| - }, |
59 |
| - gttLayer: gtt_tile_source, |
60 |
| - } |
61 |
| - return mapConfig |
62 |
| - end |
| 27 | + IssueStatus.all.sort.each {|status| |
| 28 | + default_status_color.append({ |
| 29 | + statusID: status.id, |
| 30 | + statusName: status.name, |
| 31 | + color: Setting.plugin_redmine_gtt['status_'+status.id.to_s] |
| 32 | + }) |
| 33 | + } |
| 34 | + |
| 35 | + GttMapLayer.where(global: true).sort.each {|mapLayer| |
| 36 | + gtt_map_layer.append( |
| 37 | + mapLayer.as_json.except("created_at", "updated_at","position","global") |
| 38 | + ) |
| 39 | + } |
| 40 | + |
| 41 | + mapConfig = { |
| 42 | + gttDefaultSetting: { |
| 43 | + defaultTrackerIcon: default_tracker_icon, |
| 44 | + defaultStatusColor: default_status_color, |
| 45 | + defaultMapSetting: { |
| 46 | + centerLng: Setting.plugin_redmine_gtt['default_map_center_longitude'], |
| 47 | + centerLat: Setting.plugin_redmine_gtt['default_map_center_latitude'] |
| 48 | + }, |
| 49 | + geometrySetting: { |
| 50 | + geometryTypes: Setting.plugin_redmine_gtt['editable_geometry_types_on_issue_map'], |
| 51 | + GeoJsonUpload: (Setting.plugin_redmine_gtt['enable_geojson_upload_on_issue_map'] == 'true'), |
| 52 | + }, |
| 53 | + geocoderSetting: { |
| 54 | + enableGeocodingOnMap: (Setting.plugin_redmine_gtt['enable_geocoding_on_map'] == 'true'), |
| 55 | + geocoderOptions: Setting.plugin_redmine_gtt['default_geocoder_options'] |
| 56 | + }, |
| 57 | + }, |
| 58 | + gttLayer: gtt_map_layer, |
| 59 | + } |
| 60 | + return mapConfig |
| 61 | + end |
63 | 62 |
|
64 |
| - private |
| 63 | + private |
65 | 64 |
|
66 |
| - def find_optional_project_and_authorize |
67 |
| - if params[:project_id] |
68 |
| - @project = Project.find params[:project_id] |
69 |
| - authorize |
70 |
| - else |
71 |
| - authorize_global |
72 |
| - end |
| 65 | + def find_optional_project_and_authorize |
| 66 | + if params[:project_id] |
| 67 | + @project = Project.find(params[:project_id]) |
| 68 | + authorize |
| 69 | + else |
| 70 | + authorize_global |
73 | 71 | end
|
| 72 | + end |
74 | 73 | end
|
0 commit comments