Skip to content

FabManager is the FabLab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.

License

Notifications You must be signed in to change notification settings

LabBoite/fab-manager

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FabManager

FabManager is the Fab Lab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.

Coverage Status Docker pulls Docker Build Status

Table of Contents
  1. Software stack
  2. Contributing
  3. Setup a production environment
  4. Setup a development environment
    4.1. General Guidelines
  5. PostgreSQL
    5.1. Install PostgreSQL 9.6
  6. ElasticSearch
    6.1. Install ElasticSearch
    6.2. Rebuild statistics
    6.3. Backup and Restore
  7. Internationalization (i18n)
    7.1. Translation
    7.1.1. Front-end translations
    7.1.2. Back-end translations
    7.2. Configuration
    7.2.1. Settings
    7.2.2. Applying changes
  8. Open Projects
  9. Plugins
  10. Single Sign-On
  11. Known issues
  12. Related Documentation

Software stack

FabManager is a Ruby on Rails / AngularJS web application that runs on the following software:

  • Ubuntu LTS 14.04+ / Debian 8+
  • Ruby 2.3
  • Redis 2.8.4+
  • Sidekiq 3.3.4+
  • Elasticsearch 5.6
  • PostgreSQL 9.6

Contributing

Contributions are welcome. Please read the contribution guidelines for more information about the contribution process.

Setup a production environment

To run fab-manager as a production application, this is highly recommended to use Docker-compose. The procedure to follow is described in the docker-compose readme.

Setup a development environment

In you intend to run fab-manager on your local machine to contribute to the project development, you can set it up with the following procedure.

This procedure is not easy to follow so if you don't need to write some code for Fab-manager, please prefer the docker-compose installation method.

Optionally, you can use a virtual development environment that relies on Vagrant and Virtual Box by following the virtual machine instructions.

General Guidelines

  1. Install RVM, with the ruby version specified in the .ruby-version file. For more details about the process, please read the official RVM documentation. If you're using ArchLinux, you may have to read this before.

  2. Install NVM, with the node.js version specified in the .nvmrc file. For instructions about installing NVM, please refer to the NVM readme.

  3. Install Yarn, the front-end package manager. Depending on your system, the installation process may differ, please read the official Yarn documentation.

  4. Install docker. Your system may provide a pre-packaged version of docker in its repositories, but this version may be outdated. Please refer to ubuntu, debian or MacOS documentation to setup a recent version of docker.

  5. Add your current user to the docker group, to allow using docker without sudo.

    # add the docker group if it doesn't already exist
    sudo groupadd docker
    # add the current user to the docker group
    sudo usermod -aG docker $(whoami)
    # restart to validate changes
    sudo reboot
  6. Create a docker network for fab-manager. You may have to change the network address if it is already in use.

    docker network create --subnet=172.18.0.0/16 fabmanager
  7. Retrieve the project from Git

    git clone https://github.com/sleede/fab-manager.git
  8. Install the software dependencies. First install PostgreSQL and ElasticSearch as specified in their respective documentations. Then install the other dependencies:

    • For Ubuntu/Debian:
    # on Ubuntu 18.04 server, you may have to enable the "universe" repository
    sudo add-apt-repository universe
    # then, install the dependencies
    sudo apt-get install libpq-dev redis-server imagemagick
    • For MacOS X:
    brew install redis imagemagick
  9. Init the RVM and NVM instances and check they were correctly configured

    cd fab-manager
    rvm current | grep -q `cat .ruby-version`@fab-manager && echo "ok"
    # Must print ok
    nvm use
    node --version | grep -q `cat .nvmrc` && echo "ok"
    # Must print ok
  10. Install bundler in the current RVM gemset

gem install bundler --version=1.17.3
  1. Install the required ruby gems and javascript plugins
bundle install
yarn install
  1. Create the default configuration files and configure them! (see the environment configuration documentation)
cp config/database.yml.default config/database.yml
cp config/application.yml.default config/application.yml
vi config/application.yml
# or use your favorite text editor instead of vi (nano, ne...)
  1. Build the databases.
  • Warning: DO NOT run rake db:setup instead of these commands, as this will not run some required raw SQL instructions.
  • Please note: Your password length must be between 8 and 128 characters, otherwise db:seed will be rejected. This is configured in config/initializers/devise.rb
# for dev
rake db:create
rake db:migrate
ADMIN_EMAIL='youradminemail' ADMIN_PASSWORD='youradminpassword' rake db:seed
rake fablab:es:build_stats
# for tests
RAILS_ENV=test rake db:create
RAILS_ENV=test rake db:migrate
  1. Create the pids folder used by Sidekiq. If you want to use a different location, you can configure it in config/sidekiq.yml
