diff --git a/README.md b/README.md
index 1fc0207a8..85ca8fa94 100644
--- a/README.md
+++ b/README.md
@@ -71,9 +71,8 @@ The deal is fair, you share your projects and as reward you benefits from projec
If you want to try it, you can visit [this Fab-manager](https://fablab.lacasemate.fr/#!/projects) and see projects from different Fab-managers.
To start using this awesome feature, there are a few steps:
-- send a mail to **contact@fab-manager.com** asking for your Open Projects client's credentials and giving them the name of your Fab-manager, they will give you an `OPENLAB_APP_ID` and an `OPENLAB_APP_SECRET`
-- fill in the value of the keys in your environment file
-- start your Fab-manager app
+- send a mail to **contact@fab-manager.com** asking for your Open Projects client's credentials and giving them the name and the URL of your Fab-manager, they will give you an `App ID` and a `secret`
+- fill in the value of the keys in Admin > Projects > Settings > Projects sharing
- export your projects to open-projects (if you already have projects created on your Fab-manager, unless you can skip that part) executing this command: `bundle exec rake fablab:openlab:bulk_export`
**IMPORTANT: please run your server in production mode.**
diff --git a/app/assets/javascripts/controllers/projects.js.erb b/app/assets/javascripts/controllers/projects.js.erb
index 99cbfd47a..5125835e1 100644
--- a/app/assets/javascripts/controllers/projects.js.erb
+++ b/app/assets/javascripts/controllers/projects.js.erb
@@ -87,7 +87,7 @@ class ProjectsController {
$scope.totalSteps = $scope.project.project_steps_attributes.length;
// List of extensions allowed for CAD attachements upload
- $scope.allowedExtensions = allowedExtensions;
+ $scope.allowedExtensions = allowedExtensions.setting.value.split(' ');
/**
* For use with ngUpload (https://github.com/twilson63/ngUpload).
@@ -266,8 +266,8 @@ class ProjectsController {
/**
* Controller used on projects listing page
*/
-Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'Project', 'machinesPromise', 'themesPromise', 'componentsPromise', 'paginationService', 'OpenlabProject', '$window', 'growl', '_t', '$location', '$timeout',
- function ($scope, $state, Project, machinesPromise, themesPromise, componentsPromise, paginationService, OpenlabProject, $window, growl, _t, $location, $timeout) {
+Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'Project', 'machinesPromise', 'themesPromise', 'componentsPromise', 'paginationService', 'OpenlabProject', '$window', 'growl', '_t', '$location', '$timeout', 'settingsPromise', 'openLabActive',
+ function ($scope, $state, Project, machinesPromise, themesPromise, componentsPromise, paginationService, OpenlabProject, $window, growl, _t, $location, $timeout, settingsPromise, openLabActive) {
/* PRIVATE STATIC CONSTANTS */
// Number of projects added to the page when the user clicks on 'load more projects'
@@ -277,11 +277,11 @@ Application.Controllers.controller('ProjectsController', ['$scope', '$state', 'P
/* PUBLIC SCOPE */
// Fab-manager's instance ID in the openLab network
- $scope.openlabAppId = Fablab.openlabAppId;
+ $scope.openlabAppId = settingsPromise.openlab_app_id
// Is openLab enabled on the instance?
$scope.openlab = {
- projectsActive: Fablab.openlabProjectsActive,
+ projectsActive: openLabActive.isPresent,
searchOverWholeNetwork: false
};
diff --git a/app/assets/javascripts/router.js.erb b/app/assets/javascripts/router.js.erb
index 8e6979fe6..7d6f20b37 100644
--- a/app/assets/javascripts/router.js.erb
+++ b/app/assets/javascripts/router.js.erb
@@ -255,7 +255,9 @@ angular.module('application.router', ['ui.router'])
resolve: {
themesPromise: ['Theme', function (Theme) { return Theme.query().$promise; }],
componentsPromise: ['Component', function (Component) { return Component.query().$promise; }],
- machinesPromise: ['Machine', function (Machine) { return Machine.query().$promise; }]
+ machinesPromise: ['Machine', function (Machine) { return Machine.query().$promise; }],
+ settingsPromise: ['Setting', function (Setting) { return Setting.query({ names: "['openlab_app_id']" }).$promise; }],
+ openLabActive: ['Setting', function (Setting) { return Setting.isPresent({ name: 'openlab_app_secret' }).$promise; }],
}
})
.state('app.logged.projects_new', {
@@ -267,7 +269,7 @@ angular.module('application.router', ['ui.router'])
}
},
resolve: {
- allowedExtensions: ['Project', function (Project) { return Project.allowedExtensions().$promise; }]
+ allowedExtensions: ['Setting', function (Setting) { return Setting.get({ name: 'allowed_cad_extensions' }).$promise; }]
}
})
.state('app.public.projects_show', {
@@ -293,7 +295,7 @@ angular.module('application.router', ['ui.router'])
},
resolve: {
projectPromise: ['$stateParams', 'Project', function ($stateParams, Project) { return Project.get({ id: $stateParams.id }).$promise; }],
- allowedExtensions: ['Project', function (Project) { return Project.allowedExtensions().$promise; }]
+ allowedExtensions: ['Setting', function (Setting) { return Setting.get({ name: 'allowed_cad_extensions' }).$promise; }]
}
})
@@ -629,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', 'open_lab_app_id', 'open_lab_app_secret']" }).$promise;
+ 'allowed_cad_mime_types', 'openlab_app_id', 'openlab_app_secret']" }).$promise;
}]
}
})
diff --git a/app/assets/javascripts/services/project.js b/app/assets/javascripts/services/project.js
index 564562f9f..2b14b36c8 100644
--- a/app/assets/javascripts/services/project.js
+++ b/app/assets/javascripts/services/project.js
@@ -12,11 +12,6 @@ Application.Services.factory('Project', ['$resource', function ($resource) {
method: 'GET',
url: '/api/projects/search',
isArray: false
- },
- allowedExtensions: {
- method: 'GET',
- url: '/api/projects/allowed_extensions',
- isArray: true
}
}
);
diff --git a/app/assets/javascripts/services/setting.js b/app/assets/javascripts/services/setting.js
index f97ef9af6..db240533a 100644
--- a/app/assets/javascripts/services/setting.js
+++ b/app/assets/javascripts/services/setting.js
@@ -20,6 +20,11 @@ Application.Services.factory('Setting', ['$resource', function ($resource) {
url: '/api/settings/reset/:name',
params: { name: '@name' },
method: 'PUT'
+ },
+ isPresent: {
+ url: '/api/settings/is_present/:name',
+ params: { name: '@name' },
+ method: 'GET'
}
}
);
diff --git a/app/assets/templates/admin/projects/settings.html.erb b/app/assets/templates/admin/projects/settings.html.erb
index b52c8cf76..d7cd3e214 100644
--- a/app/assets/templates/admin/projects/settings.html.erb
+++ b/app/assets/templates/admin/projects/settings.html.erb
@@ -74,7 +74,7 @@
+ fa-icon="fa-info">