Compare commits

..

No commits in common. "master" and "v1.0.0" have entirely different histories.

1053 changed files with 26062 additions and 203110 deletions

View file

@ -1,55 +0,0 @@
{
{$CADDY_GLOBAL_OPTIONS}
frankenphp {
{$FRANKENPHP_CONFIG}
}
# https://caddyserver.com/docs/caddyfile/directives#sorting-algorithm
order mercure after encode
order vulcain after reverse_proxy
order php_server before file_server
}
{$CADDY_EXTRA_CONFIG}
{$SERVER_NAME:localhost} {
log {
# Redact the authorization query parameter that can be set by Mercure
format filter {
wrap console
fields {
uri query {
replace authorization REDACTED
}
}
}
}
root * /app/public
encode zstd br gzip
mercure {
# Transport to use (default to Bolt)
transport_url {$MERCURE_TRANSPORT_URL:bolt:///data/mercure.db}
# Publisher JWT key
publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
# Subscriber JWT key
subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
# Allow anonymous subscribers (double-check that it's what you want)
anonymous
# Enable the subscription API (double-check that it's what you want)
subscriptions
# Extra directives
{$MERCURE_EXTRA_DIRECTIVES}
}
vulcain
{$CADDY_SERVER_EXTRA_DIRECTIVES}
# Disable Topics tracking if not enabled explicitly: https://github.com/jkarlin/topics
header ?Permissions-Policy "browsing-topics=()"
php_server
}

View file

@ -1,5 +0,0 @@
; See https://docs.docker.com/desktop/networking/#i-want-to-connect-from-a-container-to-a-service-on-the-host
; See https://github.com/docker/for-linux/issues/264
; The `client_host` below may optionally be replaced with `discover_client_host=yes`
; Add `start_with_request=yes` to start debug session on each request
xdebug.client_host = host.docker.internal

View file

@ -1,18 +0,0 @@
expose_php = 0
date.timezone = UTC
apc.enable_cli = 1
session.use_strict_mode = 1
zend.detect_unicode = 0
; https://symfony.com/doc/current/performance.html
realpath_cache_size = 4096K
realpath_cache_ttl = 600
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 20000
opcache.memory_consumption = 256
opcache.enable_file_override = 1
memory_limit = 256M
upload_max_filesize=256M
post_max_size=300M

View file

@ -1,2 +0,0 @@
opcache.preload_user = root
opcache.preload = /app/config/preload.php

View file

@ -1,60 +0,0 @@
#!/bin/sh
set -e
if [ "$1" = 'frankenphp' ] || [ "$1" = 'php' ] || [ "$1" = 'bin/console' ]; then
# Install the project the first time PHP is started
# After the installation, the following block can be deleted
if [ ! -f composer.json ]; then
rm -Rf tmp/
composer create-project "symfony/skeleton $SYMFONY_VERSION" tmp --stability="$STABILITY" --prefer-dist --no-progress --no-interaction --no-install
cd tmp
cp -Rp . ..
cd -
rm -Rf tmp/
composer require "php:>=$PHP_VERSION" runtime/frankenphp-symfony
composer config --json extra.symfony.docker 'true'
if grep -q ^DATABASE_URL= .env; then
echo "To finish the installation please press Ctrl+C to stop Docker Compose and run: docker compose up --build -d --wait"
sleep infinity
fi
fi
if [ -z "$(ls -A 'vendor/' 2>/dev/null)" ]; then
composer install --prefer-dist --no-progress --no-interaction
fi
if grep -q ^DATABASE_URL= .env; then
echo "Waiting for database to be ready..."
ATTEMPTS_LEFT_TO_REACH_DATABASE=60
until [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ] || DATABASE_ERROR=$(php bin/console dbal:run-sql -q "SELECT 1" 2>&1); do
if [ $? -eq 255 ]; then
# If the Doctrine command exits with 255, an unrecoverable error occurred
ATTEMPTS_LEFT_TO_REACH_DATABASE=0
break
fi
sleep 1
ATTEMPTS_LEFT_TO_REACH_DATABASE=$((ATTEMPTS_LEFT_TO_REACH_DATABASE - 1))
echo "Still waiting for database to be ready... Or maybe the database is not reachable. $ATTEMPTS_LEFT_TO_REACH_DATABASE attempts left."
done
if [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ]; then
echo "The database is not up or not reachable:"
echo "$DATABASE_ERROR"
exit 1
else
echo "The database is now ready and reachable"
fi
if [ "$( find ./migrations -iname '*.php' -print -quit )" ]; then
php bin/console doctrine:migrations:migrate --no-interaction
fi
fi
setfacl -R -m u:www-data:rwX -m u:"$(whoami)":rwX var
setfacl -dR -m u:www-data:rwX -m u:"$(whoami)":rwX var
fi
exec docker-php-entrypoint "$@"

View file

@ -1,4 +0,0 @@
worker {
file ./public/index.php
env APP_RUNTIME Runtime\FrankenPhpSymfony\Runtime
}

View file

@ -39,51 +39,6 @@ if [ -d /var/www/html/var/db ]; then
fi fi
fi fi
# Start PHP-FPM (the PHP_VERSION is replaced by the configured version in the Dockerfile)
service phpPHP_VERSION-fpm start
# Run migrations if automigration is enabled via env variable DB_AUTOMIGRATE
if [ "$DB_AUTOMIGRATE" = "true" ]; then
echo "Waiting for database to be ready..."
ATTEMPTS_LEFT_TO_REACH_DATABASE=60
until [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ] || DATABASE_ERROR=$(sudo -E -u www-data php bin/console dbal:run-sql -q "SELECT 1" 2>&1); do
if [ $? -eq 255 ]; then
# If the Doctrine command exits with 255, an unrecoverable error occurred
ATTEMPTS_LEFT_TO_REACH_DATABASE=0
break
fi
sleep 1
ATTEMPTS_LEFT_TO_REACH_DATABASE=$((ATTEMPTS_LEFT_TO_REACH_DATABASE - 1))
echo "Still waiting for database to be ready... Or maybe the database is not reachable. $ATTEMPTS_LEFT_TO_REACH_DATABASE attempts left."
done
if [ $ATTEMPTS_LEFT_TO_REACH_DATABASE -eq 0 ]; then
echo "The database is not up or not reachable:"
echo "$DATABASE_ERROR"
exit 1
else
echo "The database is now ready and reachable"
fi
# Check if there are any available migrations to do, by executing doctrine:migrations:up-to-date
# and checking if the exit code is 0 (up to date) or 1 (not up to date)
if sudo -E -u www-data php bin/console doctrine:migrations:up-to-date --no-interaction; then
echo "Database is up to date, no migrations necessary."
else
echo "Migrations available..."
echo "Do backup of database..."
sudo -E -u www-data mkdir -p /var/www/html/uploads/.automigration-backup/
# Backup the database
sudo -E -u www-data php bin/console partdb:backup -n --database /var/www/html/uploads/.automigration-backup/backup-$(date +%Y-%m-%d_%H-%M-%S).zip
# Check if there are any migration files
sudo -E -u www-data php bin/console doctrine:migrations:migrate --no-interaction
fi
fi
# first arg is `-f` or `--some-option` (taken from https://github.com/docker-library/php/blob/master/8.2/bullseye/apache/docker-php-entrypoint) # first arg is `-f` or `--some-option` (taken from https://github.com/docker-library/php/blob/master/8.2/bullseye/apache/docker-php-entrypoint)
if [ "${1#-}" != "$1" ]; then if [ "${1#-}" != "$1" ]; then
set -- apache2-foreground "$@" set -- apache2-foreground "$@"

View file

@ -25,28 +25,14 @@
CustomLog ${APACHE_LOG_DIR}/access.log combined CustomLog ${APACHE_LOG_DIR}/access.log combined
# Pass the configuration from the docker env to the PHP environment (here you should list all .env options) # Pass the configuration from the docker env to the PHP environment (here you should list all .env options)
PassEnv APP_ENV APP_DEBUG APP_SECRET REDIRECT_TO_HTTPS DISABLE_YEAR2038_BUG_CHECK PassEnv APP_ENV APP_DEBUG APP_SECRET
PassEnv TRUSTED_PROXIES TRUSTED_HOSTS LOCK_DSN PassEnv DATABASE_URL
PassEnv DATABASE_URL ENFORCE_CHANGE_COMMENTS_FOR DATABASE_MYSQL_USE_SSL_CA DATABASE_MYSQL_SSL_VERIFY_CERT PassEnv DEFAULT_LANG DEFAULT_TIMEZONE BASE_CURRENCY INSTANCE_NAME ALLOW_ATTACHMENT_DOWNLOADS USE_GRAVATAR
PassEnv DEFAULT_LANG DEFAULT_TIMEZONE BASE_CURRENCY INSTANCE_NAME ALLOW_ATTACHMENT_DOWNLOADS USE_GRAVATAR MAX_ATTACHMENT_FILE_SIZE DEFAULT_URI CHECK_FOR_UPDATES ATTACHMENT_DOWNLOAD_BY_DEFAULT
PassEnv MAILER_DSN ALLOW_EMAIL_PW_RESET EMAIL_SENDER_EMAIL EMAIL_SENDER_NAME PassEnv MAILER_DSN ALLOW_EMAIL_PW_RESET EMAIL_SENDER_EMAIL EMAIL_SENDER_NAME
PassEnv HISTORY_SAVE_CHANGED_FIELDS HISTORY_SAVE_CHANGED_DATA HISTORY_SAVE_REMOVED_DATA HISTORY_SAVE_NEW_DATA PassEnv HISTORY_SAVE_CHANGED_FIELDS HISTORY_SAVE_CHANGED_DATA HISTORY_SAVE_REMOVED_DATA
PassEnv ERROR_PAGE_ADMIN_EMAIL ERROR_PAGE_SHOW_HELP PassEnv ERROR_PAGE_ADMIN_EMAIL ERROR_PAGE_SHOW_HELP
PassEnv DEMO_MODE NO_URL_REWRITE_AVAILABLE FIXER_API_KEY BANNER PassEnv DEMO_MODE NO_URL_REWRITE_AVAILABLE FIXER_API_KEY BANNER
# In old version the SAML sp private key env, was wrongly named SAMLP_SP_PRIVATE_KEY, keep it for backward compatibility
PassEnv SAML_ENABLED SAML_BEHIND_PROXY SAML_ROLE_MAPPING SAML_UPDATE_GROUP_ON_LOGIN SAML_IDP_ENTITY_ID SAML_IDP_SINGLE_SIGN_ON_SERVICE SAML_IDP_SINGLE_LOGOUT_SERVICE SAML_IDP_X509_CERT SAML_SP_ENTITY_ID SAML_SP_X509_CERT SAML_SP_PRIVATE_KEY SAMLP_SP_PRIVATE_KEY
PassEnv TABLE_DEFAULT_PAGE_SIZE TABLE_PARTS_DEFAULT_COLUMNS
PassEnv PROVIDER_DIGIKEY_CLIENT_ID PROVIDER_DIGIKEY_SECRET PROVIDER_DIGIKEY_CURRENCY PROVIDER_DIGIKEY_LANGUAGE PROVIDER_DIGIKEY_COUNTRY
PassEnv PROVIDER_ELEMENT14_KEY PROVIDER_ELEMENT14_STORE_ID
PassEnv PROVIDER_TME_KEY PROVIDER_TME_SECRET PROVIDER_TME_CURRENCY PROVIDER_TME_LANGUAGE PROVIDER_TME_COUNTRY PROVIDER_TME_GET_GROSS_PRICES
PassEnv PROVIDER_OCTOPART_CLIENT_ID PROVIDER_OCTOPART_SECRET PROVIDER_OCTOPART_CURRENCY PROVIDER_OCTOPART_COUNTRY PROVIDER_OCTOPART_SEARCH_LIMIT PROVIDER_OCTOPART_ONLY_AUTHORIZED_SELLERS
PassEnv PROVIDER_MOUSER_KEY PROVIDER_MOUSER_SEARCH_OPTION PROVIDER_MOUSER_SEARCH_LIMIT PROVIDER_MOUSER_SEARCH_WITH_SIGNUP_LANGUAGE
PassEnv PROVIDER_LCSC_ENABLED PROVIDER_LCSC_CURRENCY
PassEnv PROVIDER_OEMSECRETS_KEY PROVIDER_OEMSECRETS_COUNTRY_CODE PROVIDER_OEMSECRETS_CURRENCY PROVIDER_OEMSECRETS_ZERO_PRICE PROVIDER_OEMSECRETS_SET_PARAM PROVIDER_OEMSECRETS_SORT_CRITERIA
PassEnv PROVIDER_REICHELT_ENABLED PROVIDER_REICHELT_CURRENCY PROVIDER_REICHELT_COUNTRY PROVIDER_REICHELT_LANGUAGE PROVIDER_REICHELT_INCLUDE_VAT
PassEnv PROVIDER_POLLIN_ENABLED
PassEnv EDA_KICAD_CATEGORY_DEPTH
# For most configuration files from conf-available/, which are # For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to # enabled or disabled at a global level, it is possible to

View file

@ -5,8 +5,6 @@ tests/
docs/ docs/
.git .git
/public/media/*
###> symfony/framework-bundle ### ###> symfony/framework-bundle ###
/.env.local /.env.local
/.env.local.php /.env.local.php
@ -44,39 +42,3 @@ yarn-error.log
/phpunit.xml /phpunit.xml
.phpunit.result.cache .phpunit.result.cache
###< phpunit/phpunit ### ###< phpunit/phpunit ###
### From frankenphp
**/*.log
**/*.php~
**/*.dist.php
**/*.dist
**/*.cache
**/._*
**/.dockerignore
**/.DS_Store
**/.git/
**/.gitattributes
**/.gitignore
**/.gitmodules
**/compose.*.yaml
**/compose.*.yml
**/compose.yaml
**/compose.yml
**/docker-compose.*.yaml
**/docker-compose.*.yml
**/docker-compose.yaml
**/docker-compose.yml
**/Dockerfile
**/Thumbs.db
.github/
public/bundles/
var/
vendor/
.editorconfig
.env.*.local
.env.local
.env.local.php
.env.test

227
.env
View file

@ -14,19 +14,6 @@ DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db"
# Uncomment this line (and comment the line above to use a MySQL database # Uncomment this line (and comment the line above to use a MySQL database
#DATABASE_URL=mysql://root:@127.0.0.1:3306/part-db?serverVersion=5.7 #DATABASE_URL=mysql://root:@127.0.0.1:3306/part-db?serverVersion=5.7
# Set this value to 1, if you want to use SSL to connect to the MySQL server. It will be tried to use the CA certificate
# otherwise a CA bundle shipped with PHP will be used.
# Leave it at 0, if you do not want to use SSL or if your server does not support it
DATABASE_MYSQL_USE_SSL_CA=0
# Set this value to 0, if you don't want to verify the CA certificate of the MySQL server
# Only do this, if you know what you are doing!
DATABASE_MYSQL_SSL_VERIFY_CERT=1
# Emulate natural sorting of strings even on databases that do not support it (like SQLite, MySQL or MariaDB < 10.7)
# This can be slow on big databases and might have some problems and quirks, so use it with caution
DATABASE_EMULATE_NATURAL_SORT=0
################################################################################### ###################################################################################
# General settings # General settings
################################################################################### ###################################################################################
@ -42,25 +29,8 @@ INSTANCE_NAME="Part-DB"
# Allow users to download attachments to the server by providing an URL # 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) # 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 ALLOW_ATTACHMENT_DOWNLOADS=0
# Set this to 1, if the "download external files" checkbox should be checked by default for new attachments
ATTACHMENT_DOWNLOAD_BY_DEFAULT=0
# Use gravatars for user avatars, when user has no own avatar defined # Use gravatars for user avatars, when user has no own avatar defined
USE_GRAVATAR=0 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"
# 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
ENFORCE_CHANGE_COMMENTS_FOR=""
# Disable that if you do not want that Part-DB connects to GitHub to check for available updates, or if your server can not connect to the internet
CHECK_FOR_UPDATES=1
################################################################################### ###################################################################################
# Email settings # Email settings
@ -89,9 +59,6 @@ HISTORY_SAVE_CHANGED_FIELDS=1
HISTORY_SAVE_CHANGED_DATA=1 HISTORY_SAVE_CHANGED_DATA=1
# Save the data of an element that gets removed into log entry. This allows to undelete an element # Save the data of an element that gets removed into log entry. This allows to undelete an element
HISTORY_SAVE_REMOVED_DATA=1 HISTORY_SAVE_REMOVED_DATA=1
# Save the new data of an element that gets changed or added. This allows an easy comparison of the old and new data on the detail page
# This option only becomes active when HISTORY_SAVE_CHANGED_DATA is set to 1
HISTORY_SAVE_NEW_DATA=1
################################################################################### ###################################################################################
# Error pages settings # Error pages settings
@ -102,189 +69,6 @@ ERROR_PAGE_ADMIN_EMAIL=''
# If this is set to true, solutions to common problems are shown on error pages. Disable this, if you do not want your users to see them... # If this is set to true, solutions to common problems are shown on error pages. Disable this, if you do not want your users to see them...
ERROR_PAGE_SHOW_HELP=1 ERROR_PAGE_SHOW_HELP=1
##################################################################################
# Part table settings
##################################################################################
# The default page size for the part table (set to -1 to show all parts on one page)
TABLE_DEFAULT_PAGE_SIZE=50
# Configure which columns will be visible by default in the parts table (and in which order).
# This is a comma separated list of column names. See documentation for available values.
TABLE_PARTS_DEFAULT_COLUMNS=name,description,category,footprint,manufacturer,storage_location,amount
##################################################################################
# Info provider settings
##################################################################################
# Digikey Provider:
# You can get your client id and secret from https://developer.digikey.com/
PROVIDER_DIGIKEY_CLIENT_ID=
PROVIDER_DIGIKEY_SECRET=
# The currency to get prices in
PROVIDER_DIGIKEY_CURRENCY=EUR
# The language to get results in (en, de, fr, it, es, zh, ja, ko)
PROVIDER_DIGIKEY_LANGUAGE=en
# The country to get results for
PROVIDER_DIGIKEY_COUNTRY=DE
# Farnell Provider:
# You can get your API key from https://partner.element14.com/
PROVIDER_ELEMENT14_KEY=
# Configure the store domain you want to use. This decides the language and currency of results. You can get a list of available stores from https://partner.element14.com/docs/Product_Search_API_REST__Description
PROVIDER_ELEMENT14_STORE_ID=de.farnell.com
# TME Provider:
# You can get your API key from https://developers.tme.eu/en/
PROVIDER_TME_KEY=
PROVIDER_TME_SECRET=
# The currency to get prices in
PROVIDER_TME_CURRENCY=EUR
# The language to get results in (en, de, pl)
PROVIDER_TME_LANGUAGE=en
# The country to get results for
PROVIDER_TME_COUNTRY=DE
# [DEPRECATED] Set this to 1 to get gross prices (including VAT) instead of net prices
# With private API keys, this option cannot be used anymore is ignored by Part-DB. The VAT inclusion depends on your TME account settings.
PROVIDER_TME_GET_GROSS_PRICES=1
# Octopart / Nexar Provider:
# You can get your API key from https://nexar.com/api
PROVIDER_OCTOPART_CLIENT_ID=
PROVIDER_OCTOPART_SECRET=
# The currency and country to get prices for (you have to set both to get meaningful results)
# 3 letter ISO currency code (e.g. EUR, USD, GBP)
PROVIDER_OCTOPART_CURRENCY=EUR
# 2 letter ISO country code (e.g. DE, US, GB)
PROVIDER_OCTOPART_COUNTRY=DE
# The number of results to get from Octopart while searching (please note that this counts towards your API limits)
PROVIDER_OCTOPART_SEARCH_LIMIT=10
# Set to false to include non authorized offers in the results
PROVIDER_OCTOPART_ONLY_AUTHORIZED_SELLERS=1
# Mouser Provider API V2:
# You can get your API key from https://www.mouser.it/api-hub/
PROVIDER_MOUSER_KEY=
# Filter search results by RoHS compliance and stock availability:
# Available options: None | Rohs | InStock | RohsAndInStock
PROVIDER_MOUSER_SEARCH_OPTION='None'
# The number of results to get from Mouser while searching (please note that this value is max 50)
PROVIDER_MOUSER_SEARCH_LIMIT=50
# It is recommended to leave this set to 'true'. The option is not really good doumented by Mouser:
# Used when searching for keywords in the language specified when you signed up for Search API.
PROVIDER_MOUSER_SEARCH_WITH_SIGNUP_LANGUAGE='true'
# LCSC Provider:
# LCSC does not provide an offical API, so this used the API LCSC uses to render their webshop.
# LCSC did not intended the use of this API and it could break any time, so use it at your own risk.
# We dont require an API key for LCSC, just set this to 1 to enable LCSC support
PROVIDER_LCSC_ENABLED=0
# The currency to get prices in (e.g. EUR, USD, etc.)
PROVIDER_LCSC_CURRENCY=EUR
# Oemsecrets Provider API 3.0.1:
# You can get your API key from https://www.oemsecrets.com/api
PROVIDER_OEMSECRETS_KEY=
# The country you want the output for
PROVIDER_OEMSECRETS_COUNTRY_CODE=DE
# Available country code are:
# AD, AE, AQ, AR, AT, AU, BE, BO, BR, BV, BY, CA, CH, CL, CN, CO, CZ, DE, DK, EC, EE, EH,
# ES, FI, FK, FO, FR, GB, GE, GF, GG, GI, GL, GR, GS, GY, HK, HM, HR, HU, IE, IM, IN, IS,
# IT, JM, JP, KP, KR, KZ, LI, LK, LT, LU, MC, MD, ME, MK, MT, NL, NO, NZ, PE, PH, PL, PT,
# PY, RO, RS, RU, SB, SD, SE, SG, SI, SJ, SK, SM, SO, SR, SY, SZ, TC, TF, TG, TH, TJ, TK,
# TM, TN, TO, TR, TT, TV, TW, TZ, UA, UG, UM, US, UY, UZ, VA, VE, VG, VI, VN, VU, WF, YE,
# ZA, ZM, ZW
#
# The currency you want the prices to be displayed in
PROVIDER_OEMSECRETS_CURRENCY=EUR
# Available currency are:AUD, CAD, CHF, CNY, DKK, EUR, GBP, HKD, ILS, INR, JPY, KRW, NOK,
# NZD, RUB, SEK, SGD, TWD, USD
#
# If PROVIDER_OEMSECRETS_ZERO_PRICE is set to 0, distributors with zero prices
# will be discarded from the creation of a new part (set to 1 otherwise)
PROVIDER_OEMSECRETS_ZERO_PRICE=0
#
# When PROVIDER_OEMSECRETS_SET_PARAM is set to 1 the parameters for the part are generated
# from the description transforming unstructured descriptions into structured parameters;
# each parameter in description should have the form: "...;name1:value1;name2:value2"
PROVIDER_OEMSECRETS_SET_PARAM=1
#
# This environment variable determines the sorting criteria for product results.
# The sorting process first arranges items based on the provided keyword.
# Then, if set to 'C', it further sorts by completeness (prioritizing items with the most
# detailed information). If set to 'M', it further sorts by manufacturer name.
#If unset or set to any other value, no sorting is performed.
PROVIDER_OEMSECRETS_SORT_CRITERIA=C
# Reichelt provider:
# Reichelt.com offers no official API, so this info provider webscrapes the website to extract info
# It could break at any time, use it at your own risk
# We dont require an API key for Reichelt, just set this to 1 to enable Reichelt support
PROVIDER_REICHELT_ENABLED=0
# The country to get prices for
PROVIDER_REICHELT_COUNTRY=DE
# The language to get results in (en, de, fr, nl, pl, it, es)
PROVIDER_REICHELT_LANGUAGE=en
# Include VAT in prices (set to 1 to include VAT, 0 to exclude VAT)
PROVIDER_REICHELT_INCLUDE_VAT=1
# The currency to get prices in (only for countries with countries other than EUR)
PROVIDER_REICHELT_CURRENCY=EUR
# Pollin provider:
# Pollin.de offers no official API, so this info provider webscrapes the website to extract info
# It could break at any time, use it at your own risk
# We dont require an API key for Pollin, just set this to 1 to enable Pollin support
PROVIDER_POLLIN_ENABLED=0
##################################################################################
# EDA integration related settings
##################################################################################
# This value determines the depth of the category tree, that is visible inside KiCad
# 0 means that only the top level categories are visible. Set to a value > 0 to show more levels.
# Set to -1, to show all parts of Part-DB inside a single category in KiCad
EDA_KICAD_CATEGORY_DEPTH=0
###################################################################################
# SAML Single sign on-settings
###################################################################################
# Set this to 1 to enable SAML single sign on
# Be also sure to set the correct values for DEFAULT_URI
SAML_ENABLED=0
# Set to 1, if your Part-DB installation is behind a reverse proxy and you want to use SAML
SAML_BEHIND_PROXY=0
# A JSON encoded array of role mappings in the form { "saml_role": PARTDB_GROUP_ID, "*": PARTDB_GROUP_ID }
# The first match is used, so the order is important! Put the group mapping with the most privileges first.
# Please not to only use single quotes to enclose the JSON string
SAML_ROLE_MAPPING='{}'
# A mapping could look like the following
#SAML_ROLE_MAPPING='{ "*": 2, "admin": 1, "editor": 3}'
# When this is set to 1, the group of SAML users will be updated everytime they login based on their SAML roles
SAML_UPDATE_GROUP_ON_LOGIN=1
# The entity ID of your SAML IDP (e.g. the realm name of your Keycloak server)
SAML_IDP_ENTITY_ID="https://idp.changeme.invalid/realms/master"
# The URL of your SAML IDP SingleSignOnService (e.g. the endpoint of your Keycloak server)
SAML_IDP_SINGLE_SIGN_ON_SERVICE="https://idp.changeme.invalid/realms/master/protocol/saml"
# The URL of your SAML IDP SingleLogoutService (e.g. the endpoint of your Keycloak server)
SAML_IDP_SINGLE_LOGOUT_SERVICE="https://idp.changeme.invalid/realms/master/protocol/saml"
# The public certificate of the SAML IDP (e.g. the certificate of your Keycloak server)
SAML_IDP_X509_CERT="MIIC..."
# The entity of your SAML SP, must match the SP entityID configured in your SAML IDP (e.g. Keycloak).
# This should be a the domain name of your Part-DB installation, followed by "/sp"
SAML_SP_ENTITY_ID="https://partdb.changeme.invalid/sp"
# The public certificate of the SAML SP
SAML_SP_X509_CERT="MIIC..."
# The private key of the SAML SP
SAML_SP_PRIVATE_KEY="MIIE..."
###################################################################################### ######################################################################################
# Other settings # Other settings
###################################################################################### ######################################################################################
@ -295,9 +79,6 @@ DEMO_MODE=0
# In that case all URL contains the index.php front controller in URL # In that case all URL contains the index.php front controller in URL
NO_URL_REWRITE_AVAILABLE=0 NO_URL_REWRITE_AVAILABLE=0
# Set to 1, if Part-DB should redirect all HTTP requests to HTTPS. You dont need to configure this, if your webserver already does this.
REDIRECT_TO_HTTPS=0
# If you want to use fixer.io for currency conversion, you have to set this to your API key # If you want to use fixer.io for currency conversion, you have to set this to your API key
FIXER_API_KEY=CHANGEME FIXER_API_KEY=CHANGEME
@ -308,11 +89,9 @@ BANNER=""
APP_ENV=prod APP_ENV=prod
APP_SECRET=a03498528f5a5fc089273ec9ae5b2849 APP_SECRET=a03498528f5a5fc089273ec9ae5b2849
# Set this to zero, if you want to disable the year 2038 bug check on 32-bit systems (it will cause errors with current 32-bit PHP versions)
DISABLE_YEAR2038_BUG_CHECK=0
# Set the trusted IPs here, when using an reverse proxy # Set the trusted IPs here, when using an reverse proxy
#TRUSTED_PROXIES=127.0.0.0/8,::1,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 #TRUSTED_PROXIES=127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16
#TRUSTED_HOSTS='^(localhost|example\.com)$' #TRUSTED_HOSTS='^(localhost|example\.com)$'
@ -321,7 +100,3 @@ DISABLE_YEAR2038_BUG_CHECK=0
# postgresql+advisory://db_user:db_password@localhost/db_name # postgresql+advisory://db_user:db_password@localhost/db_name
LOCK_DSN=flock LOCK_DSN=flock
###< symfony/lock ### ###< symfony/lock ###
###> nelmio/cors-bundle ###
CORS_ALLOW_ORIGIN='^https?://(localhost|127\.0\.0\.1)(:[0-9]+)?$'
###< nelmio/cors-bundle ###

View file

View file

@ -5,9 +5,5 @@ SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
DATABASE_URL="sqlite:///%kernel.project_dir%/var/app_test.db"
# Doctrine automatically adds an _test suffix to database name in test env # Doctrine automatically adds an _test suffix to database name in test env
#DATABASE_URL=mysql://root:@127.0.0.1:3306/part-db DATABASE_URL=mysql://root:@127.0.0.1:3306/part-db
# Disable update checks, as tests would fail, when github is not reachable
CHECK_FOR_UPDATES=0

2
.gitattributes vendored
View file

@ -1,2 +0,0 @@
# For sh files, always use LF line endings
*.sh text eol=lf

View file

@ -1,752 +0,0 @@
-- phpMyAdmin SQL Dump
-- version 5.1.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Erstellungszeit: 07. Mai 2023 um 01:58
-- Server-Version: 10.6.5-MariaDB-log
-- PHP-Version: 8.1.2
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Datenbank: `partdb_demo`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `attachements`
--
CREATE TABLE `attachements` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`class_name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL,
`element_id` int(11) NOT NULL,
`type_id` int(11) NOT NULL,
`filename` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`show_in_table` tinyint(1) NOT NULL DEFAULT 0,
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `attachements`
--
INSERT INTO `attachements` (`id`, `name`, `class_name`, `element_id`, `type_id`, `filename`, `show_in_table`, `last_modified`) VALUES
(1, 'BC547', 'Part', 2, 2, '%BASE%/data/media/bc547.pdf', 1, '0000-00-00 00:00:00');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `attachement_types`
--
CREATE TABLE `attachement_types` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `attachement_types`
--
INSERT INTO `attachement_types` (`id`, `name`, `parent_id`, `comment`, `datetime_added`, `last_modified`) VALUES
(1, 'Bilder', NULL, NULL, '2017-10-21 17:58:48', '0000-00-00 00:00:00'),
(2, 'Datenblätter', NULL, NULL, '2017-10-21 17:58:48', '0000-00-00 00:00:00');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `categories`
--
CREATE TABLE `categories` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`disable_footprints` tinyint(1) NOT NULL DEFAULT 0,
`disable_manufacturers` tinyint(1) NOT NULL DEFAULT 0,
`disable_autodatasheets` tinyint(1) NOT NULL DEFAULT 0,
`disable_properties` tinyint(1) NOT NULL DEFAULT 0,
`partname_regex` text COLLATE utf8mb3_unicode_ci NOT NULL,
`partname_hint` text COLLATE utf8mb3_unicode_ci NOT NULL,
`default_description` text COLLATE utf8mb3_unicode_ci NOT NULL,
`default_comment` text COLLATE utf8mb3_unicode_ci NOT NULL,
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `categories`
--
INSERT INTO `categories` (`id`, `name`, `parent_id`, `disable_footprints`, `disable_manufacturers`, `disable_autodatasheets`, `disable_properties`, `partname_regex`, `partname_hint`, `default_description`, `default_comment`, `comment`, `datetime_added`, `last_modified`) VALUES
(1, 'aktive Bauteile', NULL, 0, 0, 0, 0, '', '', '', '', NULL, '2017-10-21 17:58:49', '0000-00-00 00:00:00');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `devices`
--
CREATE TABLE `devices` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`order_quantity` int(11) NOT NULL DEFAULT 0,
`order_only_missing_parts` tinyint(1) NOT NULL DEFAULT 0,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `devices`
--
INSERT INTO `devices` (`id`, `name`, `parent_id`, `order_quantity`, `order_only_missing_parts`, `datetime_added`, `last_modified`, `comment`) VALUES
(1, 'Test', NULL, 0, 0, '2015-04-16 15:08:56', '0000-00-00 00:00:00', NULL);
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `device_parts`
--
CREATE TABLE `device_parts` (
`id` int(11) NOT NULL,
`id_part` int(11) NOT NULL DEFAULT 0,
`id_device` int(11) NOT NULL DEFAULT 0,
`quantity` int(11) NOT NULL DEFAULT 0,
`mountnames` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `device_parts`
--
INSERT INTO `device_parts` (`id`, `id_part`, `id_device`, `quantity`, `mountnames`) VALUES
(1, 2, 1, 1, '');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `footprints`
--
CREATE TABLE `footprints` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`filename` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`filename_3d` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `footprints`
--
INSERT INTO `footprints` (`id`, `name`, `filename`, `filename_3d`, `parent_id`, `comment`, `datetime_added`, `last_modified`) VALUES
(1, 'LEDs', '%BASE%/img/footprints/Optik/LEDs/Bedrahtet/LED-GELB_3MM.png', '', NULL, NULL, '2017-10-21 17:58:49', '0000-00-00 00:00:00');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `groups`
--
CREATE TABLE `groups` (
`id` int(11) NOT NULL,
`name` varchar(32) NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`comment` mediumtext DEFAULT NULL,
`perms_system` int(11) NOT NULL,
`perms_groups` int(11) NOT NULL,
`perms_users` int(11) NOT NULL,
`perms_self` int(11) NOT NULL,
`perms_system_config` int(11) NOT NULL,
`perms_system_database` int(11) NOT NULL,
`perms_parts` bigint(11) NOT NULL,
`perms_parts_name` smallint(6) NOT NULL,
`perms_parts_description` smallint(6) NOT NULL,
`perms_parts_instock` smallint(6) NOT NULL,
`perms_parts_mininstock` smallint(6) NOT NULL,
`perms_parts_footprint` smallint(6) NOT NULL,
`perms_parts_storelocation` smallint(6) NOT NULL,
`perms_parts_manufacturer` smallint(6) NOT NULL,
`perms_parts_comment` smallint(6) NOT NULL,
`perms_parts_order` smallint(6) NOT NULL,
`perms_parts_orderdetails` smallint(6) NOT NULL,
`perms_parts_prices` smallint(6) NOT NULL,
`perms_parts_attachements` smallint(6) NOT NULL,
`perms_devices` int(11) NOT NULL,
`perms_devices_parts` int(11) NOT NULL,
`perms_storelocations` int(11) NOT NULL,
`perms_footprints` int(11) NOT NULL,
`perms_categories` int(11) NOT NULL,
`perms_suppliers` int(11) NOT NULL,
`perms_manufacturers` int(11) NOT NULL,
`perms_attachement_types` int(11) NOT NULL,
`perms_tools` int(11) NOT NULL,
`perms_labels` smallint(6) NOT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
--
-- Daten für Tabelle `groups`
--
INSERT INTO `groups` (`id`, `name`, `parent_id`, `comment`, `perms_system`, `perms_groups`, `perms_users`, `perms_self`, `perms_system_config`, `perms_system_database`, `perms_parts`, `perms_parts_name`, `perms_parts_description`, `perms_parts_instock`, `perms_parts_mininstock`, `perms_parts_footprint`, `perms_parts_storelocation`, `perms_parts_manufacturer`, `perms_parts_comment`, `perms_parts_order`, `perms_parts_orderdetails`, `perms_parts_prices`, `perms_parts_attachements`, `perms_devices`, `perms_devices_parts`, `perms_storelocations`, `perms_footprints`, `perms_categories`, `perms_suppliers`, `perms_manufacturers`, `perms_attachement_types`, `perms_tools`, `perms_labels`, `datetime_added`, `last_modified`) VALUES
(1, 'admins', NULL, 'Users of this group can do everything: Read, Write and Administrative actions.', 21, 1365, 87381, 85, 85, 21, 1431655765, 5, 5, 5, 5, 5, 5, 5, 5, 5, 325, 325, 325, 5461, 325, 5461, 5461, 5461, 5461, 5461, 1365, 1365, 85, '2017-10-21 17:58:46', '2018-10-08 17:27:41'),
(2, 'readonly', NULL, 'Users of this group can only read informations, use tools, and don\'t have access to administrative tools.', 2, 2730, 43690, 25, 170, 42, 2778027689, 9, 9, 9, 9, 9, 9, 9, 9, 9, 649, 649, 649, 1705, 649, 1705, 1705, 1705, 1705, 1705, 681, 1366, 165, '2017-10-21 17:58:46', '2018-10-08 17:28:35'),
(3, 'users', NULL, 'Users of this group, can edit part informations, create new ones, etc. but are not allowed to use administrative tools. (But can read current configuration, and see Server status)', 42, 2730, 43689, 89, 105, 41, 1431655765, 5, 5, 5, 5, 5, 5, 5, 5, 5, 325, 325, 325, 5461, 325, 5461, 5461, 5461, 5461, 5461, 1365, 1365, 85, '2017-10-21 17:58:46', '2018-10-08 17:28:17');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `internal`
--
CREATE TABLE `internal` (
`keyName` char(30) CHARACTER SET ascii NOT NULL,
`keyValue` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `internal`
--
INSERT INTO `internal` (`keyName`, `keyValue`) VALUES
('dbVersion', '26');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `log`
--
CREATE TABLE `log` (
`id` int(11) NOT NULL,
`datetime` timestamp NOT NULL DEFAULT current_timestamp(),
`id_user` int(11) NOT NULL,
`level` tinyint(4) NOT NULL,
`type` smallint(6) NOT NULL,
`target_id` int(11) NOT NULL,
`target_type` smallint(6) NOT NULL,
`extra` mediumtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `manufacturers`
--
CREATE TABLE `manufacturers` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`address` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`phone_number` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`fax_number` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`email_address` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`website` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`auto_product_url` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `manufacturers`
--
INSERT INTO `manufacturers` (`id`, `name`, `parent_id`, `address`, `phone_number`, `fax_number`, `email_address`, `website`, `auto_product_url`, `datetime_added`, `comment`, `last_modified`) VALUES
(1, 'Atmel', NULL, '', '', '', '', '', '', '2015-03-01 11:27:10', NULL, '0000-00-00 00:00:00');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `orderdetails`
--
CREATE TABLE `orderdetails` (
`id` int(11) NOT NULL,
`part_id` int(11) NOT NULL,
`id_supplier` int(11) NOT NULL DEFAULT 0,
`supplierpartnr` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`obsolete` tinyint(1) DEFAULT 0,
`supplier_product_url` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `parts`
--
CREATE TABLE `parts` (
`id` int(11) NOT NULL,
`id_category` int(11) NOT NULL DEFAULT 0,
`name` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`description` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`instock` int(11) NOT NULL DEFAULT 0,
`mininstock` int(11) NOT NULL DEFAULT 0,
`comment` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`visible` tinyint(1) NOT NULL,
`id_footprint` int(11) DEFAULT NULL,
`id_storelocation` int(11) DEFAULT NULL,
`order_orderdetails_id` int(11) DEFAULT NULL,
`order_quantity` int(11) NOT NULL DEFAULT 1,
`manual_order` tinyint(1) NOT NULL DEFAULT 0,
`id_manufacturer` int(11) DEFAULT NULL,
`id_master_picture_attachement` int(11) DEFAULT NULL,
`manufacturer_product_url` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`favorite` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `parts`
--
INSERT INTO `parts` (`id`, `id_category`, `name`, `description`, `instock`, `mininstock`, `comment`, `visible`, `id_footprint`, `id_storelocation`, `order_orderdetails_id`, `order_quantity`, `manual_order`, `id_manufacturer`, `id_master_picture_attachement`, `manufacturer_product_url`, `datetime_added`, `last_modified`, `favorite`) VALUES
(2, 1, 'BC547C', 'NPN 45V 0,1A 0,5W', 59, 0, '', 0, 1, 1, NULL, 1, 0, NULL, NULL, '', '2015-03-01 10:40:31', '2016-12-26 10:48:49', 0);
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `pricedetails`
--
CREATE TABLE `pricedetails` (
`id` int(11) NOT NULL,
`orderdetails_id` int(11) NOT NULL,
`price` decimal(11,5) DEFAULT NULL,
`price_related_quantity` int(11) NOT NULL DEFAULT 1,
`min_discount_quantity` int(11) NOT NULL DEFAULT 1,
`manual_input` tinyint(1) NOT NULL DEFAULT 1,
`last_modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `storelocations`
--
CREATE TABLE `storelocations` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`is_full` tinyint(1) NOT NULL DEFAULT 0,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `storelocations`
--
INSERT INTO `storelocations` (`id`, `name`, `parent_id`, `is_full`, `datetime_added`, `comment`, `last_modified`) VALUES
(1, 'Halbleiter I', NULL, 0, '2015-03-01 11:26:37', NULL, '0000-00-00 00:00:00');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `suppliers`
--
CREATE TABLE `suppliers` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`address` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`phone_number` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`fax_number` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`email_address` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`website` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`auto_product_url` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `suppliers`
--
INSERT INTO `suppliers` (`id`, `name`, `parent_id`, `address`, `phone_number`, `fax_number`, `email_address`, `website`, `auto_product_url`, `datetime_added`, `comment`, `last_modified`) VALUES
(1, 'Test', NULL, '', '', '', '', '', 'Test', '2015-03-01 10:37:23', NULL, '0000-00-00 00:00:00');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`name` varchar(32) NOT NULL,
`password` varchar(255) DEFAULT NULL,
`first_name` tinytext DEFAULT NULL,
`last_name` tinytext DEFAULT NULL,
`department` tinytext DEFAULT NULL,
`email` tinytext DEFAULT NULL,
`need_pw_change` tinyint(1) NOT NULL DEFAULT 0,
`group_id` int(11) DEFAULT NULL,
`config_language` tinytext DEFAULT NULL,
`config_timezone` tinytext DEFAULT NULL,
`config_theme` tinytext DEFAULT NULL,
`config_currency` tinytext DEFAULT NULL,
`config_image_path` text NOT NULL,
`config_instock_comment_w` text NOT NULL,
`config_instock_comment_a` text NOT NULL,
`perms_system` int(11) NOT NULL,
`perms_groups` int(11) NOT NULL,
`perms_users` int(11) NOT NULL,
`perms_self` int(11) NOT NULL,
`perms_system_config` int(11) NOT NULL,
`perms_system_database` int(11) NOT NULL,
`perms_parts` bigint(11) NOT NULL,
`perms_parts_name` smallint(6) NOT NULL,
`perms_parts_description` smallint(6) NOT NULL,
`perms_parts_instock` smallint(6) NOT NULL,
`perms_parts_mininstock` smallint(6) NOT NULL,
`perms_parts_footprint` smallint(6) NOT NULL,
`perms_parts_storelocation` smallint(6) NOT NULL,
`perms_parts_manufacturer` smallint(6) NOT NULL,
`perms_parts_comment` smallint(6) NOT NULL,
`perms_parts_order` smallint(6) NOT NULL,
`perms_parts_orderdetails` smallint(6) NOT NULL,
`perms_parts_prices` smallint(6) NOT NULL,
`perms_parts_attachements` smallint(6) NOT NULL,
`perms_devices` int(11) NOT NULL,
`perms_devices_parts` int(11) NOT NULL,
`perms_storelocations` int(11) NOT NULL,
`perms_footprints` int(11) NOT NULL,
`perms_categories` int(11) NOT NULL,
`perms_suppliers` int(11) NOT NULL,
`perms_manufacturers` int(11) NOT NULL,
`perms_attachement_types` int(11) NOT NULL,
`perms_tools` int(11) NOT NULL,
`perms_labels` smallint(6) NOT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;
--
-- Daten für Tabelle `users`
--
INSERT INTO `users` (`id`, `name`, `password`, `first_name`, `last_name`, `department`, `email`, `need_pw_change`, `group_id`, `config_language`, `config_timezone`, `config_theme`, `config_currency`, `config_image_path`, `config_instock_comment_w`, `config_instock_comment_a`, `perms_system`, `perms_groups`, `perms_users`, `perms_self`, `perms_system_config`, `perms_system_database`, `perms_parts`, `perms_parts_name`, `perms_parts_description`, `perms_parts_instock`, `perms_parts_mininstock`, `perms_parts_footprint`, `perms_parts_storelocation`, `perms_parts_manufacturer`, `perms_parts_comment`, `perms_parts_order`, `perms_parts_orderdetails`, `perms_parts_prices`, `perms_parts_attachements`, `perms_devices`, `perms_devices_parts`, `perms_storelocations`, `perms_footprints`, `perms_categories`, `perms_suppliers`, `perms_manufacturers`, `perms_attachement_types`, `perms_tools`, `perms_labels`, `datetime_added`, `last_modified`) VALUES
(1, 'anonymous', '', '', '', '', '', 0, 2, '', '', '', NULL, '', '', '', 21848, 20480, 0, 0, 0, 0, 0, 21840, 21840, 21840, 21840, 21840, 21840, 21840, 21840, 21840, 21520, 21520, 21520, 20480, 21520, 20480, 20480, 20480, 20480, 20480, 21504, 20480, 0, '2017-10-21 17:58:46', '2018-02-18 12:46:58'),
(2, 'admin', '$2a$12$j0RKrKlx60bzX1DWMyXwjeaW.pe3bFjAK8ByIGnvjrRnET2JtsFoe', 'Admin', 'Ad', NULL, 'admin@ras.pi', 0, 1, '', '', '', NULL, '', '', '', 21845, 21845, 21845, 21, 85, 21, 349525, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 0, '2017-10-21 17:58:46', '2017-12-23 11:04:48');
--
-- Indizes der exportierten Tabellen
--
--
-- Indizes für die Tabelle `attachements`
--
ALTER TABLE `attachements`
ADD PRIMARY KEY (`id`),
ADD KEY `attachements_class_name_k` (`class_name`),
ADD KEY `attachements_element_id_k` (`element_id`),
ADD KEY `attachements_type_id_fk` (`type_id`);
--
-- Indizes für die Tabelle `attachement_types`
--
ALTER TABLE `attachement_types`
ADD PRIMARY KEY (`id`),
ADD KEY `attachement_types_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `categories`
--
ALTER TABLE `categories`
ADD PRIMARY KEY (`id`),
ADD KEY `categories_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `devices`
--
ALTER TABLE `devices`
ADD PRIMARY KEY (`id`),
ADD KEY `devices_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `device_parts`
--
ALTER TABLE `device_parts`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `device_parts_combination_uk` (`id_part`,`id_device`),
ADD KEY `device_parts_id_part_k` (`id_part`),
ADD KEY `device_parts_id_device_k` (`id_device`);
--
-- Indizes für die Tabelle `footprints`
--
ALTER TABLE `footprints`
ADD PRIMARY KEY (`id`),
ADD KEY `footprints_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `groups`
--
ALTER TABLE `groups`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `name` (`name`);
--
-- Indizes für die Tabelle `internal`
--
ALTER TABLE `internal`
ADD UNIQUE KEY `keyName` (`keyName`);
--
-- Indizes für die Tabelle `log`
--
ALTER TABLE `log`
ADD PRIMARY KEY (`id`),
ADD KEY `id_user` (`id_user`);
--
-- Indizes für die Tabelle `manufacturers`
--
ALTER TABLE `manufacturers`
ADD PRIMARY KEY (`id`),
ADD KEY `manufacturers_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `orderdetails`
--
ALTER TABLE `orderdetails`
ADD PRIMARY KEY (`id`),
ADD KEY `orderdetails_part_id_k` (`part_id`),
ADD KEY `orderdetails_id_supplier_k` (`id_supplier`);
--
-- Indizes für die Tabelle `parts`
--
ALTER TABLE `parts`
ADD PRIMARY KEY (`id`),
ADD KEY `parts_id_category_k` (`id_category`),
ADD KEY `parts_id_footprint_k` (`id_footprint`),
ADD KEY `parts_id_storelocation_k` (`id_storelocation`),
ADD KEY `parts_order_orderdetails_id_k` (`order_orderdetails_id`),
ADD KEY `parts_id_manufacturer_k` (`id_manufacturer`),
ADD KEY `favorite` (`favorite`);
--
-- Indizes für die Tabelle `pricedetails`
--
ALTER TABLE `pricedetails`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `pricedetails_combination_uk` (`orderdetails_id`,`min_discount_quantity`),
ADD KEY `pricedetails_orderdetails_id_k` (`orderdetails_id`);
--
-- Indizes für die Tabelle `storelocations`
--
ALTER TABLE `storelocations`
ADD PRIMARY KEY (`id`),
ADD KEY `storelocations_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `suppliers`
--
ALTER TABLE `suppliers`
ADD PRIMARY KEY (`id`),
ADD KEY `suppliers_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `name` (`name`);
--
-- AUTO_INCREMENT für exportierte Tabellen
--
--
-- AUTO_INCREMENT für Tabelle `attachements`
--
ALTER TABLE `attachements`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=201;
--
-- AUTO_INCREMENT für Tabelle `attachement_types`
--
ALTER TABLE `attachement_types`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT für Tabelle `categories`
--
ALTER TABLE `categories`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=123;
--
-- AUTO_INCREMENT für Tabelle `devices`
--
ALTER TABLE `devices`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT für Tabelle `device_parts`
--
ALTER TABLE `device_parts`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=12;
--
-- AUTO_INCREMENT für Tabelle `footprints`
--
ALTER TABLE `footprints`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=82;
--
-- AUTO_INCREMENT für Tabelle `groups`
--
ALTER TABLE `groups`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT für Tabelle `log`
--
ALTER TABLE `log`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=218;
--
-- AUTO_INCREMENT für Tabelle `manufacturers`
--
ALTER TABLE `manufacturers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT für Tabelle `orderdetails`
--
ALTER TABLE `orderdetails`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=650;
--
-- AUTO_INCREMENT für Tabelle `parts`
--
ALTER TABLE `parts`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1171;
--
-- AUTO_INCREMENT für Tabelle `pricedetails`
--
ALTER TABLE `pricedetails`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=437;
--
-- AUTO_INCREMENT für Tabelle `storelocations`
--
ALTER TABLE `storelocations`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=340;
--
-- AUTO_INCREMENT für Tabelle `suppliers`
--
ALTER TABLE `suppliers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT für Tabelle `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- Constraints der exportierten Tabellen
--
--
-- Constraints der Tabelle `attachements`
--
ALTER TABLE `attachements`
ADD CONSTRAINT `attachements_type_id_fk` FOREIGN KEY (`type_id`) REFERENCES `attachement_types` (`id`);
--
-- Constraints der Tabelle `attachement_types`
--
ALTER TABLE `attachement_types`
ADD CONSTRAINT `attachement_types_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `attachement_types` (`id`);
--
-- Constraints der Tabelle `categories`
--
ALTER TABLE `categories`
ADD CONSTRAINT `categories_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `categories` (`id`);
--
-- Constraints der Tabelle `devices`
--
ALTER TABLE `devices`
ADD CONSTRAINT `devices_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `devices` (`id`);
--
-- Constraints der Tabelle `footprints`
--
ALTER TABLE `footprints`
ADD CONSTRAINT `footprints_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `footprints` (`id`);
--
-- Constraints der Tabelle `manufacturers`
--
ALTER TABLE `manufacturers`
ADD CONSTRAINT `manufacturers_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `manufacturers` (`id`);
--
-- Constraints der Tabelle `parts`
--
ALTER TABLE `parts`
ADD CONSTRAINT `parts_id_footprint_fk` FOREIGN KEY (`id_footprint`) REFERENCES `footprints` (`id`),
ADD CONSTRAINT `parts_id_manufacturer_fk` FOREIGN KEY (`id_manufacturer`) REFERENCES `manufacturers` (`id`),
ADD CONSTRAINT `parts_id_storelocation_fk` FOREIGN KEY (`id_storelocation`) REFERENCES `storelocations` (`id`),
ADD CONSTRAINT `parts_order_orderdetails_id_fk` FOREIGN KEY (`order_orderdetails_id`) REFERENCES `orderdetails` (`id`);
--
-- Constraints der Tabelle `storelocations`
--
ALTER TABLE `storelocations`
ADD CONSTRAINT `storelocations_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `storelocations` (`id`);
--
-- Constraints der Tabelle `suppliers`
--
ALTER TABLE `suppliers`
ADD CONSTRAINT `suppliers_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `suppliers` (`id`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

View file

@ -1,736 +0,0 @@
-- phpMyAdmin SQL Dump
-- version 5.1.3
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Erstellungszeit: 07. Mai 2023 um 01:48
-- Server-Version: 10.6.5-MariaDB-log
-- PHP-Version: 8.1.2
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Datenbank: `partdb-legacy`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `attachements`
--
CREATE TABLE `attachements` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`class_name` varchar(255) COLLATE utf8mb3_unicode_ci NOT NULL,
`element_id` int(11) NOT NULL,
`type_id` int(11) NOT NULL,
`filename` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`show_in_table` tinyint(1) NOT NULL DEFAULT 0,
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `attachement_types`
--
CREATE TABLE `attachement_types` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `attachement_types`
--
INSERT INTO `attachement_types` (`id`, `name`, `parent_id`, `comment`, `datetime_added`, `last_modified`) VALUES
(1, 'Bilder', NULL, NULL, '2023-01-07 18:31:48', '0000-00-00 00:00:00'),
(2, 'Datenblätter', NULL, NULL, '2023-01-07 18:31:48', '0000-00-00 00:00:00');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `categories`
--
CREATE TABLE `categories` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`disable_footprints` tinyint(1) NOT NULL DEFAULT 0,
`disable_manufacturers` tinyint(1) NOT NULL DEFAULT 0,
`disable_autodatasheets` tinyint(1) NOT NULL DEFAULT 0,
`disable_properties` tinyint(1) NOT NULL DEFAULT 0,
`partname_regex` text COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
`partname_hint` text COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
`default_description` text COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
`default_comment` text COLLATE utf8mb3_unicode_ci NOT NULL DEFAULT '',
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `categories`
--
INSERT INTO `categories` (`id`, `name`, `parent_id`, `disable_footprints`, `disable_manufacturers`, `disable_autodatasheets`, `disable_properties`, `partname_regex`, `partname_hint`, `default_description`, `default_comment`, `comment`, `datetime_added`, `last_modified`) VALUES
(1, 'Test', NULL, 0, 0, 0, 0, '', '', '', '', '', '2023-01-07 18:32:29', '2023-01-07 18:32:29');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `devices`
--
CREATE TABLE `devices` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`order_quantity` int(11) NOT NULL DEFAULT 0,
`order_only_missing_parts` tinyint(1) NOT NULL DEFAULT 0,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `device_parts`
--
CREATE TABLE `device_parts` (
`id` int(11) NOT NULL,
`id_part` int(11) NOT NULL DEFAULT 0,
`id_device` int(11) NOT NULL DEFAULT 0,
`quantity` int(11) NOT NULL DEFAULT 0,
`mountnames` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `footprints`
--
CREATE TABLE `footprints` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`filename` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`filename_3d` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `groups`
--
CREATE TABLE `groups` (
`id` int(11) NOT NULL,
`name` varchar(32) NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`comment` mediumtext DEFAULT NULL,
`perms_system` int(11) NOT NULL,
`perms_groups` int(11) NOT NULL,
`perms_users` int(11) NOT NULL,
`perms_self` int(11) NOT NULL,
`perms_system_config` int(11) NOT NULL,
`perms_system_database` int(11) NOT NULL,
`perms_parts` bigint(11) NOT NULL,
`perms_parts_name` smallint(6) NOT NULL,
`perms_parts_description` smallint(6) NOT NULL,
`perms_parts_instock` smallint(6) NOT NULL,
`perms_parts_mininstock` smallint(6) NOT NULL,
`perms_parts_footprint` smallint(6) NOT NULL,
`perms_parts_storelocation` smallint(6) NOT NULL,
`perms_parts_manufacturer` smallint(6) NOT NULL,
`perms_parts_comment` smallint(6) NOT NULL,
`perms_parts_order` smallint(6) NOT NULL,
`perms_parts_orderdetails` smallint(6) NOT NULL,
`perms_parts_prices` smallint(6) NOT NULL,
`perms_parts_attachements` smallint(6) NOT NULL,
`perms_devices` int(11) NOT NULL,
`perms_devices_parts` int(11) NOT NULL,
`perms_storelocations` int(11) NOT NULL,
`perms_footprints` int(11) NOT NULL,
`perms_categories` int(11) NOT NULL,
`perms_suppliers` int(11) NOT NULL,
`perms_manufacturers` int(11) NOT NULL,
`perms_attachement_types` int(11) NOT NULL,
`perms_tools` int(11) NOT NULL,
`perms_labels` smallint(6) NOT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Daten für Tabelle `groups`
--
INSERT INTO `groups` (`id`, `name`, `parent_id`, `comment`, `perms_system`, `perms_groups`, `perms_users`, `perms_self`, `perms_system_config`, `perms_system_database`, `perms_parts`, `perms_parts_name`, `perms_parts_description`, `perms_parts_instock`, `perms_parts_mininstock`, `perms_parts_footprint`, `perms_parts_storelocation`, `perms_parts_manufacturer`, `perms_parts_comment`, `perms_parts_order`, `perms_parts_orderdetails`, `perms_parts_prices`, `perms_parts_attachements`, `perms_devices`, `perms_devices_parts`, `perms_storelocations`, `perms_footprints`, `perms_categories`, `perms_suppliers`, `perms_manufacturers`, `perms_attachement_types`, `perms_tools`, `perms_labels`, `datetime_added`, `last_modified`) VALUES
(1, 'admins', NULL, 'Users of this group can do everything: Read, Write and Administrative actions.', 21, 1365, 87381, 85, 85, 21, 1431655765, 5, 5, 5, 5, 5, 5, 5, 5, 5, 325, 325, 325, 5461, 325, 5461, 5461, 5461, 5461, 5461, 1365, 1365, 85, '2023-01-07 18:31:48', '0000-00-00 00:00:00'),
(2, 'readonly', NULL, 'Users of this group can only read informations, use tools, and don\'t have access to administrative tools.', 42, 2730, 174762, 154, 170, 42, -1516939607, 9, 9, 9, 9, 9, 9, 9, 9, 9, 649, 649, 649, 1705, 649, 1705, 1705, 1705, 1705, 1705, 681, 1366, 165, '2023-01-07 18:31:48', '0000-00-00 00:00:00'),
(3, 'users', NULL, 'Users of this group, can edit part informations, create new ones, etc. but are not allowed to use administrative tools. (But can read current configuration, and see Server status)', 42, 2730, 109226, 89, 105, 41, 1431655765, 5, 5, 5, 5, 5, 5, 5, 5, 5, 325, 325, 325, 5461, 325, 5461, 5461, 5461, 5461, 5461, 1365, 1365, 85, '2023-01-07 18:31:48', '0000-00-00 00:00:00');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `internal`
--
CREATE TABLE `internal` (
`keyName` char(30) CHARACTER SET ascii NOT NULL,
`keyValue` varchar(255) COLLATE utf8mb3_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `internal`
--
INSERT INTO `internal` (`keyName`, `keyValue`) VALUES
('dbVersion', '26');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `log`
--
CREATE TABLE `log` (
`id` int(11) NOT NULL,
`datetime` timestamp NOT NULL DEFAULT current_timestamp(),
`id_user` int(11) NOT NULL,
`level` tinyint(4) NOT NULL,
`type` smallint(6) NOT NULL,
`target_id` int(11) NOT NULL,
`target_type` smallint(6) NOT NULL,
`extra` mediumtext NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Daten für Tabelle `log`
--
INSERT INTO `log` (`id`, `datetime`, `id_user`, `level`, `type`, `target_id`, `target_type`, `extra`) VALUES
(1, '2023-01-07 18:31:48', 1, 4, 10, 0, 0, '{\"o\":0,\"n\":26,\"s\":true}'),
(2, '2023-01-07 18:32:13', 2, 6, 1, 2, 1, '{\"i\":\"::\"}'),
(3, '2023-01-07 18:32:29', 2, 6, 6, 1, 4, '[]'),
(4, '2023-01-07 18:32:53', 2, 6, 6, 1, 12, '[]'),
(5, '2023-01-07 18:33:26', 2, 6, 6, 1, 10, '{\"i\":0}');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `manufacturers`
--
CREATE TABLE `manufacturers` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`address` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`phone_number` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`fax_number` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`email_address` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`website` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`auto_product_url` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `orderdetails`
--
CREATE TABLE `orderdetails` (
`id` int(11) NOT NULL,
`part_id` int(11) NOT NULL,
`id_supplier` int(11) NOT NULL DEFAULT 0,
`supplierpartnr` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`obsolete` tinyint(1) DEFAULT 0,
`supplier_product_url` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `orderdetails`
--
INSERT INTO `orderdetails` (`id`, `part_id`, `id_supplier`, `supplierpartnr`, `obsolete`, `supplier_product_url`, `datetime_added`) VALUES
(1, 1, 1, 'BC547', 0, '', '2023-01-07 18:45:59'),
(2, 1, 1, 'Test', 0, '', '2023-01-07 18:46:09');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `parts`
--
CREATE TABLE `parts` (
`id` int(11) NOT NULL,
`id_category` int(11) NOT NULL DEFAULT 0,
`name` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`description` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`instock` int(11) NOT NULL DEFAULT 0,
`mininstock` int(11) NOT NULL DEFAULT 0,
`comment` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`visible` tinyint(1) NOT NULL,
`id_footprint` int(11) DEFAULT NULL,
`id_storelocation` int(11) DEFAULT NULL,
`order_orderdetails_id` int(11) DEFAULT NULL,
`order_quantity` int(11) NOT NULL DEFAULT 1,
`manual_order` tinyint(1) NOT NULL DEFAULT 0,
`id_manufacturer` int(11) DEFAULT NULL,
`id_master_picture_attachement` int(11) DEFAULT NULL,
`manufacturer_product_url` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
`favorite` tinyint(1) NOT NULL DEFAULT 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `parts`
--
INSERT INTO `parts` (`id`, `id_category`, `name`, `description`, `instock`, `mininstock`, `comment`, `visible`, `id_footprint`, `id_storelocation`, `order_orderdetails_id`, `order_quantity`, `manual_order`, `id_manufacturer`, `id_master_picture_attachement`, `manufacturer_product_url`, `datetime_added`, `last_modified`, `favorite`) VALUES
(1, 1, 'BC547', '', 0, 0, '', 0, NULL, NULL, NULL, 1, 0, NULL, NULL, '', '2023-01-07 18:33:26', '2023-01-07 18:33:26', 0);
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `pricedetails`
--
CREATE TABLE `pricedetails` (
`id` int(11) NOT NULL,
`orderdetails_id` int(11) NOT NULL,
`price` decimal(11,5) DEFAULT NULL,
`price_related_quantity` int(11) NOT NULL DEFAULT 1,
`min_discount_quantity` int(11) NOT NULL DEFAULT 1,
`manual_input` tinyint(1) NOT NULL DEFAULT 1,
`last_modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `pricedetails`
--
INSERT INTO `pricedetails` (`id`, `orderdetails_id`, `price`, `price_related_quantity`, `min_discount_quantity`, `manual_input`, `last_modified`) VALUES
(1, 2, '3.55000', 1, 1, 1, '2023-01-07 18:46:19');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `storelocations`
--
CREATE TABLE `storelocations` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`is_full` tinyint(1) NOT NULL DEFAULT 0,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `suppliers`
--
CREATE TABLE `suppliers` (
`id` int(11) NOT NULL,
`name` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`address` mediumtext COLLATE utf8mb3_unicode_ci NOT NULL,
`phone_number` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`fax_number` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`email_address` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`website` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`auto_product_url` tinytext COLLATE utf8mb3_unicode_ci NOT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`comment` text COLLATE utf8mb3_unicode_ci DEFAULT NULL,
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
--
-- Daten für Tabelle `suppliers`
--
INSERT INTO `suppliers` (`id`, `name`, `parent_id`, `address`, `phone_number`, `fax_number`, `email_address`, `website`, `auto_product_url`, `datetime_added`, `comment`, `last_modified`) VALUES
(1, 'Reichelt', NULL, '', '', '', '', '', '', '2023-01-07 18:32:53', '', '2023-01-07 18:32:53');
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `users`
--
CREATE TABLE `users` (
`id` int(11) NOT NULL,
`name` varchar(32) NOT NULL,
`password` varchar(255) DEFAULT NULL,
`first_name` tinytext DEFAULT NULL,
`last_name` tinytext DEFAULT NULL,
`department` tinytext DEFAULT NULL,
`email` tinytext DEFAULT NULL,
`need_pw_change` tinyint(1) NOT NULL DEFAULT 0,
`group_id` int(11) DEFAULT NULL,
`config_language` tinytext DEFAULT NULL,
`config_timezone` tinytext DEFAULT NULL,
`config_theme` tinytext DEFAULT NULL,
`config_currency` tinytext DEFAULT NULL,
`config_image_path` text NOT NULL,
`config_instock_comment_w` text NOT NULL,
`config_instock_comment_a` text NOT NULL,
`perms_system` int(11) NOT NULL,
`perms_groups` int(11) NOT NULL,
`perms_users` int(11) NOT NULL,
`perms_self` int(11) NOT NULL,
`perms_system_config` int(11) NOT NULL,
`perms_system_database` int(11) NOT NULL,
`perms_parts` bigint(11) NOT NULL,
`perms_parts_name` smallint(6) NOT NULL,
`perms_parts_description` smallint(6) NOT NULL,
`perms_parts_instock` smallint(6) NOT NULL,
`perms_parts_mininstock` smallint(6) NOT NULL,
`perms_parts_footprint` smallint(6) NOT NULL,
`perms_parts_storelocation` smallint(6) NOT NULL,
`perms_parts_manufacturer` smallint(6) NOT NULL,
`perms_parts_comment` smallint(6) NOT NULL,
`perms_parts_order` smallint(6) NOT NULL,
`perms_parts_orderdetails` smallint(6) NOT NULL,
`perms_parts_prices` smallint(6) NOT NULL,
`perms_parts_attachements` smallint(6) NOT NULL,
`perms_devices` int(11) NOT NULL,
`perms_devices_parts` int(11) NOT NULL,
`perms_storelocations` int(11) NOT NULL,
`perms_footprints` int(11) NOT NULL,
`perms_categories` int(11) NOT NULL,
`perms_suppliers` int(11) NOT NULL,
`perms_manufacturers` int(11) NOT NULL,
`perms_attachement_types` int(11) NOT NULL,
`perms_tools` int(11) NOT NULL,
`perms_labels` smallint(6) NOT NULL,
`datetime_added` timestamp NOT NULL DEFAULT current_timestamp(),
`last_modified` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
--
-- Daten für Tabelle `users`
--
INSERT INTO `users` (`id`, `name`, `password`, `first_name`, `last_name`, `department`, `email`, `need_pw_change`, `group_id`, `config_language`, `config_timezone`, `config_theme`, `config_currency`, `config_image_path`, `config_instock_comment_w`, `config_instock_comment_a`, `perms_system`, `perms_groups`, `perms_users`, `perms_self`, `perms_system_config`, `perms_system_database`, `perms_parts`, `perms_parts_name`, `perms_parts_description`, `perms_parts_instock`, `perms_parts_mininstock`, `perms_parts_footprint`, `perms_parts_storelocation`, `perms_parts_manufacturer`, `perms_parts_comment`, `perms_parts_order`, `perms_parts_orderdetails`, `perms_parts_prices`, `perms_parts_attachements`, `perms_devices`, `perms_devices_parts`, `perms_storelocations`, `perms_footprints`, `perms_categories`, `perms_suppliers`, `perms_manufacturers`, `perms_attachement_types`, `perms_tools`, `perms_labels`, `datetime_added`, `last_modified`) VALUES
(1, 'anonymous', '', '', '', '', '', 0, 2, NULL, NULL, NULL, NULL, '', '', '', 21844, 20480, 0, 0, 0, 0, 0, 21840, 21840, 21840, 21840, 21840, 21840, 21840, 21840, 21840, 21520, 21520, 21520, 20480, 21520, 20480, 20480, 20480, 20480, 20480, 21504, 20480, 0, '2023-01-07 18:31:48', '0000-00-00 00:00:00'),
(2, 'admin', '$2a$12$j0RKrKlx60bzX1DWMyXwjeaW.pe3bFjAK8ByIGnvjrRnET2JtsFoe$2a$12$j0RKrKlx60bzX1DWMyXwjeaW.pe3bFjAK8ByIGnvjrRnET2JtsFoe', '', '', '', '', 1, 1, NULL, NULL, NULL, NULL, '', '', '', 21845, 21845, 21845, 21, 85, 21, 349525, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 21845, 0, '2023-01-07 18:31:48', '0000-00-00 00:00:00');
--
-- Indizes der exportierten Tabellen
--
--
-- Indizes für die Tabelle `attachements`
--
ALTER TABLE `attachements`
ADD PRIMARY KEY (`id`),
ADD KEY `attachements_class_name_k` (`class_name`),
ADD KEY `attachements_element_id_k` (`element_id`),
ADD KEY `attachements_type_id_fk` (`type_id`);
--
-- Indizes für die Tabelle `attachement_types`
--
ALTER TABLE `attachement_types`
ADD PRIMARY KEY (`id`),
ADD KEY `attachement_types_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `categories`
--
ALTER TABLE `categories`
ADD PRIMARY KEY (`id`),
ADD KEY `categories_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `devices`
--
ALTER TABLE `devices`
ADD PRIMARY KEY (`id`),
ADD KEY `devices_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `device_parts`
--
ALTER TABLE `device_parts`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `device_parts_combination_uk` (`id_part`,`id_device`),
ADD KEY `device_parts_id_part_k` (`id_part`),
ADD KEY `device_parts_id_device_k` (`id_device`);
--
-- Indizes für die Tabelle `footprints`
--
ALTER TABLE `footprints`
ADD PRIMARY KEY (`id`),
ADD KEY `footprints_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `groups`
--
ALTER TABLE `groups`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `name` (`name`);
--
-- Indizes für die Tabelle `internal`
--
ALTER TABLE `internal`
ADD UNIQUE KEY `keyName` (`keyName`);
--
-- Indizes für die Tabelle `log`
--
ALTER TABLE `log`
ADD PRIMARY KEY (`id`),
ADD KEY `id_user` (`id_user`);
--
-- Indizes für die Tabelle `manufacturers`
--
ALTER TABLE `manufacturers`
ADD PRIMARY KEY (`id`),
ADD KEY `manufacturers_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `orderdetails`
--
ALTER TABLE `orderdetails`
ADD PRIMARY KEY (`id`),
ADD KEY `orderdetails_part_id_k` (`part_id`),
ADD KEY `orderdetails_id_supplier_k` (`id_supplier`);
--
-- Indizes für die Tabelle `parts`
--
ALTER TABLE `parts`
ADD PRIMARY KEY (`id`),
ADD KEY `parts_id_category_k` (`id_category`),
ADD KEY `parts_id_footprint_k` (`id_footprint`),
ADD KEY `parts_id_storelocation_k` (`id_storelocation`),
ADD KEY `parts_order_orderdetails_id_k` (`order_orderdetails_id`),
ADD KEY `parts_id_manufacturer_k` (`id_manufacturer`),
ADD KEY `favorite` (`favorite`);
--
-- Indizes für die Tabelle `pricedetails`
--
ALTER TABLE `pricedetails`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `pricedetails_combination_uk` (`orderdetails_id`,`min_discount_quantity`),
ADD KEY `pricedetails_orderdetails_id_k` (`orderdetails_id`);
--
-- Indizes für die Tabelle `storelocations`
--
ALTER TABLE `storelocations`
ADD PRIMARY KEY (`id`),
ADD KEY `storelocations_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `suppliers`
--
ALTER TABLE `suppliers`
ADD PRIMARY KEY (`id`),
ADD KEY `suppliers_parent_id_k` (`parent_id`);
--
-- Indizes für die Tabelle `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `name` (`name`);
--
-- AUTO_INCREMENT für exportierte Tabellen
--
--
-- AUTO_INCREMENT für Tabelle `attachements`
--
ALTER TABLE `attachements`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT für Tabelle `attachement_types`
--
ALTER TABLE `attachement_types`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT für Tabelle `categories`
--
ALTER TABLE `categories`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT für Tabelle `devices`
--
ALTER TABLE `devices`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT für Tabelle `device_parts`
--
ALTER TABLE `device_parts`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT für Tabelle `footprints`
--
ALTER TABLE `footprints`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT für Tabelle `groups`
--
ALTER TABLE `groups`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT für Tabelle `log`
--
ALTER TABLE `log`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
--
-- AUTO_INCREMENT für Tabelle `manufacturers`
--
ALTER TABLE `manufacturers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT für Tabelle `orderdetails`
--
ALTER TABLE `orderdetails`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- AUTO_INCREMENT für Tabelle `parts`
--
ALTER TABLE `parts`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT für Tabelle `pricedetails`
--
ALTER TABLE `pricedetails`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT für Tabelle `storelocations`
--
ALTER TABLE `storelocations`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
--
-- AUTO_INCREMENT für Tabelle `suppliers`
--
ALTER TABLE `suppliers`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
--
-- AUTO_INCREMENT für Tabelle `users`
--
ALTER TABLE `users`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
--
-- Constraints der exportierten Tabellen
--
--
-- Constraints der Tabelle `attachements`
--
ALTER TABLE `attachements`
ADD CONSTRAINT `attachements_type_id_fk` FOREIGN KEY (`type_id`) REFERENCES `attachement_types` (`id`);
--
-- Constraints der Tabelle `attachement_types`
--
ALTER TABLE `attachement_types`
ADD CONSTRAINT `attachement_types_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `attachement_types` (`id`);
--
-- Constraints der Tabelle `categories`
--
ALTER TABLE `categories`
ADD CONSTRAINT `categories_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `categories` (`id`);
--
-- Constraints der Tabelle `devices`
--
ALTER TABLE `devices`
ADD CONSTRAINT `devices_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `devices` (`id`);
--
-- Constraints der Tabelle `footprints`
--
ALTER TABLE `footprints`
ADD CONSTRAINT `footprints_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `footprints` (`id`);
--
-- Constraints der Tabelle `manufacturers`
--
ALTER TABLE `manufacturers`
ADD CONSTRAINT `manufacturers_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `manufacturers` (`id`);
--
-- Constraints der Tabelle `parts`
--
ALTER TABLE `parts`
ADD CONSTRAINT `parts_id_footprint_fk` FOREIGN KEY (`id_footprint`) REFERENCES `footprints` (`id`),
ADD CONSTRAINT `parts_id_manufacturer_fk` FOREIGN KEY (`id_manufacturer`) REFERENCES `manufacturers` (`id`),
ADD CONSTRAINT `parts_id_storelocation_fk` FOREIGN KEY (`id_storelocation`) REFERENCES `storelocations` (`id`),
ADD CONSTRAINT `parts_order_orderdetails_id_fk` FOREIGN KEY (`order_orderdetails_id`) REFERENCES `orderdetails` (`id`);
--
-- Constraints der Tabelle `storelocations`
--
ALTER TABLE `storelocations`
ADD CONSTRAINT `storelocations_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `storelocations` (`id`);
--
-- Constraints der Tabelle `suppliers`
--
ALTER TABLE `suppliers`
ADD CONSTRAINT `suppliers_parent_id_fk` FOREIGN KEY (`parent_id`) REFERENCES `suppliers` (`id`);
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

View file

@ -1,54 +0,0 @@
#
# This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
#
# Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#!/bin/bash
# This script is used to test the legacy import of Part-DB
SQL_FILES_TO_TEST=("db_minimal.sql" "db_jbtronics.sql")
DB_NAME="legacy_db_test"
DB_USER="root"
DB_PASSWORD="root"
# Iterate over all given SQL files and import them into the mysql database with the given name, drop the database if it already exists before
for SQL_FILE in "${SQL_FILES_TO_TEST[@]}"
do
echo "Testing for $SQL_FILE"
mysql -u $DB_USER --password=$DB_PASSWORD -e "DROP DATABASE IF EXISTS $DB_NAME; CREATE DATABASE $DB_NAME;"
# If the last command failed, exit the script
if [ $? -ne 0 ]; then
echo "Failed to create database $DB_NAME"
exit 1
fi
# Import the SQL file into the database. The file pathes are relative to the current script location
mysql -u $DB_USER --password=$DB_PASSWORD $DB_NAME < .github/assets/legacy_import/$SQL_FILE
# If the last command failed, exit the script
if [ $? -ne 0 ]; then
echo "Failed to import $SQL_FILE into database $DB_NAME"
exit 1
fi
# Run doctrine migrations, this will migrate the database to the current version. This process should not fail
php bin/console doctrine:migrations:migrate -n
# If the last command failed, exit the script
if [ $? -ne 0 ]; then
echo "Failed to migrate database $DB_NAME"
exit 1
fi
done

View file

@ -1,11 +0,0 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

View file

@ -19,22 +19,14 @@ jobs:
APP_ENV: prod APP_ENV: prod
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: none
ini-values: xdebug.max_nesting_level=1000
extensions: mbstring, intl, gd, xsl, gmp, bcmath, :php-psr
- name: Get Composer Cache Directory - name: Get Composer Cache Directory
id: composer-cache id: composer-cache
run: | run: |
echo "::set-output name=dir::$(composer config cache-files-dir)" echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v4 - uses: actions/cache@v3
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -48,7 +40,7 @@ jobs:
id: yarn-cache-dir-path id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)" run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v4 - uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with: with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@ -57,7 +49,7 @@ jobs:
${{ runner.os }}-yarn- ${{ runner.os }}-yarn-
- name: Setup node - name: Setup node
uses: actions/setup-node@v4 uses: actions/setup-node@v3
with: with:
node-version: '18' node-version: '18'
@ -77,13 +69,13 @@ jobs:
run: zip -r /tmp/partdb_assets.zip public/build/ vendor/ run: zip -r /tmp/partdb_assets.zip public/build/ vendor/
- name: Upload assets artifact - name: Upload assets artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v3
with: with:
name: Only dependencies and built assets name: Only dependencies and built assets
path: /tmp/partdb_assets.zip path: /tmp/partdb_assets.zip
- name: Upload full artifact - name: Upload full artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v3
with: with:
name: Full Part-DB including dependencies and built assets name: Full Part-DB including dependencies and built assets
path: /tmp/partdb_with_assets.zip path: /tmp/partdb_with_assets.zip

54
.github/workflows/codeql-analysis.yml vendored Normal file
View file

@ -0,0 +1,54 @@
name: "CodeQL"
on:
push:
branches: [master, ]
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
schedule:
- cron: '0 14 * * 3'
jobs:
analyse:
name: Analyse
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2
# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

View file

@ -10,6 +10,9 @@ on:
tags: tags:
- 'v*.*.*' - 'v*.*.*'
- 'v*.*.*-**' - 'v*.*.*-**'
pull_request:
branches:
- 'master'
jobs: jobs:
docker: docker:
@ -17,11 +20,11 @@ jobs:
steps: steps:
- -
name: Checkout name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- -
name: Docker meta name: Docker meta
id: docker_meta id: docker_meta
uses: docker/metadata-action@v5 uses: docker/metadata-action@v4
with: with:
# list of Docker images to use as base name for tags # list of Docker images to use as base name for tags
images: | images: |
@ -49,23 +52,23 @@ jobs:
- -
name: Set up QEMU name: Set up QEMU
uses: docker/setup-qemu-action@v3 uses: docker/setup-qemu-action@v2
with: with:
platforms: 'arm64,arm' platforms: 'arm64,arm'
- -
name: Set up Docker Buildx name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v2
- -
name: Login to DockerHub name: Login to DockerHub
if: github.event_name != 'pull_request' if: github.event_name != 'pull_request'
uses: docker/login-action@v3 uses: docker/login-action@v2
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- -
name: Build and push name: Build and push
uses: docker/build-push-action@v6 uses: docker/build-push-action@v4
with: with:
context: . context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7 platforms: linux/amd64,linux/arm64,linux/arm/v7

View file

@ -1,77 +0,0 @@
name: Docker Image Build (FrankenPHP)
on:
#schedule:
# - cron: '0 10 * * *' # everyday at 10am
push:
branches:
- '**'
- '!l10n_**'
tags:
- 'v*.*.*'
- 'v*.*.*-**'
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
partdborg/part-db
# Mark the image build from master as latest (as we dont have really releases yet)
tags: |
type=edge,branch=master
type=ref,event=branch,
type=ref,event=tag,
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=pr
labels: |
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.title=Part-DB
org.opencontainers.image.description=Part-DB is a web application for managing electronic components and your inventory.
org.opencontainers.image.url=https://github.com/Part-DB/Part-DB-server
org.opencontainers.image.source=https://github.com/Part-DB/Part-DB-server
org.opencontainers.image.authors=Jan Böhmer
org.opencontainers.licenses=AGPL-3.0-or-later
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: 'arm64,arm'
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile-frankenphp
platforms: linux/amd64,linux/arm64,linux/arm/v7
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

View file

@ -16,22 +16,14 @@ jobs:
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v3
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
coverage: none
ini-values: xdebug.max_nesting_level=1000
extensions: mbstring, intl, gd, xsl, gmp, bcmath, :php-psr
- name: Get Composer Cache Directory - name: Get Composer Cache Directory
id: composer-cache id: composer-cache
run: | run: |
echo "::set-output name=dir::$(composer config cache-files-dir)" echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v4 - uses: actions/cache@v3
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -47,19 +39,17 @@ jobs:
- name: Lint twig templates - name: Lint twig templates
run: ./bin/console lint:twig templates --env=prod run: ./bin/console lint:twig templates --env=prod
# This causes problems with emtpy language files - name: Lint translations
#- name: Lint translations run: ./bin/console lint:xliff translations
# run: ./bin/console lint:xliff translations
- name: Check dependencies for security - name: Check dependencies for security
uses: symfonycorp/security-checker-action@v5 uses: symfonycorp/security-checker-action@v3
- name: Check doctrine mapping - name: Check doctrine mapping
run: ./bin/console doctrine:schema:validate --skip-sync -vvv --no-interaction run: ./bin/console doctrine:schema:validate --skip-sync -vvv --no-interaction
# Use the -d option to raise the max nesting level
- name: Generate dev container - name: Generate dev container
run: php -d xdebug.max_nesting_level=1000 ./bin/console cache:clear --env dev run: ./bin/console cache:clear --env dev
- name: Run PHPstan - name: Run PHPstan
run: composer phpstan run: composer phpstan

View file

@ -13,13 +13,13 @@ on:
jobs: jobs:
phpunit: phpunit:
name: PHPUnit and coverage Test (PHP ${{ matrix.php-versions }}, ${{ matrix.db-type }}) name: PHPUnit and coverage Test (PHP ${{ matrix.php-versions }}, ${{ matrix.db-type }})
# Ubuntu 20.04 ships MySQL 8.0 which causes problems with login, so we just use ubuntu 18.04 for now...
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
strategy: strategy:
fail-fast: false
matrix: matrix:
php-versions: [ '8.1', '8.2', '8.3', '8.4' ] php-versions: [ '7.4', '8.0', '8.1', '8.2' ]
db-type: [ 'mysql', 'sqlite', 'postgres' ] db-type: [ 'mysql', 'sqlite' ]
env: env:
# Note that we set DATABASE URL later based on our db-type matrix value # Note that we set DATABASE URL later based on our db-type matrix value
@ -27,45 +27,30 @@ jobs:
SYMFONY_DEPRECATIONS_HELPER: disabled SYMFONY_DEPRECATIONS_HELPER: disabled
PHP_VERSION: ${{ matrix.php-versions }} PHP_VERSION: ${{ matrix.php-versions }}
DB_TYPE: ${{ matrix.db-type }} DB_TYPE: ${{ matrix.db-type }}
CHECK_FOR_UPDATES: false # Disable update checks for tests
steps: steps:
- name: Set Database env for MySQL - name: Set Database env for MySQL
run: echo "DATABASE_URL=mysql://root:root@127.0.0.1:3306/partdb?serverVersion=8.0.35" >> $GITHUB_ENV run: echo "DATABASE_URL=mysql://root:root@127.0.0.1:3306/test" >> $GITHUB_ENV
if: matrix.db-type == 'mysql' if: matrix.db-type == 'mysql'
- name: Set Database env for SQLite - name: Set Database env for SQLite
run: echo "DATABASE_URL="sqlite:///%kernel.project_dir%/var/app_test.db"" >> $GITHUB_ENV run: echo "DATABASE_URL="sqlite:///%kernel.project_dir%/var/app_test.db"" >> $GITHUB_ENV
if: matrix.db-type == 'sqlite' if: matrix.db-type == 'sqlite'
- name: Set Database env for PostgreSQL
run: echo "DATABASE_URL=postgresql://postgres:postgres @127.0.0.1:5432/partdb?serverVersion=14&charset=utf8" >> $GITHUB_ENV
if: matrix.db-type == 'postgres'
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: Setup PHP - name: Setup PHP
uses: shivammathur/setup-php@v2 uses: shivammathur/setup-php@v2
with: with:
php-version: ${{ matrix.php-versions }} php-version: ${{ matrix.php-versions }}
coverage: pcov coverage: pcov
ini-values: xdebug.max_nesting_level=1000 extensions: mbstring, intl, gd, xsl, gmp, bcmath
extensions: mbstring, intl, gd, xsl, gmp, bcmath, :php-psr
- name: Start MySQL - name: Start MySQL
run: sudo systemctl start mysql.service run: sudo systemctl start mysql.service
if: matrix.db-type == 'mysql'
# Replace the scram-sha-256 with trust for host connections, to avoid password authentication #- name: Setup MySQL
- name: Start PostgreSQL
run: |
sudo sed -i 's/^\(host.*all.*all.*\)scram-sha-256/\1trust/' /etc/postgresql/14/main/pg_hba.conf
sudo systemctl start postgresql.service
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
if: matrix.db-type == 'postgres'
#- name: Setup MySQL
# uses: mirromutth/mysql-action@v1.1 # uses: mirromutth/mysql-action@v1.1
# with: # with:
# mysql version: 5.7 # mysql version: 5.7
@ -78,7 +63,7 @@ jobs:
id: composer-cache id: composer-cache
run: | run: |
echo "::set-output name=dir::$(composer config cache-files-dir)" echo "::set-output name=dir::$(composer config cache-files-dir)"
- uses: actions/cache@v4 - uses: actions/cache@v1
with: with:
path: ${{ steps.composer-cache.outputs.dir }} path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
@ -89,7 +74,7 @@ jobs:
id: yarn-cache-dir-path id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)" run: echo "::set-output name=dir::$(yarn cache dir)"
- uses: actions/cache@v4 - uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with: with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
@ -101,7 +86,7 @@ jobs:
run: composer install --prefer-dist --no-progress run: composer install --prefer-dist --no-progress
- name: Setup node - name: Setup node
uses: actions/setup-node@v4 uses: actions/setup-node@v3
with: with:
node-version: '18' node-version: '18'
@ -113,24 +98,26 @@ jobs:
- name: Create DB - name: Create DB
run: php bin/console --env test doctrine:database:create --if-not-exists -n run: php bin/console --env test doctrine:database:create --if-not-exists -n
if: matrix.db-type == 'mysql' || matrix.db-type == 'postgres' if: matrix.db-type == 'mysql'
# Checkinf for existance is not supported for sqlite, so do it without it
- name: Create DB
run: php bin/console --env test doctrine:database:create -n
if: matrix.db-type == 'sqlite'
- name: Do migrations - name: Do migrations
run: php bin/console --env test doctrine:migrations:migrate -n run: php bin/console --env test doctrine:migrations:migrate -n
# Use our own custom fixtures loading command to circumvent some problems with reset the autoincrement values
- name: Load fixtures - name: Load fixtures
run: php bin/console --env test partdb:fixtures:load -n run: php bin/console --env test doctrine:fixtures:load -n --purger reset_autoincrement_purger
- name: Run PHPunit and generate coverage - name: Run PHPunit and generate coverage
run: ./bin/phpunit --coverage-clover=coverage.xml run: ./bin/phpunit --coverage-clover=coverage.xml
- name: Upload coverage - name: Upload coverage
uses: codecov/codecov-action@v5 uses: codecov/codecov-action@v3
with: with:
env_vars: PHP_VERSION,DB_TYPE env_vars: PHP_VERSION,DB_TYPE
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
- name: Test app:clean-attachments - name: Test app:clean-attachments
run: php bin/console partdb:attachments:clean-unused -n run: php bin/console partdb:attachments:clean-unused -n
@ -144,11 +131,3 @@ jobs:
- name: Test check-requirements command - name: Test check-requirements command
run: php bin/console partdb:check-requirements -n run: php bin/console partdb:check-requirements -n
- name: Test partdb:backup command
run: php bin/console partdb:backup -n --full /tmp/test_backup.zip
- name: Test legacy Part-DB import
run: bash .github/assets/legacy_import/test_legacy_import.sh
if: matrix.db-type == 'mysql' && matrix.php-versions == '8.2'
env:
DATABASE_URL: mysql://root:root@localhost:3306/legacy_db

4
.gitignore vendored
View file

@ -43,7 +43,3 @@ yarn-error.log
/phpunit.xml /phpunit.xml
.phpunit.result.cache .phpunit.result.cache
###< phpunit/phpunit ### ###< phpunit/phpunit ###
###> phpstan/phpstan ###
phpstan.neon
###< phpstan/phpstan ###

View file

@ -1,64 +1,22 @@
ARG BASE_IMAGE=debian:bookworm-slim FROM debian:bullseye-slim
ARG PHP_VERSION=8.3
FROM ${BASE_IMAGE} AS base
ARG PHP_VERSION
# Install needed dependencies for PHP build # Install needed dependencies for PHP build
#RUN apt-get update && apt-get install -y pkg-config curl libcurl4-openssl-dev libicu-dev \ #RUN apt-get update && apt-get install -y pkg-config curl libcurl4-openssl-dev libicu-dev \
# libpng-dev libjpeg-dev libfreetype6-dev gnupg zip libzip-dev libjpeg62-turbo-dev libonig-dev libxslt-dev libwebp-dev vim \ # libpng-dev libjpeg-dev libfreetype6-dev gnupg zip libzip-dev libjpeg62-turbo-dev libonig-dev libxslt-dev libwebp-dev vim \
# && apt-get -y autoremove && apt-get clean autoclean && rm -rf /var/lib/apt/lists/* # && apt-get -y autoremove && apt-get clean autoclean && rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get -y install \ RUN apt-get update && apt-get -y install apt-transport-https lsb-release ca-certificates curl zip \
apt-transport-https \
lsb-release \
ca-certificates \
curl \
zip \
mariadb-client \
postgresql-client \
&& curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg \ && curl -sSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg \
&& sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' \ && sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' \
&& apt-get update && apt-get upgrade -y \ && apt-get update && apt-get upgrade -y \
&& apt-get install -y \ && apt-get install -y apache2 php8.1 libapache2-mod-php8.1 php8.1-opcache php8.1-curl php8.1-gd php8.1-mbstring php8.1-xml php8.1-bcmath php8.1-intl php8.1-zip php8.1-xsl php8.1-sqlite3 php8.1-mysql gpg \
apache2 \ && apt-get -y autoremove && apt-get clean autoclean && rm -rf /var/lib/apt/lists/*;
php${PHP_VERSION} \
php${PHP_VERSION}-fpm \ ENV APACHE_CONFDIR /etc/apache2
php${PHP_VERSION}-opcache \ ENV APACHE_ENVVARS $APACHE_CONFDIR/envvars
php${PHP_VERSION}-curl \
php${PHP_VERSION}-gd \
php${PHP_VERSION}-mbstring \
php${PHP_VERSION}-xml \
php${PHP_VERSION}-bcmath \
php${PHP_VERSION}-intl \
php${PHP_VERSION}-zip \
php${PHP_VERSION}-xsl \
php${PHP_VERSION}-sqlite3 \
php${PHP_VERSION}-mysql \
php${PHP_VERSION}-pgsql \
gpg \
sudo \
&& apt-get -y autoremove && apt-get clean autoclean && rm -rf /var/lib/apt/lists/* \
# Create workdir and set permissions if directory does not exists # Create workdir and set permissions if directory does not exists
&& mkdir -p /var/www/html \ RUN mkdir -p /var/www/html && chown -R www-data:www-data /var/www/html
&& chown -R www-data:www-data /var/www/html \
# delete the "index.html" that installing Apache drops in here
&& rm -rvf /var/www/html/*
# Install node and yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
curl -sL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get update && apt-get install -y \
nodejs \
yarn \
&& apt-get -y autoremove && apt-get clean autoclean && rm -rf /var/lib/apt/lists/*
# Install composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
ENV APACHE_CONFDIR=/etc/apache2
ENV APACHE_ENVVARS=$APACHE_CONFDIR/envvars
# Configure apache 2 (taken from https://github.com/docker-library/php/blob/master/8.2/bullseye/apache/Dockerfile) # Configure apache 2 (taken from https://github.com/docker-library/php/blob/master/8.2/bullseye/apache/Dockerfile)
# generically convert lines like # generically convert lines like
@ -69,6 +27,8 @@ ENV APACHE_ENVVARS=$APACHE_CONFDIR/envvars
# so that they can be overridden at runtime ("-e APACHE_RUN_USER=...") # so that they can be overridden at runtime ("-e APACHE_RUN_USER=...")
RUN sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS"; \ RUN sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS"; \
set -eux; . "$APACHE_ENVVARS"; \ set -eux; . "$APACHE_ENVVARS"; \
# delete the "index.html" that installing Apache drops in here
rm -rvf /var/www/html/*; \
\ \
# logs should go to stdout / stderr # logs should go to stdout / stderr
ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \ ln -sfT /dev/stderr "$APACHE_LOG_DIR/error.log"; \
@ -76,87 +36,66 @@ RUN sed -ri 's/^export ([^=]+)=(.*)$/: ${\1:=\2}\nexport \1/' "$APACHE_ENVVARS"
ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log"; \ ln -sfT /dev/stdout "$APACHE_LOG_DIR/other_vhosts_access.log"; \
chown -R --no-dereference "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$APACHE_LOG_DIR"; chown -R --no-dereference "$APACHE_RUN_USER:$APACHE_RUN_GROUP" "$APACHE_LOG_DIR";
# --- # Enable mpm_prefork
RUN a2dismod mpm_event && a2enmod mpm_prefork
FROM scratch AS apache-config
ARG PHP_VERSION
# Configure php-fpm to log to stdout of the container (stdout of PID 1)
# We have to use /proc/1/fd/1 because /dev/stdout or /proc/self/fd/1 does not point to the container stdout (because we use apache as entrypoint)
# We also disable the clear_env option to allow the use of environment variables in php-fpm
COPY <<EOF /etc/php/${PHP_VERSION}/fpm/pool.d/zz-docker.conf
[global]
error_log = /proc/1/fd/1
[www]
access.log = /proc/1/fd/1
catch_workers_output = yes
decorate_workers_output = no
clear_env = no
EOF
# PHP files should be handled by PHP, and should be preferred over any other file type # PHP files should be handled by PHP, and should be preferred over any other file type
COPY <<EOF /etc/apache2/conf-available/docker-php.conf RUN { \
<FilesMatch \\.php$> echo '<FilesMatch \.php$>'; \
SetHandler application/x-httpd-php echo '\tSetHandler application/x-httpd-php'; \
</FilesMatch> echo '</FilesMatch>'; \
echo; \
DirectoryIndex disabled echo 'DirectoryIndex disabled'; \
DirectoryIndex index.php index.html echo 'DirectoryIndex index.php index.html'; \
echo; \
<Directory /var/www/> echo '<Directory /var/www/>'; \
Options -Indexes echo '\tOptions -Indexes'; \
AllowOverride All echo '\tAllowOverride All'; \
</Directory> echo '</Directory>'; \
EOF } | tee "$APACHE_CONFDIR/conf-available/docker-php.conf" \
&& a2enconf docker-php
# Enable opcache and configure it recommended for symfony (see https://symfony.com/doc/current/performance.html) # Enable opcache and configure it recommended for symfony (see https://symfony.com/doc/current/performance.html)
COPY <<EOF /etc/php/${PHP_VERSION}/fpm/conf.d/symfony-recommended.ini RUN \
opcache.memory_consumption=256 { \
opcache.max_accelerated_files=20000 echo 'opcache.memory_consumption=256'; \
opcache.validate_timestamp=0 echo 'opcache.max_accelerated_files=20000'; \
# Configure Realpath cache for performance echo 'opcache.validate_timestamp=0'; \
realpath_cache_size=4096K # Configure Realpath cache for performance
realpath_cache_ttl=600 echo 'realpath_cache_size=4096K'; \
EOF echo 'realpath_cache_ttl=600'; \
} > /etc/php/8.1/apache2/conf.d/symfony-recommended.ini
# Increase upload limit and enable preloading # Increase upload limit
COPY <<EOF /etc/php/${PHP_VERSION}/fpm/conf.d/partdb.ini RUN \
upload_max_filesize=256M { \
post_max_size=300M echo 'upload_max_filesize=256M'; \
opcache.preload_user=www-data echo 'post_max_size=300M'; \
opcache.preload=/var/www/html/config/preload.php } > /etc/php/8.1/apache2/conf.d/partdb.ini
log_limit=8096
EOF
COPY ./.docker/symfony.conf /etc/apache2/sites-available/symfony.conf # Install node and yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN curl -sL https://deb.nodesource.com/setup_18.x | bash - && apt-get update && apt-get install -y nodejs yarn && apt-get -y autoremove && apt-get clean autoclean && rm -rf /var/lib/apt/lists/*
# --- # Install composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
FROM base
ARG PHP_VERSION
# Set working dir # Set working dir
WORKDIR /var/www/html WORKDIR /var/www/html
COPY --from=apache-config / /
COPY --chown=www-data:www-data . . COPY --chown=www-data:www-data . .
# Setup apache2 # Setup apache2
RUN a2dissite 000-default.conf && \ RUN a2dissite 000-default.conf
a2ensite symfony.conf && \ COPY ./.docker/symfony.conf /etc/apache2/sites-available/symfony.conf
# Enable php-fpm RUN a2ensite symfony.conf
a2enmod proxy_fcgi setenvif && \ RUN a2enmod rewrite
a2enconf php${PHP_VERSION}-fpm && \
a2enconf docker-php && \
a2enmod rewrite
# Install composer and yarn dependencies for Part-DB # Install composer and yarn dependencies for Part-DB
USER www-data USER www-data
RUN composer install -a --no-dev && \ RUN composer install -a --no-dev && composer clear-cache
composer clear-cache RUN yarn install --network-timeout 600000 && yarn build && yarn cache clean && rm -rf node_modules/
RUN yarn install --network-timeout 600000 && \
yarn build && \
yarn cache clean && \
rm -rf node_modules/
# Use docker env to output logs to stdout # Use docker env to output logs to stdout
ENV APP_ENV=docker ENV APP_ENV=docker
@ -164,12 +103,10 @@ ENV DATABASE_URL="sqlite:///%kernel.project_dir%/uploads/app.db"
USER root USER root
# Replace the php version placeholder in the entry point, with our php version # Copy entrypoint to /usr/local/bin and make it executable
RUN sed -i "s/PHP_VERSION/${PHP_VERSION}/g" ./.docker/partdb-entrypoint.sh RUN cp ./.docker/partdb-entrypoint.sh /usr/local/bin/partdb-entrypoint.sh && chmod +x /usr/local/bin/partdb-entrypoint.sh
# Copy apache2-foreground to /usr/local/bin and make it executable
# Copy entrypoint and apache2-foreground to /usr/local/bin and make it executable RUN cp ./.docker/apache2-foreground /usr/local/bin/apache2-foreground && chmod +x /usr/local/bin/apache2-foreground
RUN install ./.docker/partdb-entrypoint.sh /usr/local/bin && \
install ./.docker/apache2-foreground /usr/local/bin
ENTRYPOINT ["partdb-entrypoint.sh"] ENTRYPOINT ["partdb-entrypoint.sh"]
CMD ["apache2-foreground"] CMD ["apache2-foreground"]

View file

@ -1,101 +0,0 @@
FROM dunglas/frankenphp:1-php8.3 AS frankenphp_upstream
RUN apt-get update && apt-get -y install \
curl \
ca-certificates \
mariadb-client \
postgresql-client \
file \
acl \
git \
gettext \
gnupg \
zip \
&& apt-get -y autoremove && apt-get clean autoclean && rm -rf /var/lib/apt/lists/*;
# Install node and yarn
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
curl -sL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get update && apt-get install -y \
nodejs yarn \
&& apt-get -y autoremove && apt-get clean autoclean && rm -rf /var/lib/apt/lists/*
# Install PHP
RUN set -eux; \
install-php-extensions \
@composer \
apcu \
intl \
opcache \
zip \
pdo_mysql \
pdo_sqlite \
pdo_pgsql \
gd \
bcmath \
xsl \
;
# Copy config files for php and caddy
COPY --link .docker/frankenphp/conf.d/app.ini $PHP_INI_DIR/conf.d/
COPY --chmod=755 .docker/frankenphp/docker-entrypoint.sh /usr/local/bin/docker-entrypoint
COPY --link .docker/frankenphp/Caddyfile /etc/caddy/Caddyfile
COPY --link .docker/frankenphp/conf.d/app.prod.ini $PHP_INI_DIR/conf.d/
COPY --link .docker/frankenphp/worker.Caddyfile /etc/caddy/worker.Caddyfile
ENV FRANKENPHP_CONFIG="import worker.Caddyfile"
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# Install composer
ENV COMPOSER_ALLOW_SUPERUSER=1
#COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Create workdir and set permissions if directory does not exists
WORKDIR /app
# prevent the reinstallation of vendors at every changes in the source code
COPY --link composer.* symfony.* ./
RUN set -eux; \
composer install --no-cache --prefer-dist --no-dev --no-autoloader --no-scripts --no-progress
# copy sources
COPY --link . ./
# Install composer and yarn dependencies for Part-DB
RUN set -eux; \
mkdir -p var/cache var/log; \
composer dump-autoload --classmap-authoritative --no-dev; \
composer dump-env prod; \
composer run-script --no-dev post-install-cmd; \
chmod +x bin/console; sync;
RUN yarn install --network-timeout 600000 && \
yarn build && \
yarn cache clean && \
rm -rf node_modules/
# Use docker env to output logs to stdout
ENV APP_ENV=docker
ENV DATABASE_URL="sqlite:///%kernel.project_dir%/uploads/app.db"
USER root
ENTRYPOINT ["docker-entrypoint"]
CMD ["frankenphp", "run", "--config", "/etc/caddy/Caddyfile"]
# https://httpd.apache.org/docs/2.4/stopping.html#gracefulstop
STOPSIGNAL SIGWINCH
VOLUME ["/var/www/html/uploads", "/var/www/html/public/media"]
HEALTHCHECK --start-period=60s CMD curl -f http://localhost:2019/metrics || exit 1
# See https://caddyserver.com/docs/conventions#file-locations for details
ENV XDG_CONFIG_HOME /config
ENV XDG_DATA_HOME /data
EXPOSE 80
EXPOSE 443
EXPOSE 443/udp
EXPOSE 2019

144
README.md
View file

@ -1,164 +1,126 @@
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Part-DB/Part-DB-symfony/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Part-DB/Part-DB-symfony/?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Part-DB/Part-DB-symfony/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Part-DB/Part-DB-symfony/?branch=master)
![PHPUnit Tests](https://github.com/Part-DB/Part-DB-symfony/workflows/PHPUnit%20Tests/badge.svg) ![PHPUnit Tests](https://github.com/Part-DB/Part-DB-symfony/workflows/PHPUnit%20Tests/badge.svg)
![Static analysis](https://github.com/Part-DB/Part-DB-symfony/workflows/Static%20analysis/badge.svg) ![Static analysis](https://github.com/Part-DB/Part-DB-symfony/workflows/Static%20analysis/badge.svg)
[![codecov](https://codecov.io/gh/Part-DB/Part-DB-server/branch/master/graph/badge.svg)](https://codecov.io/gh/Part-DB/Part-DB-server) [![codecov](https://codecov.io/gh/Part-DB/Part-DB-symfony/branch/master/graph/badge.svg)](https://codecov.io/gh/Part-DB/Part-DB-server)
![GitHub License](https://img.shields.io/github/license/Part-DB/Part-DB-symfony) ![GitHub License](https://img.shields.io/github/license/Part-DB/Part-DB-symfony)
![PHP Version](https://img.shields.io/badge/PHP-%3E%3D%208.1-green) ![PHP Version](https://img.shields.io/badge/PHP-%3E%3D%207.4-green)
![Docker Pulls](https://img.shields.io/docker/pulls/jbtronics/part-db1) ![Docker Pulls](https://img.shields.io/docker/pulls/jbtronics/part-db1)
![Docker Build Status](https://github.com/Part-DB/Part-DB-symfony/workflows/Docker%20Image%20Build/badge.svg) ![Docker Build Status](https://github.com/Part-DB/Part-DB-symfony/workflows/Docker%20Image%20Build/badge.svg)
[![Crowdin](https://badges.crowdin.net/e/8325196085d4bee8c04b75f7c915452a/localized.svg)](https://part-db.crowdin.com/part-db) [![Crowdin](https://badges.crowdin.net/e/8325196085d4bee8c04b75f7c915452a/localized.svg)](https://part-db.crowdin.com/part-db)
**[Documentation](https://docs.part-db.de/)** | **[Demo](https://demo.part-db.de/)** | **[Docker Image](https://hub.docker.com/r/jbtronics/part-db1)** **[Documentation](https://docs.part-db.de/)** | **[Demo](https://part-db.herokuapp.com)** | **[Docker Image](https://hub.docker.com/r/jbtronics/part-db1)**
# Part-DB # Part-DB
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. 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) 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.
(Version < 1.0) based on a modern framework and is the recommended version to use. 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.
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 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.
for everybody.
## Demo ## Demo
If you want to test Part-DB without installing it, you can use [this](https://part-db.herokuapp.com) Heroku instance.
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://part-db.herokuapp.com/de/)).
(Or this link for the [German Version](https://demo.part-db.de/de/)).
You can log in with username: *user* and password: *user*. 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 Every change to the master branch gets automatically deployed, so it represents the current development progress and is
may not completely stable. Please mind, that the free Heroku instance is used, so it can take some time when loading maybe not completely stable. Please mind, that the free Heroku instance is used, so it can take some time when loading the page
the page
for the first time. for the first time.
<img src="https://github.com/Part-DB/Part-DB-server/raw/master/docs/assets/readme/part_info.png"> <img src="https://github.com/Part-DB/Part-DB-server/raw/master/docs/assets/readme/part_info.png">
<img src="https://github.com/Part-DB/Part-DB-server/raw/master/docs/assets/readme/parts_list.png"> <img src="https://github.com/Part-DB/Part-DB-server/raw/master/docs/assets/readme/parts_list.png">
## Features ## Features
* Inventory management of your electronic parts. Each part can be assigned to a category, footprint, manufacturer
* 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.
and multiple store locations and price information. Parts can be grouped using tags. You can associate various files * Multi-Language support (currently German, English, Russian, Japanese and French (experimental))
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 * 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. * 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. Two-factor authentication is supported (Google Authenticator and Webauthn/U2F keys) and can be enforced for groups. Password reset via email can be setuped.
Password reset via email can be set up. * Import/Export system (partial working)
* Optional support for single sign-on (SSO) via SAML (using an intermediate service * 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
like [Keycloak](https://www.keycloak.org/) you can connect Part-DB to an existing LDAP or Active Directory server) * Event log: Track what changes happens to your inventory, track which user does what. Revert your parts to older versions.
* Import/Export system for parts and data structure. BOM import for projects from KiCAD is supported. * Responsive design: You can use Part-DB on your PC, your tablet and your smartphone using the same interface.
* Project management: Create projects and assign parts to the bill of material (BOM), to show how often you could build * MySQL and SQLite supported as database backends
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 rich text descriptions and comments in parts
* Support for multiple currencies and automatic update of exchange rates supported * 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) * Powerful search and filter function, including parametric search (search for parts according to some specifications)
* Automatic thumbnail generation for pictures * 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 maker spaces, where many users 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 makerspaces, where many users have should have (controlled) access to the shared inventory.
Part-DB is also used by small companies and universities for managing their inventory. Part-DB is also used by small companies and universities for managing their inventory.
## Requirements ## Requirements
* A **web server** (like Apache2 or nginx) that is capable of running [Symfony 5](https://symfony.com/doc/current/reference/requirements.html),
* A **web server** (like Apache2 or nginx) that is capable of this includes a minimum PHP version of **PHP 7.4**
running [Symfony 6](https://symfony.com/doc/current/reference/requirements.html), * A **MySQL** (at least 5.7) /**MariaDB** (at least 10.2.2) database server if you do not want to use SQLite.
this includes a minimum PHP version of **PHP 8.1** * Shell access to your server is highly suggested!
* A **MySQL** (at least 5.7) /**MariaDB** (at least 10.4) database server, or **PostgreSQL** 10+ if you do not want to use SQLite. * For building the client side assets **yarn** and **nodejs** is needed.
* Shell access to your server is highly recommended!
* For building the client-side assets **yarn** and **nodejs** (>= 18.0) is needed.
## Installation ## 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.
If you want to upgrade your legacy (< 1.0.0) version of Part-DB to this version, please *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).
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 **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.**
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. 1. Copy or clone this repository into a folder on your server.
2. Configure your webserver to serve from the `public/` folder. 2. Configure your webserver to serve from the `public/` folder. See [here](https://symfony.com/doc/current/setup/web_server_configuration.html)
See [here](https://symfony.com/doc/current/setup/web_server_configuration.html) for additional information.
for additional information.
3. Copy the global config file `cp .env .env.local` and edit `.env.local`: 3. Copy the global config file `cp .env .env.local` and edit `.env.local`:
* Change the line `APP_ENV=dev` to `APP_ENV=prod` * 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 ( * 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.
see [here](http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url)) In bigger instances with concurrent accesses, MySQL is more performant. This can not be changed easily later, so choose wisely.
for the format.
In bigger instances with concurrent accesses, MySQL is more performant. This can not be changed easily later, so
choose wisely.
4. Install composer dependencies and generate autoload files: `composer install -o --no-dev` 4. Install composer dependencies and generate autoload files: `composer install -o --no-dev`
5. Install client side dependencies and build it: `yarn install` and `yarn build` 5. If you have put Part-DB into a sub-directory on your server (like `part-db/`), you have to edit the file
6. _Optional_ (speeds up first load): Warmup cache: `php bin/console cache:warmup` `webpack.config.js` and uncomment the lines (remove the `//` before the lines) `.setPublicPath('/part-db/build')` (line 43) and
7. Upgrade database to new scheme (or create it, when it was empty): `php bin/console doctrine:migrations:migrate` and `.setManifestKeyPrefix('build/')` (line 44). You have to replace `/part-db` with your own path on line 44.
follow the instructions given. During the process the password for the admin is user is shown. Copy it. **Caution**: 6. Install client side dependencies and build it: `yarn install` and `yarn build`
These steps tamper with your database and could potentially destroy it. So make sure to make a backup of your 7. _Optional_ (speeds up first load): Warmup cache: `php bin/console cache:warmup`
database. 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.
8. You can configure Part-DB via `config/parameters.yaml`. You should check if settings match your expectations after 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).
you installed/upgraded Part-DB. Check if `partdb.default_currency` matches your mainly used currency (this can not be Run `php bin/console cache:clear` when you changed something.
changed after creating price information). 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.
Run `php bin/console cache:clear` when you change something. 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.
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 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. and repeat the steps 4. to 7.
Normally a random password is generated when the admin user is created during initial database creation, Normally a random password is generated when the admin user is created during inital database creation,
however, you can set the initial admin password, by setting the `INITIAL_ADMIN_PW` env var. however you can set the inital 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. See [here](https://docs.part-db.de/configuration.html) for more information.
### Reverse proxy ### 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 you are using a reverse proxy, you have to ensure that the proxies set the `X-Forwarded-*` headers correctly, or you 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.
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 ## 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). 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 one-time base. There you will find various methods to support development on a monthly or a one time base.
## Built with ## Built with
* [Symfony 5](https://symfony.com/): The main framework used for the serverside PHP * [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 * [Bootstrap 5](https://getbootstrap.com/) and [Bootswatch](https://bootswatch.com/): Used as website theme
* [Fontawesome](https://fontawesome.com/): Used as icon set * [Fontawesome](https://fontawesome.com/): Used as icon set
* [Hotwire Stimulus](https://stimulus.hotwired.dev/) and [Hotwire Turbo](https://turbo.hotwired.dev/): Frontend * [Hotwire Stimulus](https://stimulus.hotwired.dev/) and [Hotwire Turbo](https://turbo.hotwired.dev/): Frontend Javascript
Javascript
## Authors ## Authors
* **Jan Böhmer** - *Inital work* - [Github](https://github.com/jbtronics/)
* **Jan Böhmer** - *Initial work* - [GitHub](https://github.com/jbtronics/) See also the list of [contributors](https://github.com/Part-DB/Part-DB-server/graphs/contributors) who participated in this project.
See also the list of [contributors](https://github.com/Part-DB/Part-DB-server/graphs/contributors) who participated in
this project.
Based on the original Part-DB by Christoph Lechner and K. Jacobs Based on the original Part-DB by Christoph Lechner and K. Jacobs
## License ## License
Part-DB is licensed under the GNU Affero General Public License v3.0 (or at your opinion any later). Part-DB is licensed under the GNU Affero General Public License v3.0 (or at your opinion any later).
This mostly means that you can use Part-DB for whatever you want (even use it commercially) This mostly means that you can use Part-DB for whatever you want (even use it commercially)
as long as you publish the source code for every change you make under the AGPL, too. as long as you publish the source code for every change you make under the AGPL, too.

View file

@ -9,4 +9,4 @@ fixed before the next release. However, if you find a security vulnerability in
## Reporting a Vulnerability ## Reporting a Vulnerability
If you find a security vulnerability, report a vulnerability in the [security section of GitHub](https://github.com/Part-DB/Part-DB-server/security/advisories) or contact the maintainer directly (Email: security@part-db.de) If you find a security vulnerability, contact the maintainer directly (Email: security@part-db.de).

View file

@ -1 +1 @@
1.17.1 1.0.0

3
assets/bootstrap.js vendored
View file

@ -4,7 +4,8 @@ import { startStimulusApp } from '@symfony/stimulus-bridge';
export const app = startStimulusApp(require.context( export const app = startStimulusApp(require.context(
'@symfony/stimulus-bridge/lazy-controller-loader!./controllers', '@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
true, true,
/\.[jt]sx?$/ /\.(j|t)sx?$/
)); ));
// register any custom, 3rd party controllers here // register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController); // app.register('some_controller_name', SomeImportedController);

View file

@ -181,8 +181,7 @@ Editor.defaultConfig = {
'DejaVu Serif, serif', 'DejaVu Serif, serif',
'Helvetica, Arial, sans-serif', 'Helvetica, Arial, sans-serif',
'Times New Roman, Times, serif', 'Times New Roman, Times, serif',
'Courier New, Courier, monospace', 'Courier New, Courier, monospace'
'Unifont, monospace',
], ],
supportAllValues: true supportAllValues: true
}, },

View file

@ -76,7 +76,6 @@ const PLACEHOLDERS = [
['[[FOOTPRINT_FULL]]', 'Footprint (Full path)'], ['[[FOOTPRINT_FULL]]', 'Footprint (Full path)'],
['[[MASS]]', 'Mass'], ['[[MASS]]', 'Mass'],
['[[MPN]]', 'Manufacturer Product Number (MPN)'], ['[[MPN]]', 'Manufacturer Product Number (MPN)'],
['[[IPN]]', 'Internal Part Number (IPN)'],
['[[TAGS]]', 'Tags'], ['[[TAGS]]', 'Tags'],
['[[M_STATUS]]', 'Manufacturing status'], ['[[M_STATUS]]', 'Manufacturing status'],
['[[DESCRIPTION]]', 'Description'], ['[[DESCRIPTION]]', 'Description'],
@ -85,9 +84,6 @@ const PLACEHOLDERS = [
['[[COMMENT_T]]', 'Comment (plain text)'], ['[[COMMENT_T]]', 'Comment (plain text)'],
['[[LAST_MODIFIED]]', 'Last modified datetime'], ['[[LAST_MODIFIED]]', 'Last modified datetime'],
['[[CREATION_DATE]]', 'Creation datetime'], ['[[CREATION_DATE]]', 'Creation datetime'],
['[[IPN_BARCODE_QR]]', 'IPN as QR code'],
['[[IPN_BARCODE_C128]]', 'IPN as Code 128 barcode'],
['[[IPN_BARCODE_C39]]', 'IPN as Code 39 barcode'],
] ]
}, },
{ {
@ -100,8 +96,6 @@ const PLACEHOLDERS = [
['[[AMOUNT]]', 'Lot amount'], ['[[AMOUNT]]', 'Lot amount'],
['[[LOCATION]]', 'Storage location'], ['[[LOCATION]]', 'Storage location'],
['[[LOCATION_FULL]]', 'Storage location (Full path)'], ['[[LOCATION_FULL]]', 'Storage location (Full path)'],
['[[OWNER]]', 'Full name of the lot owner'],
['[[OWNER_USERNAME]]', 'Username of the lot owner'],
] ]
}, },
{ {
@ -116,8 +110,6 @@ const PLACEHOLDERS = [
['[[COMMENT_T]]', 'Comment (plain text)'], ['[[COMMENT_T]]', 'Comment (plain text)'],
['[[LAST_MODIFIED]]', 'Last modified datetime'], ['[[LAST_MODIFIED]]', 'Last modified datetime'],
['[[CREATION_DATE]]', 'Creation datetime'], ['[[CREATION_DATE]]', 'Creation datetime'],
['[[OWNER]]', 'Full name of the location owner'],
['[[OWNER_USERNAME]]', 'Username of the location owner'],
] ]
}, },
{ {
@ -128,8 +120,6 @@ const PLACEHOLDERS = [
['[[BARCODE_QR]]', 'QR code linking to this element'], ['[[BARCODE_QR]]', 'QR code linking to this element'],
['[[BARCODE_C128]]', 'Code 128 barcode linking to this element'], ['[[BARCODE_C128]]', 'Code 128 barcode linking to this element'],
['[[BARCODE_C39]]', 'Code 39 barcode linking to this element'], ['[[BARCODE_C39]]', 'Code 39 barcode linking to this element'],
['[[BARCODE_C93]]', 'Code 93 barcode linking to this element'],
['[[BARCODE_DATAMATRIX]]', 'Datamatrix code linking to this element'],
] ]
}, },
{ {

View file

@ -39,7 +39,6 @@ Object.assign( window.CKEDITOR_TRANSLATIONS[ 'de' ].dictionary, {
'Footprint (Full path)': 'Footprint (Vollständiger Pfad)', 'Footprint (Full path)': 'Footprint (Vollständiger Pfad)',
'Mass': 'Gewicht', 'Mass': 'Gewicht',
'Manufacturer Product Number (MPN)': 'Hersteller Produktnummer (MPN)', 'Manufacturer Product Number (MPN)': 'Hersteller Produktnummer (MPN)',
'Internal Part Number (IPN)': 'Internal Part Number (IPN)',
'Tags': 'Tags', 'Tags': 'Tags',
'Manufacturing status': 'Herstellungsstatus', 'Manufacturing status': 'Herstellungsstatus',
'Description': 'Beschreibung', 'Description': 'Beschreibung',
@ -48,9 +47,6 @@ Object.assign( window.CKEDITOR_TRANSLATIONS[ 'de' ].dictionary, {
'Comment (plain text)': 'Kommentar (Nur-Text)', 'Comment (plain text)': 'Kommentar (Nur-Text)',
'Last modified datetime': 'Zuletzt geändert', 'Last modified datetime': 'Zuletzt geändert',
'Creation datetime': 'Erstellt', 'Creation datetime': 'Erstellt',
'IPN as QR code': 'IPN als QR Code',
'IPN as Code 128 barcode': 'IPN als Code 128 Barcode',
'IPN as Code 39 barcode': 'IPN als Code 39 Barcode',
'Lot ID': 'Lot ID', 'Lot ID': 'Lot ID',
'Lot name': 'Lot Name', 'Lot name': 'Lot Name',
@ -59,8 +55,6 @@ Object.assign( window.CKEDITOR_TRANSLATIONS[ 'de' ].dictionary, {
'Lot amount': 'Lot Menge', 'Lot amount': 'Lot Menge',
'Storage location': 'Lagerort', 'Storage location': 'Lagerort',
'Storage location (Full path)': 'Lagerort (Vollständiger Pfad)', 'Storage location (Full path)': 'Lagerort (Vollständiger Pfad)',
'Full name of the lot owner': 'Name des Besitzers des Lots',
'Username of the lot owner': 'Benutzername des Besitzers des Lots',
'Barcodes': 'Barcodes', 'Barcodes': 'Barcodes',
@ -69,16 +63,12 @@ Object.assign( window.CKEDITOR_TRANSLATIONS[ 'de' ].dictionary, {
'QR code linking to this element': 'QR Code verknüpft mit diesem Element', 'QR code linking to this element': 'QR Code verknüpft mit diesem Element',
'Code 128 barcode linking to this element': 'Code 128 Barcode verknüpft mit diesem Element', 'Code 128 barcode linking to this element': 'Code 128 Barcode verknüpft mit diesem Element',
'Code 39 barcode linking to this element': 'Code 39 Barcode verknüpft mit diesem Element', 'Code 39 barcode linking to this element': 'Code 39 Barcode verknüpft mit diesem Element',
'Code 93 barcode linking to this element': 'Code 93 Barcode verknüpft mit diesem Element',
'Datamatrix code linking to this element': 'Datamatrix Code verknüpft mit diesem Element',
'Location ID': 'Lagerort ID', 'Location ID': 'Lagerort ID',
'Name': 'Name', 'Name': 'Name',
'Full path': 'Vollständiger Pfad', 'Full path': 'Vollständiger Pfad',
'Parent name': 'Name des Übergeordneten Elements', 'Parent name': 'Name des Übergeordneten Elements',
'Parent full path': 'Ganzer Pfad des Übergeordneten Elements', 'Parent full path': 'Ganzer Pfad des Übergeordneten Elements',
'Full name of the location owner': 'Name des Besitzers des Lagerorts',
'Username of the location owner': 'Benutzername des Besitzers des Lagerorts',
'Username': 'Benutzername', 'Username': 'Benutzername',
'Username (including name)': 'Benutzername (inklusive Name)', 'Username (including name)': 'Benutzername (inklusive Name)',

View file

@ -30,73 +30,9 @@ export default class SpecialCharactersEmoji extends Plugin {
const editor = this.editor; const editor = this.editor;
const specialCharsPlugin = editor.plugins.get('SpecialCharacters'); const specialCharsPlugin = editor.plugins.get('SpecialCharacters');
//Add greek characters to special characters
specialCharsPlugin.addItems('Greek', this.getGreek());
//Add Emojis to special characters
specialCharsPlugin.addItems('Emoji', this.getEmojis()); specialCharsPlugin.addItems('Emoji', this.getEmojis());
} }
getGreek() {
return [
{ title: 'Alpha', character: 'Α' },
{ title: 'Beta', character: 'Β' },
{ title: 'Gamma', character: 'Γ' },
{ title: 'Delta', character: 'Δ' },
{ title: 'Epsilon', character: 'Ε' },
{ title: 'Zeta', character: 'Ζ' },
{ title: 'Eta', character: 'Η' },
{ title: 'Theta', character: 'Θ' },
{ title: 'Iota', character: 'Ι' },
{ title: 'Kappa', character: 'Κ' },
{ title: 'Lambda', character: 'Λ' },
{ title: 'Mu', character: 'Μ' },
{ title: 'Nu', character: 'Ν' },
{ title: 'Xi', character: 'Ξ' },
{ title: 'Omicron', character: 'Ο' },
{ title: 'Pi', character: 'Π' },
{ title: 'Rho', character: 'Ρ' },
{ title: 'Sigma', character: 'Σ' },
{ title: 'Tau', character: 'Τ' },
{ title: 'Upsilon', character: 'Υ' },
{ title: 'Phi', character: 'Φ' },
{ title: 'Chi', character: 'Χ' },
{ title: 'Psi', character: 'Ψ' },
{ title: 'Omega', character: 'Ω' },
{ title: 'alpha', character: 'α' },
{ title: 'beta', character: 'β' },
{ title: 'gamma', character: 'γ' },
{ title: 'delta', character: 'δ' },
{ title: 'epsilon', character: 'ε' },
{ title: 'zeta', character: 'ζ' },
{ title: 'eta', character: 'η' },
{ title: 'theta', character: 'θ' },
{ title: 'alternate theta', character: 'ϑ' },
{ title: 'iota', character: 'ι' },
{ title: 'kappa', character: 'κ' },
{ title: 'lambda', character: 'λ' },
{ title: 'mu', character: 'μ' },
{ title: 'nu', character: 'ν' },
{ title: 'xi', character: 'ξ' },
{ title: 'omicron', character: 'ο' },
{ title: 'pi', character: 'π' },
{ title: 'rho', character: 'ρ' },
{ title: 'sigma', character: 'σ' },
{ title: 'tau', character: 'τ' },
{ title: 'upsilon', character: 'υ' },
{ title: 'phi', character: 'φ' },
{ title: 'chi', character: 'χ' },
{ title: 'psi', character: 'ψ' },
{ title: 'omega', character: 'ω' },
{ title: 'digamma', character: 'Ϝ' },
{ title: 'stigma', character: 'Ϛ' },
{ title: 'heta', character: 'Ͱ' },
{ title: 'sampi', character: 'Ϡ' },
{ title: 'koppa', character: 'Ϟ' },
{ title: 'san', character: 'Ϻ' },
];
}
getEmojis() { getEmojis() {
//Map our emoji data to the format the plugin expects //Map our emoji data to the format the plugin expects
return emoji.map(emoji => { return emoji.map(emoji => {

View file

@ -18,118 +18,43 @@
*/ */
import {Controller} from "@hotwired/stimulus"; import {Controller} from "@hotwired/stimulus";
import Darkmode from "darkmode-js/src";
import "darkmode-js"
export default class extends Controller { export default class extends Controller {
_darkmode;
connect() { connect() {
this.setMode(this.getMode()); if (typeof window.getComputedStyle(document.body).mixBlendMode == 'undefined') {
document.querySelectorAll('input[name="darkmode"]').forEach((radio) => { console.warn("The browser does not support mix blend mode. Darkmode will not work.");
radio.addEventListener('change', this._radioChanged.bind(this));
});
}
/**
* Event listener for the change of radio buttons
* @private
*/
_radioChanged(event) {
const new_mode = this.getSelectedMode();
this.setMode(new_mode);
}
/**
* Get the current mode from the local storage
* @return {'dark', 'light', 'auto'}
*/
getMode() {
return localStorage.getItem('darkmode') ?? 'auto';
}
/**
* Set the mode in the local storage and apply it and change the state of the radio buttons
* @param mode
*/
setMode(mode) {
if (mode !== 'dark' && mode !== 'light' && mode !== 'auto') {
console.warn('Invalid darkmode mode: ' + mode);
mode = 'auto';
}
localStorage.setItem('darkmode', mode);
this.setButtonMode(mode);
if (mode === 'auto') {
this._setDarkmodeAuto();
} else if (mode === 'dark') {
this._enableDarkmode();
} else if (mode === 'light') {
this._disableDarkmode();
}
}
/**
* Get the selected mode via the radio buttons
* @return {'dark', 'light', 'auto'}
*/
getSelectedMode() {
return document.querySelector('input[name="darkmode"]:checked').value;
}
/**
* Set the state of the radio buttons
* @param mode
*/
setButtonMode(mode) {
document.querySelector('input[name="darkmode"][value="' + mode + '"]').checked = true;
}
/**
* Enable darkmode by adding the data-bs-theme="dark" to the html tag
* @private
*/
_enableDarkmode() {
//Add data-bs-theme="dark" to the html tag
document.documentElement.setAttribute('data-bs-theme', 'dark');
}
/**
* Disable darkmode by adding the data-bs-theme="light" to the html tag
* @private
*/
_disableDarkmode() {
//Set data-bs-theme to light
document.documentElement.setAttribute('data-bs-theme', 'light');
}
/**
* Set the darkmode to auto and enable/disable it depending on the system settings, also add
* an event listener to change the darkmode if the system settings change
* @private
*/
_setDarkmodeAuto() {
if (this.getMode() !== 'auto') {
return; return;
} }
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { try {
this._enableDarkmode(); const darkmode = new Darkmode();
} else { this._darkmode = darkmode;
this._disableDarkmode();
//Unhide darkmode button
this._showWidget();
//Set the switch according to our current darkmode state
const toggler = document.getElementById("toggleDarkmode");
toggler.checked = darkmode.isActivated();
}
catch (e)
{
console.error(e);
} }
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
console.log('Prefered color scheme changed to ' + event.matches ? 'dark' : 'light');
this._setDarkmodeAuto();
});
} }
/** _showWidget() {
* Check if darkmode is activated this.element.classList.remove('hidden');
* @return {boolean} }
*/
isDarkmodeActivated() { toggleDarkmode() {
return document.documentElement.getAttribute('data-bs-theme') === 'dark'; this._darkmode.toggle();
} }
} }

