Skip to content

Commit

Permalink
Merge pull request #242 from gtt-project/next
Browse files Browse the repository at this point in the history
Prepares for the v5.0.0 release
  • Loading branch information
dkastl authored Jun 21, 2023
2 parents 45a4bdc + bad1f8c commit 3297a7e
Show file tree
Hide file tree
Showing 133 changed files with 11,380 additions and 5,530 deletions.
36 changes: 13 additions & 23 deletions .github/workflows/test-postgis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ on:
push:
branches:
- main
- next
pull_request:
branches:
- main
- next

jobs:
test:
Expand All @@ -22,18 +24,9 @@ jobs:
strategy:
fail-fast: false
matrix:
redmine_version: [4.2-stable, 5.0-stable, master]
ruby_version: ['2.7', '3.0', '3.1', '3.2']
db_version: [11-2.5, 15-3.3]
exclude:
- redmine_version: 4.2-stable
ruby_version: 3.0
- redmine_version: 4.2-stable
ruby_version: 3.1
- redmine_version: 4.2-stable
ruby_version: 3.2
- redmine_version: 5.0-stable
ruby_version: 3.2
redmine_version: [5.0-stable, master]
ruby_version: ['3.0', '3.1']
db_version: [12-3.0, 15-3.3]

services:
postgres:
Expand Down Expand Up @@ -94,17 +87,14 @@ jobs:
encoding: utf8
EOF
- name: Adjust Gem environment
run: |
case "${{ matrix.redmine_version }}" in
4.2-stable)
echo "GEM_RGEO_ACTIVERECORD_VERSION=6.2.2" >> ${GITHUB_ENV}
echo "GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=5.2.3" >> ${GITHUB_ENV}
;;
master)
echo "GEM_PG_VERSION=1.4.5" >> ${GITHUB_ENV}
;;
esac
# - name: Adjust Gem environment
# run: |
# case "${{ matrix.redmine_version }}" in
# 4.2-stable)
# echo "GEM_RGEO_ACTIVERECORD_VERSION=6.2.2" >> ${GITHUB_ENV}
# echo "GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=5.2.3" >> ${GITHUB_ENV}
# ;;
# esac

