* Add supplier information to KiCad part exports
- Include supplier name and part numbers from order details in KiCad exports
- Handle multiple suppliers with sequential numbering (Supplier 2, Supplier 3, etc.)
- Include both active and obsolete order details for comprehensive supplier info
- Add null checks to prevent errors when supplier or part number is missing
* Add SPN suffix to field name
---------
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
* Update AbstractParameter.php
Make lazy null conditionals explicit.
Try to handle LaTeX special chars gracefully.
Fixes#958
* Only escape the percentage sign, so that you can still use latex for units
* Only escape previously unescaped percentage signs
* simplify regex
* Render the percentage sign correctly in units in the frontend.
---------
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
* Add env option to disable part image overlay
Fixes#369 while preserving the state as-is
* Added documentation and use 1 instead of true for new env
---------
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
* fix sidebar root node links
link sidebar root nodes to their corresponding "new" route
* Use "Show all parts" for most root categories and started to make it configurable for the future
---------
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
* Modified the DigiKey Provider to works with the V4 API
* Correclty apply the MarketPlaceFilter option to digikey v4 API
* Show the packe type (Tape&Reel, Box, etc.) as footprint in digikey provider search
---------
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
Added more headers to make it appear more like a browser request, and try to use TLS1.3, if we get a 403 (which is useful for digikey).
Commit cherry picked from @Treeed
* fixed attachment statistics for sqlite
* Split attachment path into internal and external path, so the external source URL can be retained after a file is downloaded
* Make internal and external path for attachments nullable, to make clear that they have no internal or external path
* Added migrations for nullable columns for postgres and mysql
* Added migration for nullable internal and external pathes for sqlite
* Added translations
* Fixed upload error
* Restrict length of filename badge in attachment edit view
* Improved margins with badges in attachment edit
* Added a link to view external version from attachment edit
* Let media_url stay in API attachments responses for backward compatibility
---------
Co-authored-by: jona <a@b.c>
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
* made autocomplete controller allow selecting text and autocommit typed text on blur
* moved click_to_edit and autoselect_typed into separate plugins
---------
Co-authored-by: jona <a@b.c>
* New translations security.en.xlf (Russian)
* New translations validators.en.xlf (Russian)
* New translations messages.en.xlf (Russian)
* New translations messages.en.xlf (English)
* New translations messages.en.xlf (Italian)
* added capability to scan digikey barcodes and open the local part page based on the digikey part number or manufacturer part number
* had replaced one too many doublequotes
* Generalized interpretation of format06 barcodes, added ids for mouser
* Renamed vendor_barcode to user_barcode in entities
* Added a own class to parse EIGP114 barcodes
* Added tests to EIGP114Barcode parser
* Refactored code
* Changed BarcodeRedirector to support the new Barcode EIGP114BarcodeScanResult class
* Added possibility to just show all information contained in a barcode
* Dont require trailer for EIGP114 barcodes, as digikey does not seem to put them onto their barcodes
* Fixed inspection issues
---------
Co-authored-by: jona <a@b.c>
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
* added button to show existing part with same manufacturer and mpn in provider list
* added button to edit existing part in provider list
* added docstring and comments
* replaced unnecessary double quotes
* Introduced a new twig variable localPart to split up the result
* Highlight a row, if the part is already existing
* Made buttons translatable
* Improved styling of the buttons and added a badge to show a hint
* Extracted database queries for part matching into its own service and optimized the query reducing the required queries by factor 2
* Allow to find existing parts via the stored providerReference
This should allow the database to more quickly find entries
* Allow to use part name and manufacturer alternative names for mapping
* Added a button to update a local part from the info provider and moved some buttons into dropdown menu
---------
Co-authored-by: jona <a@b.c>
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
This is required only for postgres as every other database is case invariant by default. But to achieve a portable way, we implement it via a custom DQL function.
This fixes issue #784
This fixes issue #701. For the search field this was caused by algolia/autocomplete lib, which do not support multiple autocomplete fields on a single page. If initailly loaded on the homepage, which features a second autocomplete, this one "steals" the input listening, and the one in the navbar do not close anymore when clicking outside.
Custom code which triggers the closing of the autocomplete manually when clicking outside, was added as a workaround.
* New translations messages.en.xlf (English)
* New translations validators.en.xlf (German)
* New translations messages.en.xlf (German)
* New translations messages.en.xlf (Italian)
* OEMSecrets provider interface v.1.0
New class for interacting with the OEMSecrets (https://www.oemsecrets.com) API version 3.0.1.
* Refactored info provider to be stateless and independent from session, optimized Part-DB API usage, and fixed PHPStan issues.
Refactored info provider to be stateless and independent from session, now use Psr\Cache, fixed issues identified by PHPStan, additional minor enhancements and bug fixes.
* Prefix cache keys with oemsecrets_ to avoid key collissions
* Use uniqid with more entropy to reduce probability of collisions
* Made $resultData local as it is only used inside searchByKeyword
* Use the parameter name $id from interface declaration for getDetails to avoid problems with named arguments
* Use unicode modifier for preg_match to avoid problems when parameters contain non-unicode strings
* Various small code quality improvements
* Try to retrieve the part from the API in getDetails, if the DTO was not cached before
* Improved code formatting
* Channged OEMSecret default country to DE to be consistent with other default values
* Do not call gc_collect_cycles in the loop to process the results, but only after all processBatch calls
---------
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
* New translations messages.en.xlf (English)
* New translations validators.en.xlf (English)
* New translations security.en.xlf (English)
* New translations validators.en.xlf (Italian)
* reorder nodejs/yarn install, separate packages per line
* reduce run actions and reorganize commands
* simplify file creation, copy in one layer only
* fix lint LegacyKeyValueFormat
* arg php_version to run different version
* reorder copy from generated config
* update dockerfile-frankenphp
We now look directly onto the driver arguments instead of retrieving a database platform, for which we would need the database version.
As we modify driver specific options there, this might be the better choice anyway
* DigiKey: Skip empty values
* Move improved range detection from LCSCProvider to ParameterDTO class
Improve numeric value detection by moving extra info to value_text
* ParameterDTO: Add micro unit prefix
* Bring $value_text2 to a defined state
* ParameterDTO: Don't overwrite $unit if it's not empty
* ParameterDTO: Don't overwrite $unit if it's not empty
* Correct some inaccuacies in comments
* Added tests and fixed certain edge cases in parsing parameters
* Added more tests for parameter parsing
---------
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
* New translations security.en.xlf (Polish)
* New translations validators.en.xlf (Polish)
* New translations messages.en.xlf (English)
* New translations messages.en.xlf (Russian)
* New translations validators.en.xlf (Russian)
* New translations messages.en.xlf (Italian)
* Follow first 'pdfUrl' link to get real datasheet URL
* Fix @param
* Fix @param
* Remove User-Agent header
It's not needed - LCSC was just having some server troubles over the weekend
* Added comment explaining the json_decode in getRealDatasheetUrl
---------
Co-authored-by: Jan Böhmer <mail@jan-boehmer.de>
* Fix RegEx to include negative values
* Update RegEx to handle Ω without prefix
* Update RegEx to include %
* Handle plus/minus values as range
* Fix copy&paste error
* Change minimum value to negative
* Escape decimal point and add slash to valid unit characters to be able to pick up for example "ppm/°C"
* Skip empty values
This fixes issue #512.
The error was introduced when trying to allow the modification of attachments/parameters throught the parent element. We need a seperate write scope to the element, or we end up with an infinite loop.
As they work on abstract classes, they can not be initialized directly currently and you need to create them via a PATCH operation on their owning elements.
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations security.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Czech)
* New translations messages.en.xlf (Czech)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Czech)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations validators.en.xlf (Danish)
* New translations security.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations validators.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Czech)
* New translations validators.en.xlf (Czech)
* New translations security.en.xlf (Czech)
* New translations messages.en.xlf (Danish)
* New translations messages.en.xlf (Czech)
* New translations validators.en.xlf (Czech)
* New translations security.en.xlf (Czech)
* New translations messages.en.xlf (Czech)
* New translations messages.en.xlf (Czech)
* New translations messages.en.xlf (Czech)
* New translations messages.en.xlf (Dutch)
* New translations messages.en.xlf (Dutch)
This was because the objectSerializer in PartNormalizer messed up the JSONLD IRI generation of the paramaters property. It tried to generate this IRI via the Part ressource class, which is not possible
* New translations messages.en.xlf (English)
* New translations validators.en.xlf (English)
* New translations security.en.xlf (English)
* New translations messages.en.xlf (German)
For some very very weird reasoning this cause issues with the ObjectNormalizer, which does not get an an serializer injected anymore.
When the EventLoggerSubscriber is a doctrine subscriber it seems that the serializer service is initialized (as its requested in constructor but not used) and later injected into the object normalizer.
When its an listener, this does not work anymore.
This only affects database which were older than the new permission system and hopefully everybody should have updated by now. The message could irritate new users, so it was removed
The php-saml library use its own logic to determine the current path, and we need to set the use_proxy_vars so that it respects the proxy FORWARDED headers.
This should fix issue #436
API Platform seems to have slightly changed the serialization process of errors and the requested HTML format was not available for error serialization
Therefore it does not need to be configured in the webpack.config.js before compilation. This should help to make things like issue #426 easier to resolve.
Before this was not possible, as this was messed up with the DB ids. Now we prefix the new created values with a special prefix, to mark them as new.
This fixes issue #381
* New translations messages.en.xlf (French)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations validators.en.xlf (Italian)
* New translations security.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations validators.en.xlf (French)
* New translations messages.en.xlf (German)
* New translations validators.en.xlf (German)
* New translations messages.en.xlf (Italian)
* New translations validators.en.xlf (Italian)
* New translations security.en.xlf (Italian)
* New translations messages.en.xlf (Japanese)
* New translations validators.en.xlf (Japanese)
* New translations messages.en.xlf (Russian)
* New translations validators.en.xlf (Russian)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (English)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
* New translations messages.en.xlf (Italian)
In older versions doctrine allowed overriding attributes, by simply redifining them in subclasses. In 2.16 this throws an exception. We now use the proper way using the AttributeOverrides attribute
Now it matches the documented value and follows the naming schema. The old env name is still valid, to maintain backwards compatibility.
Fixes issue #339
# The language to use serverwide as default (en, de, ru, etc.)
DEFAULT_LANG="en"
#DEFAULT_LANG="en"
# The default timezone to use serverwide (e.g. Europe/Berlin)
DEFAULT_TIMEZONE="Europe/Berlin"
#DEFAULT_TIMEZONE="Europe/Berlin"
# The currency that is used inside the DB (and is assumed when no currency is set). This can not be changed later, so be sure to set it the currency used in your country
BASE_CURRENCY="EUR"
# The name of this installation. This will be shown as title in the browser and in the header of the website
INSTANCE_NAME="Part-DB"
# Allow users to download attachments to the server by providing an URL
# This could be a potential security issue, as the user can retrieve any file the server has access to (via internet)
ALLOW_ATTACHMENT_DOWNLOADS=0
# Use gravatars for user avatars, when user has no own avatar defined
USE_GRAVATAR=0
# The maximum allowed size for attachment files in bytes (you can use M for megabytes and G for gigabytes)
# Please note that the php.ini setting upload_max_filesize also limits the maximum size of uploaded files
MAX_ATTACHMENT_FILE_SIZE="100M"
#BASE_CURRENCY="EUR"
# The public reachable URL of this Part-DB installation. This is used for generating links to the website in emails and so on
# The public reachable URL of this Part-DB installation. This is used for generating links in SAML and email templates
# This must end with a slash!
DEFAULT_URI="https://partdb.changeme.invalid/"
# With this option you can configure, where users are enforced to give a change reason, which will be logged
# This is a comma separated list of values, see documentation for available values
# Leave this empty, to make all change reasons optional
Part-DB is an Open-Source inventory managment system for your electronic components.
Part-DB is an Open-Source inventory management system for your electronic components.
It is installed on a web server and so can be accessed with any browser without the need to install additional software.
The version in this Repository is a complete rewrite of the legacy [Part-DB](https://github.com/Part-DB/Part-DB) (Version < 1.0) based on a modern framework.
Currently, it is still missing some (minor) features from the old version (see [UPGRADE.md](https://docs.part-db.de/upgrade_legacy.html)) for more details, but also many huge improvements and advantages compared to the old version.
If you start completely new with Part-DB it is recommended that you use the version from this repository, as it is actively developed.
The version in this repository is a complete rewrite of the legacy [Part-DB](https://github.com/Part-DB/Part-DB)
(Version < 1.0) based on a modern framework and is the recommended version to use.
If you find a bug, please open an [Issue on Github](https://github.com/Part-DB/Part-DB-server/issues) so it can be fixed for everybody.
If you find a bug, please open an [Issue on GitHub,](https://github.com/Part-DB/Part-DB-server/issues) so it can be fixed
for everybody.
## Demo
If you want to test Part-DB without installing it, you can use [this](https://part-db.herokuapp.com) Heroku instance.
(Or this link for the [German Version](https://part-db.herokuapp.com/de/)).
If you want to test Part-DB without installing it, you can use [this](https://demo.part-db.de/) Heroku instance.
(Or this link for the [German Version](https://demo.part-db.de/de/)).
You can log in with username: *user* and password: *user*.
Every change to the master branch gets automatically deployed, so it represents the current development progress and is
maybe not completely stable. Please mind, that the free Heroku instance is used, so it can take some time when loading the page
may not completely stable. Please mind, that the free Heroku instance is used, so it can take some time when loading
* Inventory management of your electronic parts. Each part can be assigned to a category, footprint, manufacturer
and multiple store locations and price information. Parts can be grouped using tags. You can associate various files like datasheets or pictures with the parts.
* Multi-Language support (currently German, English, Russian, Japanese and French (experimental))
* Inventory management of your electronic parts. Each part can be assigned to a category, footprint, manufacturer,
and multiple store locations and price information. Parts can be grouped using tags. You can associate various files
like datasheets or pictures with the parts.
* Multi-language support (currently German, English, Russian, Japanese, French, Czech, Danish, and Chinese)
* Barcodes/Labels generator for parts and storage locations, scan barcodes via webcam using the builtin barcode scanner
* User system with groups and detailed (fine granular) permissions.
Two-factor authentication is supported (Google Authenticator and Webauthn/U2F keys) and can be enforced for groups. Password reset via email can be setuped.
* Optional support for single sign-on (SSO) via SAML (using an intermediate service like [Keycloak](https://www.keycloak.org/) you can connect Part-DB to an existing LDAP or Active Directory server)
*Import/Export system for parts and datastructure. BOM import for projects from KiCAD is supported.
* Project management: Create projects and assign parts to the bill of material (BOM), to show how often you could build this project and directly withdraw all components needed from DB
*Event log: Track what changes happens to your inventory, track which user does what. Revert your parts to older versions.
*Responsive design: You can use Part-DB on your PC, your tablet and your smartphone using the same interface.
* MySQL and SQLite supported as database backends
* User system with groups and detailed (fine granular) permissions.
Two-factor authentication is supported (Google Authenticator and Webauthn/U2F keys) and can be enforced for groups.
Password reset via email can be set up.
*Optional support for single sign-on (SSO) via SAML (using an intermediate service
like [Keycloak](https://www.keycloak.org/) you can connect Part-DB to an existing LDAP or Active Directory server)
*Import/Export system for parts and data structure. BOM import for projects from KiCAD is supported.
*Project management: Create projects and assign parts to the bill of material (BOM), to show how often you could build
this project and directly withdraw all components needed from DB
* Event log: Track what changes happen to your inventory, track which user does what. Revert your parts to older
versions.
* Responsive design: You can use Part-DB on your PC, your tablet, and your smartphone using the same interface.
* MySQL, SQLite and PostgreSQL are supported as database backends
* Support for rich text descriptions and comments in parts
* Support for multiple currencies and automatic update of exchange rates supported
* Powerful search and filter function, including parametric search (search for parts according to some specifications)
* Automatic thumbnail generation for pictures
* Use cloud providers (like Octopart, Digikey, Farnell, LCSC or TME) to automatically get part information, datasheets, and
prices for parts
* API to access Part-DB from other applications/scripts
* [Integration with KiCad](https://docs.part-db.de/usage/eda_integration.html): Use Part-DB as the central datasource for your
KiCad and see available parts from Part-DB directly inside KiCad.
With these features Part-DB is useful to hobbyists, who want to keep track of their private electronic parts inventory,
or makerspaces, where many users have should have (controlled) access to the shared inventory.
With these features, Part-DB is useful to hobbyists, who want to keep track of their private electronic parts inventory,
or maker spaces, where many users should have (controlled) access to the shared inventory.
Part-DB is also used by small companies and universities for managing their inventory.
## Requirements
* A **web server** (like Apache2 or nginx) that is capable of running [Symfony 5](https://symfony.com/doc/current/reference/requirements.html),
this includes a minimum PHP version of **PHP 8.1**
* A **MySQL** (at least 5.7) /**MariaDB** (at least 10.2.2) database server if you do not want to use SQLite.
* Shell access to your server is highly suggested!
* For building the client side assets **yarn** and **nodejs** (>= 18.0) is needed.
* A **web server** (like Apache2 or nginx) that is capable of
this includes a minimum PHP version of **PHP 8.1**
* A **MySQL** (at least 5.7) /**MariaDB** (at least 10.4) database server, or **PostgreSQL** 10+ if you do not want to use SQLite.
* Shell access to your server is highly recommended!
* For building the client-side assets **yarn** and **nodejs** (>= 18.0) is needed.
## Installation
If you want to upgrade your legacy (< 1.0.0) version of Part-DB to this version, please read [this](https://docs.part-db.de/upgrade_legacy.html) first.
*Hint:* A docker image is available under [jbtronics/part-db1](https://hub.docker.com/r/jbtronics/part-db1). How to set up Part-DB via docker is described [here](https://docs.part-db.de/installation/installation_docker.html).
If you want to upgrade your legacy (< 1.0.0) version of Part-DB to this version, please
**Below you find some very rough outline of the installation process, see [here](https://docs.part-db.de/installation/) for a detailed guide how to install Part-DB.**
*Hint:* A docker image is available under [jbtronics/part-db1](https://hub.docker.com/r/jbtronics/part-db1). How to set
up Part-DB via docker is described [here](https://docs.part-db.de/installation/installation_docker.html).
**Below you find a very rough outline of the installation process, see [here](https://docs.part-db.de/installation/)
for a detailed guide on how to install Part-DB.**
1. Copy or clone this repository into a folder on your server.
2. Configure your webserver to serve from the `public/` folder. See [here](https://symfony.com/doc/current/setup/web_server_configuration.html)
for additional information.
2. Configure your webserver to serve from the `public/` folder.
See [here](https://symfony.com/doc/current/setup/web_server_configuration.html)
for additional information.
3. Copy the global config file `cp .env .env.local` and edit `.env.local`:
* Change the line `APP_ENV=dev` to `APP_ENV=prod`
* If you do not want to use SQLite, change the value of `DATABASE_URL=` to your needs (see [here](http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url)) for the format.
In bigger instances with concurrent accesses, MySQL is more performant. This can not be changed easily later, so choose wisely.
* If you do not want to use SQLite, change the value of `DATABASE_URL=` to your needs (
see [here](http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url))
for the format.
In bigger instances with concurrent accesses, MySQL is more performant. This can not be changed easily later, so
5. If you have put Part-DB into a sub-directory on your server (like`part-db/`), you have to edit the file
`webpack.config.js` and uncomment the lines (remove the `//` before the lines) `.setPublicPath('/part-db/build')` (line 43) and
`.setManifestKeyPrefix('build/')` (line 44). You have to replace `/part-db` with your own path on line 44.
6. Install client side dependencies and build it: `yarn install` and `yarn build`
7._Optional_ (speeds up first load): Warmup cache: `php bin/console cache:warmup`
8. Upgrade database to new scheme (or create it, when it was empty): `php bin/console doctrine:migrations:migrate` and follow the instructions given. During the process the password for the admin is user is shown. Copy it. **Caution**: This steps tamper with your database and could potentially destroy it. So make sure to make a backup of your database.
9. You can configure Part-DB via `config/parameters.yaml`. You should check if settings match your expectations, after you installed/upgraded Part-DB. Check if `partdb.default_currency` matches your mainly used currency (this can not be changed after creating price informations).
Run `php bin/console cache:clear` when you changed something.
10. Access Part-DB in your browser (under the URL you put it) and login with user *admin*. Password is the one outputted during DB setup.
If you can not remember the password, set a new one with `php bin/console app:set-password admin`. You can create new users with the admin user and start using Part-DB.
5. Install client side dependencies and build it:`yarn install` and `yarn build`
6._Optional_ (speeds up first load): Warmup cache:`php bin/console cache:warmup`
7. Upgrade database to new scheme (or create it, when it was empty): `php bin/console doctrine:migrations:migrate` and
follow the instructions given. During the process the password for the admin is user is shown. Copy it. **Caution**:
These steps tamper with your database and could potentially destroy it. So make sure to make a backup of your
database.
8. You can configure Part-DB via `config/parameters.yaml`. You should check if settings match your expectations after
you installed/upgraded Part-DB. Check if `partdb.default_currency` matches your mainly used currency (this can not be
changed after creating price information).
Run `php bin/console cache:clear` when you change something.
9. Access Part-DB in your browser (under the URL you put it) and log in with user *admin*. Password is the one outputted
during DB setup.
If you can not remember the password, set a new one with `php bin/console app:set-password admin`. You can create
new users with the admin user and start using Part-DB.
When you want to upgrade to a newer version, then just copy the new files into the folder
and repeat the steps 4. to 7.
Normally a random password is generated when the admin user is created during inital database creation,
however you can set the inital admin password, by setting the `INITIAL_ADMIN_PW` env var.
Normally a random password is generated when the admin user is created during initial database creation,
however, you can set the initial admin password, by setting the `INITIAL_ADMIN_PW` env var.
You can configure Part-DB to your needs by changing environment variables in the `.env.local` file.
You can configure Part-DB to your needs by changing environment variables in the `.env.local` file.
See [here](https://docs.part-db.de/configuration.html) for more information.
### Reverse proxy
If you are using a reverse proxy, you have to ensure that the proxies sets the `X-Forwarded-*` headers correctly, or you will get HTTP/HTTPS mixup and wrong hostnames.
If the reverse proxy is on a different server (or it cannot access Part-DB via localhost) you have to set the `TRUSTED_PROXIES` env variable to match your reverse proxies IP-address (or IP block). You can do this in your `.env.local` or (when using docker) in your `docker-compose.yml` file.
If you are using a reverse proxy, you have to ensure that the proxies set the `X-Forwarded-*` headers correctly, or you
will get HTTP/HTTPS mixup and wrong hostnames.
If the reverse proxy is on a different server (or it cannot access Part-DB via localhost) you have to set
the `TRUSTED_PROXIES` env variable to match your reverse proxy's IP address (or IP block). You can do this in
your `.env.local` or (when using docker) in your `docker-compose.yml` file.
## Donate for development
If you want to donate to the Part-DB developer, see the sponsor button in the top bar (next to the repo name).
There you will find various methods to support development on a monthly or a onetime base.
There you will find various methods to support development on a monthly or a one-time base.
## Built with
* [Symfony 5](https://symfony.com/): The main framework used for the serverside PHP
* [Bootstrap 5](https://getbootstrap.com/) and [Bootswatch](https://bootswatch.com/): Used as website theme
* [Fontawesome](https://fontawesome.com/): Used as icon set
* [Hotwire Stimulus](https://stimulus.hotwired.dev/) and [Hotwire Turbo](https://turbo.hotwired.dev/): Frontend Javascript
* [Hotwire Stimulus](https://stimulus.hotwired.dev/) and [Hotwire Turbo](https://turbo.hotwired.dev/): Frontend
//Remove the padding-right and overflow:hidden from the body
document.body.style.paddingRight='';
document.body.style.overflow='';
}
});
}
@@ -59,13 +77,16 @@ class RegisterEventHelper {
}
registerTooltips(){
this.registerLoadHandler(()=>{
consthandler=()=>{
$(".tooltip").remove();
//Exclude dropdown buttons from tooltips, otherwise we run into endless errors from bootstrap (bootstrap.esm.js:614 Bootstrap doesn't allow more than one instance per element. Bound instance: bs.dropdown.)
# We set this header by ourselves, so we can disable it here
disallow_search_engine_index:false
# Must be set to true, to enable the change of HTTP method via _method parameter, otherwise our delete routines does not work anymore
# TODO: Rework delete routines to work without _method parameter as it is not recommended anymore (see https://github.com/symfony/symfony/issues/45278)
partdb.locale:'%env(string:DEFAULT_LANG)%'# The default language to use serverwide
partdb.timezone:'%env(string:DEFAULT_TIMEZONE)%'# The default timezone
partdb.title:'%env(trim:string:INSTANCE_NAME)%'# The title shown inside of Part-DB (e.g. in the navbar and on homepage)
partdb.banner:'%env(trim:string:BANNER)%'# The info text shown in the homepage, if empty config/banner.md is used
partdb.default_currency:'%env(string:BASE_CURRENCY)%'# The currency that is used inside the DB (and is assumed when no currency is set). This can not be changed later, so be sure to set it the currency used in your country
partdb.global_theme:''# The theme to use globally (see public/build/themes/ for choices, use name without .css). Set to '' for default bootstrap theme
partdb.locale_menu:['en','de','fr','ru','ja']# The languages that are shown in user drop down menu
partdb.enforce_change_comments_for:'%env(csv:ENFORCE_CHANGE_COMMENTS_FOR)%'# The actions for which a change comment is required (e.g. "part_edit", "part_create", etc.). If this is empty, change comments are not required at all.
# This is used as workaround for places where we can not access the settings directly (like the 2FA application names)
partdb.title:'%env(string:settings:customization:instanceName)%'# The title shown inside of Part-DB (e.g. in the navbar and on homepage)
partdb.locale_menu:['en','de','it','fr','ru','ja','cs','da','zh','pl']# The languages that are shown in user drop down menu
partdb.default_uri:'%env(string:DEFAULT_URI)%'# The default URI to use for the Part-DB instance (e.g. https://part-db.example.com/). This is used for generating links in emails
partdb.db.emulate_natural_sort:'%env(bool:DATABASE_EMULATE_NATURAL_SORT)%'# If this is set to true, natural sorting is emulated on platforms that do not support it natively. This can be slow on large datasets.
partdb.gdpr_compliance:true# If this option is activated, IP addresses are anonymized to be GDPR compliant
partdb.users.use_gravatar:'%env(bool:USE_GRAVATAR)%'# Set to false, if no Gravatar images should be used for user profiles.
partdb.users.email_pw_reset:'%env(bool:ALLOW_EMAIL_PW_RESET)%'# Config if users are able, to reset their password by email. By default this enabled, when a mail server is configured.
partdb.attachments.allow_downloads: '%env(bool:ALLOW_ATTACHMENT_DOWNLOADS)%' # Allow users to download attachments to server. Warning:This can be dangerous, because via that feature attackers maybe can access ressources on your intranet!
partdb.attachments.dir.media:'public/media/'# The folder where uploaded attachment files are saved (must be in public folder)
partdb.attachments.dir.secure:'uploads/'# The folder where secured attachment files are saved (must not be in public/)
partdb.attachments.max_file_size:'%env(string:MAX_ATTACHMENT_FILE_SIZE)%'# The maximum size of an attachment file (in bytes, you can use M for megabytes and G for gigabytes)
# You can configures the default shown tree items in the sidebar here. You can add or remove entries here, to change the number of trees in the sidebar. The possible entries are: categories, locations, footprints, manufacturers, suppliers, devices, tools
partdb.sidebar.items:
- categories
- devices
- tools
partdb.sidebar.root_expanded:true# If this is set to true, the root node of the sidebar is expanded by default
partdb.sidebar.root_node_enable:true# Put all entities below a root node in the sidebar
Part-DB provides a [REST API](https://en.wikipedia.org/wiki/REST) to programmatically access the data stored in the
database.
This allows external applications to interact with Part-DB, extend it or integrate it into other applications.
{: .warning }
> This feature is currently in beta. Please report any bugs you find.
> The API should not be considered stable yet and could change in future versions, without prior notice.
> Some features might be missing or not working yet.
> Also be aware, that there might be security issues in the API, which could allow attackers to access or edit data via
> the API, which
> they normally should be able to access. So currently you should only use the API with trusted users and trusted
> applications.
Part-DB uses [API Platform](https://api-platform.com/) to provide the API, which allows for easy creation of REST APIs
with Symfony and gives you a lot of features out of the box.
See the [API Platform documentation](https://api-platform.com/docs/core/) for more details about the API Platform
features and how to use them.
## Enable the API
The API is available under the `/api` path, but not reachable without proper permissions.
You have to give the users, which should be able to access the API the proper permissions (Miscellaneous -> API).
Please note that there are two relevant permissions, the first one allows users to access the `/api/` path at all and show the documentation,
and the second one allows them to create API tokens which are needed for the authentication of external applications.
## Authentication
To use API endpoints, the external application has to authenticate itself, so that Part-DB knows which user is accessing
the data and
which permissions the application should have. Basically, this is done by creating an API token for a user and then
passing it on every request
with the `Authorization` header as bearer token, so you add a header `Authorization: Bearer <your token>`.
See [Authentication chapter]({% link api/authentication.md %}) for more details.
## API endpoints
The API is split into different endpoints, which are reachable under the `/api/` path of your Part-DB instance (
e.g. `https://your-part-db.local/api/`).
There are various endpoints for each entity type (like `part`, `manufacturer`, etc.), which allow you to read and write data, and some special endpoints like `search` or `statistics`.
For example, all API endpoints for managing categories are available under `/api/categories/`. Depending on the exact
path and the HTTP method used, you can read, create, update or delete categories.
For most entities, there are endpoints like this:
* **GET**: `/api/categories/` - List all categories in the database (with pagination of the results)
* **POST**: `/api/categories/` - Create a new category
* **GET**: `/api/categories/{id}` - Get a specific category by its ID
* **DELETE**: `/api/categories/{id}` - Delete a specific category by its ID
* **UPDATE**: `/api/categories/{id}` - Update a specific category by its ID. Only the fields which are sent in the
request are updated, all other fields are left unchanged.
Be aware that you have to set the [JSON Merge Patch](https://datatracker.ietf.org/doc/html/rfc7386) content type
header (`Content-Type: application/merge-patch+json`) for this to work.
A full (interactive) list of endpoints can be displayed when visiting the `/api/` path in your browser, when you are
logged in with a user, which is allowed to access the API.
There is also a link to this page, on the user settings page in the API token section.
This documentation also lists all available fields for each entity type and the allowed operations.
## Formats
The API supports different formats for the request and response data, which you can control via the `Accept`
and `Content-Type` headers.
You should use [JSON-LD](https://json-ld.org/) as format, which is basically JSON with some additional metadata, which
allows you to describe the data in a more structured way and also allows to link between different entities. You can achieve this
by setting `Accept: application/ld+json` header to the API requests.
To get plain JSON without any metadata or links, use the `Accept: application/json` header.
Without an `Accept` header (e.g. when you call the endpoint in a browser), the API will return an HTML page with the
documentation, so be sure to include the desired `Accept` header in your API requests.
If you can not control the `Accept` header, you can add a `.json` or `.jsonld` suffix to the URL to enforce a JSON or
JSON-LD response (e.g. `/api/parts.jsonld`).
## OpenAPI schema
Part-DB provides a [OpenAPI](https://swagger.io/specification/) (formally Swagger) schema for the API
under `/api/docs.json` (so `https://your-part-db.local/api/docs.json`).
This schema is a machine-readable description of the API, which can be imported into software to test the API or even
automatically generate client libraries for the API.
API generators which can generate a client library for the API from the schema are available for many programming
languages, like [OpenAPI Generator](https://openapi-generator.tech/).
An JSONLD/Hydra version of the schema is also available under `/api/docs.jsonld` (
so `https://your-part-db.local/api/docs.jsonld`).
## Interactive documentation
Part-DB provides an interactive documentation for the API, which is available under `/api/docs` (
so `https://your-part-db.local/api/docs`).
You can pass your API token in the form on the top of the page, to authenticate yourself, and then you can try out the
API directly in the browser.
This is a great way to test the API and see how it works, without having to write any code.
## Pagination
By default, all list endpoints are paginated, which means only a certain number of results is returned per request.
To get another page of the results, you have to use the `page` query parameter, which contains the page number you want
to get (e.g. `/api/categoues/?page=2`).
When using JSONLD, the links to the next page are also included in the `hydra:view` property of the response.
To change the size of the pages (the number of items in a single page) use the `itemsPerPage` query parameter (
e.g. `/api/categoues/?itemsPerPage=50`).
See [API Platform docs](https://api-platform.com/docs/core/pagination) for more infos.
## Filtering results / Searching
When retrieving a list of entities, you can restrict the results by various filters. Almost all entities have a search
filter, which allows you to only include entities, which (text) fields match the given search term: For example, if you only want
to get parts, with the Name "BC547", you can use `/api/parts.jsonld?name=BC547`. You can use `%` as a wildcard for multiple
characters in the search term (Be sure to properly encode the search term, if you use special characters). For example, if you want
to get all parts, whose name starts with "BC", you can use `/api/parts.jsonld?name=BC%25` (the `%25` is the url encoded version of `%`).
There are other filters available for some entities, allowing you to search on other fields, or restricting the results
by numeric values or dates. See the endpoint documentation for the available filters.
## Filter by associated entities
To get all parts with a certain category, manufacturer, etc. you can use the `category`, `manufacturer`, etc. query
parameters of the `/api/parts` endpoint.
They are so-called entity filters and accept a comma-separated list of IDs of the entities you want to filter by.
For example, if you want to get all parts with the category "Resistor" (Category ID 1) and "Capacitor" (Category ID 2),
you can use `/api/parts.jsonld?category=1,2`.
Suffix an id with `+` to suffix, to include all direct children categories of the given category. Use the `++` suffix to
include all children categories recursively.
To get all parts with the category "Resistor" (Category ID 1) and all children categories of "Capacitor" (Category ID
2), you can use `/api/parts.jsonld?category=1,2++`.
See the endpoint documentation for the available entity filters.
## Ordering results
When retrieving a list of entities, you can order the results by various fields using the `order` query parameter.
For example, if you want to get all parts ordered by their name, you can use `/api/parts/?order[name]=asc`. You can use
this parameter multiple times to order by multiple fields.
See the endpoint documentation for the available fields to order by.
## Property filter
Sometimes you only want to get a subset of the properties of an entity, for example when you only need the name of a
part, but not all the other properties.
You can achieve this using the `properties[]` query parameter with the name of the field you want to get. You can use
this parameter multiple times to get multiple fields.
For example, if you only want to get the name and the description of a part, you can
use `/api/parts/123?properties[]=name&properties[]=description`.
It is also possible to use these filters on list endpoints (get collection), to only get a subset of the properties of
all entities in the collection.
See [API Platform docs](https://api-platform.com/docs/core/filters/#property-filter) for more info.
## Change comment
Similar to the changes using Part-DB web interface, you can add a change comment to every change you make via the API,
which will be
visible in the log of the entity.
You can pass the text for this via the `_comment` query parameter (beware of the proper encoding). For
example `/api/parts/123?_comment=This%20is%20a%20change%20comment`.
## Creating attachments and parameters
To create attachments and parameters, use the POST endpoint. Internally there are different types of attachments and
parameters, for each entity type, where the attachments or parameters are used (e.g. PartAttachment for parts, etc.).
The type of the attachment or parameter is automatically determined by the `element` property of the request data if a
IRI is passed. You can use the `_type` property to explicitly set the type of the attachment or parameter (the value must
be the value of the `@type` property of the owning entity. e.g. `Part` for parts).
For example, to create an attachment on a part, you can use the following request:
```
POST /api/attachments
{
"name": "front68",
"attachment_type": "/api/attachment_types/1",
"url": "https://invalid.invalid/test.url",
"element": "/api/parts/123"
}
```
## Uploading files to attachments
To upload files to the attachments you can use the special `upload` property of the attachment entity during write operations (POST, PUT, PATCH).
Under `data` you can pass a base64 encoded string of the file content, and under `filename` the name of the file.
Using the `private` property you can control if the file is the attachment should be stored privately or public.
For example, to upload a file to an attachment, you can use the following request:
This also works for creating new attachments, by including the `upload` property in the request data along with the other properties.
Using the `downloadUrl` property of `upload` you can say Part-DB to upload the file specified at the URL set on the attachment.
```
PATCH /api/attachments/123
{
"upload": {
"downloadUrl": true
},
"url": "https://host.invalid/myfile.pdf"
}
```
Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.