View file

@ -88,8 +88,5 @@ export default class extends Controller {
} else { } else {
this.hideSidebar(); this.hideSidebar();
} }
//Hide the tootip on the button
this._toggle_button.blur();
} }
} }

View file

@ -20,26 +20,16 @@
'use strict'; 'use strict';
import { Controller } from '@hotwired/stimulus'; import { Controller } from '@hotwired/stimulus';
import { Marked } from "marked"; import { marked } from "marked";
import { mangle } from "marked-mangle";
import { gfmHeadingId } from "marked-gfm-heading-id";
import DOMPurify from 'dompurify'; import DOMPurify from 'dompurify';
import "../../css/app/markdown.css"; import "../../css/app/markdown.css";
export default class MarkdownController extends Controller { export default class extends Controller {
static _marked = new Marked([
{
gfm: true,
},
gfmHeadingId(),
mangle(),
])
;
connect() connect()
{ {
this.configureMarked();
this.render(); this.render();
//Dispatch an event that we are now finished //Dispatch an event that we are now finished
@ -53,7 +43,7 @@ export default class MarkdownController extends Controller {
let raw = this.element.dataset['markdown']; let raw = this.element.dataset['markdown'];
//Apply purified parsed markdown //Apply purified parsed markdown
this.element.innerHTML = DOMPurify.sanitize(MarkdownController._marked.parse(this.unescapeHTML(raw))); this.element.innerHTML = DOMPurify.sanitize(marked(this.unescapeHTML(raw)));
for(let a of this.element.querySelectorAll('a')) { for(let a of this.element.querySelectorAll('a')) {
//Mark all links as external //Mark all links as external
@ -89,23 +79,10 @@ export default class MarkdownController extends Controller {
/** /**
* Configure the marked parser * Configure the marked parser
*/ */
/*static newMarked() configureMarked()
{ {
const marked = new Marked([
{
gfm: true,
},
gfmHeadingId(),
mangle(),
])
;
marked.use(mangle());
marked.use(gfmHeadingId({
}));
marked.setOptions({ marked.setOptions({
gfm: true, gfm: true,
}); });
}*/ }
} }

View file

@ -23,12 +23,6 @@ import "tom-select/dist/css/tom-select.bootstrap5.css";
import '../../css/components/tom-select_extensions.css'; import '../../css/components/tom-select_extensions.css';
import TomSelect from "tom-select"; import TomSelect from "tom-select";
import TomSelect_click_to_edit from '../../tomselect/click_to_edit/click_to_edit'
import TomSelect_autoselect_typed from '../../tomselect/autoselect_typed/autoselect_typed'
TomSelect.define('click_to_edit', TomSelect_click_to_edit)
TomSelect.define('autoselect_typed', TomSelect_autoselect_typed)
export default class extends Controller { export default class extends Controller {
_tomSelect; _tomSelect;
@ -52,12 +46,6 @@ export default class extends Controller {
} }
return '<div>' + escape(data.label) + '</div>'; return '<div>' + escape(data.label) + '</div>';
} }
},
plugins: {
'autoselect_typed': {},
'click_to_edit': {},
'clear_button': {},
"restore_on_backspace": {}
} }
}; };

