1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-28 09:24:24 +01:00

set openlab_default from the UI

This commit is contained in:
Sylvain 2020-06-08 16:15:44 +02:00
parent f78eb10c75
commit b44a8da73b
13 changed files with 29 additions and 25 deletions

View File

@ -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;

View File

@ -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;
}]
}
})

View File

@ -85,5 +85,14 @@
</text-setting>
</div>
</div>
<div class="row m-t" ng-show="allSettings.openlab_app_secret">
<p class="alert alert-warning m-h-md" ng-bind-html="'app.admin.projects.settings.openlab_default_info_html' | translate"></p>
<boolean-setting name="openlab_default"
settings="allSettings"
label="app.admin.projects.settings.default_to_openlab"
classes="m-l"
yes-label="app.shared.buttons.yes"
no-label="app.shared.buttons.no"></boolean-setting>
</div>
</div>
</div>

View File

@ -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

View File

@ -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)

View File

@ -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 <a href='mailto:contact@fab-manager.com'>contact@fab-manager.com</a> 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.<br/>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"

View File

@ -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 à <a href='mailto:contact@fab-manager.com'>contact@fab-manager.com</a> 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.<br/>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"

View File

@ -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"] %>

View File

@ -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`.
<a name="open-projects-settings"></a>
## OpenLab settings
<a name="OPENLAB_DEFAULT"></a>
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.
<a name="OPENLAB_BASE_URI"></a>
OPENLAB_BASE_URI

View File

@ -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

View File

@ -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|

View File

@ -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=

View File

@ -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")