diff --git a/CHANGELOG.md b/CHANGELOG.md index ad0936712..2d8b85475 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog Fab-manager +## v5.3.12 2022 April 20 + +- Auto sync projects to OpenLab if set openlab_app_id and openlab_app_secret +- Fix a bug: back bouton can't return to previously page in projects page (list/new/show/edit) +- Fix a bug: OpenLab duplicate projects, if you are using OpenLab Projects, please follow the following TODO DEPLOY +- Fix a security issue: updated async to 2.6.4 to fix [CVE-2021-43138](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-43138) +- [TODO DEPLOY] `rails fablab:openlab:bulk_export` +- [TODO DEPLOY] wait 1 minute +- [TODO DEPLOY] `rails fablab:openlab:bulk_update` + ## v5.3.11 2022 April 15 - Fix a bug: unable to send notification mail if no set a logo diff --git a/app/frontend/src/javascript/controllers/projects.js b/app/frontend/src/javascript/controllers/projects.js index 7cd5c1bef..e1be57f41 100644 --- a/app/frontend/src/javascript/controllers/projects.js +++ b/app/frontend/src/javascript/controllers/projects.js @@ -287,7 +287,7 @@ Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'P // Is openLab enabled on the instance? $scope.openlab = { projectsActive: openLabActive.isPresent, - searchOverWholeNetwork: false + searchOverWholeNetwork: settingsPromise.openlab_default === 'true' }; // default search parameters @@ -397,6 +397,20 @@ Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'P return true; }; + /** + * Overlap global function to allow the user to navigate to the previous screen + * If no previous $state were recorded, navigate to the project list page + */ + $scope.backPrevLocation = function (event) { + event.preventDefault(); + event.stopPropagation(); + if ($state.prevState === '' || $state.prevState === 'app.public.projects_list') { + $state.prevState = 'app.public.home'; + return $state.go($state.prevState, {}); + } + window.history.back(); + }; + /* PRIVATE SCOPE */ /** @@ -405,8 +419,10 @@ Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'P const initialize = function () { if ($location.$$search.whole_network === 'f') { $scope.openlab.searchOverWholeNetwork = false; + } else if ($location.$$search.whole_network === undefined) { + $scope.openlab.searchOverWholeNetwork = $scope.openlab.projectsActive && settingsPromise.openlab_default === 'true'; } else { - $scope.openlab.searchOverWholeNetwork = ($scope.openlab.projectsActive && settingsPromise.openlab_default === 'true') || false; + $scope.openlab.searchOverWholeNetwork = $scope.openlab.projectsActive; } return $scope.triggerSearch(); }; @@ -472,6 +488,20 @@ Application.Controllers.controller('NewProjectController', ['$rootScope', '$scop $scope.matchingMembers = []; + /* + * Overlap global function to allow the user to navigate to the previous screen + * If no previous $state were recorded, navigate to the project list page + */ + $scope.backPrevLocation = function (event) { + event.preventDefault(); + event.stopPropagation(); + if ($state.prevState === '') { + $state.prevState = 'app.public.projects_list'; + return $state.go($state.prevState, {}); + } + window.history.back(); + }; + // Using the ProjectsController return new ProjectsController($rootScope, $scope, $state, Project, Machine, Member, Component, Theme, Licence, $document, Diacritics, dialogs, allowedExtensions, _t); } @@ -500,6 +530,19 @@ Application.Controllers.controller('EditProjectController', ['$rootScope', '$sco }); }); + /** + * Overlap global function to allow the user to navigate to the previous screen + * If no previous $state were recorded, navigate to the project show page + */ + $scope.backPrevLocation = function (event) { + event.preventDefault(); + event.stopPropagation(); + if ($state.prevState === '') { + $state.prevState = 'app.public.projects_show'; + } + $state.go($state.prevState, { id: $transition$.params().id }); + }; + /* PRIVATE SCOPE */ /** @@ -637,5 +680,19 @@ Application.Controllers.controller('ShowProjectController', ['$scope', '$state', * Return the URL allowing to share the current project on the Twitter social network */ $scope.shareOnTwitter = function () { return `https://twitter.com/intent/tweet?url=${encodeURIComponent($state.href('app.public.projects_show', { id: $scope.project.slug }, { absolute: true }))}&text=${encodeURIComponent($scope.project.name)}`; }; + + /** + * Overlap global function to allow the user to navigate to the previous screen + * If no previous $state were recorded, navigate to the project list page + */ + $scope.backPrevLocation = function (event) { + event.preventDefault(); + event.stopPropagation(); + if ($state.prevState === '') { + $state.prevState = 'app.public.projects_list'; + return $state.go($state.prevState, {}); + } + window.history.back(); + }; } ]); diff --git a/app/services/setting_service.rb b/app/services/setting_service.rb index 5b458cfb8..2a74fd1b9 100644 --- a/app/services/setting_service.rb +++ b/app/services/setting_service.rb @@ -23,5 +23,12 @@ class SettingService # generate statistics PeriodStatisticsWorker.perform_async(setting.previous_update) if setting.name == 'statistics_module' && setting.value == 'true' + + # export projects to openlab + if %w[openlab_app_id openlab_app_secret].include? setting.name + if Setting.get('openlab_app_id').present? && Setting.get('openlab_app_secret').present? + Project.all.each { |pr| pr.openlab_create } + end + end end end diff --git a/lib/tasks/fablab/openlab.rake b/lib/tasks/fablab/openlab.rake index 41bcb7d1c..927593e14 100644 --- a/lib/tasks/fablab/openlab.rake +++ b/lib/tasks/fablab/openlab.rake @@ -5,13 +5,25 @@ namespace :fablab do namespace :openlab do desc 'bulk and export projects to openlab' task bulk_export: :environment do - if Setting.get('openlab_app_secret').present? + if Setting.get('openlab_app_id').present? && Setting.get('openlab_app_secret').present? Project.find_each do |project| project.openlab_create puts '-> Done' end else - warn "Openlab_app_secret was not configured. Export can't be done." + warn "openlab_app_id or openlab_app_secret was not configured. Export can't be done." + end + end + + desc 'bulk update projects to openlab' + task bulk_update: :environment do + if Setting.get('openlab_app_id').present? && Setting.get('openlab_app_secret').present? + Project.find_each do |project| + project.openlab_update + puts '-> Done' + end + else + warn "openlab_app_id or openlab_app_secret was not configured. Update can't be done." end end end diff --git a/package.json b/package.json index bb6c118c0..d8b7e1f5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fab-manager", - "version": "5.3.11", + "version": "5.3.12", "description": "Fab-manager is the FabLab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.", "keywords": [ "fablab", diff --git a/yarn.lock b/yarn.lock index 775bf3f83..76dca88dd 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2230,9 +2230,9 @@ astral-regex@^1.0.0: integrity sha512-+Ryf6g3BKoRc7jfp7ad8tM4TtMiaWvbF/1/sQcZPkkS7ag3D5nMBCe2UfOTONtAkaG0tO0ij3C5Lwmf1EiyjHg== async@^2.6.2: - version "2.6.3" - resolved "https://registry.yarnpkg.com/async/-/async-2.6.3.tgz#d72625e2344a3656e3a3ad4fa749fa83299d82ff" - integrity sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg== + version "2.6.4" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.4.tgz#706b7ff6084664cd7eae713f6f965433b5504221" + integrity sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA== dependencies: lodash "^4.17.14"