View file

@ -53,7 +53,6 @@ export default class extends Controller {
const config = { const config = {
language: language, language: language,
licenseKey: "GPL",
} }
const watchdog = new EditorWatchdog(); const watchdog = new EditorWatchdog();
@ -71,9 +70,7 @@ export default class extends Controller {
editor_div.classList.add(...new_classes.split(",")); editor_div.classList.add(...new_classes.split(","));
} }
//This return is important! Otherwise we get mysterious errors in the console console.log(editor);
//See: https://github.com/ckeditor/ckeditor5/issues/5897#issuecomment-628471302
return editor;
}) })
.catch(error => { .catch(error => {
console.error(error); console.error(error);

View file

@ -27,7 +27,6 @@ export default class extends Controller {
deleteMessage: String, deleteMessage: String,
prototype: String, prototype: String,
rowsToDelete: Number, //How many rows (including the current one) shall be deleted after the current row rowsToDelete: Number, //How many rows (including the current one) shall be deleted after the current row
fieldPlaceholder: String
} }
static targets = ["target"]; static targets = ["target"];
@ -61,63 +60,24 @@ export default class extends Controller {
if(!prototype) { if(!prototype) {
console.warn("Prototype is not set, we cannot create a new element. This is most likely due to missing permissions."); console.warn("Prototype is not set, we cannot create a new element. This is most likely due to missing permissions.");
bootbox.alert("You do not have the permissions to create a new element. (No protoype element is set)"); bootbox.alert("You do not have the permsissions to create a new element. (No protoype element is set)");
return; return;
} }
const regexString = this.fieldPlaceholderValue || "__name__";
const regex = new RegExp(regexString, "g");
//Apply the index to prototype to create our element to insert //Apply the index to prototype to create our element to insert
const newElementStr = this.htmlDecode(prototype.replace(regex, this.generateUID())); const newElementStr = this.htmlDecode(prototype.replace(/__name__/g, this.generateUID()));
//Insert new html after the last child element //Insert new html after the last child element
//If the table has a tbody, insert it there //If the table has a tbody, insert it there
//Afterwards return the newly created row
if(targetTable.tBodies[0]) { if(targetTable.tBodies[0]) {
targetTable.tBodies[0].insertAdjacentHTML('beforeend', newElementStr); targetTable.tBodies[0].insertAdjacentHTML('beforeend', newElementStr);
return targetTable.tBodies[0].lastElementChild;
} else { //Otherwise just insert it } else { //Otherwise just insert it
targetTable.insertAdjacentHTML('beforeend', newElementStr); targetTable.insertAdjacentHTML('beforeend', newElementStr);
return targetTable.lastElementChild;
} }
} }
/**
* This action opens a file dialog to select multiple files and then creates a new element for each file, where
* the file is assigned to the input field.
* This should only be used for attachments collection types
* @param event
*/
uploadMultipleFiles(event) {
//Open a file dialog to select multiple files
const input = document.createElement('input');
input.type = 'file';
input.multiple = true;
input.click();
input.addEventListener('change', (event) => {
//Create a element for each file
for (let i = 0; i < input.files.length; i++) {
const file = input.files[i];
const newElement = this.createElement(event);
const rowInput = newElement.querySelector("input[type='file']");
//We can not directly assign the file to the input, so we have to create a new DataTransfer object
const dataTransfer = new DataTransfer();
dataTransfer.items.add(file);
rowInput.files = dataTransfer.files;
}
});
}
/** /**
* Similar to createEvent Pricedetails need some special handling to fill min amount * Similar to createEvent Pricedetails need some special handling to fill min amount
* @param event * @param event

View file

@ -24,25 +24,18 @@ import 'datatables.net-bs5/css/dataTables.bootstrap5.css'
import 'datatables.net-buttons-bs5/css/buttons.bootstrap5.css' import 'datatables.net-buttons-bs5/css/buttons.bootstrap5.css'
import 'datatables.net-fixedheader-bs5/css/fixedHeader.bootstrap5.css' import 'datatables.net-fixedheader-bs5/css/fixedHeader.bootstrap5.css'
import 'datatables.net-responsive-bs5/css/responsive.bootstrap5.css'; import 'datatables.net-responsive-bs5/css/responsive.bootstrap5.css';
import 'datatables.net-select-bs5/css/select.bootstrap5.css';
//Use our own styles for the select extension which fit the bootstrap theme better
//import 'datatables.net-select-bs5/css/select.bootstrap5.css';
import '../../../css/components/datatables_select_bs5.css';
//JS //JS
import 'datatables.net-bs5'; import 'datatables.net-bs5';
import 'datatables.net-buttons-bs5'; import 'datatables.net-buttons-bs5';
import 'datatables.net-buttons/js/buttons.colVis.js'; import 'datatables.net-buttons/js/buttons.colVis.js';
import 'datatables.net-fixedheader-bs5'; import 'datatables.net-fixedheader-bs5';
import 'datatables.net-select-bs5';
import 'datatables.net-colreorder-bs5'; import 'datatables.net-colreorder-bs5';
import 'datatables.net-responsive-bs5'; import 'datatables.net-responsive-bs5';
import '../../../js/lib/datatables'; import '../../../js/lib/datatables';
//import 'datatables.net-select-bs5';
//Use the local version containing the fix for the select extension
import '../../../js/lib/dataTables.select.mjs';
const EVENT_DT_LOADED = 'dt:loaded'; const EVENT_DT_LOADED = 'dt:loaded';
export default class extends Controller { export default class extends Controller {
@ -72,22 +65,8 @@ export default class extends Controller {
localStorage.setItem( this.getStateSaveKey(), JSON.stringify(data) ); localStorage.setItem( this.getStateSaveKey(), JSON.stringify(data) );
} }
stateLoadCallback() { stateLoadCallback(settings) {
const json = localStorage.getItem(this.getStateSaveKey()); return JSON.parse( localStorage.getItem(this.getStateSaveKey()) );
if(json === null || json === undefined) {
return null;
}
const data = JSON.parse(json);
if (data) {
//Do not save the start value (current page), as we want to always start at the first page on a page reload
delete data.start;
//Reset the data length to the default value by deleting the length property
delete data.length;
}
return data;
} }
connect() { connect() {
@ -102,19 +81,6 @@ export default class extends Controller {
//Add url info, as the one available in the history is not enough, as Turbo may have not changed it yet //Add url info, as the one available in the history is not enough, as Turbo may have not changed it yet
settings.url = this.element.dataset.dtUrl; settings.url = this.element.dataset.dtUrl;
//Add initial_order info to the settings, so that the order on the initial page load is the one saved in the state
const saved_state = this.stateLoadCallback();
if (saved_state !== null) {
const raw_order = saved_state.order;
settings.initial_order = raw_order.map((order) => {
return {
column: order[0],
dir: order[1]
}
});
}
let options = { let options = {
colReorder: true, colReorder: true,
responsive: true, responsive: true,
@ -124,7 +90,7 @@ export default class extends Controller {
}, },
buttons: [{ buttons: [{
"extend": 'colvis', "extend": 'colvis',
'className': 'mr-2 btn-outline-secondary', 'className': 'mr-2 btn-light',
'columns': ':not(.no-colvis)', 'columns': ':not(.no-colvis)',
"text": "<i class='fa fa-cog'></i>" "text": "<i class='fa fa-cog'></i>"
}], }],
@ -139,7 +105,7 @@ export default class extends Controller {
if(this.isSelectable()) { if(this.isSelectable()) {
options.select = { options.select = {
style: 'multi+shift', style: 'multi+shift',
selector: 'td.dt-select', selector: 'td.select-checkbox'
}; };
} }
@ -150,28 +116,6 @@ export default class extends Controller {
console.error("Error initializing datatables: " + err); console.error("Error initializing datatables: " + err);
}); });
//Fix height of the length selector
promise.then((dt) => {
//Draw the rows to make sure the correct status text is displayed ("No matching records found" instead of "Loading...")
if (dt.data().length === 0) {
dt.rows().draw()
}
//Find all length selectors (select with name dt_length), which are inside a label
const lengthSelectors = document.querySelectorAll('label select[name="dt_length"]');
//And remove the surrounding label, while keeping the select with all event handlers
lengthSelectors.forEach((selector) => {
selector.parentElement.replaceWith(selector);
});
//Find all column visibility buttons (button with buttons-colvis class) and remove the btn-secondary class
const colVisButtons = document.querySelectorAll('button.buttons-colvis');
colVisButtons.forEach((button) => {
button.classList.remove('btn-secondary');
});
});
//Dispatch an event to let others know that the datatables has been loaded //Dispatch an event to let others know that the datatables has been loaded
promise.then((dt) => { promise.then((dt) => {
const event = new CustomEvent(EVENT_DT_LOADED, {bubbles: true}); const event = new CustomEvent(EVENT_DT_LOADED, {bubbles: true});
@ -231,16 +175,4 @@ export default class extends Controller {
return this.element.dataset.select ?? false; return this.element.dataset.select ?? false;
} }
invertSelection() {
//Do nothing if the datatable is not selectable
if(!this.isSelectable()) {
return;
}
//Invert the selected rows on the datatable
const selected_rows = this._dt.rows({selected: true});
this._dt.rows().select();
selected_rows.deselect();
}
} }

View file

@ -107,13 +107,6 @@ export default class extends DatatablesController {
//Hide the select element (the tomselect button is the sibling of the select element) //Hide the select element (the tomselect button is the sibling of the select element)
select_target.nextElementSibling.classList.add('d-none'); select_target.nextElementSibling.classList.add('d-none');
} }
//If the selected option has a data-turbo attribute, set it to the form
if (selected_option.dataset.turbo) {
this.element.dataset.turbo = selected_option.dataset.turbo;
} else {
this.element.dataset.turbo = true;
}
} }
confirmDeletionAtSubmit(event) { confirmDeletionAtSubmit(event) {

View file

@ -29,47 +29,62 @@ export default class extends Controller
this._confirmed = false; this._confirmed = false;
} }
submit(event) { click(event) {
//If a user has not already confirmed the deletion, just let turbo do its work //If a user has not already confirmed the deletion, just let turbo do its work
if (this._confirmed) { if(this._confirmed) {
this._confirmed = false; this._confirmed = false;
return; return;
} }
//Prevent turbo from doing its work
event.preventDefault(); event.preventDefault();
event.stopPropagation();
const message = this.element.dataset.deleteMessage; const message = this.element.dataset.deleteMessage;
const title = this.element.dataset.deleteTitle; const title = this.element.dataset.deleteTitle;
//Use event target, to find the form, where the submit button was clicked
const form = event.target;
const submitter = event.submitter;
const that = this; const that = this;
const confirm = bootbox.confirm({ const confirm = bootbox.confirm({
message: message, title: title, callback: function (result) { message: message, title: title, callback: function (result) {
//If the dialog was confirmed, then submit the form. //If the dialog was confirmed, then submit the form.
if (result) { if (result) {
//Set a flag to prevent the dialog from popping up again and allowing turbo to submit the form
that._confirmed = true; that._confirmed = true;
event.target.click();
} else {
that._confirmed = false;
}
}
});
}
//Create a submit button in the form and click it to submit the form submit(event) {
//Before a submit event was dispatched, but this caused weird issues on Firefox causing the delete request being posted twice (and the second time was returning 404). See https://github.com/Part-DB/Part-DB-server/issues/273 //If a user has not already confirmed the deletion, just let turbo do its work
const submit_btn = document.createElement('button'); if(this._confirmed) {
submit_btn.type = 'submit'; this._confirmed = false;
submit_btn.style.display = 'none'; return;
}
//If the clicked button has a value, set it on the submit button //Prevent turbo from doing its work
if (submitter.value) { event.preventDefault();
submit_btn.value = submitter.value;
} const message = this.element.dataset.deleteMessage;
if (submitter.name) { const title = this.element.dataset.deleteTitle;
submit_btn.name = submitter.name;
} const form = this.element;
form.appendChild(submit_btn); const that = this;
submit_btn.click();
//Create a clone of the event with the same submitter, so we can redispatch it if needed
//We need to do this that way, as we need the submitter info, just calling form.submit() would not work
this._our_event = new SubmitEvent('submit', {
submitter: event.submitter,
bubbles: true, //This line is important, otherwise Turbo will not receive the event
});
const confirm = bootbox.confirm({
message: message, title: title, callback: function (result) {
//If the dialog was confirmed, then submit the form.
if (result) {
that._confirmed = true;
form.dispatchEvent(that._our_event);
} else { } else {
that._confirmed = false; that._confirmed = false;
} }

View file

@ -1,40 +0,0 @@
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Controller} from "@hotwired/stimulus";
import JSONFormatter from 'json-formatter-js';
/**
* This controller implements an element that renders a JSON object as a collapsible tree.
* The JSON object is passed as a data attribute.
* You have to apply the controller to a div element or similar block element which can contain other elements.
*/
export default class extends Controller {
connect() {
const depth_to_open = this.element.dataset.depthToOpen ?? 0;
const json_string = this.element.dataset.json;
const json_object = JSON.parse(json_string);
const formatter = new JSONFormatter(json_object, depth_to_open);
this.element.appendChild(formatter.render());
}
}

View file

@ -1,72 +0,0 @@
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Controller} from "@hotwired/stimulus";
import * as bootbox from "bootbox";
import "../../css/components/bootbox_extensions.css";
export default class extends Controller
{
static values = {
message: String,
title: String
}
connect()
{
this._confirmed = false;
this.element.addEventListener('click', this._onClick.bind(this));
}
_onClick(event)
{
//If a user has not already confirmed the deletion, just let turbo do its work
if (this._confirmed) {
this._confirmed = false;
return;
}
event.preventDefault();
event.stopPropagation();
const that = this;
bootbox.confirm({
title: this.titleValue,
message: this.messageValue,
callback: (result) => {
if (result) {
//Set a flag to prevent the dialog from popping up again and allowing turbo to submit the form
that._confirmed = true;
//Click the link
that.element.click();
} else {
that._confirmed = false;
}
}
});
}
}

View file

@ -1,67 +0,0 @@
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Controller} from "@hotwired/stimulus";
export default class extends Controller
{
static values = {
id: String
}
connect() {
this.loadState()
this.element.addEventListener('change', () => {
this.saveState()
});
}
loadState() {
let storageKey = this.getStorageKey();
let value = localStorage.getItem(storageKey);
if (value === null) {
return;
}
if (value === 'true') {
this.element.checked = true
}
if (value === 'false') {
this.element.checked = false
}
}
saveState() {
let storageKey = this.getStorageKey();
if (this.element.checked) {
localStorage.setItem(storageKey, 'true');
} else {
localStorage.setItem(storageKey, 'false');
}
}
getStorageKey() {
if (this.hasIdValue) {
return 'persistent_checkbox_' + this.idValue
}
return 'persistent_checkbox_' + this.element.id;
}
}

