diff --git a/app/assets/javascripts/controllers/projects.js.erb b/app/assets/javascripts/controllers/projects.js.erb
index 5125835e1..bd0b2c3ff 100644
--- a/app/assets/javascripts/controllers/projects.js.erb
+++ b/app/assets/javascripts/controllers/projects.js.erb
@@ -390,32 +390,32 @@ Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'P
if ($location.$$search.whole_network === 'f') {
$scope.openlab.searchOverWholeNetwork = false;
} else {
- $scope.openlab.searchOverWholeNetwork = ($scope.openlab.projectsActive && Fablab.openlabDefault) || false;
+ $scope.openlab.searchOverWholeNetwork = ($scope.openlab.projectsActive && settingsPromise.openlab_default === 'true') || false;
}
return $scope.triggerSearch();
};
/**
- * function to update url query param, little hack to turn off reloadOnSearch and re-enable it after setting the params
+ * function to update url query param, little hack to turn off reloadOnSearch and re-enable it after we set the params.
* params example: 'q' , 'presse-purée'
*/
- var updateUrlParam = function (name, value) {
+ const updateUrlParam = function (name, value) {
$state.current.reloadOnSearch = false;
$location.search(name, value);
return $timeout(function () { $state.current.reloadOnSearch = undefined; });
};
- var loadMoreCallback = function (projectsPromise) {
+ const loadMoreCallback = function (projectsPromise) {
$scope.projects = $scope.projects.concat(projectsPromise.projects);
return updateUrlParam('page', $scope.projectsPagination.currentPage);
};
- var loadMoreOpenlabCallback = function (projectsPromise) {
+ const loadMoreOpenlabCallback = function (projectsPromise) {
$scope.projects = $scope.projects.concat(normalizeProjectsAttrs(projectsPromise.projects));
return updateUrlParam('page', $scope.projectsPagination.currentPage);
};
- var normalizeProjectsAttrs = function (projects) {
+ const normalizeProjectsAttrs = function (projects) {
return projects.map(function (project) {
project.project_image = project.image_url;
return project;
diff --git a/app/assets/javascripts/router.js.erb b/app/assets/javascripts/router.js.erb
index 7d6f20b37..460b62f26 100644
--- a/app/assets/javascripts/router.js.erb
+++ b/app/assets/javascripts/router.js.erb
@@ -256,7 +256,7 @@ angular.module('application.router', ['ui.router'])
themesPromise: ['Theme', function (Theme) { return Theme.query().$promise; }],
componentsPromise: ['Component', function (Component) { return Component.query().$promise; }],
machinesPromise: ['Machine', function (Machine) { return Machine.query().$promise; }],
- settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['openlab_app_id']" }).$promise; }],
+ settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['openlab_app_id', 'openlab_default']" }).$promise; }],
openLabActive: ['Setting', function (Setting) { return Setting.isPresent({ name: 'openlab_app_secret' }).$promise; }],
}
})
@@ -616,7 +616,7 @@ angular.module('application.router', ['ui.router'])
}
})
- // project's elements
+ // project's settings
.state('app.admin.projects', {
url: '/admin/projects',
views: {
@@ -631,7 +631,7 @@ angular.module('application.router', ['ui.router'])
themesPromise: ['Theme', function (Theme) { return Theme.query().$promise; }],
settingsPromise: ['Setting', function (Setting) {
return Setting.query({ names: "['feature_tour_display', 'disqus_shortname', 'allowed_cad_extensions', \
- 'allowed_cad_mime_types', 'openlab_app_id', 'openlab_app_secret']" }).$promise;
+ 'allowed_cad_mime_types', 'openlab_app_id', 'openlab_app_secret', 'openlab_default']" }).$promise;
}]
}
})
diff --git a/app/assets/templates/admin/projects/settings.html.erb b/app/assets/templates/admin/projects/settings.html.erb
index d7cd3e214..12c1e32df 100644
--- a/app/assets/templates/admin/projects/settings.html.erb
+++ b/app/assets/templates/admin/projects/settings.html.erb
@@ -85,5 +85,14 @@
+
diff --git a/app/models/setting.rb b/app/models/setting.rb
index cf810ac00..a1fb0bf93 100644
--- a/app/models/setting.rb
+++ b/app/models/setting.rb
@@ -94,7 +94,8 @@ class Setting < ApplicationRecord
allowed_cad_extensions
allowed_cad_mime_types
openlab_app_id
- openlab_app_secret] }
+ openlab_app_secret
+ openlab_default] }
def value
last_value = history_values.order(HistoryValue.arel_table['created_at'].desc).first
last_value&.value
diff --git a/app/views/application/index.html.erb b/app/views/application/index.html.erb
index 534872a1c..eb8076215 100644
--- a/app/views/application/index.html.erb
+++ b/app/views/application/index.html.erb
@@ -48,7 +48,6 @@
Fablab.weekStartingDay = <%= Date.parse(Rails.application.secrets.week_starting_day).strftime('%w') %>;
Fablab.d3DateFormat = "<%= Rails.application.secrets.d3_date_format %>";
Fablab.uibDateFormat = "<%= Rails.application.secrets.uib_date_format %>";
- Fablab.openlabDefault = ('<%= Rails.application.secrets.openlab_default %>' !== 'false');
Fablab.userConfirmationNeededToSignIn = ('<%= Rails.application.secrets.user_confirmation_needed_to_sign_in %>' === 'true');
// feature tour (used when feature_tour_display = session)
diff --git a/config/locales/app.admin.en.yml b/config/locales/app.admin.en.yml
index 778f82e25..65aa2b1d8 100644
--- a/config/locales/app.admin.en.yml
+++ b/config/locales/app.admin.en.yml
@@ -161,6 +161,8 @@ en:
open_lab_info_html: "Enable OpenLab to share your projects with other Fab Labs and display a gallery of shared projects. Please send an email to contact@fab-manager.com to get your access credentials for free."
open_lab_app_id: "ID"
open_lab_app_secret: "Secret"
+ openlab_default_info_html: "In the projects gallery, visitors can switch between two views: all shared projets from the whole OpenLab network, or only the projects documented in your Fab Lab.
Here, you can choose which view is shown by default."
+ default_to_openlab: "Display OpenLab by default"
#track and monitor the trainings
trainings:
trainings_monitoring: "Trainings monitoring"
@@ -1079,6 +1081,7 @@ en:
item_added: "One item added"
openlab_app_id: "OpenLab ID"
openlab_app_secret: "OpenLab secret"
+ openlab_default: "default gallery view"
general:
general: "General"
title: "Title"
diff --git a/config/locales/app.admin.fr.yml b/config/locales/app.admin.fr.yml
index 4a4c58c72..9379f82bc 100644
--- a/config/locales/app.admin.fr.yml
+++ b/config/locales/app.admin.fr.yml
@@ -161,6 +161,8 @@ fr:
open_lab_info_html: "Activez OpenLab pout partager vos projets avec d'autres Fab Labs et afficher une galerie de projets partagés. Veuillez envoyer un courriel à contact@fab-manager.com pour obtenir gratuitement vos identifiants d'accès."
open_lab_app_id: "Identifiant"
open_lab_app_secret: "Secret"
+ openlab_default_info_html: "Dans la galerie de projets, les visiteurs peuvent choisir entre deux vues: tous les projets de l'ensemble du réseau OpenLab, ou uniquement les projets documentés dans votre Fab Lab.
Ici, vous pouvez choisir quelle vue est affichée par défaut."
+ default_to_openlab: "Afficher OpenLab par défaut"
#track and monitor the trainings
trainings:
trainings_monitoring: "Suivi formations"
@@ -1079,6 +1081,7 @@ fr:
item_added: "Un élément ajouté"
openlab_app_id: "l'identifiant OpenLab"
openlab_app_secret: "secret OpenLab"
+ openlab_default: "l'affichage par défaut de la galerie"
general:
general: "Général"
title: "Titre"
diff --git a/config/secrets.yml b/config/secrets.yml
index a37bddfa3..6be246373 100644
--- a/config/secrets.yml
+++ b/config/secrets.yml
@@ -32,7 +32,6 @@ development:
angular_locale: <%= ENV["ANGULAR_LOCALE"] %>
fullcalendar_locale: <%= ENV["FULLCALENDAR_LOCALE"] %>
elasticsearch_language_analyzer: <%= ENV["ELASTICSEARCH_LANGUAGE_ANALYZER"] %>
- openlab_default: <%= ENV["OPENLAB_DEFAULT"] %>
openlab_base_uri: <%= ENV["OPENLAB_BASE_URI"] %>
navinum_api_login: <%= ENV["NAVINUM_API_LOGIN"] %>
navinum_api_password: <%= ENV["NAVINUM_API_PASSWORD"] %>
@@ -66,7 +65,6 @@ test:
angular_locale: en-us
fullcalendar_locale: en
elasticsearch_language_analyzer: french
- openlab_default:
openlab_base_uri:
navinum_api_login:
navinum_api_password:
@@ -108,7 +106,6 @@ staging:
angular_locale: <%= ENV["ANGULAR_LOCALE"] %>
fullcalendar_locale: <%= ENV["FULLCALENDAR_LOCALE"] %>
elasticsearch_language_analyzer: <%= ENV["ELASTICSEARCH_LANGUAGE_ANALYZER"] %>
- openlab_default: <%= ENV["OPENLAB_DEFAULT"] %>
openlab_base_uri: <%= ENV["OPENLAB_BASE_URI"] %>
navinum_api_login: <%= ENV["NAVINUM_API_LOGIN"] %>
navinum_api_password: <%= ENV["NAVINUM_API_PASSWORD"] %>
@@ -153,7 +150,6 @@ production:
angular_locale: <%= ENV["ANGULAR_LOCALE"] %>
fullcalendar_locale: <%= ENV["FULLCALENDAR_LOCALE"] %>
elasticsearch_language_analyzer: <%= ENV["ELASTICSEARCH_LANGUAGE_ANALYZER"] %>
- openlab_default: <%= ENV["OPENLAB_DEFAULT"] %>
openlab_base_uri: <%= ENV["OPENLAB_BASE_URI"] %>
navinum_api_login: <%= ENV["NAVINUM_API_LOGIN"] %>
navinum_api_password: <%= ENV["NAVINUM_API_PASSWORD"] %>
diff --git a/doc/environment.md b/doc/environment.md
index 5b698bb2d..128d368c2 100644
--- a/doc/environment.md
+++ b/doc/environment.md
@@ -280,12 +280,6 @@ See [Crowdin documentation](https://support.crowdin.com/in-context-localization/
Accordingly, `RAILS_LOCALE` and `APP_LOCALE` must be configured to `zu`.
## OpenLab settings
-
-
- OPENLAB_DEFAULT
-
-When set to false, the default display will be the local projects when browsing the projects gallery.
-If not set or set to true, the projects from the OpenLab repository will be shown first.
OPENLAB_BASE_URI
diff --git a/env.example b/env.example
index 60306e0c7..888ceb410 100644
--- a/env.example
+++ b/env.example
@@ -56,7 +56,6 @@ UIB_DATE_FORMAT=dd/MM/yyyy
EXCEL_DATE_FORMAT=dd/mm/yyyy
# OpenLab Projects
-OPENLAB_DEFAULT=true
# do not change this URL
OPENLAB_BASE_URI=https://openprojects.fab-manager.com
diff --git a/lib/tasks/fablab/setup.rake b/lib/tasks/fablab/setup.rake
index 81830bca0..2784c04b3 100644
--- a/lib/tasks/fablab/setup.rake
+++ b/lib/tasks/fablab/setup.rake
@@ -124,7 +124,8 @@ namespace :fablab do
%w[_ ALLOWED_EXTENSIONS allowed_cad_extensions],
%w[_ ALLOWED_MIME_TYPES allowed_cad_mime_types],
%w[_ OPENLAB_APP_ID openlab_app_id],
- %w[_ OPENLAB_APP_SECRET openlab_app_secret]
+ %w[_ OPENLAB_APP_SECRET openlab_app_secret],
+ %w[_ OPENLAB_DEFAULT openlab_default]
]
mapping.each do |m|
diff --git a/setup/env.example b/setup/env.example
index 571ac6e1a..862847836 100644
--- a/setup/env.example
+++ b/setup/env.example
@@ -44,7 +44,6 @@ D3_DATE_FORMAT=%d/%m/%y
UIB_DATE_FORMAT=dd/MM/yyyy
EXCEL_DATE_FORMAT=dd/mm/yyyy
-OPENLAB_DEFAULT='true'
OPENLAB_BASE_URI=https://openprojects.fab-manager.com
NAVINUM_API_LOGIN=
diff --git a/setup/setup.sh b/setup/setup.sh
index 79b0460fe..aa4ed6596 100755
--- a/setup/setup.sh
+++ b/setup/setup.sh
@@ -239,7 +239,7 @@ configure_env_file()
SMTP_ENABLE_STARTTLS_AUTO SMTP_OPENSSL_VERIFY_MODE SMTP_TLS \
LOG_LEVEL MAX_IMAGE_SIZE MAX_CAO_SIZE MAX_IMPORT_SIZE DISK_SPACE_MB_ALERT \
SUPERADMIN_EMAIL APP_LOCALE RAILS_LOCALE MOMENT_LOCALE SUMMERNOTE_LOCALE ANGULAR_LOCALE FULLCALENDAR_LOCALE ELASTICSEARCH_LANGUAGE_ANALYZER TIME_ZONE \
- WEEK_STARTING_DAY D3_DATE_FORMAT UIB_DATE_FORMAT EXCEL_DATE_FORMAT OPENLAB_DEFAULT)
+ WEEK_STARTING_DAY D3_DATE_FORMAT UIB_DATE_FORMAT EXCEL_DATE_FORMAT)
for variable in "${variables[@]}"; do
local var_doc current
var_doc=$(get_md_anchor "$doc" "$variable")