- name: Install Ruby dependencies
working-directory: redmine
Expand Down
16 changes: 5 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
# Ignore commonly generated/ignored files
.DS_Store
node_modules
# webpack generate files
assets/javascripts/main.js
assets/javascripts/main.js.*
assets/javascripts/*.png
assets/javascripts/*.svg
assets/javascripts/*.ttf
assets/javascripts/*.eot
assets/javascripts/*.woff2
assets/javascripts/*.woff

node_modules/

# Ignore webpack generated files
assets/*
!assets/.keep
16 changes: 12 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
source 'https://rubygems.org'

# Define gem versions with environment variables or default versions
gem_versions = {
pg: ENV['GEM_PG_VERSION'] || '1.5.3',
rgeo: ENV['GEM_RGEO_VERSION'] || '3.0.0',
rgeo_activerecord: ENV['GEM_RGEO_ACTIVERECORD_VERSION'] || '7.0.1',
activerecord_postgis_adapter: ENV['GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION'] || '7.1.1'
}

gem 'deface'
gem 'immutable-struct'
gem "rgeo", "~> 2.4.0"
gem "rgeo", "~> #{gem_versions[:rgeo]}"
gem "rgeo-geojson"
gem "pg", (ENV['GEM_PG_VERSION'] ? "~> #{ENV['GEM_PG_VERSION']}" : "~> 1.2.2") # make sure we use a version compatible with AR
gem "rgeo-activerecord", (ENV['GEM_RGEO_ACTIVERECORD_VERSION'] ? "~> #{ENV['GEM_RGEO_ACTIVERECORD_VERSION']}" : "~> 7.0.1") # same as above
gem 'activerecord-postgis-adapter', (ENV['GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION'] ? "~> #{ENV['GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION']}" : "~> 7.1.1") # same as above
gem "pg", "~> #{gem_versions[:pg]}"
gem "rgeo-activerecord", "~> #{gem_versions[:rgeo_activerecord]}"
gem 'activerecord-postgis-adapter', "~> #{gem_versions[:activerecord_postgis_adapter]}"
gem 'rails-controller-testing' # This gem brings back assigns to your controller tests as well as assert_template to both controller and integration tests.
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ The Geo-Task-Tracker (GTT) plugin adds spatial capabilities to Redmine:
Redmine GTT plugins **require PostgreSQL/PostGIS** and will not work with SQLite
or MariaDB/MySQL!!!

- Redmine >= 4.2.0
- PostgreSQL >= 10
- PostGIS >= 2.5
- NodeJS v14
- Redmine >= 5.0.0
- PostgreSQL >= 12
- PostGIS >= 3.0
- NodeJS v18
- yarn

## Installation
Expand All @@ -43,12 +43,17 @@ yarn
npx webpack
```

Optionally export to override the [default GEM version](./Gemfile)

```sh
export GEM_PG_VERSION=your-pg-version
export GEM_RGEO_ACTIVERECORD_VERSION=your-rgeo-activerecord-version
export GEM_ACTIVERECORD_POSTGIS_ADAPTER_VERSION=your-activerecord-postgis-adapter-version
```

Then run

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

```sh
npx webpack --watch --mode=development
npx webpack --watch --mode=development --devtool=source-map
```

### How to run test
Expand Down
123 changes: 61 additions & 62 deletions app/controllers/gtt_configuration_controller.rb
Original file line number Diff line number Diff line change
@@ -1,74 +1,73 @@
class GttConfigurationController < ApplicationController

before_action :find_optional_project_and_authorize
before_action :find_optional_project_and_authorize

accept_api_auth :default_setting_configuration
accept_api_auth :default_setting_configuration

def default_setting_configuration
gtt_map_config = build_default_setting_config
respond_to do |format|
format.api { render json: build_default_setting_config}
end
def default_setting_configuration
gtt_map_config = build_default_setting_config
respond_to do |format|
format.api { render json: build_default_setting_config}
end
end

def build_default_setting_config
default_tracker_icon = []
default_status_color = []
gtt_tile_source = []
def build_default_setting_config
default_tracker_icon = []
default_status_color = []
gtt_map_layer = []

Tracker.all.sort.each {|tracker|
default_tracker_icon.append({
trackerID: tracker.id,
trackerName: tracker.name,
icon: Setting.plugin_redmine_gtt['tracker_'+tracker.id.to_s]
})
}
IssueStatus.all.sort.each {|status|
default_status_color.append({
statusID: status.id,
statusName: status.name,
color: Setting.plugin_redmine_gtt['status_'+status.id.to_s]
})
}
GttTileSource.where(global: true).sort.each {|tileSource|
gtt_tile_source.append({
id: tileSource.id,
name: tileSource.name,
type: tileSource.type,
options: tileSource.options
})
}
Tracker.all.sort.each {|tracker|
default_tracker_icon.append({
trackerID: tracker.id,
trackerName: tracker.name,
icon: Setting.plugin_redmine_gtt['tracker_'+tracker.id.to_s]
})
}

mapConfig = {
gttDefaultSetting: {
defaultTrackerIcon: default_tracker_icon,
defaultStatusColor: default_status_color,
defaultMapSetting: {
centerLng: Setting.plugin_redmine_gtt['default_map_center_longitude'],
centerLat: Setting.plugin_redmine_gtt['default_map_center_latitude']
},
geometrySetting: {
geometryTypes: Setting.plugin_redmine_gtt['editable_geometry_types_on_issue_map'],
GeoJsonUpload: (Setting.plugin_redmine_gtt['enable_geojson_upload_on_issue_map'] == 'true'),
},
geocoderSetting: {
enableGeocodingOnMap: (Setting.plugin_redmine_gtt['enable_geocoding_on_map'] == 'true'),
geocoderOptions: Setting.plugin_redmine_gtt['default_geocoder_options']
},
},
gttLayer: gtt_tile_source,
}
return mapConfig
end
IssueStatus.all.sort.each {|status|
default_status_color.append({
statusID: status.id,
statusName: status.name,
color: Setting.plugin_redmine_gtt['status_'+status.id.to_s]
})
}

GttMapLayer.where(global: true).sort.each {|mapLayer|
gtt_map_layer.append(
mapLayer.as_json.except("created_at", "updated_at","position","global")
)
}

mapConfig = {
gttDefaultSetting: {
defaultTrackerIcon: default_tracker_icon,
defaultStatusColor: default_status_color,
defaultMapSetting: {
centerLng: Setting.plugin_redmine_gtt['default_map_center_longitude'],
centerLat: Setting.plugin_redmine_gtt['default_map_center_latitude']
},
geometrySetting: {
geometryTypes: Setting.plugin_redmine_gtt['editable_geometry_types_on_issue_map'],
GeoJsonUpload: (Setting.plugin_redmine_gtt['enable_geojson_upload_on_issue_map'] == 'true'),
},
geocoderSetting: {
enableGeocodingOnMap: (Setting.plugin_redmine_gtt['enable_geocoding_on_map'] == 'true'),
geocoderOptions: Setting.plugin_redmine_gtt['default_geocoder_options']
},
},
gttLayer: gtt_map_layer,
}
return mapConfig
end

private
private

def find_optional_project_and_authorize
if params[:project_id]
@project = Project.find params[:project_id]
authorize
else
authorize_global
end
def find_optional_project_and_authorize
if params[:project_id]
@project = Project.find(params[:project_id])
authorize
else
authorize_global
end
end
end
6 changes: 6 additions & 0 deletions app/controllers/gtt_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class GttController < ApplicationController
def map
path = Rails.root.join('public', 'plugin_assets', 'redmine_gtt', 'javascripts', 'main.js.map')
send_file path, type: 'application/json', disposition: 'inline'
end
end
71 changes: 71 additions & 0 deletions app/controllers/gtt_map_layers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
class GttMapLayersController < ApplicationController
layout 'admin'

before_action :require_admin

self.main_menu = false

def index
@map_layers = GttMapLayer.sorted
end

def new
@map_layer = GttMapLayer.new
end

def create
r = RedmineGtt::Actions::CreateMapLayer.(map_layer_params)
if r.map_layer_created?
redirect_to(params[:continue] ? new_gtt_map_layer_path : gtt_map_layers_path)
else
@map_layer = r.map_layer
render 'new'
end
end

def edit
@map_layer = GttMapLayer.find(params[:id])
end

def update
ml = GttMapLayer.find(params[:id])
r = RedmineGtt::Actions::UpdateMapLayer.(ml, map_layer_params)
if r.map_layer_updated?
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_update)
redirect_to gtt_map_layers_path
}
format.js { head 200 }
end
else
respond_to do |format|
format.html {
@map_layer = r.map_layer
render 'edit'
}
format.js { head 422 }
end
end
end

def destroy
ml = GttMapLayer.find(params[:id])
ml.destroy
redirect_to gtt_map_layers_path
end

private

def map_layer_params
return {} unless params[:map_layer]

params[:map_layer].permit(
:name, :default, :global, :baselayer, :position,
:layer, :layer_options_string,
:source, :source_options_string,
:format, :format_options_string,
:styles
)
end
end
Loading

0 comments on commit 3297a7e

Please sign in to comment.