View file

@ -1,200 +0,0 @@
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2024 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { Controller } from "@hotwired/stimulus";
import { autocomplete } from '@algolia/autocomplete-js';
//import "@algolia/autocomplete-theme-classic/dist/theme.css";
import "../../css/components/autocomplete_bootstrap_theme.css";
import { createLocalStorageRecentSearchesPlugin } from '@algolia/autocomplete-plugin-recent-searches';
import {marked} from "marked";
import {
trans,
SEARCH_PLACEHOLDER,
SEARCH_SUBMIT,
STATISTICS_PARTS
} from '../../translator';
/**
* This controller is responsible for the search fields in the navbar and the homepage.
* It uses the Algolia Autocomplete library to provide a fast and responsive search.
*/
export default class extends Controller {
static targets = ["input"];
_autocomplete;
// Highlight the search query in the results
_highlight = (text, query) => {
if (!text) return text;
if (!query) return text;
const HIGHLIGHT_PRE_TAG = '__aa-highlight__'
const HIGHLIGHT_POST_TAG = '__/aa-highlight__'
const escaped = query.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&');
const regex = new RegExp(escaped, 'gi');
return text.replace(regex, (match) => `${HIGHLIGHT_PRE_TAG}${match}${HIGHLIGHT_POST_TAG}`);
}
initialize() {
// The endpoint for searching parts
const base_url = this.element.dataset.autocomplete;
// The URL template for the part detail pages
const part_detail_uri_template = this.element.dataset.detailUrl;
//The URL of the placeholder picture
const placeholder_image = this.element.dataset.placeholderImage;
//If the element is in navbar mode, or not
const navbar_mode = this.element.dataset.navbarMode === "true";
const that = this;
const recentSearchesPlugin = createLocalStorageRecentSearchesPlugin({
key: 'RECENT_SEARCH',
limit: 5,
});
this._autocomplete = autocomplete({
container: this.element,
//Place the panel in the navbar, if the element is in navbar mode
panelContainer: navbar_mode ? document.getElementById("navbar-search-form") : document.body,
panelPlacement: this.element.dataset.panelPlacement,
plugins: [recentSearchesPlugin],
openOnFocus: true,
placeholder: trans(SEARCH_PLACEHOLDER),
translations: {
submitButtonTitle: trans(SEARCH_SUBMIT)
},
// Use a navigator compatible with turbo:
navigator: {
navigate({ itemUrl }) {
window.Turbo.visit(itemUrl, { action: "advance" });
},
navigateNewTab({ itemUrl }) {
const windowReference = window.open(itemUrl, '_blank', 'noopener');
if (windowReference) {
windowReference.focus();
}
},
navigateNewWindow({ itemUrl }) {
window.open(itemUrl, '_blank', 'noopener');
},
},
// If the form is submitted, forward the term to the form
onSubmit({state, event, ...setters}) {
//Put the current text into each target input field
const input = that.inputTarget;
if (!input) {
return;
}
//Do not submit the form, if the input is empty
if (state.query === "") {
return;
}
input.value = state.query;
input.form.requestSubmit();
},
getSources({ query }) {
return [
// The parts source
{
sourceId: 'parts',
getItems() {
const url = base_url.replace('__QUERY__', encodeURIComponent(query));
const data = fetch(url)
.then((response) => response.json())
;
//Iterate over all fields besides the id and highlight them
const fields = ["name", "description", "category", "footprint"];
data.then((items) => {
items.forEach((item) => {
for (const field of fields) {
item[field] = that._highlight(item[field], query);
}
});
});
return data;
},
getItemUrl({ item }) {
return part_detail_uri_template.replace('__ID__', item.id);
},
templates: {
header({ html }) {
return html`<span class="aa-SourceHeaderTitle">${trans(STATISTICS_PARTS)}</span>
<div class="aa-SourceHeaderLine" />`;
},
item({item, components, html}) {
const details_url = part_detail_uri_template.replace('__ID__', item.id);
return html`
<a class="aa-ItemLink" href="${details_url}">
<div class="aa-ItemContent">
<div class="aa-ItemIcon aa-ItemIcon--picture aa-ItemIcon--alignTop">
<img src="${item.image !== "" ? item.image : placeholder_image}" alt="${item.name}" width="30" height="30"/>
</div>
<div class="aa-ItemContentBody">
<div class="aa-ItemContentTitle">
<b>
${components.Highlight({hit: item, attribute: 'name'})}
</b>
</div>
<div class="aa-ItemContentDescription">
${components.Highlight({hit: item, attribute: 'description'})}
${item.category ? html`<p class="m-0"><span class="fa-solid fa-tags fa-fw"></span>${components.Highlight({hit: item, attribute: 'category'})}</p>` : ""}
${item.footprint ? html`<p class="m-0"><span class="fa-solid fa-microchip fa-fw"></span>${components.Highlight({hit: item, attribute: 'footprint'})}</p>` : ""}
</div>
</div>
</div>
</a>
`;
},
},
},
];
},
});
//Try to find the input field and register a defocus handler. This is necessarry, as by default the autocomplete
//lib has problems when multiple inputs are present on the page. (see https://github.com/algolia/autocomplete/issues/1216)
const inputs = this.element.getElementsByClassName('aa-Input');
for (const input of inputs) {
input.addEventListener('blur', () => {
this._autocomplete.setIsOpen(false);
});
}
}
}

