Skip to content

Commit 3297a7e

Browse files
authored
Merge pull request #242 from gtt-project/next
Prepares for the v5.0.0 release
2 parents 45a4bdc + bad1f8c commit 3297a7e

File tree

133 files changed

+11380
-5530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+11380
-5530
lines changed

.github/workflows/test-postgis.yml

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ on:
77
push:
88
branches:
99
- main
10+
- next
1011
pull_request:
1112
branches:
1213
- main
14+
- next
1315

1416
jobs:
1517
test:
@@ -22,18 +24,9 @@ jobs:
2224
strategy:
2325
fail-fast: false
2426
matrix:
25-
redmine_version: [4.2-stable, 5.0-stable, master]
26-
ruby_version: ['2.7', '3.0', '3.1', '3.2']
27-
db_version: [11-2.5, 15-3.3]
28-
exclude:
29-
- redmine_version: 4.2-stable
30-
ruby_version: 3.0
31-
- redmine_version: 4.2-stable
32-
ruby_version: 3.1
33-
- redmine_version: 4.2-stable
34-
ruby_version: 3.2
35-
- redmine_version: 5.0-stable
36-
ruby_version: 3.2
27+
redmine_version: [5.0-stable, master]
28+
ruby_version: ['3.0', '3.1']
29+
db_version: [12-3.0, 15-3.3]
3730

3831
services:
3932
postgres:
@@ -94,17 +87,14 @@ jobs:
9487
encoding: utf8
9588
EOF
9689
97-
- name: Adjust Gem environment
98-
run: |
99-
case "${{ matrix.redmine_version }}" in
100-
4.2-stable)
101-
echo "GEM_RGEO_ACTIVERECORD_VERSION=6.2.2" >> ${GITHUB_ENV}
102-
echo "GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=5.2.3" >> ${GITHUB_ENV}
103-
;;
104-
master)
105-
echo "GEM_PG_VERSION=1.4.5" >> ${GITHUB_ENV}
106-
;;
107-
esac
90+
# - name: Adjust Gem environment
91+
# run: |
92+
# case "${{ matrix.redmine_version }}" in
93+
# 4.2-stable)
94+
# echo "GEM_RGEO_ACTIVERECORD_VERSION=6.2.2" >> ${GITHUB_ENV}
95+
# echo "GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=5.2.3" >> ${GITHUB_ENV}
96+
# ;;
97+
# esac
10898

10999
- name: Install Ruby dependencies
110100
working-directory: redmine