mkdir -p tmp/pids
  1. Start the development web server
foreman s -p 3000
  1. You should now be able to access your local development FabManager instance by accessing http://localhost:3000 in your web browser.

  2. You can login as the default administrator using the credentials defined previously.

  3. Email notifications will be caught by MailCatcher. To see the emails sent by the platform, open your web browser at http://localhost:1080 to access the MailCatcher interface.

PostgreSQL

Install PostgreSQL 9.6

We will use docker to easily install the required version of PostgreSQL.

  1. Create the docker binding folder

    mkdir -p .docker/postgresql
  2. Start the PostgreSQL container.

    docker run --restart=always -d --name fabmanager-postgres \
    -v $(pwd)/.docker/postgresql:/var/lib/postgresql/data \
    --network fabmanager --ip 172.18.0.2 \
    -p 5432:5432 \
    postgres:9.6
  3. Configure fab-manager to use it. On linux systems, PostgreSQL will be available at 172.18.0.2. On MacOS, you'll have to set the host to 127.0.0.1 (or localhost). See environment.md for more details.

4 . Finally, you may want to have a look at detailed informations about PostgreSQL usage in fab-manager. Some information about that is available in the PostgreSQL Readme.

ElasticSearch

ElasticSearch is a powerful search engine based on Apache Lucene combined with a NoSQL database used as a cache to index data and quickly process complex requests on it.

In FabManager, it is used for the admin's statistics module and to perform searches in projects.

Install ElasticSearch

  1. Create the docker binding folders

    mkdir -p .docker/elasticsearch/config
    mkdir -p .docker/elasticsearch/plugins
    mkdir -p .docker/elasticsearch/backups
  2. Copy the default configuration files

    cp docker/elasticsearch.yml .docker/elasticsearch/config
    cp docker/log4j2.properties .docker/elasticsearch/config
  3. Start the ElasticSearch container.

    docker run --restart=always -d --name fabmanager-elastic \
    -v $(pwd)/.docker/elasticsearch/config:/usr/share/elasticsearch/config \
    -v $(pwd)/.docker/elasticsearch:/usr/share/elasticsearch/data \
    -v $(pwd)/.docker/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
    -v $(pwd)/.docker/elasticsearch/backups:/usr/share/elasticsearch/backups \
    --network fabmanager --ip 172.18.0.3 \
    -p 9200:9200 -p 9300:9300 \
    elasticsearch:5.6
  4. Configure fab-manager to use it. On linux systems, ElasticSearch will be available at 172.18.0.3. On MacOS, you'll have to set the host to 127.0.0.1 (or localhost). See environment.md for more details.

Rebuild statistics

Every nights, the statistics for the day that just ended are built automatically at 01:00 (AM) and stored in ElastricSearch. See schedule.yml to modify this behavior. If the scheduled task wasn't executed for any reason (eg. you are in a dev environment and your computer was turned off at 1 AM), you can force the statistics data generation in ElasticSearch, running the following command.

# Here for the 50 last days
rake fablab:es:generate_stats[50]

Backup and Restore

To backup and restore the ElasticSearch database, use the elasticsearch-dump tool.

Dump the database with: elasticdump --input=http://localhost:9200/stats --output=fablab_stats.json. Restore it with: elasticdump --input=fablab_stats.json --output=http://localhost:9200/stats.

Internationalization (i18n)

The FabManager application can only run in a single language but this language can easily be changed.

Translation

Check the files located in config/locales:

  • Front app translations (angular.js) are located in config/locales/app.scope.XX.yml. Where scope has one the following meaning :
    • admin: translations of the administrator views (manage and configure the FabLab).
    • logged: translations of the end-user's views accessible only to connected users.
    • public: translation of end-user's views publicly accessible to anyone.
    • shared: translations shared by many views (like forms or buttons).
  • Back app translations (Ruby on Rails) are located in config/locales/XX.yml.
  • Emails translations are located in config/locales/mails.XX.yml.
  • Messages related to the authentication system are located in config/locales/devise.XX.yml.

If you plan to translate the application to a new locale, please consider that the reference translation is French. Indeed, in some cases, the English texts/sentences can seems confuse or lack of context as they were originally translated from French.

To prevent syntax mistakes while translating locale files, we STRONGLY advise you to use a text editor which support syntax coloration for YML and Ruby.

Front-end translations

Front-end translations uses angular-translate with some interpolations interpreted by angular.js and other interpreted by MessageFormat. These two kinds of interpolation use a near but different syntax witch SHOULD NOT be confused. Please refer to the official angular-translate documentation before translating.