View file

@ -27,7 +27,7 @@ export default class extends Controller {
} }
let tmp = '<div class="row m-0">' + let tmp = '<div class="row m-0">' +
"<div class='col-2 p-0 d-flex align-items-center' style='max-width: 80px;'>" + "<div class='col-2 p-0 d-flex align-items-center'>" +
(data.image ? "<img class='typeahead-image' src='" + data.image + "'/>" : "") + (data.image ? "<img class='typeahead-image' src='" + data.image + "'/>" : "") +
"</div>" + "</div>" +
"<div class='col-10'>" + "<div class='col-10'>" +

View file

@ -1,123 +0,0 @@
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Controller} from "@hotwired/stimulus";
import { zxcvbn, zxcvbnOptions } from '@zxcvbn-ts/core';
import * as zxcvbnCommonPackage from '@zxcvbn-ts/language-common';
import * as zxcvbnEnPackage from '@zxcvbn-ts/language-en';
import * as zxcvbnDePackage from '@zxcvbn-ts/language-de';
import * as zxcvbnFrPackage from '@zxcvbn-ts/language-fr';
import * as zxcvbnJaPackage from '@zxcvbn-ts/language-ja';
import {trans, USER_PASSWORD_STRENGTH_VERY_WEAK, USER_PASSWORD_STRENGTH_WEAK, USER_PASSWORD_STRENGTH_MEDIUM,
USER_PASSWORD_STRENGTH_STRONG, USER_PASSWORD_STRENGTH_VERY_STRONG} from '../../translator.js';
/* stimulusFetch: 'lazy' */
export default class extends Controller {
_passwordInput;
static targets = ["badge", "warning"]
_getTranslations() {
//Get the current locale
const locale = document.documentElement.lang;
if (locale.includes('de')) {
return zxcvbnDePackage.translations;
} else if (locale.includes('fr')) {
return zxcvbnFrPackage.translations;
} else if (locale.includes('ja')) {
return zxcvbnJaPackage.translations;
}
//Fallback to english
return zxcvbnEnPackage.translations;
}
connect() {
//Find the password input field
this._passwordInput = this.element.querySelector('input[type="password"]');
//Configure zxcvbn
const options = {
graphs: zxcvbnCommonPackage.adjacencyGraphs,
dictionary: {
...zxcvbnCommonPackage.dictionary,
// We could use the english dictionary here too, but it is very big. So we just use the common words
//...zxcvbnEnPackage.dictionary,
},
translations: this._getTranslations(),
};
zxcvbnOptions.setOptions(options);
//Add event listener to the password input field
this._passwordInput.addEventListener('input', this._onPasswordInput.bind(this));
}
_onPasswordInput() {
//Retrieve the password
const password = this._passwordInput.value;
//Estimate the password strength
const result = zxcvbn(password);
//Update the badge
this.badgeTarget.parentElement.classList.remove("d-none");
this._setBadgeToLevel(result.score);
this.warningTarget.innerHTML = result.feedback.warning;
}
_setBadgeToLevel(level) {
let text, classes;
switch (level) {
case 0:
text = trans(USER_PASSWORD_STRENGTH_VERY_WEAK);
classes = "bg-danger badge-danger";
break;
case 1:
text = trans(USER_PASSWORD_STRENGTH_WEAK);
classes = "bg-warning badge-warning";
break;
case 2:
text = trans(USER_PASSWORD_STRENGTH_MEDIUM)
classes = "bg-info badge-info";
break;
case 3:
text = trans(USER_PASSWORD_STRENGTH_STRONG);
classes = "bg-primary badge-primary";
break;
case 4:
text = trans(USER_PASSWORD_STRENGTH_VERY_STRONG);
classes = "bg-success badge-success";
break;
default:
text = "???";
classes = "bg-secondary badge-secondary";
}
this.badgeTarget.innerHTML = text;
//Remove all classes
this.badgeTarget.className = '';
//Re-add the classes
this.badgeTarget.classList.add("badge");
this.badgeTarget.classList.add(...classes.split(" "));
}
}

