Skip to content

Commit

Permalink
Merge pull request #325 from gtt-project/next
Browse files Browse the repository at this point in the history
Prepares for v5.1.0 release
  • Loading branch information
dkastl authored Jul 4, 2024
2 parents 1507ee5 + 12ef60e commit 2647e7a
Show file tree
Hide file tree
Showing 34 changed files with 1,611 additions and 473 deletions.
46 changes: 35 additions & 11 deletions .github/workflows/test-postgis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ on:
branches:
- main
- next
workflow_dispatch:

jobs:
test:
Expand All @@ -24,9 +25,17 @@ jobs:
strategy:
fail-fast: false
matrix:
redmine_version: [5.0-stable, master]
ruby_version: ['3.0', '3.1']
db_version: [12-3.0, 15-3.3]
redmine_version: [5.0-stable, 5.1-stable, master]
ruby_version: ['3.0', '3.1', '3.2']
db_version: [12-3.4, 16-3.4]
include:
- system_test: true
redmine_version: 5.1-stable
ruby_version: '3.2'
exclude:
- redmine_version: 5.0-stable
ruby_version: '3.2'
- redmine_version: master

services:
postgres:
Expand All @@ -40,29 +49,36 @@ jobs:

steps:
- name: Checkout Redmine
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: redmine/redmine
ref: ${{ matrix.redmine_version }}
path: redmine

- name: Checkout Plugin
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: redmine/plugins/${{ env.PLUGIN_NAME }}

- name: Update package archives
run: apt-get update --yes --quiet

