Skip to content

Commit 2c3e7e7

Browse files
committed
Merge branch 'main' into next
Signed-off-by: Daniel Kastl <[email protected]>
2 parents f9563fa + 50d9b98 commit 2c3e7e7

File tree

20 files changed

+643
-81
lines changed

20 files changed

+643
-81
lines changed

.github/workflows/redmine.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

.github/workflows/test-postgis.yml

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
name: Test with PostGIS
2+
3+
env:
4+
PLUGIN_NAME: ${{ github.event.repository.name }}
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
- master
11+
pull_request:
12+
branches:
13+
- main
14+
- master
15+
16+
jobs:
17+
test:
18+
name: redmine:${{ matrix.redmine_version }} ruby:${{ matrix.ruby_version }} postgis:${{ matrix.db_version }}
19+
runs-on: ubuntu-22.04
20+
21+
container:
22+
image: ruby:${{ matrix.ruby_version }}-bullseye
23+
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
redmine_version: [4.2-stable, 5.0-stable, master]
28+
ruby_version: [2.7, 3.0, 3.1]
29+
db_version: [11-2.5, 14-3.2]
30+
exclude:
31+
- redmine_version: 4.2-stable
32+
ruby_version: 3.0
33+
- redmine_version: 4.2-stable
34+
ruby_version: 3.1
35+
36+
services:
37+
postgres:
38+
image: postgis/postgis:${{ matrix.db_version }}
39+
env:
40+
POSTGRES_USER: postgres
41+
POSTGRES_PASSWORD: postgres
42+
ports:
43+
- 5432:5432
44+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
45+
46+
steps:
47+
- name: Checkout Redmine
48+
uses: actions/checkout@v2
49+
with:
50+
repository: redmine/redmine
51+
ref: ${{ matrix.redmine_version }}
52+
path: redmine
53+
54+
- name: Checkout Plugin
55+
uses: actions/checkout@v2
56+
with:
57+
path: redmine/plugins/${{ env.PLUGIN_NAME }}
58+
59+
- name: Update package archives
60+
run: apt-get update --yes --quiet
61+
62+
- name: Install package dependencies
63+
run: >
64+
apt-get install --yes --quiet
65+
postgresql-client
66+
gcc libpq-dev make patch libgeos-dev curl
67+
68+
- name: Install Node/Yarn packages
69+
run: |
70+
curl -sL https://deb.nodesource.com/setup_16.x | bash -
71+
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
72+
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
73+
apt-get update --yes --quiet
74+
apt-get install --yes --quiet --no-install-recommends nodejs yarn
75+
76+
- name: Prepare Plugin
77+
working-directory: redmine/plugins/redmine_gtt
78+
run: |
79+
yarn
80+
npx webpack
81+
82+
- name: Prepare Redmine source
83+
working-directory: redmine
84+
run: |
85+
cat <<EOF > config/database.yml
86+
test:
87+
adapter: postgis
88+
database: redmine
89+
host: postgres
90+
username: postgres
91+
password: postgres
92+
encoding: utf8
93+
EOF
94+
95+
- name: Adjust Gem environment
96+
run: |
97+
case "${{ matrix.redmine_version }}" in
98+
4.2-stable)
99+
echo "GEM_RGEO_ACTIVERECORD_VERSION=6.2.2" >> ${GITHUB_ENV}
100+
echo "GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=5.2.3" >> ${GITHUB_ENV}
101+
;;
102+
esac
103+
104+
- name: Install Ruby dependencies
105+
working-directory: redmine
106+
run: |
107+
bundle config set --local without 'development'
108+
bundle install --jobs=4 --retry=3
109+
110+
- name: Run Redmine rake tasks
111+
env:
112+
RAILS_ENV: test
113+
working-directory: redmine
114+
run: |
115+
bundle exec rake generate_secret_token
116+
bundle exec rake db:create db:migrate redmine:plugins:migrate
117+
118+
- name: Zeitwerk check
119+
env:
120+
RAILS_ENV: test
121+
working-directory: redmine
122+
run: |
123+
if grep -q zeitwerk config/application.rb ; then
124+
bundle exec rake zeitwerk:check
125+
fi
126+
shell: bash
127+
128+
- name: Run tests
129+
env:
130+
RAILS_ENV: test
131+
working-directory: redmine
132+
run: bundle exec rake redmine:plugins:test NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0"
133+
134+
- name: Run uninstall test
135+
env:
136+
RAILS_ENV: test
137+
working-directory: redmine
138+
run: bundle exec rake redmine:plugins:migrate NAME=${{ env.PLUGIN_NAME }} VERSION=0

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Redmine Geo-Task-Tracker (GTT) Plugin
22