View file

@ -1,106 +0,0 @@
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Controller} from "@hotwired/stimulus";
import "tom-select/dist/css/tom-select.bootstrap5.css";
import '../../css/components/tom-select_extensions.css';
import TomSelect from "tom-select";
import TomSelect_click_to_edit from '../../tomselect/click_to_edit/click_to_edit'
import TomSelect_autoselect_typed from '../../tomselect/autoselect_typed/autoselect_typed'
TomSelect.define('click_to_edit', TomSelect_click_to_edit)
TomSelect.define('autoselect_typed', TomSelect_autoselect_typed)
/**
* This is the frontend controller for StaticFileAutocompleteType form element.
* Basically it loads a text file from the given url (via data-url) and uses it as a source for the autocomplete.
* The file is just a list of strings, one per line, which will be used as the autocomplete options.
* Lines starting with # will be ignored.
*/
export default class extends Controller {
_tomSelect;
connect() {
let settings = {
persistent: false,
create: true,
maxItems: 1,
maxOptions: 100,
createOnBlur: true,
selectOnTab: true,
valueField: 'text',
searchField: 'text',
orderField: 'text',
//This a an ugly solution to disable the delimiter parsing of the TomSelect plugin
delimiter: 'VERY_L0NG_D€LIMITER_WHICH_WILL_NEVER_BE_ENCOUNTERED_IN_A_STRING',
plugins: {
'autoselect_typed': {},
'click_to_edit': {},
'clear_button': {},
'restore_on_backspace': {}
}
};
if (this.element.dataset.url) {
const url = this.element.dataset.url;
settings.load = (query, callback) => {
const self = this;
if (self.loading > 1) {
callback();
return;
}
fetch(url)
.then(response => response.text())
.then(text => {
// Convert the text file to array
let lines = text.split("\n");
//Remove all lines beginning with #
lines = lines.filter(x => !x.startsWith("#"));
//Convert the array to an object, where each line is in the text field
lines = lines.map(x => {
return {text: x};
});
//Unset the load function to prevent endless recursion
self._tomSelect.settings.load = null;
callback(lines);
}).catch(() => {
callback();
});
};
}
this._tomSelect = new TomSelect(this.element, settings);
}
disconnect() {
super.disconnect();
//Destroy the TomSelect instance
this._tomSelect.destroy();
}
}

View file