- name: Install package dependencies
run: >
apt-get install --yes --quiet
postgresql-client
gcc libpq-dev make patch libgeos-dev curl
run: |
apt-get install --yes --quiet \
postgresql-client \
gcc libpq-dev make patch libgeos-dev curl
# For system test
if [ ${{ matrix.system_test }} = "true" ]; then
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
apt-get -y update
apt-get install -y google-chrome-stable
fi
- name: Install Node/Yarn packages
run: |
curl -sL https://deb.nodesource.com/setup_16.x | bash -
curl -sL https://deb.nodesource.com/setup_20.x | bash -
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
apt-get update --yes --quiet
Expand Down Expand Up @@ -122,8 +138,16 @@ jobs:
- name: Run tests
env:
RAILS_ENV: test
# For system test in plugin
GOOGLE_CHROME_OPTS_ARGS: "headless,disable-gpu,no-sandbox,disable-dev-shm-usage"
working-directory: redmine
run: bundle exec rake redmine:plugins:test NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0"
run: |
bundle exec rake redmine:plugins:test:units NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0"
bundle exec rake redmine:plugins:test:functionals NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0"
bundle exec rake redmine:plugins:test:integration NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0"
if [ ${{ matrix.system_test }} = "true" ]; then
bundle exec rake redmine:plugins:test:system NAME=${{ env.PLUGIN_NAME }} RUBYOPT="-W0"
fi
- name: Run uninstall test
env:
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ 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.
gem 'blankslate', '~> 3.1.3'
9 changes: 9 additions & 0 deletions app/helpers/gtt_map_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def map_tag(map: nil, layers: map&.layers,
data[:upload] = upload
data[:collapsed] = collapsed if collapsed
data[:geocoding] = true if Setting.plugin_redmine_gtt['enable_geocoding_on_map'] == 'true'
data[:measure] = true if Setting.plugin_redmine_gtt['default_measure_enabled'] == 'true'
data[:target] = true if Setting.plugin_redmine_gtt['default_target_enabled'] == 'true'

uid = "ol-" + rand(36**8).to_s(36)

Expand Down Expand Up @@ -68,6 +70,13 @@ def map_tag(map: nil, layers: map&.layers,
window.createGttClient(target);
contentObserver();
}, { once: true });
var target = document.getElementById('#{uid}');
if (
document.readyState === 'complete'
&& !target.hasChildNodes()
) {
window.createGttClient(target);
}
}
document.addEventListener('DOMContentLoaded', function(){
var target = document.getElementById('#{uid}');
Expand Down
21 changes: 18 additions & 3 deletions app/views/gtt_map_layers/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<p>
<%= f.select :layer,
options_for_select(
['Image','Tile','MapboxVector','Vector','VectorTile'],
['Image','Tile','MapboxVector','Vector','VectorTile','WebGLTile'],
selected: f.object.layer ),
{ include_blank: t('map_layer.layer_options_select'), required: true }
%>
Expand All @@ -22,7 +22,7 @@
<p>
<%= f.select :source,
options_for_select(
['BingMaps','CartoDB','ImageStatic','ImageWMS','OSM','Raster','Stamen',
['BingMaps','CartoDB','Google','ImageStatic','ImageWMS','OSM','Raster',
'TileJSON','TileWMS','UTFGrid','Vector','VectorTile','WMTS','XYZ'],
selected: f.object.source ),
{ include_blank: t('map_layer.source_options_select') }
Expand Down Expand Up @@ -51,10 +51,11 @@
document.addEventListener('DOMContentLoaded', function() {
const map_layer_config = {
'Image': ['ImageStatic','ImageWMS','Raster'],
'Tile': ['BingMaps','CartoDB','OSM','Stamen','TileJSON','TileWMS','UTFGrid','WMTS','XYZ'],
'Tile': ['BingMaps','CartoDB','OSM','TileJSON','TileWMS','UTFGrid','WMTS','XYZ'],
'MapboxVector': [],
'Vector': ['Vector'],
'VectorTile': ['VectorTile'],
'WebGLTile': ['Google'],
};

const map_format_config = {
Expand Down Expand Up @@ -211,5 +212,19 @@
},
'format': 'ol.format.MVT',
'format_options': {}
},{
'name': 'Google Maps',
'layer': 'WebGLTile',
'layer_options': {},
'source': 'Google',
'source_options': {
'key': 'YOUR_API_KEY',
'mapType': 'roadmap',
'language': 'ja_JP',
'scale': 'scaleFactor2x',
'layerTypes': ['layerTraffic'],
},
'format': '',
'format_options': {}
}];
</script>
2 changes: 1 addition & 1 deletion app/views/issues/show.api.rsb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ api.issue do
api.total_spent_hours(@issue.total_spent_hours)
end

if @issue.geom
if @issue.geom.present?
api.geojson (params[:format] == "json") ? @issue.geojson : @issue.geojson.to_json
else
api.geojson nil
Expand Down
8 changes: 7 additions & 1 deletion app/views/issues/show/_map.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
<% if @project.nil? or @project.module_enabled?(:gtt) %>
<%= map_tag map: @issue.map, geom: (@issue.as_geojson(include_properties: { only: %i(tracker_id status_id) }) if @issue), rotation: @project.map_rotation %>
<% if @issue.geom.present? or !Setting.plugin_redmine_gtt['hide_map_for_invalid_geom'] %>
<%= map_tag map: @issue.map,
geom: (@issue.as_geojson(include_properties: { only: %i(tracker_id status_id) }) if @issue),
rotation: @project.map_rotation %>
<% else %>
<div class="flash nodata"><%= l(:gtt_hide_map_for_invalid_geom_info) %></div>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<% if (@project.nil? or @project.module_enabled?(:gtt)) &&
<% if issue.project && issue.project.module_enabled?(:gtt) &&
((issue.new_record? && User.current.allowed_to?(:add_issues, issue.project)) ||
User.current.allowed_to?(:edit_issues, issue.project))
%>
<%= map_form_field form, issue.map, bounds: issue.project.map.bounds, rotation: @project.map_rotation,
<%= map_form_field form, issue.map, bounds: issue.project.map.bounds, rotation: issue.project.map_rotation || 0,
edit_mode: Setting.plugin_redmine_gtt['editable_geometry_types_on_issue_map'] && Setting.plugin_redmine_gtt['editable_geometry_types_on_issue_map'].join(' '),
upload: Setting.plugin_redmine_gtt['enable_geojson_upload_on_issue_map'] == "true" %>
<% end %>

20 changes: 20 additions & 0 deletions app/views/settings/gtt/_general.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
@settings['default_map_fit_maxzoom_level'],
:size => 10) %>
</p>

</div>

<div class="box tabular settings">
Expand All @@ -62,3 +63,22 @@
<%= check_box_tag 'settings[enable_geojson_upload_on_issue_map]', true, @settings[:enable_geojson_upload_on_issue_map] %>
</p>
</div>

<div class="box tabular settings">
<h3><%= l(:select_other_gtt_settings) %></h3>

<p>
<%= content_tag(:label, l(:label_default_target_enabled)) %>
<%= check_box_tag 'settings[default_target_enabled]', true, @settings[:default_target_enabled] %>
</p>

<p>
<%= content_tag(:label, l(:label_default_measure_enabled)) %>
<%= check_box_tag 'settings[default_measure_enabled]', true, @settings[:default_measure_enabled] %>
</p>

<p>
<%= content_tag(:label, l(:label_hide_map_for_invalid_geom)) %>
<%= check_box_tag 'settings[hide_map_for_invalid_geom]', 1, Setting.plugin_redmine_gtt['hide_map_for_invalid_geom'] %>
</p>
</div>
40 changes: 40 additions & 0 deletions app/views/settings/gtt/_geocoder.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
<%= check_box_tag 'settings[enable_geocoding_on_map]', true, @settings[:enable_geocoding_on_map] %>
</p>

<p>
<%= content_tag(:label, l(:geocoder_provider)) %>
<%= select_tag 'settings[default_geocoder_provider]',
options_for_select([
['Google', 'google'],
['Nominatim (OSM)', 'nominatim'],
['Photon', 'photon'],
['Custom', 'custom', {disabled: true}]
], @settings['default_geocoder_provider']),
include_blank: true %>
<%= link_to t('geocoder_load_example'), '#', id: 'geocoder_load_example', class: 'info' %>
</p>

<p>
<%= content_tag(:label, l(:geocoder_options)) %>
<%= text_area_tag('settings[default_geocoder_options]',
Expand All @@ -15,3 +28,30 @@
:cols => 100) %>
</p>
</div>

<script>
document.getElementById('geocoder_load_example').addEventListener('click', (event) => {
event.preventDefault();
const provider = document.getElementById('settings_default_geocoder_provider').value;
const example = geocoder_examples.find((example) => example.name === provider);
document.getElementById('settings_default_geocoder_options').value = example?.options ? JSON.stringify(example.options, undefined, 2) : "{}";
});

const geocoder_examples = [{
'name': 'nominatim',
'options': {}
}, {
'name': 'google',
'options': {
'apiKey': 'YOUR_API_KEY'
}
}, {
'name': 'photon',
'options': {}
}, {
'name': 'custom',
'options': {
'url': 'https://example.com/geocoder'
}
}];
</script>
26 changes: 25 additions & 1 deletion app/views/settings/gtt/_settings.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,33 @@
{ :name => :geocoder, :partial => 'settings/gtt/geocoder', :label => :gtt_settings_label_geocoder }
] %>
<%= render_tabs plugin_tabs %>
<%= javascript_tag do %>
// Read query parameter
function getQueryParam(param) {
var urlParams = new URLSearchParams(window.location.search);
return urlParams.get(param);
}

// Activate tab by name
function activateTab(tabName) {
var tabLinks = document.querySelectorAll('.tabs a');
tabLinks.forEach(function(link) {
if (link.href.includes('tab=' + tabName)) {
link.click();
}
});
}

// Activate tab if it is specified in the URL
document.addEventListener('DOMContentLoaded', function() {
var tab = getQueryParam('tab');
if (tab) {
activateTab(tab);
}
});

// Apply settings
window.gtt_setting()
<% end %>
Loading

0 comments on commit 2647e7a

Please sign in to comment.