3-
![CI #develop](https://github.com/gtt-project/redmine_gtt/workflows/Test%20with%20Redmine/badge.svg)
4-
[![Translation status](https://weblate.osgeo.org/widgets/gtt-project/-/redmine_gtt/svg-badge.svg)](https://weblate.osgeo.org/engage/gtt-project/)
3+
[![CI](https://github.com/gtt-project/redmine_gtt/workflows/Test%20with%20PostGIS/badge.svg)](https://github.com/gtt-project/redmine_gtt/actions?query=workflow%3A%22Test%20with%20PostGIS%22+branch%3Amain)
54

65
The Geo-Task-Tracker (GTT) plugin adds spatial capabilities to Redmine:
76

@@ -27,14 +26,14 @@ Redmine GTT plugins **require PostgreSQL/PostGIS** and will not work with SQLite
2726

2827
Create a PostGIS-enabled database:
2928

30-
```
29+
```sh
3130
createdb -U postgres -O redmine redmine
3231
psql -U postgres -d redmine -c "CREATE EXTENSION postgis;"
3332
```
3433

3534
To install Redmine GTT plugin, download or clone this repository in your Redmine installation plugins directory!
3635

37-
```
36+
```sh
3837
cd path/to/plugin/directory
3938
git clone https://github.com/gtt-project/redmine_gtt.git
4039
cd redmine_gtt
@@ -44,7 +43,7 @@ npx webpack
4443

4544
Then run
4645

47-
```
46+
```sh
4847
export GEM_PG_VERSION=your-pg-version # skip this line if redmine use pg 1.2.2.
4948
export GEM_RGEO_ACTIVERECORD_VERSION=your-rgeo-activerecord-version # skip this line if using rgeo-activerecord 6.2.2.
5049
export GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=your-activerecord-postgis-adapter-version # skip this line if using activerecord-postgis-adapter 5.2.3.
@@ -56,7 +55,7 @@ Before restarting Redmine, you need to set `postgis` adapter instead of `postgre
5655

5756
After restarting Redmine, you should be able to see the Redmine GTT plugin in the Plugins page.
5857

59-
More information on installing (and uninstalling) Redmine plugins can be found here: http://www.redmine.org/wiki/redmine/Plugins
58+
More information on installing (and uninstalling) Redmine plugins can be found in the [Redmine Plugin docs](http://www.redmine.org/wiki/redmine/Plugins).
6059

6160
## How to use
6261

@@ -68,6 +67,10 @@ More information on installing (and uninstalling) Redmine plugins can be found h
6867

6968
For more information with screenshots see the [Getting Started](doc/getting-started.md) guide.
7069

70+
## Plugin API
71+
72+
For more information see the [Redmine GTT API](doc/api.md) docs.
73+
7174
## Contributing and Support
7275

7376
The GTT Project appreciates any [contributions](https://github.com/gtt-project/.github/blob/main/CONTRIBUTING.md)! Feel free to contact us for [reporting problems and support](https://github.com/gtt-project/.github/blob/main/CONTRIBUTING.md).
@@ -82,15 +85,15 @@ Help us to translate GTT Project using [OSGeo Weblate](https://weblate.osgeo.org
8285

8386
You can debug frontend by running the following command on another console:
8487

85-
```
88+
```sh
8689
npx webpack --watch --mode=development
8790
```
8891

8992
### How to run test
9093

9194
You can run the plugin test on rails test environment by the following command:
9295

93-
```
96+
```sh
9497
bundle exec rake db:create
9598
RAILS_ENV=test bundle exec rake db:migrate
9699
RAILS_ENV=test bundle exec rake redmine:plugins:migrate
@@ -99,8 +102,7 @@ RAILS_ENV=test NAME=redmine_gtt bundle exec rake redmine:plugins:test
99102

100103
## Version History
101104

102-
- **4.0.0**: Support Redmine >= 5.0 and drop Redmine <= 4.1 support
103-
- See [all releases](https://github.com/gtt-project/redmine_gtt/releases) with release notes.
105+
See [all releases](https://github.com/gtt-project/redmine_gtt/releases) with release notes.
104106

105107
## Authors
106108

@@ -109,6 +111,8 @@ RAILS_ENV=test NAME=redmine_gtt bundle exec rake redmine:plugins:test
109111
- [Thibault Mutabazi](https://github.com/eyewritecode)
110112
- [Ko Nagase](https://github.com/sanak)
111113
- [Taro Matsuzawa](https://github.com/smellman)
114+
- [Mario Basa](https://github.com/mbasa)
115+
- [Nisai Nob](https://github.com/nobnisai)
112116
- ... [and others](https://github.com/gtt-project/redmine_gtt/graphs/contributors)
113117

114118
## LICENSE
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
class GttConfigurationController < ApplicationController
2+
3+
before_action :find_optional_project_and_authorize
4+
5+
accept_api_auth :default_setting_configuration
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
12+
end
13+
14+
def build_default_setting_config
15+
default_tracker_icon = []
16+
default_status_color = []
17+
gtt_tile_source = []
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+
}
41+
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
63+
64+
private
65+
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
73+
end
74+
end

app/controllers/gtt_tile_sources_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def new
1616
def create
1717
r = RedmineGtt::Actions::CreateTileSource.(tile_source_params)
1818
if r.tile_source_created?
19-
redirect_to gtt_tile_sources_path
19+
redirect_to(params[:continue] ? new_gtt_tile_source_path : gtt_tile_sources_path)
2020
else
2121
@tile_source = r.tile_source
2222
render 'new'
@@ -61,7 +61,7 @@ def destroy
6161
def tile_source_params
6262
return {} unless params[:tile_source]
6363

64-
params[:tile_source].permit( :name, :type, :global, :position,
64+
params[:tile_source].permit( :name, :type, :baselayer, :global, :position,
6565
:default, :options_string )
6666
end
6767
end

0 commit comments

Comments
 (0)