Back-end translations

Back-end translations uses the Ruby on Rails syntax but some complex interpolations are interpreted by MessageFormat and are marked as it in comments. DO NOT confuse the syntaxes.

In each cases, some inline comments are included in the localisation files. They can be recognized as they start with the sharp character (#). These comments are not required to be translated, they are intended to help the translator to have some context information about the sentence to translate.

You will also need to translate the invoice watermark, located in app/pdfs/data/. You'll find there the GIMP source of the image, which is using Rubik Mono One as font. Use it to generate a similar localised PNG image which keep the default image size, as PDF are not responsive.

Configuration

Locales configurations are made in config/application.yml. If you are in a development environment, your can keep the default values, otherwise, in production, values must be configured carefully.

Settings

Please refer to the environment configuration documentation

Applying changes

After modifying any values concerning the localisation, restart the application (ie. web server) to apply these changes in the i18n configuration.

Open Projects

This configuration is optional.

You can configure your fab-manager to synchronize every project with the Open Projects platform. It's very simple and straightforward and in return, your users will be able to search over projects from all fab-manager instances from within your platform. The deal is fair, you share your projects and as reward you benefits from projects of the whole community.

If you want to try it, you can visit this fab-manager 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
  • 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.

Go to your projects gallery and enjoy seeing your projects available from everywhere ! That's all.

Plugins

Fab-manager has a system of plugins mainly inspired by Discourse architecture.

It enables you to write plugins which can:

  • have its proper models and database tables
  • have its proper assets (js & css)
  • override existing behaviours of Fab-manager
  • add features by adding views, controllers, ect...

To install a plugin, you just have to copy the plugin folder which contains its code into the folder plugins of Fab-manager.

You can see an example on the repo of navinum gamification plugin

Single Sign-On

Fab-manager can be connected to a Single Sign-On server which will provide its own authentication for the platform's users. Currently OAuth 2 is the only supported protocol for SSO authentication.

For an example of how to use configure a SSO in Fab-manager, please read sso_with_github.md. Developers may find information on how to implement their own authentication protocol in sso_authentication.md.

Known issues

  • When browsing a machine page, you may encounter an "InterceptError" in the console and the loading bar will stop loading before reaching its ending. This may happen if the machine was created through a seed file without any image. To solve this, simply add an image to the machine's profile and refresh the web page.

  • When starting the Ruby on Rails server (eg. foreman s) you may receive the following error:

      worker.1 | invalid url: redis::6379
      web.1    | Exiting
      worker.1 | ...lib/redis/client.rb...:in `_parse_options'
    

    This may happen when the application.yml file is missing. To solve this issue copy config/application.yml.default to config/application.yml. This is required before the first start.

  • Due to a stripe limitation, you won't be able to create plans longer than one year.

  • When running the tests suite with rake test, all tests may fail with errors similar to the following:

      Error:
      ...
      ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR:  insert or update on table "..." violates foreign key constraint "fk_rails_..."
      DETAIL:  Key (group_id)=(1) is not present in table "...".
      : ...
          test_after_commit (1.0.0) lib/test_after_commit/database_statements.rb:11:in `block in transaction'
          test_after_commit (1.0.0) lib/test_after_commit/database_statements.rb:5:in `transaction'
    

    This is due to an ActiveRecord behavior witch disable referential integrity in PostgreSQL to load the fixtures. PostgreSQL will prevent any users to disable referential integrity on the fly if they doesn't have the SUPERUSER role. To fix that, logon as the postgres user and run the PostgreSQL shell (see the dedicated section for instructions). Then, run the following command (replace sleede with your test database user, as specified in your database.yml):

      ALTER ROLE sleede WITH SUPERUSER;
    

    DO NOT do this in a production environment, unless you know what you're doing: this could lead to a serious security issue.

  • With Ubuntu 16.04, ElasticSearch may refuse to start even after having configured the service with systemd. To solve this issue, you may have to set START_DAEMON to true in /etc/default/elasticsearch. Then reload ElasticSearch with:

    sudo systemctl restart elasticsearch.service
  • In some cases, the invoices won't be generated. This can be due to the image included in the invoice header not being supported. To fix this issue, change the image in the administrator interface (manage the invoices / invoices settings). See this thread for more info.

Related Documentation

About

FabManager is the FabLab management solution. It provides a comprehensive, web-based, open-source tool to simplify your administrative tasks and your marker's projects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 38.2%
  • HTML 30.6%
  • JavaScript 25.6%
  • SCSS 3.9%
  • Shell 1.6%
  • Dockerfile 0.1%