.gitignore

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
1+
# Ignore commonly generated/ignored files
12
.DS_Store
2-
node_modules
3-
# webpack generate files
4-
assets/javascripts/main.js
5-
assets/javascripts/main.js.*
6-
assets/javascripts/*.png
7-
assets/javascripts/*.svg
8-
assets/javascripts/*.ttf
9-
assets/javascripts/*.eot
10-
assets/javascripts/*.woff2
11-
assets/javascripts/*.woff
12-
3+
node_modules/
134

5+
# Ignore webpack generated files
6+
assets/*
7+
!assets/.keep

Gemfile

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
source 'https://rubygems.org'
22

3+
# Define gem versions with environment variables or default versions
4+
gem_versions = {
5+
pg: ENV['GEM_PG_VERSION'] || '1.5.3',
6+
rgeo: ENV['GEM_RGEO_VERSION'] || '3.0.0',
7+
rgeo_activerecord: ENV['GEM_RGEO_ACTIVERECORD_VERSION'] || '7.0.1',
8+
activerecord_postgis_adapter: ENV['GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION'] || '7.1.1'
9+
}
10+
311
gem 'deface'
412
gem 'immutable-struct'
5-
gem "rgeo", "~> 2.4.0"
13+
gem "rgeo", "~> #{gem_versions[:rgeo]}"
614
gem "rgeo-geojson"
7-
gem "pg", (ENV['GEM_PG_VERSION'] ? "~> #{ENV['GEM_PG_VERSION']}" : "~> 1.2.2") # make sure we use a version compatible with AR
8-
gem "rgeo-activerecord", (ENV['GEM_RGEO_ACTIVERECORD_VERSION'] ? "~> #{ENV['GEM_RGEO_ACTIVERECORD_VERSION']}" : "~> 7.0.1") # same as above
9-
gem 'activerecord-postgis-adapter', (ENV['GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION'] ? "~> #{ENV['GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION']}" : "~> 7.1.1") # same as above
15+
gem "pg", "~> #{gem_versions[:pg]}"
16+
gem "rgeo-activerecord", "~> #{gem_versions[:rgeo_activerecord]}"
17+
gem 'activerecord-postgis-adapter', "~> #{gem_versions[:activerecord_postgis_adapter]}"
1018
gem 'rails-controller-testing' # This gem brings back assigns to your controller tests as well as assert_template to both controller and integration tests.

README.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ The Geo-Task-Tracker (GTT) plugin adds spatial capabilities to Redmine:
1717
Redmine GTT plugins **require PostgreSQL/PostGIS** and will not work with SQLite
1818
or MariaDB/MySQL!!!
1919

20-
- Redmine >= 4.2.0
21-
- PostgreSQL >= 10
22-
- PostGIS >= 2.5
23-
- NodeJS v14
20+
- Redmine >= 5.0.0
21+
- PostgreSQL >= 12
22+
- PostGIS >= 3.0
23+
- NodeJS v18
2424
- yarn
2525

2626
## Installation
@@ -43,12 +43,17 @@ yarn
4343
npx webpack
4444
```
4545

46+
Optionally export to override the [default GEM version](./Gemfile)
47+
48+
```sh
49+
export GEM_PG_VERSION=your-pg-version
50+
export GEM_RGEO_ACTIVERECORD_VERSION=your-rgeo-activerecord-version
51+
export GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=your-activerecord-postgis-adapter-version
52+
```
53+
4654
Then run
4755

4856
```sh
49-
export GEM_PG_VERSION=your-pg-version # skip this line if redmine use pg 1.2.2.
50-
export GEM_RGEO_ACTIVERECORD_VERSION=your-rgeo-activerecord-version # skip this line if using rgeo-activerecord 6.2.2.
51-
export GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=your-activerecord-postgis-adapter-version # skip this line if using activerecord-postgis-adapter 5.2.3.
5257
bundle install
5358
bundle exec rake redmine:plugins:migrate
5459
```
@@ -91,7 +96,7 @@ Help us to translate GTT Project using [OSGeo Weblate](https://weblate.osgeo.org
9196
You can debug frontend by running the following command on another console:
9297

9398
```sh
94-
npx webpack --watch --mode=development
99+
npx webpack --watch --mode=development --devtool=source-map
95100
```
96101

97102
### How to run test
Lines changed: 61 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,73 @@
11
class GttConfigurationController < ApplicationController
22

3-
before_action :find_optional_project_and_authorize
3+
before_action :find_optional_project_and_authorize
44

5-
accept_api_auth :default_setting_configuration
5+
accept_api_auth :default_setting_configuration
66

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}
1211
end
12+
end
1313

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 = []
1818

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+
}
4126

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
6362

64-
private
63+
private
6564

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
7371
end
72+
end
7473
end

app/controllers/gtt_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class GttController < ApplicationController
2+
def map
3+
path = Rails.root.join('public', 'plugin_assets', 'redmine_gtt', 'javascripts', 'main.js.map')
4+
send_file path, type: 'application/json', disposition: 'inline'
5+
end
6+
end
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
class GttMapLayersController < ApplicationController
2+
layout 'admin'
3+
4+
before_action :require_admin
5+
6+
self.main_menu = false
7+
8+
def index
9+
@map_layers = GttMapLayer.sorted
10+
end
11+
12+
def new
13+
@map_layer = GttMapLayer.new
14+
end
15+
16+
def create
17+
r = RedmineGtt::Actions::CreateMapLayer.(map_layer_params)
18+
if r.map_layer_created?
19+
redirect_to(params[:continue] ? new_gtt_map_layer_path : gtt_map_layers_path)
20+
else
21+
@map_layer = r.map_layer
22+
render 'new'
23+
end
24+
end
25+
26+
def edit
27+
@map_layer = GttMapLayer.find(params[:id])
28+
end
29+
30+
def update
31+
ml = GttMapLayer.find(params[:id])
32+
r = RedmineGtt::Actions::UpdateMapLayer.(ml, map_layer_params)
33+
if r.map_layer_updated?
34+
respond_to do |format|
35+
format.html {
36+
flash[:notice] = l(:notice_successful_update)
37+
redirect_to gtt_map_layers_path
38+
}
39+
format.js { head 200 }
40+
end
41+
else
42+
respond_to do |format|
43+
format.html {
44+
@map_layer = r.map_layer
45+
render 'edit'
46+
}
47+
format.js { head 422 }
48+
end
49+
end
50+
end
51+
52+
def destroy
53+
ml = GttMapLayer.find(params[:id])
54+
ml.destroy
55+
redirect_to gtt_map_layers_path
56+
end
57+
58+
private
59+
60+
def map_layer_params
61+
return {} unless params[:map_layer]
62+
63+
params[:map_layer].permit(
64+
:name, :default, :global, :baselayer, :position,
65+
:layer, :layer_options_string,
66+
:source, :source_options_string,
67+
:format, :format_options_string,
68+
:styles
69+
)
70+
end
71+
end

0 commit comments

Comments
 (0)