Modular logistics and supply chain operating system (LSOS)
JavaScript driver-appfleet-managementfreight-managementinfrastructureinventory-managementlast-mile-deliverylogisticsondemandopen-sourceorder-managementroute-optimizationsupply-chain-managementtracking-and-monitoringtransport-management-systemtransportationwarehouse-management
feat(console): ship inline SVG placeholders as the default resource images
Ronald A. Richardson323e5f051784
diff --git a/console/config/environment.js b/console/config/environment.jsindex 52ed8919..8a7b0b44 100644--- a/console/config/environment.js+++ b/console/config/environment.js@@ -3,6 +3,7 @@ const toBoolean = require('./utils/to-boolean');const getenv = require('./utils/getenv');const fixApiHost = require('./utils/fix-api-host');const asArray = require('./utils/as-array');+const inlinePlaceholder = require('./utils/inline-placeholder');const { version } = require('../package');module.exports = function (environment) {@@ -52,12 +53,15 @@ module.exports = function (environment) {categoryImage: getenv('DEFAULT_CATEGORY_IMAGE', 'https://flb-assets.s3.ap-southeast-1.amazonaws.com/images/fallback-placeholder-1.png'),placeholderImage: getenv('DEFAULT_PLACEHOLDER_IMAGE', 'https://flb-assets.s3.ap-southeast-1.amazonaws.com/static/image-file-icon.png'),placeholderImageOld: getenv('DEFAULT_PLACEHOLDER_IMAGE_OLD', 'https://flb-assets.s3.ap-southeast-1.amazonaws.com/images/fallback-placeholder-2.png'),- driverImage: getenv('DEFAULT_DRIVER_IMAGE', 'https://s3.ap-southeast-1.amazonaws.com/flb-assets/static/no-avatar.png'),- userImage: getenv('DEFAULT_USER_IMAGE', 'https://s3.ap-southeast-1.amazonaws.com/flb-assets/static/no-avatar.png'),- contactImage: getenv('DEFAULT_CONTACT_IMAGE', 'https://s3.ap-southeast-1.amazonaws.com/flb-assets/static/no-avatar.png'),+ driverImage: getenv('DEFAULT_DRIVER_IMAGE', inlinePlaceholder('driver')),+ userImage: getenv('DEFAULT_USER_IMAGE', inlinePlaceholder('contact')),+ contactImage: getenv('DEFAULT_CONTACT_IMAGE', inlinePlaceholder('contact')),+ customerImage: getenv('DEFAULT_CUSTOMER_IMAGE', inlinePlaceholder('customer')),entityImage: getenv('DEFAULT_ENTITY_IMAGE', 'https://flb-assets.s3-ap-southeast-1.amazonaws.com/static/parcels/medium.png'),- vendorImage: getenv('DEFAULT_VENDOR_IMAGE', 'https://s3.ap-southeast-1.amazonaws.com/flb-assets/static/no-avatar.png'),- vehicleImage: getenv('DEFAULT_VEHICLE_IMAGE', 'https://s3.ap-southeast-1.amazonaws.com/flb-assets/static/vehicle-placeholder.png'),+ vendorImage: getenv('DEFAULT_VENDOR_IMAGE', inlinePlaceholder('vendor')),+ vehicleImage: getenv('DEFAULT_VEHICLE_IMAGE', inlinePlaceholder('vehicle')),+ trailerImage: getenv('DEFAULT_TRAILER_IMAGE', inlinePlaceholder('trailer')),+ fleetImage: getenv('DEFAULT_FLEET_IMAGE', inlinePlaceholder('fleet')),vehicleAvatar: getenv('DEFAULT_VEHICLE_AVATAR', 'https://flb-assets.s3-ap-southeast-1.amazonaws.com/static/vehicle-icons/mini_bus.svg'),driverAvatar: getenv('DEFAULT_DRIVER_AVATAR', 'https://flb-assets.s3-ap-southeast-1.amazonaws.com/static/driver-icons/moto-driver.png'),placeAvatar: getenv('DEFAULT_PLACE_AVATAR', 'https://flb-assets.s3-ap-southeast-1.amazonaws.com/static/place-icons/basic-building.png'),diff --git a/console/config/placeholders/contact.svg b/console/config/placeholders/contact.svgnew file mode 100644index 00000000..60871264--- /dev/null+++ b/console/config/placeholders/contact.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 480" width="640" height="480"><g stroke-linejoin="round" stroke-linecap="round"><path d="M110 480c0-96 76-166 210-166s210 70 210 166z" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><path d="M270 322l50 54 50-54" fill="none" stroke="#d9d9d9" stroke-width="8"/><circle cx="320" cy="188" r="96" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/></g></svg>\ No newline at end of filediff --git a/console/config/placeholders/customer.svg b/console/config/placeholders/customer.svgnew file mode 100644index 00000000..c94c8a76--- /dev/null+++ b/console/config/placeholders/customer.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 480" width="640" height="480"><g stroke-linejoin="round" stroke-linecap="round"><path d="M110 480c0-96 76-166 210-166s210 70 210 166z" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><path d="M270 322l50 54 50-54" fill="none" stroke="#d9d9d9" stroke-width="8"/><circle cx="320" cy="188" r="96" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><circle cx="490" cy="392" r="60" fill="#8f8f8f" stroke="#dedede" stroke-width="10"/><path d="M458 394l22 22 44-48" fill="none" stroke="#d9d9d9" stroke-width="14"/></g></svg>\ No newline at end of filediff --git a/console/config/placeholders/driver.svg b/console/config/placeholders/driver.svgnew file mode 100644index 00000000..f890e4de--- /dev/null+++ b/console/config/placeholders/driver.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 480" width="640" height="480"><g stroke-linejoin="round" stroke-linecap="round"><path d="M110 480c0-96 76-166 210-166s210 70 210 166z" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><path d="M270 322l50 54 50-54" fill="none" stroke="#d9d9d9" stroke-width="8"/><circle cx="320" cy="204" r="92" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><path d="M230 186c0-62 42-96 90-96s90 34 90 96z" fill="#a9a9a9" stroke="#dedede" stroke-width="10"/><path d="M320 96v88" stroke="#dedede" stroke-width="6"/><circle cx="320" cy="92" r="9" fill="#a9a9a9" stroke="#dedede" stroke-width="6"/><path d="M222 186h190c66 0 96 10 96 22s-30 22-96 22H222z" fill="#a9a9a9" stroke="#dedede" stroke-width="8"/></g></svg>\ No newline at end of filediff --git a/console/config/placeholders/fleet.svg b/console/config/placeholders/fleet.svgnew file mode 100644index 00000000..50e5b9b6--- /dev/null+++ b/console/config/placeholders/fleet.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 480" width="640" height="480"><g stroke-linejoin="round" stroke-linecap="round"><g transform="translate(150 -40) scale(0.72)" opacity="0.45"><rect x="216" y="132" width="350" height="192" rx="14" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><rect x="236" y="154" width="310" height="148" rx="8" fill="#c9c9c9"/><path d="M256 182h270M256 230h270M256 278h270" stroke="#bdbdbd" stroke-width="6"/><path d="M216 324V190H96c-12 0-22 8-26 20L60 244v80z" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><path d="M104 206h88v52H84z" fill="#d9d9d9"/><rect x="60" y="324" width="506" height="18" rx="6" fill="#a9a9a9"/><rect x="56" y="292" width="18" height="30" rx="5" fill="#d9d9d9"/><circle cx="150" cy="366" r="40" fill="#8f8f8f" stroke="#dedede" stroke-width="8"/><circle cx="150" cy="366" r="16" fill="#d9d9d9"/><circle cx="470" cy="366" r="40" fill="#8f8f8f" stroke="#dedede" stroke-width="8"/><circle cx="470" cy="366" r="16" fill="#d9d9d9"/></g><g transform="translate(80 10) scale(0.8)" opacity="0.7"><rect x="216" y="132" width="350" height="192" rx="14" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><rect x="236" y="154" width="310" height="148" rx="8" fill="#c9c9c9"/><path d="M256 182h270M256 230h270M256 278h270" stroke="#bdbdbd" stroke-width="6"/><path d="M216 324V190H96c-12 0-22 8-26 20L60 244v80z" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><path d="M104 206h88v52H84z" fill="#d9d9d9"/><rect x="60" y="324" width="506" height="18" rx="6" fill="#a9a9a9"/><rect x="56" y="292" width="18" height="30" rx="5" fill="#d9d9d9"/><circle cx="150" cy="366" r="40" fill="#8f8f8f" stroke="#dedede" stroke-width="8"/><circle cx="150" cy="366" r="16" fill="#d9d9d9"/><circle cx="470" cy="366" r="40" fill="#8f8f8f" stroke="#dedede" stroke-width="8"/><circle cx="470" cy="366" r="16" fill="#d9d9d9"/></g><g transform="translate(0 60) scale(0.88)" opacity="1.0"><rect x="216" y="132" width="350" height="192" rx="14" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><rect x="236" y="154" width="310" height="148" rx="8" fill="#c9c9c9"/><path d="M256 182h270M256 230h270M256 278h270" stroke="#bdbdbd" stroke-width="6"/><path d="M216 324V190H96c-12 0-22 8-26 20L60 244v80z" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><path d="M104 206h88v52H84z" fill="#d9d9d9"/><rect x="60" y="324" width="506" height="18" rx="6" fill="#a9a9a9"/><rect x="56" y="292" width="18" height="30" rx="5" fill="#d9d9d9"/><circle cx="150" cy="366" r="40" fill="#8f8f8f" stroke="#dedede" stroke-width="8"/><circle cx="150" cy="366" r="16" fill="#d9d9d9"/><circle cx="470" cy="366" r="40" fill="#8f8f8f" stroke="#dedede" stroke-width="8"/><circle cx="470" cy="366" r="16" fill="#d9d9d9"/></g></g></svg>\ No newline at end of filediff --git a/console/config/placeholders/trailer.svg b/console/config/placeholders/trailer.svgnew file mode 100644index 00000000..4b95c0de--- /dev/null+++ b/console/config/placeholders/trailer.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 480" width="640" height="480"><g stroke-linejoin="round" stroke-linecap="round"><rect x="88" y="128" width="470" height="196" rx="16" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><rect x="108" y="150" width="430" height="152" rx="8" fill="#c9c9c9"/><path d="M128 178h390M128 226h390M128 274h390" stroke="#bdbdbd" stroke-width="6"/><rect x="522" y="146" width="10" height="160" rx="4" fill="#b0b0b0"/><rect x="88" y="324" width="470" height="18" rx="6" fill="#a9a9a9"/><rect x="156" y="342" width="14" height="52" rx="4" fill="#a9a9a9"/><rect x="146" y="392" width="34" height="10" rx="4" fill="#a9a9a9"/><rect x="88" y="342" width="52" height="16" rx="6" fill="#a9a9a9"/><circle cx="412" cy="366" r="40" fill="#8f8f8f" stroke="#dedede" stroke-width="8"/><circle cx="412" cy="366" r="16" fill="#d9d9d9"/><circle cx="500" cy="366" r="40" fill="#8f8f8f" stroke="#dedede" stroke-width="8"/><circle cx="500" cy="366" r="16" fill="#d9d9d9"/></g></svg>\ No newline at end of filediff --git a/console/config/placeholders/vehicle.svg b/console/config/placeholders/vehicle.svgnew file mode 100644index 00000000..35546ff1--- /dev/null+++ b/console/config/placeholders/vehicle.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 480" width="640" height="480"><g stroke-linejoin="round" stroke-linecap="round"><g transform="translate(0 0) scale(1.0)" opacity="1.0"><rect x="216" y="132" width="350" height="192" rx="14" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><rect x="236" y="154" width="310" height="148" rx="8" fill="#c9c9c9"/><path d="M256 182h270M256 230h270M256 278h270" stroke="#bdbdbd" stroke-width="6"/><path d="M216 324V190H96c-12 0-22 8-26 20L60 244v80z" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><path d="M104 206h88v52H84z" fill="#d9d9d9"/><rect x="60" y="324" width="506" height="18" rx="6" fill="#a9a9a9"/><rect x="56" y="292" width="18" height="30" rx="5" fill="#d9d9d9"/><circle cx="150" cy="366" r="40" fill="#8f8f8f" stroke="#dedede" stroke-width="8"/><circle cx="150" cy="366" r="16" fill="#d9d9d9"/><circle cx="470" cy="366" r="40" fill="#8f8f8f" stroke="#dedede" stroke-width="8"/><circle cx="470" cy="366" r="16" fill="#d9d9d9"/></g></g></svg>\ No newline at end of filediff --git a/console/config/placeholders/vendor.svg b/console/config/placeholders/vendor.svgnew file mode 100644index 00000000..ac4f6045--- /dev/null+++ b/console/config/placeholders/vendor.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 480" width="640" height="480"><g stroke-linejoin="round" stroke-linecap="round"><path d="M72 200L320 96l248 104v24H72z" fill="#a9a9a9" stroke="#dedede" stroke-width="10"/><rect x="100" y="222" width="440" height="190" rx="8" fill="#bdbdbd" stroke="#dedede" stroke-width="10"/><rect x="272" y="292" width="96" height="120" rx="6" fill="#8f8f8f" stroke="#dedede" stroke-width="8"/><rect x="140" y="262" width="88" height="66" rx="6" fill="#d9d9d9"/><rect x="412" y="262" width="88" height="66" rx="6" fill="#d9d9d9"/><path d="M184 262v66M140 295h88M456 262v66M412 295h88" stroke="#bdbdbd" stroke-width="6"/><rect x="60" y="412" width="520" height="16" rx="6" fill="#a9a9a9"/></g></svg>\ No newline at end of filediff --git a/console/config/utils/inline-placeholder.js b/console/config/utils/inline-placeholder.jsnew file mode 100644index 00000000..4ffbd8db--- /dev/null+++ b/console/config/utils/inline-placeholder.js@@ -0,0 +1,15 @@+'use strict';+const fs = require('fs');+const path = require('path');++/**+ * Reads one of the flat silhouettes in `config/placeholders` and returns it as an inline+ * SVG data URI, so the console's default resource images ship with the build instead of+ * depending on a hosted asset. Each `DEFAULT_*_IMAGE` env var still overrides the result.+ */+module.exports = function inlinePlaceholder(name) {+ const file = path.join(__dirname, '..', 'placeholders', `${name}.svg`);+ const svg = fs.readFileSync(file, 'utf8').trim();++ return `data:image/svg+xml;base64,${Buffer.from(svg, 'utf8').toString('base64')}`;+};