@ -22,10 +22,6 @@ import '../../css/components/tom-select_extensions.css';
import TomSelect from "tom-select"; import TomSelect from "tom-select";
import {Controller} from "@hotwired/stimulus"; import {Controller} from "@hotwired/stimulus";
import {trans, ENTITY_SELECT_GROUP_NEW_NOT_ADDED_TO_DB} from '../../translator.js'
import TomSelect_autoselect_typed from '../../tomselect/autoselect_typed/autoselect_typed'
TomSelect.define('autoselect_typed', TomSelect_autoselect_typed)
export default class extends Controller { export default class extends Controller {
_tomSelect; _tomSelect;
@ -40,20 +36,12 @@ export default class extends Controller {
const allowAdd = this.element.getAttribute("data-allow-add") === "true"; const allowAdd = this.element.getAttribute("data-allow-add") === "true";
const addHint = this.element.getAttribute("data-add-hint") ?? ""; const addHint = this.element.getAttribute("data-add-hint") ?? "";
let settings = { let settings = {
allowEmptyOption: true, allowEmptyOption: true,
selectOnTab: true, selectOnTab: true,
maxOptions: null, maxOptions: null,
create: allowAdd ? this.createItem.bind(this) : false, create: allowAdd,
createFilter: this.createFilter.bind(this), createFilter: /\D/, //Must contain a non-digit character, otherwise they would be recognized as DB ID
// This three options allow us to paste element names with commas: (see issue #538)
maxItems: 1,
delimiter: "$$VERY_LONG_DELIMITER_THAT_SHOULD_NEVER_APPEAR$$",
splitOn: null,
searchField: [ searchField: [
{field: "text", weight : 2}, {field: "text", weight : 2},
@ -64,108 +52,15 @@ export default class extends Controller {
render: { render: {
item: this.renderItem.bind(this), item: this.renderItem.bind(this),
option: this.renderOption.bind(this), option: this.renderOption.bind(this),
option_create: (data, escape) => { option_create: function(data, escape) {
//If the input starts with "->", we prepend the current selected value, for easier extension of existing values
//This here handles the display part, while the createItem function handles the actual creation
if (data.input.startsWith("->")) {
//Get current selected value
const current = this._tomSelect.getItem(this._tomSelect.getValue()).textContent.replaceAll("→", "->").trim();
//Prepend it to the input
if (current) {
data.input = current + " " + data.input;
} else {
//If there is no current value, we remove the "->"
data.input = data.input.substring(2);
}
}
return '<div class="create"><i class="fa-solid fa-plus fa-fw"></i>&nbsp;<strong>' + escape(data.input) + '</strong>&hellip;&nbsp;' + return '<div class="create"><i class="fa-solid fa-plus fa-fw"></i>&nbsp;<strong>' + escape(data.input) + '</strong>&hellip;&nbsp;' +
'<small class="text-muted float-end">(' + addHint +')</small>' + '<small class="text-muted float-end">(' + addHint +')</small>' +
'</div>'; '</div>';
}, },
},
//Add callbacks to update validity
onInitialize: this.updateValidity.bind(this),
onChange: this.updateValidity.bind(this),
plugins: {
"autoselect_typed": {},
} }
}; };
//Add clear button plugin, if an empty option is present
if (this.element.querySelector("option[value='']") !== null) {
settings.plugins["clear_button"] = {};
}
this._tomSelect = new TomSelect(this.element, settings); this._tomSelect = new TomSelect(this.element, settings);
//Do not do a sync here as this breaks the initial rendering of the empty option
//this._tomSelect.sync();
}
createItem(input, callback) {
//If the input starts with "->", we prepend the current selected value, for easier extension of existing values
if (input.startsWith("->")) {
//Get current selected value
let current = this._tomSelect.getItem(this._tomSelect.getValue()).textContent.replaceAll("→", "->").trim();
//Replace no break spaces with normal spaces
current = current.replaceAll("\u00A0", " ");
//Prepend it to the input
if (current) {
input = current + " " + input;
} else {
//If there is no current value, we remove the "->"
input = input.substring(2);
}
}
callback({
//$%$ is a special value prefix, that is used to identify items, that are not yet in the DB
value: '$%$' + input,
text: input,
not_in_db_yet: true,
});
}
createFilter(input) {
//Normalize the input (replace spacing around arrows)
if (input.includes("->")) {
const inputs = input.split("->");
inputs.forEach((value, index) => {
inputs[index] = value.trim();
});
input = inputs.join("->");
} else {
input = input.trim();
}
const options = this._tomSelect.options;
//Iterate over all options and check if the input is already present
for (let index in options) {
const option = options[index];
if (option.path === input) {
return false;
}
}
return true;
}
updateValidity() {
//Mark this input as invalid, if the selected option is disabled
const input = this.element;
const selectedOption = input.options[input.selectedIndex];
if (selectedOption && selectedOption.disabled) {
input.setCustomValidity("This option was disabled. Please select another option.");
} else {
input.setCustomValidity("");
}
} }
getTomSelect() { getTomSelect() {
@ -183,27 +78,14 @@ export default class extends Controller {
} }
if (data.short) { if (data.short) {
let short = escape(data.short) return '<div><b>' + escape(data.short) + '</b></div>';
//Make text italic, if the item is not yet in the DB
if (data.not_in_db_yet) {
short = '<i>' + short + '</i>';
}
return '<div><b>' + short + '</b></div>';
} }
let name = ""; let name = "";
if (data.parent) { if (data.parent) {
name += escape(data.parent) + "&nbsp;→&nbsp;"; name += escape(data.parent) + "&nbsp;→&nbsp;";
} }
name += "<b>" + escape(data.text) + "</b>";
if (data.not_in_db_yet) {
//Not yet added items are shown italic and with a badge
name += "<i><b>" + escape(data.text) + "</b></i>" + "<span class='ms-3 badge bg-info badge-info'>" + trans(ENTITY_SELECT_GROUP_NEW_NOT_ADDED_TO_DB) + "</span>";
} else {
name += "<b>" + escape(data.text) + "</b>";
}
return '<div>' + (data.image ? "<img class='structural-entity-select-image' style='margin-right: 5px;' ' src='" + data.image + "'/>" : "") + name + '</div>'; return '<div>' + (data.image ? "<img class='structural-entity-select-image' style='margin-right: 5px;' ' src='" + data.image + "'/>" : "") + name + '</div>';
} }

View file

@ -23,21 +23,14 @@ import "tom-select/dist/css/tom-select.bootstrap5.css";
import '../../css/components/tom-select_extensions.css'; import '../../css/components/tom-select_extensions.css';
import TomSelect from "tom-select"; import TomSelect from "tom-select";
import TomSelect_click_to_edit from '../../tomselect/click_to_edit/click_to_edit'
import TomSelect_autoselect_typed from '../../tomselect/autoselect_typed/autoselect_typed'
TomSelect.define('click_to_edit', TomSelect_click_to_edit)
TomSelect.define('autoselect_typed', TomSelect_autoselect_typed)
export default class extends Controller { export default class extends Controller {
_tomSelect; _tomSelect;
connect() { connect() {
let settings = { let settings = {
plugins: { plugins: {
remove_button:{}, remove_button:{
'autoselect_typed': {}, }
'click_to_edit': {},
}, },
persistent: false, persistent: false,
selectOnTab: true, selectOnTab: true,

View file

@ -81,71 +81,31 @@ export default class extends Controller {
this._tree.remove(); this._tree.remove();
} }
const BS53Theme = {
getOptions() {
return {
onhoverColor: 'var(--bs-secondary-bg)',
};
}
}
this._tree = new BSTreeView(this.treeTarget, { this._tree = new BSTreeView(this.treeTarget, {
levels: 1, levels: 1,
showTags: this._showTags, showTags: this._showTags,
data: data, data: data,
showIcon: true, showIcon: true,
preventUnselect: true,
allowReselect: true,
onNodeSelected: (event) => { onNodeSelected: (event) => {
const node = event.detail.node; const node = event.detail.node;
if (node.href) { if (node.href) {
window.Turbo.visit(node.href, {action: "advance"}); window.Turbo.visit(node.href, {action: "advance"});
this._registerURLWatcher(node);
} }
}, },
}, [BS5Theme, BS53Theme, FAIconTheme]); //onNodeContextmenu: contextmenu_handler,
}, [BS5Theme, FAIconTheme]);
this.treeTarget.addEventListener(EVENT_INITIALIZED, (event) => { this.treeTarget.addEventListener(EVENT_INITIALIZED, (event) => {
/** @type {BSTreeView} */ /** @type {BSTreeView} */
const treeView = event.detail.treeView; const treeView = event.detail.treeView;
treeView.revealNode(treeView.getSelected()); treeView.revealNode(treeView.getSelected());
//Add the url watcher to all selected nodes
for (const node of treeView.getSelected()) {
this._registerURLWatcher(node);
}
//Add contextmenu event listener to the tree, which allows us to open the links in a new tab with a right click //Add contextmenu event listener to the tree, which allows us to open the links in a new tab with a right click
treeView.getTreeElement().addEventListener("contextmenu", this._onContextMenu.bind(this)); treeView.getTreeElement().addEventListener("contextmenu", this._onContextMenu.bind(this));
}); });
} }
_registerURLWatcher(node)
{
//Register a watcher for a location change, which will unselect the node, if the location changes
const desired_url = node.href;
//Ensure that the node is unselected, if the location changes
const unselectNode = () => {
//Parse url so we can properly compare them
const desired = new URL(node.href, window.location.origin);
//We only compare the pathname, because the hash and parameters should not matter
if(window.location.pathname !== desired.pathname) {
//The ignore parameter is important here, otherwise the node will not be unselected
node.setSelected(false, {silent: true, ignorePreventUnselect: true});
//Unregister the watcher
document.removeEventListener('turbo:load', unselectNode);
}
};
//Register the watcher via hotwire turbo
//We must just load to have the new url in window.location
document.addEventListener('turbo:load', unselectNode);
}
_onContextMenu(event) _onContextMenu(event)
{ {
//Find the node that was clicked and open link in new tab //Find the node that was clicked and open link in new tab

View file

@ -1,44 +0,0 @@
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Controller} from "@hotwired/stimulus";
export default class extends Controller {
static targets = [ "display", "select" ]
connect()
{
this.update();
this.selectTarget.addEventListener('change', this.update.bind(this));
}
update()
{
//If the select value is 0, then we show the input field
if( this.selectTarget.value === '0')
{
this.displayTarget.classList.remove('d-none');
}
else
{
this.displayTarget.classList.add('d-none');
}
}
}

View file

@ -20,7 +20,7 @@
import {Controller} from "@hotwired/stimulus"; import {Controller} from "@hotwired/stimulus";
//import * as ZXing from "@zxing/library"; //import * as ZXing from "@zxing/library";
import {Html5QrcodeScanner, Html5Qrcode} from "@part-db/html5-qrcode"; import {Html5QrcodeScanner, Html5Qrcode} from "html5-qrcode";
/* stimulusFetch: 'lazy' */ /* stimulusFetch: 'lazy' */
export default class extends Controller { export default class extends Controller {
@ -50,7 +50,7 @@ export default class extends Controller {
}); });
this._scanner = new Html5QrcodeScanner(this.element.id, { this._scanner = new Html5QrcodeScanner(this.element.id, {
fps: 10, fps: 2,
qrbox: qrboxFunction, qrbox: qrboxFunction,
experimentalFeatures: { experimentalFeatures: {
//This option improves reading quality on android chrome //This option improves reading quality on android chrome
@ -61,11 +61,6 @@ export default class extends Controller {
this._scanner.render(this.onScanSuccess.bind(this)); this._scanner.render(this.onScanSuccess.bind(this));
} }
disconnect() {
this._scanner.pause();
this._scanner.clear();
}
onScanSuccess(decodedText, decodedResult) { onScanSuccess(decodedText, decodedResult) {
//Put our decoded Text into the input box //Put our decoded Text into the input box
document.getElementById('scan_dialog_input').value = decodedText; document.getElementById('scan_dialog_input').value = decodedText;

View file

@ -1,65 +0,0 @@
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Controller} from "@hotwired/stimulus";
/**
* This controller is used on a checkbox, which toggles the max value of all number input fields
*/
export default class extends Controller {
_checkbox;
getCheckbox() {
if (this._checkbox) {
return this._checkbox;
}
//Find the checkbox inside the controller element
this._checkbox = this.element.querySelector('input[type="checkbox"]');
return this._checkbox;
}
connect() {
//Add event listener to the checkbox
this.getCheckbox().addEventListener('change', this.toggleInputLimits.bind(this));
}
toggleInputLimits() {
//Find all input fields with the data-toggle-input-limits-target="max"
const inputFields = document.querySelectorAll("input[type='number']");
inputFields.forEach((inputField) => {
//Ensure that the input field has either a max or a data-max attribute
if (!inputField.hasAttribute('max') && !inputField.hasAttribute('data-max')) {
return;
}
//If the checkbox is checked, rename the max attribute to data-max
if (this.getCheckbox().checked) {
inputField.setAttribute('data-max', inputField.getAttribute('max'));
inputField.removeAttribute('max');
} else {
//If the checkbox is not checked, rename the data-max attribute back to max
inputField.setAttribute('max', inputField.getAttribute('data-max'));
inputField.removeAttribute('data-max');
}
});
}
}

View file

@ -25,20 +25,9 @@ import "katex/dist/katex.css";
export default class extends Controller { export default class extends Controller {
static targets = ["input", "preview"]; static targets = ["input", "preview"];
static values = {
unit: {type: Boolean, default: false} //Render as upstanding (non-italic) text, useful for units
}
updatePreview() updatePreview()
{ {
let value = ""; katex.render(this.inputTarget.value, this.previewTarget, {
if (this.unitValue) {
value = "\\mathrm{" + this.inputTarget.value + "}";
} else {
value = this.inputTarget.value;
}
katex.render(value, this.previewTarget, {
throwOnError: false, throwOnError: false,
}); });
} }

View file

@ -22,13 +22,6 @@ import TomSelect from "tom-select";
import katex from "katex"; import katex from "katex";
import "katex/dist/katex.css"; import "katex/dist/katex.css";
import TomSelect_click_to_edit from '../../tomselect/click_to_edit/click_to_edit'
import TomSelect_autoselect_typed from '../../tomselect/autoselect_typed/autoselect_typed'
TomSelect.define('click_to_edit', TomSelect_click_to_edit)
TomSelect.define('autoselect_typed', TomSelect_autoselect_typed)
/* stimulusFetch: 'lazy' */ /* stimulusFetch: 'lazy' */
export default class extends Controller export default class extends Controller
{ {
@ -60,10 +53,7 @@ export default class extends Controller
connect() { connect() {
const settings = { const settings = {
plugins: { plugins: {
'autoselect_typed': {}, clear_button:{}
'click_to_edit': {},
'clear_button': {},
'restore_on_backspace': {}
}, },
persistent: false, persistent: false,
maxItems: 1, maxItems: 1,

View file

@ -1,68 +0,0 @@
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import {Controller} from "@hotwired/stimulus";
export default class extends Controller
{
static targets = ['link', 'mode', 'otherSelect'];
static values = {
targetId: Number,
};
connect() {
}
update() {
const link = this.linkTarget;
const other_select = this.otherSelectTarget;
//Extract the mode using the mode radio buttons (we filter the array to get the checked one)
const mode = (this.modeTargets.filter((e)=>e.checked))[0].value;
if (other_select.value === '') {
link.classList.add('disabled');
return;
}
//Extract href template from data attribute on link target
let href = link.getAttribute('data-href-template');
let target, other;
if (mode === '1') {
target = this.targetIdValue;
other = other_select.value;
} else if (mode === '2') {
target = other_select.value;
other = this.targetIdValue;
} else {
throw 'Invalid mode';
}
//Replace placeholder with actual target id
href = href.replace('__target__', target);
//Replace placeholder with selected value of the select (the event sender)
href = href.replace('__other__', other);
//Assign new href to link
link.setAttribute('href', href);
//Make link clickable
link.classList.remove('disabled');
}
}

View file

@ -1,8 +1,7 @@
<?php
/* /*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony). * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
* *
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics) * Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published * it under the terms of the GNU Affero General Public License as published
@ -18,13 +17,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
declare(strict_types=1); import {Controller} from "@hotwired/stimulus";
export default class extends Controller
namespace App\Repository\UserSystem;
use Doctrine\ORM\EntityRepository;
class ApiTokenRepository extends EntityRepository
{ {
connect() {
this.element.onclick = function() {
window.u2fauth.register();
}
}
} }

View file

@ -99,25 +99,10 @@ label:not(.form-check-label, .custom-control-label) {
form .col-form-label.required:after, form label.required:after { form .col-form-label.required:after, form label.required:after {
bottom: 4px; bottom: 4px;
color: var(--bs-secondary-color); color: var(--bs-dark);
content: "\2022"; content: "\2022";
filter: opacity(75%); filter: opacity(75%);
position: relative; position: relative;
right: -2px; right: -2px;
z-index: 700; z-index: 700;
} }
/****************************************
* HTML diff styling
****************************************/
/* Insertations are marked with green background and bold */
ins {
background-color: #95f095;
font-weight: bold;
}
del {
background-color: #f09595;
font-weight: bold;
}

View file

@ -1,11 +1,7 @@
<?php
declare(strict_types=1);
/* /*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony). * This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
* *
* Copyright (C) 2019 - 2023 Jan Böhmer (https://github.com/jbtronics) * Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published * it under the terms of the GNU Affero General Public License as published
@ -20,12 +16,17 @@ declare(strict_types=1);
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
namespace App\Entity\LabelSystem;
enum LabelProcessMode: string .darkmode-layer {
{ z-index: 2020;
/** Use placeholders like [[PLACEHOLDER]] which gets replaced with content */ }
case PLACEHOLDER = 'html';
/** Interpret the given lines as twig template */ /** If darkmode is enabled revert the blening for images and videos, as these should be shown not inverted */
case TWIG = 'twig'; .darkmode--activated img,
.darkmode--activated video {
mix-blend-mode: difference;
}
.darkmode--activated .hoverpic:hover {
background: black;
} }

View file

@ -67,6 +67,7 @@ ul.structural_link {
padding-bottom: 7px; padding-bottom: 7px;
padding-left: 0; padding-left: 0;
list-style: none; list-style: none;
background-color: inherit;
} }
/* Display list items side by side */ /* Display list items side by side */
@ -78,7 +79,7 @@ ul.structural_link li {
/* Add a slash symbol (/) before/behind each list item */ /* Add a slash symbol (/) before/behind each list item */
ul.structural_link li+li:before { ul.structural_link li+li:before {
padding: 2px; padding: 2px;
color: var(--bs-tertiary-color); color: grey;
/*content: "/\00a0";*/ /*content: "/\00a0";*/
font-family: "Font Awesome 5 Free"; font-family: "Font Awesome 5 Free";
font-weight: 900; font-weight: 900;
@ -88,13 +89,13 @@ ul.structural_link li+li:before {
/* Add a color to all links inside the list */ /* Add a color to all links inside the list */
ul.structural_link li a { ul.structural_link li a {
color: var(--bs-link-color); color: #0275d8;
text-decoration: none; text-decoration: none;
} }
/* Add a color on mouse-over */ /* Add a color on mouse-over */
ul.structural_link li a:hover { ul.structural_link li a:hover {
color: var(--bs-link-hover-color); color: #01447e;
text-decoration: underline; text-decoration: underline;
} }
@ -112,10 +113,3 @@ ul.structural_link li a:hover {
background-color: var(--bs-success); background-color: var(--bs-success);
border-color: var(--bs-success); border-color: var(--bs-success);
} }
/***********************************************
* Katex rendering with same height as text
***********************************************/
.katex-same-height-as-text .katex {
font-size: 1.0em;
}

View file

@ -47,17 +47,3 @@
max-width: 2.0em; max-width: 2.0em;
object-fit: contain; object-fit: contain;
} }
.part-table-image {
max-height: 40px;
object-fit: contain;
}
.part-info-image {
max-height: 350px;
object-fit: contain;
}
.object-fit-cover {
object-fit: cover;
}

View file

@ -78,6 +78,8 @@ body {
overflow: -moz-scrollbars-none; overflow: -moz-scrollbars-none;
/* Use standard version for hiding the scrollbar */ /* Use standard version for hiding the scrollbar */
scrollbar-width: none; scrollbar-width: none;
background-color: var(--light);
} }
#sidebar-container { #sidebar-container {
@ -108,8 +110,8 @@ body {
.back-to-top { .back-to-top {
cursor: pointer; cursor: pointer;
position: fixed; position: fixed;
bottom: 60px; bottom: 20px;
right: 40px; right: 20px;
display:none; display:none;
z-index: 1030; z-index: 1030;
} }

View file

@ -63,6 +63,10 @@ table.dataTable > tbody > tr.selected > td > a {
margin-block-end: 0; margin-block-end: 0;
} }
.card-footer-table {
padding-top: 0;
}
table.dataTable { table.dataTable {
margin-top: 0 !important; margin-top: 0 !important;
} }
@ -80,24 +84,13 @@ th.select-checkbox {
* Datatables definitions/overrides * Datatables definitions/overrides
********************************************************************/ ********************************************************************/
.dt-length { .dataTables_length {
display: inline-flex; display: inline-flex;
} }
/** Fix datatables select-checkbox position */ /** Fix datatables select-checkbox position */
table.dataTable tr.selected td.select-checkbox:after table.dataTable tr.selected td.select-checkbox:after, table.dataTable tr.selected th.select-checkbox:after {
{ margin-top: -28px !important;
margin-top: -20px !important;
}
/** Show pagination right aligned */
.dt-paging .pagination {
justify-content: flex-end;
}
/** Fix table row coloring */
table.table.dataTable > :not(caption) > * > * {
background-color: var(--bs-table-bg);
} }

File diff suppressed because it is too large Load diff

View file

@ -24,8 +24,9 @@
/** Should be the same settings, as in label_style.css */ /** Should be the same settings, as in label_style.css */
.ck-html-label .ck-content { .ck-html-label .ck-content {
font-family: "DejaVu Sans Mono", monospace; font-family: "DejaVu Sans Mono", monospace;
font-size: 12pt; font-size: 12px;
line-height: 1.0; line-height: 1.0;
font-size-adjust: 1.5;
} }
.ck-html-label .ck-content p { .ck-html-label .ck-content p {
@ -35,42 +36,3 @@
.ck-html-label .ck-content hr { .ck-html-label .ck-content hr {
margin: 2px; margin: 2px;
} }
/***********************************************
* Hide CKEditor powered by message
***********************************************/
.ck-powered-by {
display: none;
}
/***********************************************
* Use Bootstrap color vars for CKEditor
***********************************************/
:root {
--ck-color-base-foreground: var(--bs-secondary-bg);
--ck-color-base-background: var(--bs-body-bg);
--ck-color-base-border: var(--bs-border-color);
--ck-color-base-action: var(--bs-success);
--ck-color-base-focus: var(--bs-primary-border-subtle);
--ck-color-base-text: var(--bs-body-color);
--ck-color-base-active: var(--bs-primary-bg-subtle);
--ck-color-base-active-focus: var(--bs-primary);
--ck-color-base-error: var(--bs-danger);
/* Improve contrast between text and toolbar */
--ck-color-toolbar-background: var(--bs-tertiary-bg);
/* Buttons */
--ck-color-button-default-hover-background: var(--bs-secondary-bg);
--ck-color-button-default-active-background: var(--bs-secondary-bg);
--ck-color-button-on-background: var(--bs-body-bg);
--ck-color-button-on-hover-background: var(--bs-secondary-bg);
--ck-color-button-on-active-background: var(--bs-secondary-bg);
--ck-color-button-on-disabled-background: var(--bs-secondary-bg);
--ck-color-button-on-color: var(--bs-primary)
}

View file

@ -1,69 +0,0 @@
/******************************************************************************************
* This styles the checkboxes of the select extension exactly like the ones in bootstrap 5
******************************************************************************************/
table.dataTable > tbody > tr > .selected {
background-color: var(--bs-primary-bg-subtle) !important;
color: white;
}
table.dataTable > tbody > tr > .dt-select {
text-align: center;
vertical-align: middle;
}
table.dataTable > thead > tr > .dt-select {
text-align: center;
}
table.dataTable input.dt-select-checkbox {
--bs-form-check-bg: var(--bs-body-bg);
flex-shrink: 0;
width: 1em;
height: 1em;
margin-top: 0.25em;
vertical-align: top;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background-color: var(--bs-form-check-bg);
background-image: var(--bs-form-check-bg-image);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
border: var(--bs-border-width) solid var(--bs-border-color);
-webkit-print-color-adjust: exact;
color-adjust: exact;
print-color-adjust: exact;
border-radius: 0.25em;
}
table.dataTable input.dt-select-checkbox:checked {
background-color: rgb(var(--bs-secondary-rgb));
border-color: rgb(var(--bs-secondary-rgb));
--bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
}
table.dataTable input.dt-select-checkbox:indeterminate {
background-color: rgb(var(--bs-secondary-rgb));
border-color: rgb(var(--bs-secondary-rgb));
--bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/%3e%3c/svg%3e");
}
div.dt-container span.select-info,
div.dt-container span.select-item {
margin-left: 0.5em;
}
@media screen and (max-width: 640px) {
div.dt-container span.select-info,
div.dt-container span.select-item {
margin-left: 0;
display: block;
}
}
table.dataTable.table-sm tbody td.select-checkbox::before {
margin-top: -9px;
}

View file

@ -18,29 +18,6 @@
*/ */
.tagsinput.ts-wrapper.multi .ts-control > div { .tagsinput.ts-wrapper.multi .ts-control > div {
background: var(--bs-secondary-bg); background: var(--bs-secondary);
color: var(--bs-body-color); color: var(--bs-white);
}
/*********
* BS 5.3 compatible dark mode
***************/
.ts-dropdown .active {
background-color: var(--bs-secondary-bg) !important;
color: var(--bs-body-color) !important;
}
.ts-dropdown, .ts-control, .ts-control input {
color: var(--bs-body-color) !important;
}
.ts-dropdown, .ts-dropdown.form-control, .ts-dropdown.form-select {
background: var(--bs-body-bg);
}
.ts-dropdown .optgroup-header {
color: var(--bs-tertiary-color);
background: var(--bs-body-bg);
cursor: default;
} }

File diff suppressed because it is too large Load diff

View file

@ -1,3 +0,0 @@
# Ignore font files
*.otf
*.ttf

View file

@ -1 +0,0 @@
Put your font ttf files in this folder to make them available to the label generator.

View file

@ -22,6 +22,7 @@
import '../css/app/layout.css'; import '../css/app/layout.css';
import '../css/app/helpers.css'; import '../css/app/helpers.css';
import '../css/app/darkmode.css';
import '../css/app/tables.css'; import '../css/app/tables.css';
import '../css/app/bs-overrides.css'; import '../css/app/bs-overrides.css';
import '../css/app/treeview.css'; import '../css/app/treeview.css';
@ -44,18 +45,4 @@ import "./register_events";
import "./tristate_checkboxes"; import "./tristate_checkboxes";
//Define jquery globally //Define jquery globally
window.$ = window.jQuery = require("jquery"); window.$ = window.jQuery = require("jquery")
//Use the local WASM file for the ZXing library
import {
setZXingModuleOverrides,
} from "barcode-detector/pure";
import wasmFile from "../../node_modules/zxing-wasm/dist/reader/zxing_reader.wasm";
setZXingModuleOverrides({
locateFile: (path, prefix) => {
if (path.endsWith(".wasm")) {
return wasmFile;
}
return prefix + path;
},
});

View file

@ -27,67 +27,14 @@ class ErrorHandlerHelper {
constructor() { constructor() {
console.log('Error Handler registered'); console.log('Error Handler registered');
//const content = document.getElementById('content'); const content = document.getElementById('content');
//It seems that the content element is unreliable for these events, so we use the document instead content.addEventListener('turbo:before-fetch-response', (event) => this.handleError(event));
const content = document;
//content.addEventListener('turbo:before-fetch-response', (event) => this.handleError(event));
content.addEventListener('turbo:fetch-request-error', (event) => this.handleError(event));
content.addEventListener('turbo:frame-missing', (event) => this.handleError(event));
$(document).ajaxError(this.handleJqueryErrror.bind(this)); $(document).ajaxError(this.handleJqueryErrror.bind(this));
} }
_showAlert(statusText, statusCode, location, responseHTML) _showAlert(statusText, statusCode, location, responseHTML)
{ {
const httpStatusToText = {
'200': 'OK',
'201': 'Created',
'202': 'Accepted',
'203': 'Non-Authoritative Information',
'204': 'No Content',
'205': 'Reset Content',
'206': 'Partial Content',
'300': 'Multiple Choices',
'301': 'Moved Permanently',
'302': 'Found',
'303': 'See Other',
'304': 'Not Modified',
'305': 'Use Proxy',
'306': 'Unused',
'307': 'Temporary Redirect',
'400': 'Bad Request',
'401': 'Unauthorized',
'402': 'Payment Required',
'403': 'Forbidden',
'404': 'Not Found',
'405': 'Method Not Allowed',
'406': 'Not Acceptable',
'407': 'Proxy Authentication Required',
'408': 'Request Timeout',
'409': 'Conflict',
'410': 'Gone',
'411': 'Length Required',
'412': 'Precondition Required',
'413': 'Request Entry Too Large',
'414': 'Request-URI Too Long',
'415': 'Unsupported Media Type',
'416': 'Requested Range Not Satisfiable',
'417': 'Expectation Failed',
'418': 'I\'m a teapot',
'429': 'Too Many Requests',
'500': 'Internal Server Error',
'501': 'Not Implemented',
'502': 'Bad Gateway',
'503': 'Service Unavailable',
'504': 'Gateway Timeout',
'505': 'HTTP Version Not Supported',
};
//If the statusText is empty, we use the status code as text
if (!statusText) {
statusText = httpStatusToText[statusCode];
}
//Create error text //Create error text
const title = statusText + ' (Status ' + statusCode + ')'; const title = statusText + ' (Status ' + statusCode + ')';
@ -140,10 +87,8 @@ class ErrorHandlerHelper {
} }
handleError(event) { handleError(event) {
//Prevent default error handling const fetchResponse = event.detail.fetchResponse;
event.preventDefault(); const response = fetchResponse.response;
const response = event.detail.response;
//Ignore aborted requests. //Ignore aborted requests.
if (response.statusText === 'abort' || response.status == 0) { if (response.statusText === 'abort' || response.status == 0) {
@ -155,17 +100,11 @@ class ErrorHandlerHelper {
return; return;
} }
//Skip 404 errors, on admin pages (as this causes a popup on deletion in firefox) if(fetchResponse.failed) {
if (response.status == 404 && event.target.id === 'admin-content-frame') {
return;
}
if(!response.ok) {
response.text().then(responseHTML => { response.text().then(responseHTML => {
this._showAlert(response.statusText, response.status, response.url, responseHTML); this._showAlert(response.statusText, response.status, fetchResponse.location.toString(), responseHTML);
}).catch(err => { }).catch(err => {
this._showAlert(response.statusText, response.status, response.url, '<pre>' + err + '</pre>'); this._showAlert(response.statusText, response.status, fetchResponse.location.toString(), '<pre>' + err + '</pre>');
}); });
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -47,8 +47,7 @@
method: config.method, method: config.method,
data: { data: {
_dt: config.name, _dt: config.name,
_init: true, _init: true
order: config.initial_order ?? undefined,
} }
}).done(function(data) { }).done(function(data) {
var baseState; var baseState;
@ -73,17 +72,6 @@
} }
} else { } else {
request._dt = config.name; request._dt = config.name;
//Try to resolve the original column index when the column was reordered (using the ColReorder plugin)
//Only do this when _ColReorder_iOrigCol is available
if (settings.aoColumns && settings.aoColumns.length && settings.aoColumns[0]._ColReorder_iOrigCol !== undefined) {
if (request.order && request.order.length) {
request.order.forEach(function (order) {
order.column = settings.aoColumns[order.column]._ColReorder_iOrigCol;
});
}
}
$.ajax(typeof config.url === 'function' ? config.url(dt) : config.url, { $.ajax(typeof config.url === 'function' ? config.url(dt) : config.url, {
method: config.method, method: config.method,
data: request data: request
@ -98,15 +86,6 @@
dtOpts = config.options(dtOpts); dtOpts = config.options(dtOpts);
} }
//Choose the column where the className contains "select-column" and apply the select extension to its render field
//Added for Part-DB
for (let column of dtOpts.columns) {
if (column.className && column.className.includes('dt-select')) {
column.render = $.fn.dataTable.render.select();
}
}
root.html(data.template); root.html(data.template);
dt = $('table', root).DataTable(dtOpts); dt = $('table', root).DataTable(dtOpts);
if (config.state !== 'none') { if (config.state !== 'none') {

View file

@ -20,8 +20,6 @@
'use strict'; 'use strict';
import {Dropdown} from "bootstrap"; import {Dropdown} from "bootstrap";
import ClipboardJS from "clipboard";
import {Modal} from "bootstrap";
class RegisterEventHelper { class RegisterEventHelper {
constructor() { constructor() {
@ -29,14 +27,7 @@ class RegisterEventHelper {
this.configureDropdowns(); this.configureDropdowns();
this.registerSpecialCharInput(); this.registerSpecialCharInput();
//Initialize ClipboardJS
this.registerLoadHandler(() => {
new ClipboardJS('.btn');
});
this.registerModalDropRemovalOnFormSubmit(); this.registerModalDropRemovalOnFormSubmit();
} }
registerModalDropRemovalOnFormSubmit() { registerModalDropRemovalOnFormSubmit() {
@ -46,15 +37,6 @@ class RegisterEventHelper {
if (back_drop) { if (back_drop) {
back_drop.remove(); back_drop.remove();
} }
//Remove scroll-lock if it is still active
if (document.body.classList.contains('modal-open')) {
document.body.classList.remove('modal-open');
//Remove the padding-right and overflow:hidden from the body
document.body.style.paddingRight = '';
document.body.style.overflow = '';
}
}); });
} }
@ -77,239 +59,76 @@ class RegisterEventHelper {
} }
registerTooltips() { registerTooltips() {
const handler = () => { this.registerLoadHandler(() => {
$(".tooltip").remove(); $(".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.) //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.)
$('a[title], label[title], button[title]:not([data-bs-toggle="dropdown"]), p[title], span[title], h6[title], h3[title], i[title], small[title]') $('a[title], button[title]:not([data-bs-toggle="dropdown"]), p[title], span[title], h6[title], h3[title], i.fas[title]')
//@ts-ignore //@ts-ignore
.tooltip("hide").tooltip({container: "body", placement: "auto", boundary: 'window'}); .tooltip("hide").tooltip({container: "body", placement: "auto", boundary: 'window'});
}; });
this.registerLoadHandler(handler);
document.addEventListener('dt:loaded', handler);
} }
registerSpecialCharInput() { registerSpecialCharInput() {
this.registerLoadHandler(() => { this.registerLoadHandler(() => {
//@ts-ignore //@ts-ignore
$("input[type=text], input[type=search]").unbind("keydown").keydown(function (event) { $("input[type=text], input[type=search]").unbind("keydown").keydown(function (event) {
let use_special_char = event.altKey; let greek = event.altKey;
let greek_char = ""; let greek_char = "";
if (use_special_char){ if (greek){
//Use the key property to determine the greek letter (as it is independent of the keyboard layout)
switch(event.key) { switch(event.key) {
//Greek letters case "w": //Omega
case "a": //Alpha (lowercase) greek_char = '\u2126';
greek_char = "\u03B1";
break; break;
case "A": //Alpha (uppercase) case "u":
greek_char = "\u0391"; case "m": //Micro
greek_char = "\u00B5";
break; break;
case "b": //Beta (lowercase) case "p": //Phi
greek_char = "\u03B2";
break;
case "B": //Beta (uppercase)
greek_char = "\u0392";
break;
case "g": //Gamma (lowercase)
greek_char = "\u03B3";
break;
case "G": //Gamma (uppercase)
greek_char = "\u0393";
break;
case "d": //Delta (lowercase)
greek_char = "\u03B4";
break;
case "D": //Delta (uppercase)
greek_char = "\u0394";
break;
case "e": //Epsilon (lowercase)
greek_char = "\u03B5";
break;
case "E": //Epsilon (uppercase)
greek_char = "\u0395";
break;
case "z": //Zeta (lowercase)
greek_char = "\u03B6";
break;
case "Z": //Zeta (uppercase)
greek_char = "\u0396";
break;
case "h": //Eta (lowercase)
greek_char = "\u03B7";
break;
case "H": //Eta (uppercase)
greek_char = "\u0397";
break;
case "q": //Theta (lowercase)
greek_char = "\u03B8";
break;
case "Q": //Theta (uppercase)
greek_char = "\u0398";
break;
case "i": //Iota (lowercase)
greek_char = "\u03B9";
break;
case "I": //Iota (uppercase)
greek_char = "\u0399";
break;
case "k": //Kappa (lowercase)
greek_char = "\u03BA";
break;
case "K": //Kappa (uppercase)
greek_char = "\u039A";
break;
case "l": //Lambda (lowercase)
greek_char = "\u03BB";
break;
case "L": //Lambda (uppercase)
greek_char = "\u039B";
break;
case "m": //Mu (lowercase)
greek_char = "\u03BC";
break;
case "M": //Mu (uppercase)
greek_char = "\u039C";
break;
case "n": //Nu (lowercase)
greek_char = "\u03BD";
break;
case "N": //Nu (uppercase)
greek_char = "\u039D";
break;
case "x": //Xi (lowercase)
greek_char = "\u03BE";
break;
case "X": //Xi (uppercase)
greek_char = "\u039E";
break;
case "o": //Omicron (lowercase)
greek_char = "\u03BF";
break;
case "O": //Omicron (uppercase)
greek_char = "\u039F";
break;
case "p": //Pi (lowercase)
greek_char = "\u03C0";
break;
case "P": //Pi (uppercase)
greek_char = "\u03A0";
break;
case "r": //Rho (lowercase)
greek_char = "\u03C1";
break;
case "R": //Rho (uppercase)
greek_char = "\u03A1";
break;
case "s": //Sigma (lowercase)
greek_char = "\u03C3";
break;
case "S": //Sigma (uppercase)
greek_char = "\u03A3";
break;
case "t": //Tau (lowercase)
greek_char = "\u03C4";
break;
case "T": //Tau (uppercase)
greek_char = "\u03A4";
break;
case "u": //Upsilon (lowercase)
greek_char = "\u03C5";
break;
case "U": //Upsilon (uppercase)
greek_char = "\u03A5";
break;
case "f": //Phi (lowercase)
greek_char = "\u03C6"; greek_char = "\u03C6";
break; break;
case "F": //Phi (uppercase) case "a": //Alpha
greek_char = "\u03A6"; greek_char = "\u03B1";
break; break;
case "c": //Chi (lowercase) case "b": //Beta
greek_char = "\u03C7"; greek_char = "\u03B2";
break; break;
case "C": //Chi (uppercase) case "c": //Gamma
greek_char = "\u03A7"; greek_char = "\u03B3";
break; break;
case "y": //Psi (lowercase) case "d": //Delta
greek_char = "\u03C8"; greek_char = "\u03B4";
break; break;
case "Y": //Psi (uppercase) case "l": //Pound
greek_char = "\u03A8"; greek_char = "\u00A3";
break; break;
case "w": //Omega (lowercase) case "y": //Yen
greek_char = "\u03C9"; greek_char = "\u00A5";
break; break;
case "W": //Omega (uppercase) case "o": //Yen
greek_char = "\u03A9"; greek_char = "\u00A4";
break; break;
} case "1": //Sum symbol
greek_char = "\u2211";
//Use keycodes for special characters as the shift char on the number keys are layout dependent
switch (event.keyCode) {
case 49: //1 key
//Product symbol on shift, sum on no shift
greek_char = event.shiftKey ? "\u220F" : "\u2211";
break; break;
case 50: //2 key case "2": //Integral
//Integral on no shift, partial derivative on shift greek_char = "\u222B";
greek_char = event.shiftKey ? "\u2202" : "\u222B";
break; break;
case 51: //3 key case "3": //Less-than or equal
//Less than or equal on no shift, greater than or equal on shift greek_char = "\u2264";
greek_char = event.shiftKey ? "\u2265" : "\u2264";
break; break;
case 52: //4 key case "4": //Greater than or equal
//Empty set on shift, infinity on no shift greek_char = "\u2265";
greek_char = event.shiftKey ? "\u2205" : "\u221E";
break; break;
case 53: //5 key case "5": //PI
//Not equal on shift, approx equal on no shift greek_char = "\u03c0";
greek_char = event.shiftKey ? "\u2260" : "\u2248";
break; break;
case 54: //6 key case "q": //Copyright
//Element of on no shift, not element of on shift greek_char = "\u00A9";
greek_char = event.shiftKey ? "\u2209" : "\u2208";
break; break;
case 55: //7 key case "e": //Euro
//And on shift, or on no shift greek_char = "\u20AC";
greek_char = event.shiftKey ? "\u2227" : "\u2228";
break; break;
case 56: //8 key
//Proportional to on shift, angle on no shift
greek_char = event.shiftKey ? "\u221D" : "\u2220";
break;
case 57: //9 key
//Cube root on shift, square root on no shift
greek_char = event.shiftKey ? "\u221B" : "\u221A";
break;
case 48: //0 key
//Minus-Plus on shift, plus-minus on no shift
greek_char = event.shiftKey ? "\u2213" : "\u00B1";
break;
//Special characters
case 219: //hyphen (or ß on german layout)
//Copyright on no shift, TM on shift
greek_char = event.shiftKey ? "\u2122" : "\u00A9";
break;
case 191: //forward slash (or # on german layout)
//Generic currency on no shift, paragraph on shift
greek_char = event.shiftKey ? "\u00B6" : "\u00A4";
break;
//Currency symbols
case 192: //: or (ö on german layout)
//Euro on no shift, pound on shift
greek_char = event.shiftKey ? "\u00A3" : "\u20AC";
break;
case 221: //; or (ä on german layout)
//Yen on no shift, dollar on shift
greek_char = event.shiftKey ? "\u0024" : "\u00A5";
break;
} }
if(greek_char=="") return; if(greek_char=="") return;

View file

@ -19,7 +19,7 @@
"use strict"; "use strict";
import {Tab, Dropdown, Collapse} from "bootstrap"; import {Tab} from "bootstrap";
import tab from "bootstrap/js/src/tab"; import tab from "bootstrap/js/src/tab";
/** /**
@ -54,7 +54,6 @@ class TabRememberHelper {
const first_element = merged[0] ?? null; const first_element = merged[0] ?? null;
if(first_element) { if(first_element) {
this.revealElementOnTab(first_element); this.revealElementOnTab(first_element);
this.revealElementInCollapse(first_element);
} }
} }
@ -63,27 +62,7 @@ class TabRememberHelper {
* @param event * @param event
*/ */
onInvalid(event) { onInvalid(event) {
this.revealElementInCollapse(event.target);
this.revealElementOnTab(event.target); this.revealElementOnTab(event.target);
this.revealElementInDropdown(event.target);
}
revealElementInCollapse(element) {
let collapse = element.closest('.collapse');
if(collapse) {
let bs_collapse = Collapse.getOrCreateInstance(collapse);
bs_collapse.show();
}
}
revealElementInDropdown(element) {
let dropdown = element.closest('.dropdown-menu');
if(dropdown) {
let bs_dropdown = Dropdown.getOrCreateInstance(dropdown);
bs_dropdown.show();
}
} }
revealElementOnTab(element) { revealElementOnTab(element) {

View file

@ -21,13 +21,8 @@
class WebauthnTFA { class WebauthnTFA {
_b64UrlSafeEncode = (str) => { // Decodes a Base64Url string
const b64 = btoa(str); _base64UrlDecode = (input) => {
return b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
}
// Decodes a Base64Url string
_b64UrlSafeDecode = (input) => {
input = input input = input
.replace(/-/g, '+') .replace(/-/g, '+')
.replace(/_/g, '/'); .replace(/_/g, '/');
@ -44,16 +39,13 @@ class WebauthnTFA {
}; };
// Converts an array of bytes into a Base64Url string // Converts an array of bytes into a Base64Url string
_arrayToBase64String = (a) => { _arrayToBase64String = (a) => btoa(String.fromCharCode(...a));
const str = String.fromCharCode(...a);
return this._b64UrlSafeEncode(str);
}
// Prepares the public key options object returned by the Webauthn Framework // Prepares the public key options object returned by the Webauthn Framework
_preparePublicKeyOptions = publicKey => { _preparePublicKeyOptions = publicKey => {
//Convert challenge from Base64Url string to Uint8Array //Convert challenge from Base64Url string to Uint8Array
publicKey.challenge = Uint8Array.from( publicKey.challenge = Uint8Array.from(
this._b64UrlSafeDecode(publicKey.challenge), this._base64UrlDecode(publicKey.challenge),
c => c.charCodeAt(0) c => c.charCodeAt(0)
); );
@ -75,7 +67,7 @@ class WebauthnTFA {
return { return {
...data, ...data,
id: Uint8Array.from( id: Uint8Array.from(
this._b64UrlSafeDecode(data.id), this._base64UrlDecode(data.id),
c => c.charCodeAt(0) c => c.charCodeAt(0)
), ),
}; };
@ -89,7 +81,7 @@ class WebauthnTFA {
return { return {
...data, ...data,
id: Uint8Array.from( id: Uint8Array.from(
this._b64UrlSafeDecode(data.id), this._base64UrlDecode(data.id),
c => c.charCodeAt(0) c => c.charCodeAt(0)
), ),
}; };

View file

@ -1,63 +0,0 @@
/**
* Autoselect Typed plugin for Tomselect
*
* This plugin allows automatically selecting an option matching the typed text when the Tomselect element goes out of
* focus (is blurred) and/or when the delimiter is typed.
*
* #select_on_blur option
* Tomselect natively supports the "createOnBlur" option. This option picks up any remaining text in the input field
* and uses it to create a new option and selects that option. It does behave a bit strangely though, in that it will
* not select an already existing option when the input is blurred, so if you typed something that matches an option in
* the list and then click outside the box (without pressing enter) the entered text is just removed (unless you have
* allow duplicates on in which case it will create a new option).
* This plugin fixes that, such that Tomselect will first try to select an option matching the remaining uncommitted
* text and only when no matching option is found tries to create a new one (if createOnBlur and create is on)
*
* #select_on_delimiter option
* Normally when typing the delimiter (space by default) Tomselect will try to create a new option (and select it) (if
* create is on), but if the typed text matches an option (and allow duplicates is off) it refuses to react at all until
* you press enter. With this option, the delimiter will also allow selecting an option, not just creating it.
*/
function select_current_input(self){
if(self.isLocked){
return
}
const val = self.inputValue()
//Do nothing if the input is empty
if (!val) {
return
}
if (self.options[val]) {
self.addItem(val)
self.setTextboxValue()
}
}
export default function(plugin_options_) {
const plugin_options = Object.assign({
//Autoselect the typed text when the input element goes out of focus
select_on_blur: true,
//Autoselect the typed text when the delimiter is typed
select_on_delimiter: true,
}, plugin_options_);
const self = this
if(plugin_options.select_on_blur) {
this.hook("before", "onBlur", function () {
select_current_input(self)
})
}
if(plugin_options.select_on_delimiter) {
this.hook("before", "onKeyPress", function (e) {
const character = String.fromCharCode(e.keyCode || e.which);
if (self.settings.mode === 'multi' && character === self.settings.delimiter) {
select_current_input(self)
}
})
}
}

View file

@ -1,93 +0,0 @@
/**
* click_to_edit plugin for Tomselect
*
* This plugin allows editing (and selecting text in) any selected item by clicking it.
*
* Usually, when the user typed some text and created an item in Tomselect that item cannot be edited anymore. To make
* a change, the item has to be deleted and retyped completely. There is also generally no way to copy text out of a
* tomselect item. The "restore_on_backspace" plugin improves that somewhat, by allowing the user to edit an item after
* pressing backspace. However, it is somewhat confusing to first have to focus the field an then hit backspace in order
* to copy a piece of text. It may also not be immediately obvious for editing.
* This plugin transforms an item into editable text when it is clicked, e.g. when the user tries to place the caret
* within an item or when they try to drag across the text to highlight it.
* It also plays nice with the remove_button plugin which still removes (deselects) an option entirely.
*
* It is recommended to also enable the autoselect_typed plugin when using this plugin. Without it, the text in the
* input field (i.e. the item that was just clicked) is lost when the user clicks outside the field. Also, when the user
* clicks an option (making it text) and then tries to enter another one by entering the delimiter (e.g. space) nothing
* happens until enter is pressed or the text is changed from what it was.
*/
/**
* Return a dom element from either a dom query string, jQuery object, a dom element or html string
* https://stackoverflow.com/questions/494143/creating-a-new-dom-element-from-an-html-string-using-built-in-dom-methods-or-pro/35385518#35385518
*
* param query should be {}
*/
const getDom = query => {
if (query.jquery) {
return query[0];
}
if (query instanceof HTMLElement) {
return query;
}
if (isHtmlString(query)) {
var tpl = document.createElement('template');
tpl.innerHTML = query.trim(); // Never return a text node of whitespace as the result
return tpl.content.firstChild;
}
return document.querySelector(query);
};
const isHtmlString = arg => {
if (typeof arg === 'string' && arg.indexOf('<') > -1) {
return true;
}
return false;
};
function plugin(plugin_options_) {
const self = this
const plugin_options = Object.assign({
//If there is unsubmitted text in the input field, should that text be automatically used to select a matching
//element? If this is off, clicking on item1 and then clicking on item2 will result in item1 being deselected
auto_select_before_edit: true,
//If there is unsubmitted text in the input field, should that text be automatically used to create a matching
//element if no matching element was found or auto_select_before_edit is off?
auto_create_before_edit: true,
//customize this function to change which text the item is replaced with when clicking on it
text: option => {
return option[self.settings.labelField];
}
}, plugin_options_);
self.hook('after', 'setupTemplates', () => {
const orig_render_item = self.settings.render.item;
self.settings.render.item = (data, escape) => {
const item = getDom(orig_render_item.call(self, data, escape));
item.addEventListener('click', evt => {
if (self.isLocked) {
return;
}
const val = self.inputValue();
if (self.options[val]) {
self.addItem(val)
} else if (self.settings.create) {
self.createItem();
}
const option = self.options[item.dataset.value]
self.setTextboxValue(plugin_options.text.call(self, option));
self.focus();
self.removeItem(item);
}
);
return item;
}
});
}
export { plugin as default };

View file

@ -1,16 +0,0 @@
import { localeFallbacks } from '../var/translations/configuration';
import { trans, getLocale, setLocale, setLocaleFallbacks } from '@symfony/ux-translator';
/*
* This file is part of the Symfony UX Translator package.
*
* If folder "../var/translations" does not exist, or some translations are missing,
* you must warmup your Symfony cache to refresh JavaScript translations.
*
* If you use TypeScript, you can rename this file to "translator.ts" to take advantage of types checking.
*/
setLocaleFallbacks(localeFallbacks);
export { trans };
export * from '../var/translations';

View file

@ -4,17 +4,6 @@
use App\Kernel; use App\Kernel;
use Symfony\Bundle\FrameworkBundle\Console\Application; use Symfony\Bundle\FrameworkBundle\Console\Application;
if (!is_dir(dirname(__DIR__).'/vendor')) {
throw new LogicException('Dependencies are missing. Try running "composer install".');
}
//Increase xdebug.max_nesting_level to 1000 if required (see issue #411)
//Check if xdebug extension is active, and xdebug.max_nesting_level is set to 256 or lower
if (extension_loaded('xdebug') && ((int) ini_get('xdebug.max_nesting_level')) <= 256) {
//Increase xdebug.max_nesting_level to 1000
ini_set('xdebug.max_nesting_level', '1000');
}
if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) { if (!is_file(dirname(__DIR__).'/vendor/autoload_runtime.php')) {
throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".'); throw new LogicException('Symfony Runtime is missing. Try running "composer require symfony/runtime".');
} }

View file

@ -6,13 +6,9 @@ if (!ini_get('date.timezone')) {
} }
if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) { if (is_file(dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit')) {
if (PHP_VERSION_ID >= 80000) { define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require dirname(__DIR__).'/vendor/phpunit/phpunit/phpunit'; require PHPUNIT_COMPOSER_INSTALL;
} else { PHPUnit\TextUI\Command::main();
define('PHPUNIT_COMPOSER_INSTALL', dirname(__DIR__).'/vendor/autoload.php');
require PHPUNIT_COMPOSER_INSTALL;
PHPUnit\TextUI\Command::main();
}
} else { } else {
if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) { if (!is_file(dirname(__DIR__).'/vendor/symfony/phpunit-bridge/bin/simple-phpunit.php')) {
echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n"; echo "Unable to find the `simple-phpunit.php` script in `vendor/symfony/phpunit-bridge/bin/`.\n";

View file

@ -5,5 +5,4 @@ coverage:
status: status:
project: project:
default: default:
threshold: 10% threshold: 5%
target: 40%

View file

@ -1,118 +1,101 @@
{ {
"name": "part-db/part-db-server",
"type": "project", "type": "project",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"require": { "require": {
"php": "^8.1", "php": "^7.4 || ^8.0",
"ext-ctype": "*", "ext-ctype": "*",
"ext-dom": "*",
"ext-gd": "*", "ext-gd": "*",
"ext-iconv": "*", "ext-iconv": "*",
"ext-intl": "*", "ext-intl": "*",
"ext-json": "*", "ext-json": "*",
"ext-mbstring": "*", "ext-mbstring": "*",
"amphp/http-client": "^5.1",
"api-platform/core": "^3.1",
"beberlei/doctrineextensions": "^1.2", "beberlei/doctrineextensions": "^1.2",
"brick/math": "0.12.1 as 0.11.0", "brick/math": "^0.8.15",
"composer/ca-bundle": "^1.5", "composer/package-versions-deprecated": "1.11.99.4",
"composer/package-versions-deprecated": "^1.11.99.5", "doctrine/annotations": "^1.6",
"doctrine/data-fixtures": "^2.0.0", "doctrine/dbal": "^3.4.6",
"doctrine/dbal": "^4.0.0",
"doctrine/doctrine-bundle": "^2.0", "doctrine/doctrine-bundle": "^2.0",
"doctrine/doctrine-migrations-bundle": "^3.0", "doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^3.2.0", "doctrine/orm": "^2.9",
"dompdf/dompdf": "^v3.0.0", "dompdf/dompdf": "^2.0.0",
"erusev/parsedown": "^1.7", "erusev/parsedown": "^1.7",
"florianv/swap": "^4.0", "florianv/swap": "^4.0",
"florianv/swap-bundle": "dev-master", "florianv/swap-bundle": "dev-master",
"gregwar/captcha-bundle": "^2.1.0", "gregwar/captcha-bundle": "^2.1.0",
"hshn/base64-encoded-file": "^5.0", "jbtronics/2fa-webauthn": "^1.0.0",
"jbtronics/2fa-webauthn": "^v2.2.0",
"jbtronics/dompdf-font-loader-bundle": "^1.0.0",
"jfcherng/php-diff": "^6.14",
"knpuniversity/oauth2-client-bundle": "^2.15",
"league/csv": "^9.8.0",
"league/html-to-markdown": "^5.0.1", "league/html-to-markdown": "^5.0.1",
"liip/imagine-bundle": "^2.2", "liip/imagine-bundle": "^2.2",
"nbgrp/onelogin-saml-bundle": "^1.3",
"nelexa/zip": "^4.0", "nelexa/zip": "^4.0",
"nelmio/cors-bundle": "^2.3",
"nelmio/security-bundle": "^3.0", "nelmio/security-bundle": "^3.0",
"nyholm/psr7": "^1.1", "nyholm/psr7": "^1.1",
"omines/datatables-bundle": "^0.9.1", "ocramius/proxy-manager": "2.2.*",
"paragonie/sodium_compat": "^1.21", "omines/datatables-bundle": "^0.5.0",
"part-db/label-fonts": "^1.0", "php-translation/symfony-bundle": "^0.12.0",
"rhukster/dom-sanitizer": "^1.0", "phpdocumentor/reflection-docblock": "^5.2",
"runtime/frankenphp-symfony": "^0.2.0",
"s9e/text-formatter": "^2.1", "s9e/text-formatter": "^2.1",
"scheb/2fa-backup-code": "^6.8.0", "scheb/2fa-backup-code": "^5.13",
"scheb/2fa-bundle": "^6.8.0", "scheb/2fa-bundle": "^5.13",
"scheb/2fa-google-authenticator": "^6.8.0", "scheb/2fa-google-authenticator": "^5.13",
"scheb/2fa-trusted-device": "^6.8.0", "scheb/2fa-trusted-device": "^5.13",
"sensio/framework-extra-bundle": "^6.1.1",
"shivas/versioning-bundle": "^4.0", "shivas/versioning-bundle": "^4.0",
"spatie/db-dumper": "^3.3.1", "spatie/db-dumper": "^2.21",
"symfony/apache-pack": "^1.0", "symfony/apache-pack": "^1.0",
"symfony/asset": "6.4.*", "symfony/asset": "5.4.*",
"symfony/console": "6.4.*", "symfony/console": "5.4.*",
"symfony/css-selector": "6.4.*", "symfony/dotenv": "5.4.*",
"symfony/dom-crawler": "6.4.*", "symfony/expression-language": "5.4.*",
"symfony/dotenv": "6.4.*", "symfony/flex": "^1.1",
"symfony/expression-language": "6.4.*", "symfony/form": "5.4.*",
"symfony/flex": "^v2.3.1", "symfony/framework-bundle": "5.4.*",
"symfony/form": "6.4.*", "symfony/http-client": "5.4.*",
"symfony/framework-bundle": "6.4.*", "symfony/http-kernel": "5.4.*",
"symfony/http-client": "6.4.*", "symfony/mailer": "5.4.*",
"symfony/http-kernel": "6.4.*",
"symfony/mailer": "6.4.*",
"symfony/monolog-bundle": "^3.1", "symfony/monolog-bundle": "^3.1",
"symfony/polyfill-php82": "^1.28", "symfony/process": "5.4.*",
"symfony/process": "6.4.*", "symfony/property-access": "5.4.*",
"symfony/property-access": "6.4.*", "symfony/property-info": "5.4.*",
"symfony/property-info": "6.4.*", "symfony/proxy-manager-bridge": "5.4.*",
"symfony/rate-limiter": "6.4.*", "symfony/rate-limiter": "5.4.*",
"symfony/runtime": "6.4.*", "symfony/runtime": "5.4.*",
"symfony/security-bundle": "6.4.*", "symfony/security-bundle": "5.4.*",
"symfony/serializer": "6.4.*", "symfony/serializer": "5.4.*",
"symfony/string": "6.4.*", "symfony/translation": "5.4.*",
"symfony/translation": "6.4.*", "symfony/twig-bundle": "5.4.*",
"symfony/twig-bundle": "6.4.*",
"symfony/ux-translator": "^2.10",
"symfony/ux-turbo": "^2.0", "symfony/ux-turbo": "^2.0",
"symfony/validator": "6.4.*", "symfony/validator": "5.4.*",
"symfony/web-link": "6.4.*", "symfony/web-link": "5.4.*",
"symfony/webpack-encore-bundle": "^v2.0.1", "symfony/webpack-encore-bundle": "^1.1",
"symfony/yaml": "6.4.*", "symfony/yaml": "5.4.*",
"tecnickcom/tc-lib-barcode": "^2.1.4", "tecnickcom/tc-lib-barcode": "^1.15",
"twig/cssinliner-extra": "^3.0", "twig/cssinliner-extra": "^3.0",
"twig/extra-bundle": "^3.8", "twig/extra-bundle": "^3.0",
"twig/html-extra": "^3.8", "twig/html-extra": "^3.0",
"twig/inky-extra": "^3.0", "twig/inky-extra": "^3.0",
"twig/intl-extra": "^3.8", "twig/intl-extra": "^3.0",
"twig/markdown-extra": "^3.8", "twig/markdown-extra": "^3.0",
"twig/string-extra": "^3.8", "web-auth/webauthn-symfony-bundle": "^3.3",
"web-auth/webauthn-symfony-bundle": "^4.0.0" "webmozart/assert": "^1.4"
}, },
"require-dev": { "require-dev": {
"dama/doctrine-test-bundle": "^v8.0.0", "dama/doctrine-test-bundle": "^7.0",
"doctrine/doctrine-fixtures-bundle": "^4.0.0", "doctrine/doctrine-fixtures-bundle": "^3.2",
"ekino/phpstan-banned-code": "^v3.0.0", "ekino/phpstan-banned-code": "^v1.0.0",
"jbtronics/translation-editor-bundle": "^1.0",
"phpstan/extension-installer": "^1.0", "phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^2.0.4", "phpstan/phpstan": "^1.4.7",
"phpstan/phpstan-doctrine": "^2.0.1", "phpstan/phpstan-doctrine": "^1.2.11",
"phpstan/phpstan-strict-rules": "^2.0.1", "phpstan/phpstan-symfony": "^1.1.7",
"phpstan/phpstan-symfony": "^2.0.0", "psalm/plugin-symfony": "^v5.0.1",
"phpunit/phpunit": "^9.5",
"rector/rector": "^2.0.4",
"roave/security-advisories": "dev-latest", "roave/security-advisories": "dev-latest",
"symfony/browser-kit": "6.4.*", "symfony/browser-kit": "^5.2",
"symfony/debug-bundle": "6.4.*", "symfony/css-selector": "^5.2",
"symfony/debug-bundle": "^5.2",
"symfony/maker-bundle": "^1.13", "symfony/maker-bundle": "^1.13",
"symfony/phpunit-bridge": "6.4.*", "symfony/phpunit-bridge": "5.4.*",
"symfony/stopwatch": "6.4.*", "symfony/stopwatch": "^5.2",
"symfony/web-profiler-bundle": "6.4.*", "symfony/web-profiler-bundle": "^5.2",
"symplify/easy-coding-standard": "^12.0" "symplify/easy-coding-standard": "^11.0",
"vimeo/psalm": "^5.6.0"
}, },
"suggest": { "suggest": {
"ext-bcmath": "Used to improve price calculation performance", "ext-bcmath": "Used to improve price calculation performance",
@ -123,7 +106,7 @@
"*": "dist" "*": "dist"
}, },
"platform": { "platform": {
"php": "8.1.0" "php": "7.4.0"
}, },
"sort-packages": true, "sort-packages": true,
"allow-plugins": { "allow-plugins": {
@ -155,7 +138,7 @@
"post-update-cmd": [ "post-update-cmd": [
"@auto-scripts" "@auto-scripts"
], ],
"phpstan": "vendor/bin/phpstan analyse src --level 5 --memory-limit 1G" "phpstan": "vendor/bin/phpstan analyse src --level 2 --memory-limit 1G"
}, },
"conflict": { "conflict": {
"symfony/symfony": "*" "symfony/symfony": "*"
@ -163,8 +146,9 @@
"extra": { "extra": {
"symfony": { "symfony": {
"allow-contrib": false, "allow-contrib": false,
"require": "6.4.*", "require": "5.4.*"
"docker": true
} }
} },
"repositories": [
]
} }

14131
composer.lock generated

File diff suppressed because it is too large Load diff

23
config/bootstrap.php Normal file
View file

@ -0,0 +1,23 @@
<?php
use Symfony\Component\Dotenv\Dotenv;
require dirname(__DIR__).'/vendor/autoload.php';
if (!class_exists(Dotenv::class)) {
throw new LogicException('Please run "composer require symfony/dotenv" to load the ".env" files configuring the application.');
}
// Load cached env vars if the .env.local.php file exists
// Run "composer dump-env prod" to create it (requires symfony/flex >=1.2)
if (is_array($env = @include dirname(__DIR__).'/.env.local.php') && (!isset($env['APP_ENV']) || ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? $env['APP_ENV']) === $env['APP_ENV'])) {
(new Dotenv(false))->populate($env);
} else {
// load all the .env files
(new Dotenv(false))->loadEnv(dirname(__DIR__).'/.env');
}
$_SERVER += $_ENV;
$_SERVER['APP_ENV'] = $_ENV['APP_ENV'] = ($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? null) ?: 'dev';
$_SERVER['APP_DEBUG'] = $_SERVER['APP_DEBUG'] ?? $_ENV['APP_DEBUG'] ?? 'prod' !== $_SERVER['APP_ENV'];
$_SERVER['APP_DEBUG'] = $_ENV['APP_DEBUG'] = (int) $_SERVER['APP_DEBUG'] || filter_var($_SERVER['APP_DEBUG'], FILTER_VALIDATE_BOOLEAN) ? '1' : '0';

View file

@ -2,6 +2,7 @@
return [ return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true], Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true], Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
@ -18,18 +19,12 @@ return [
DAMA\DoctrineTestBundle\DAMADoctrineTestBundle::class => ['test' => true], DAMA\DoctrineTestBundle\DAMADoctrineTestBundle::class => ['test' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true], Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Gregwar\CaptchaBundle\GregwarCaptchaBundle::class => ['all' => true], Gregwar\CaptchaBundle\GregwarCaptchaBundle::class => ['all' => true],
Translation\Bundle\TranslationBundle::class => ['all' => true],
Florianv\SwapBundle\FlorianvSwapBundle::class => ['all' => true], Florianv\SwapBundle\FlorianvSwapBundle::class => ['all' => true],
Nelmio\SecurityBundle\NelmioSecurityBundle::class => ['all' => true], Nelmio\SecurityBundle\NelmioSecurityBundle::class => ['all' => true],
Symfony\UX\Turbo\TurboBundle::class => ['all' => true], Symfony\UX\Turbo\TurboBundle::class => ['all' => true],
Jbtronics\TFAWebauthn\TFAWebauthnBundle::class => ['all' => true], Jbtronics\TFAWebauthn\TFAWebauthnBundle::class => ['all' => true],
Scheb\TwoFactorBundle\SchebTwoFactorBundle::class => ['all' => true], Scheb\TwoFactorBundle\SchebTwoFactorBundle::class => ['all' => true],
SpomkyLabs\CborBundle\SpomkyLabsCborBundle::class => ['all' => true],
Webauthn\Bundle\WebauthnBundle::class => ['all' => true], Webauthn\Bundle\WebauthnBundle::class => ['all' => true],
Nbgrp\OneloginSamlBundle\NbgrpOneloginSamlBundle::class => ['all' => true],
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
Symfony\UX\Translator\UxTranslatorBundle::class => ['all' => true],
Jbtronics\DompdfFontLoaderBundle\DompdfFontLoaderBundle::class => ['all' => true],
KnpU\OAuth2ClientBundle\KnpUOAuth2ClientBundle::class => ['all' => true],
Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true],
ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Jbtronics\TranslationEditorBundle\JbtronicsTranslationEditorBundle::class => ['dev' => true],
]; ];

View file

@ -1,41 +0,0 @@
api_platform:
title: 'Part-DB API'
description: 'API of Part-DB'
version: '0.1.0'
formats:
jsonld: ['application/ld+json']
json: ['application/json']
jsonapi: ['application/vnd.api+json']
docs_formats:
jsonld: ['application/ld+json']
jsonopenapi: ['application/vnd.openapi+json']
html: ['text/html']
json: ['application/vnd.openapi+json']
swagger:
api_keys:
# overridden in OpenApiFactoryDecorator
access_token:
name: Authorization
type: header
defaults:
# TODO: Change this to true later. In the moment it is false, because we use the session in somewhere
stateless: false
cache_headers:
vary: ['Content-Type', 'Authorization', 'Origin']
extra_properties:
standard_put: true
rfc_7807_compliant_errors: true
pagination_client_items_per_page: true # Allow clients to override the default items per page
keep_legacy_inflector: false
# Need to be true, or some tests will fail
use_symfony_listeners: true
serializer:
# Change this to false later, to remove the hydra prefix on the API
hydra_prefix: true

View file

@ -20,6 +20,3 @@ framework:
tree.cache: tree.cache:
adapter: cache.app adapter: cache.app
tags: true tags: true
info_provider.cache:
adapter: cache.app

View file

@ -1,5 +0,0 @@
when@test:
dama_doctrine_test:
enable_static_connection: true
enable_static_meta_data_cache: true
enable_static_query_cache: true

View file

@ -8,14 +8,15 @@ datatables:
# Set options, as documented at https://datatables.net/reference/option/ # Set options, as documented at https://datatables.net/reference/option/
options: options:
lengthMenu : [[10, 25, 50, 100], [10, 25, 50, 100]] # We add the "All" option, when part tables are generated lengthMenu : [[10, 25, 50, 100, -1], [10, 25, 50, 100, "All"]]
pageLength: '%partdb.table.default_page_size%' # Set to -1 to disable pagination (i.e. show all rows) by default pageLength: 50
dom: " <'row' <'col mb-2 input-group flex-nowrap' B l > <'col-auto mb-2' < p >>> #dom: "<'row' <'col-sm-12' tr>><'row' <'col-sm-6'l><'col-sm-6 text-right'pif>>"
<'card' dom: " <'row'<'col mb-2 input-group' B l> <'col mb-2' <'pull-end' p>>>
rt <'card'
<'card-footer card-footer-table text-muted' i > rt
> <'card-footer card-footer-table text-muted' i >
<'row' <'col mt-2 input-group flex-nowrap' B l > <'col-auto mt-2' < p >>>" >
<'row'<'col mt-2 input-group' B l> <'col mt-2' <'pull-right' p>>>"
pagingType: 'simple_numbers' pagingType: 'simple_numbers'
searching: true searching: true
stateSave: true stateSave: true

View file

@ -0,0 +1,5 @@
translation:
symfony_profiler:
enabled: true
webui:
enabled: true

View file

@ -2,32 +2,16 @@ doctrine:
dbal: dbal:
url: '%env(resolve:DATABASE_URL)%' url: '%env(resolve:DATABASE_URL)%'
# Required for DAMA doctrine test bundle
use_savepoints: true
# IMPORTANT: You MUST configure your server version, # IMPORTANT: You MUST configure your server version,
# either here or in the DATABASE_URL env var (see .env file) # either here or in the DATABASE_URL env var (see .env file)
types: types:
# UTC datetimes
datetime: datetime:
class: App\Doctrine\Types\UTCDateTimeType class: App\Doctrine\Types\UTCDateTimeType
date: date:
class: App\Doctrine\Types\UTCDateTimeType class: App\Doctrine\Types\UTCDateTimeType
datetime_immutable:
class: App\Doctrine\Types\UTCDateTimeImmutableType
date_immutable:
class: App\Doctrine\Types\UTCDateTimeImmutableType
big_decimal: big_decimal:
class: App\Doctrine\Types\BigDecimalType class: App\Doctrine\Types\BigDecimalType
tinyint:
class: App\Doctrine\Types\TinyIntType
# This was removed in doctrine/orm 4.0 but we need it for the WebauthnKey entity
array:
class: App\Doctrine\Types\ArrayType
schema_filter: ~^(?!internal)~ schema_filter: ~^(?!internal)~
# Only enable this when needed # Only enable this when needed
@ -35,29 +19,20 @@ doctrine:
orm: orm:
auto_generate_proxy_classes: true auto_generate_proxy_classes: true
enable_lazy_ghost_objects: true
report_fields_where_declared: true
validate_xml_mapping: true
naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware
auto_mapping: true auto_mapping: true
controller_resolver:
auto_mapping: true
mappings: mappings:
App: App:
type: attribute
is_bundle: false is_bundle: false
type: annotation
dir: '%kernel.project_dir%/src/Entity' dir: '%kernel.project_dir%/src/Entity'
prefix: 'App\Entity' prefix: 'App\Entity'
alias: App alias: App
dql: dql:
string_functions: string_functions:
regexp: App\Doctrine\Functions\Regexp regexp: DoctrineExtensions\Query\Mysql\Regexp
field: DoctrineExtensions\Query\Mysql\Field ifnull: DoctrineExtensions\Query\Mysql\IfNull
field2: App\Doctrine\Functions\Field2
natsort: App\Doctrine\Functions\Natsort
array_position: App\Doctrine\Functions\ArrayPosition
ilike: App\Doctrine\Functions\ILike
when@test: when@test:
doctrine: doctrine:

View file

@ -1,11 +0,0 @@
dompdf_font_loader:
auto_install: true
fonts:
unifont:
normal: "%kernel.project_dir%/vendor/part-db/label-fonts/fonts/unifont.ttf"
# Enable autodiscovery of fonts, so that font installation is much easier
autodiscovery:
paths:
- "%kernel.project_dir%/assets/fonts/dompdf"

View file

@ -2,13 +2,8 @@
framework: framework:
secret: '%env(APP_SECRET)%' secret: '%env(APP_SECRET)%'
csrf_protection: true csrf_protection: true
annotations: false
handle_all_throwables: true
# We set this header by ourselves, so we can disable it here # Must be set to true, to enable the change of HTTP methhod via _method parameter, otherwise our delete routines does not work anymore
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) # TODO: Rework delete routines to work without _method parameter as it is not recommended anymore (see https://github.com/symfony/symfony/issues/45278)
http_method_override: true http_method_override: true
@ -27,12 +22,16 @@ framework:
handler_id: null handler_id: null
cookie_secure: auto cookie_secure: auto
cookie_samesite: lax cookie_samesite: lax
storage_factory_id: session.storage.factory.native
#esi: true #esi: true
#fragments: true #fragments: true
php_errors: php_errors:
log: true log: true
form:
legacy_error_messages: false # Enable to use the new Form component validation messages
when@test: when@test:
framework: framework:
test: true test: true

View file

@ -1,5 +0,0 @@
framework:
http_client:
default_options:
headers:
'User-Agent': 'Part-DB'

View file

@ -1,10 +0,0 @@
services:
Psr\Http\Message\RequestFactoryInterface: '@http_discovery.psr17_factory'
Psr\Http\Message\ResponseFactoryInterface: '@http_discovery.psr17_factory'
Psr\Http\Message\ServerRequestFactoryInterface: '@http_discovery.psr17_factory'
Psr\Http\Message\StreamFactoryInterface: '@http_discovery.psr17_factory'
Psr\Http\Message\UploadedFileFactoryInterface: '@http_discovery.psr17_factory'
Psr\Http\Message\UriFactoryInterface: '@http_discovery.psr17_factory'
http_discovery.psr17_factory:
class: Http\Discovery\Psr17Factory

Some files were not shown because too many files have changed in this diff Show more