| | |
| | | "react-dom": "^18.3.0", |
| | | "react-hook-form": "^7.53.0", |
| | | "react-router-dom": "^6.26.1", |
| | | "react-syntax-highlighter": "^15.5.0", |
| | | "three": "^0.155.0", |
| | | "tweedle.js": "^2.1.0" |
| | | }, |
| | |
| | | "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", |
| | | "dev": true |
| | | }, |
| | | "node_modules/@types/hast": { |
| | | "version": "2.3.10", |
| | | "resolved": "https://registry.npmmirror.com/@types/hast/-/hast-2.3.10.tgz", |
| | | "integrity": "sha512-McWspRw8xx8J9HurkVBfYj0xKoE25tOFlHGdx4MJ5xORQrMGZNqJhVQWaIbm6Oyla5kYOXtDiopzKRJzEOkwJw==", |
| | | "dependencies": { |
| | | "@types/unist": "^2" |
| | | } |
| | | }, |
| | | "node_modules/@types/hoist-non-react-statics": { |
| | | "version": "3.3.5", |
| | | "resolved": "https://registry.npmmirror.com/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.5.tgz", |
| | |
| | | "resolved": "https://registry.npmmirror.com/@types/semver/-/semver-7.5.8.tgz", |
| | | "integrity": "sha512-I8EUhyrgfLrcTkzV3TSsGyl1tSuPrEDzr0yd5m90UgNxQkyDXULk3b6MlQqTCpZpNtWe1K0hzclnZkTcLBe2UQ==", |
| | | "dev": true |
| | | }, |
| | | "node_modules/@types/unist": { |
| | | "version": "2.0.11", |
| | | "resolved": "https://registry.npmmirror.com/@types/unist/-/unist-2.0.11.tgz", |
| | | "integrity": "sha512-CmBKiL6NNo/OqgmMn95Fk9Whlp2mtvIv+KNpQKN2F4SjvrEesubTRWGYSg+BnWZOnlCaSTU1sMpsBOzgbYhnsA==" |
| | | }, |
| | | "node_modules/@types/use-sync-external-store": { |
| | | "version": "0.0.3", |
| | |
| | | "node": ">=4" |
| | | } |
| | | }, |
| | | "node_modules/character-entities": { |
| | | "version": "1.2.4", |
| | | "resolved": "https://registry.npmmirror.com/character-entities/-/character-entities-1.2.4.tgz", |
| | | "integrity": "sha512-iBMyeEHxfVnIakwOuDXpVkc54HijNgCyQB2w0VfGQThle6NXn50zU6V/u+LDhxHcDUPojn6Kpga3PTAD8W1bQw==", |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/character-entities-legacy": { |
| | | "version": "1.1.4", |
| | | "resolved": "https://registry.npmmirror.com/character-entities-legacy/-/character-entities-legacy-1.1.4.tgz", |
| | | "integrity": "sha512-3Xnr+7ZFS1uxeiUDvV02wQ+QDbc55o97tIV5zHScSPJpcLm/r0DFPcoY3tYRp+VZukxuMeKgXYmsXQHO05zQeA==", |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/character-reference-invalid": { |
| | | "version": "1.1.4", |
| | | "resolved": "https://registry.npmmirror.com/character-reference-invalid/-/character-reference-invalid-1.1.4.tgz", |
| | | "integrity": "sha512-mKKUkUbhPpQlCOfIuZkvSEgktjPFIsZKRRbC6KWVEMvlzblj3i3asQv5ODsrwt0N3pHAEvjP8KTQPHkp0+6jOg==", |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/clsx": { |
| | | "version": "2.1.1", |
| | | "resolved": "https://registry.npmmirror.com/clsx/-/clsx-2.1.1.tgz", |
| | |
| | | }, |
| | | "engines": { |
| | | "node": ">= 0.8" |
| | | } |
| | | }, |
| | | "node_modules/comma-separated-tokens": { |
| | | "version": "1.0.8", |
| | | "resolved": "https://registry.npmmirror.com/comma-separated-tokens/-/comma-separated-tokens-1.0.8.tgz", |
| | | "integrity": "sha512-GHuDRO12Sypu2cV70d1dkA2EUmXHgntrzbpvOB+Qy+49ypNfGgFQIC2fhhXbnyrJRynDCAARsT7Ou0M6hirpfw==", |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/concat-map": { |
| | |
| | | "reusify": "^1.0.4" |
| | | } |
| | | }, |
| | | "node_modules/fault": { |
| | | "version": "1.0.4", |
| | | "resolved": "https://registry.npmmirror.com/fault/-/fault-1.0.4.tgz", |
| | | "integrity": "sha512-CJ0HCB5tL5fYTEA7ToAq5+kTwd++Borf1/bifxd9iT70QcXr4MRrO3Llf8Ifs70q+SJcGHFtnIE/Nw6giCtECA==", |
| | | "dependencies": { |
| | | "format": "^0.2.0" |
| | | }, |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/file-entry-cache": { |
| | | "version": "6.0.1", |
| | | "resolved": "https://registry.npmmirror.com/file-entry-cache/-/file-entry-cache-6.0.1.tgz", |
| | |
| | | }, |
| | | "engines": { |
| | | "node": ">= 6" |
| | | } |
| | | }, |
| | | "node_modules/format": { |
| | | "version": "0.2.2", |
| | | "resolved": "https://registry.npmmirror.com/format/-/format-0.2.2.tgz", |
| | | "integrity": "sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww==", |
| | | "engines": { |
| | | "node": ">=0.4.x" |
| | | } |
| | | }, |
| | | "node_modules/fs.realpath": { |
| | |
| | | "node": ">= 0.4" |
| | | } |
| | | }, |
| | | "node_modules/hast-util-parse-selector": { |
| | | "version": "2.2.5", |
| | | "resolved": "https://registry.npmmirror.com/hast-util-parse-selector/-/hast-util-parse-selector-2.2.5.tgz", |
| | | "integrity": "sha512-7j6mrk/qqkSehsM92wQjdIgWM2/BW61u/53G6xmC8i1OmEdKLHbk419QKQUjz6LglWsfqoiHmyMRkP1BGjecNQ==", |
| | | "funding": { |
| | | "type": "opencollective", |
| | | "url": "https://opencollective.com/unified" |
| | | } |
| | | }, |
| | | "node_modules/hastscript": { |
| | | "version": "6.0.0", |
| | | "resolved": "https://registry.npmmirror.com/hastscript/-/hastscript-6.0.0.tgz", |
| | | "integrity": "sha512-nDM6bvd7lIqDUiYEiu5Sl/+6ReP0BMk/2f4U/Rooccxkj0P5nm+acM5PrGJ/t5I8qPGiqZSE6hVAwZEdZIvP4w==", |
| | | "dependencies": { |
| | | "@types/hast": "^2.0.0", |
| | | "comma-separated-tokens": "^1.0.0", |
| | | "hast-util-parse-selector": "^2.0.0", |
| | | "property-information": "^5.0.0", |
| | | "space-separated-tokens": "^1.0.0" |
| | | }, |
| | | "funding": { |
| | | "type": "opencollective", |
| | | "url": "https://opencollective.com/unified" |
| | | } |
| | | }, |
| | | "node_modules/highlight.js": { |
| | | "version": "10.7.3", |
| | | "resolved": "https://registry.npmmirror.com/highlight.js/-/highlight.js-10.7.3.tgz", |
| | | "integrity": "sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==", |
| | | "engines": { |
| | | "node": "*" |
| | | } |
| | | }, |
| | | "node_modules/hoist-non-react-statics": { |
| | | "version": "3.3.2", |
| | | "resolved": "https://registry.npmmirror.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", |
| | |
| | | }, |
| | | "engines": { |
| | | "node": ">= 0.4" |
| | | } |
| | | }, |
| | | "node_modules/is-alphabetical": { |
| | | "version": "1.0.4", |
| | | "resolved": "https://registry.npmmirror.com/is-alphabetical/-/is-alphabetical-1.0.4.tgz", |
| | | "integrity": "sha512-DwzsA04LQ10FHTZuL0/grVDk4rFoVH1pjAToYwBrHSxcrBIGQuXrQMtD5U1b0U2XVgKZCTLLP8u2Qxqhy3l2Vg==", |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/is-alphanumerical": { |
| | | "version": "1.0.4", |
| | | "resolved": "https://registry.npmmirror.com/is-alphanumerical/-/is-alphanumerical-1.0.4.tgz", |
| | | "integrity": "sha512-UzoZUr+XfVz3t3v4KyGEniVL9BDRoQtY7tOyrRybkVNjDFWyo1yhXNGrrBTQxp3ib9BLAWs7k2YKBQsFRkZG9A==", |
| | | "dependencies": { |
| | | "is-alphabetical": "^1.0.0", |
| | | "is-decimal": "^1.0.0" |
| | | }, |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/is-array-buffer": { |
| | |
| | | "url": "https://github.com/sponsors/ljharb" |
| | | } |
| | | }, |
| | | "node_modules/is-decimal": { |
| | | "version": "1.0.4", |
| | | "resolved": "https://registry.npmmirror.com/is-decimal/-/is-decimal-1.0.4.tgz", |
| | | "integrity": "sha512-RGdriMmQQvZ2aqaQq3awNA6dCGtKpiDFcOzrTWrDAT2MiWrKQVPmxLGHl7Y2nNu6led0kEyoX0enY0qXYsv9zw==", |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/is-extglob": { |
| | | "version": "2.1.1", |
| | | "resolved": "https://registry.npmmirror.com/is-extglob/-/is-extglob-2.1.1.tgz", |
| | |
| | | }, |
| | | "engines": { |
| | | "node": ">=0.10.0" |
| | | } |
| | | }, |
| | | "node_modules/is-hexadecimal": { |
| | | "version": "1.0.4", |
| | | "resolved": "https://registry.npmmirror.com/is-hexadecimal/-/is-hexadecimal-1.0.4.tgz", |
| | | "integrity": "sha512-gyPJuv83bHMpocVYoqof5VDiZveEoGoFL8m3BXNb2VW8Xs+rz9kqO8LOQ5DH6EsuvilT1ApazU0pyl+ytbPtlw==", |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/is-map": { |
| | |
| | | "loose-envify": "cli.js" |
| | | } |
| | | }, |
| | | "node_modules/lowlight": { |
| | | "version": "1.20.0", |
| | | "resolved": "https://registry.npmmirror.com/lowlight/-/lowlight-1.20.0.tgz", |
| | | "integrity": "sha512-8Ktj+prEb1RoCPkEOrPMYUN/nCggB7qAWe3a7OpMjWQkh3l2RD5wKRQ+o8Q8YuI9RG/xs95waaI/E6ym/7NsTw==", |
| | | "dependencies": { |
| | | "fault": "^1.0.0", |
| | | "highlight.js": "~10.7.0" |
| | | }, |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/lru-cache": { |
| | | "version": "5.1.1", |
| | | "resolved": "https://registry.npmmirror.com/lru-cache/-/lru-cache-5.1.1.tgz", |
| | |
| | | "node": ">=6" |
| | | } |
| | | }, |
| | | "node_modules/parse-entities": { |
| | | "version": "2.0.0", |
| | | "resolved": "https://registry.npmmirror.com/parse-entities/-/parse-entities-2.0.0.tgz", |
| | | "integrity": "sha512-kkywGpCcRYhqQIchaWqZ875wzpS/bMKhz5HnN3p7wveJTkTtyAB/AlnS0f8DFSqYW1T82t6yEAkEcB+A1I3MbQ==", |
| | | "dependencies": { |
| | | "character-entities": "^1.0.0", |
| | | "character-entities-legacy": "^1.0.0", |
| | | "character-reference-invalid": "^1.0.0", |
| | | "is-alphanumerical": "^1.0.0", |
| | | "is-decimal": "^1.0.0", |
| | | "is-hexadecimal": "^1.0.0" |
| | | }, |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/parse-json": { |
| | | "version": "5.2.0", |
| | | "resolved": "https://registry.npmmirror.com/parse-json/-/parse-json-5.2.0.tgz", |
| | |
| | | "url": "https://github.com/prettier/prettier?sponsor=1" |
| | | } |
| | | }, |
| | | "node_modules/prismjs": { |
| | | "version": "1.29.0", |
| | | "resolved": "https://registry.npmmirror.com/prismjs/-/prismjs-1.29.0.tgz", |
| | | "integrity": "sha512-Kx/1w86q/epKcmte75LNrEoT+lX8pBpavuAbvJWRXar7Hz8jrtF+e3vY751p0R8H9HdArwaCTNDDzHg/ScJK1Q==", |
| | | "engines": { |
| | | "node": ">=6" |
| | | } |
| | | }, |
| | | "node_modules/prop-types": { |
| | | "version": "15.8.1", |
| | | "resolved": "https://registry.npmmirror.com/prop-types/-/prop-types-15.8.1.tgz", |
| | |
| | | "loose-envify": "^1.4.0", |
| | | "object-assign": "^4.1.1", |
| | | "react-is": "^16.13.1" |
| | | } |
| | | }, |
| | | "node_modules/property-information": { |
| | | "version": "5.6.0", |
| | | "resolved": "https://registry.npmmirror.com/property-information/-/property-information-5.6.0.tgz", |
| | | "integrity": "sha512-YUHSPk+A30YPv+0Qf8i9Mbfe/C0hdPXk1s1jPVToV8pk8BQtpw10ct89Eo7OWkutrwqvT0eicAxlOg3dOAu8JA==", |
| | | "dependencies": { |
| | | "xtend": "^4.0.0" |
| | | }, |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/proxy-from-env": { |
| | |
| | | "react-dom": ">=16.8" |
| | | } |
| | | }, |
| | | "node_modules/react-syntax-highlighter": { |
| | | "version": "15.5.0", |
| | | "resolved": "https://registry.npmmirror.com/react-syntax-highlighter/-/react-syntax-highlighter-15.5.0.tgz", |
| | | "integrity": "sha512-+zq2myprEnQmH5yw6Gqc8lD55QHnpKaU8TOcFeC/Lg/MQSs8UknEA0JC4nTZGFAXC2J2Hyj/ijJ7NlabyPi2gg==", |
| | | "dependencies": { |
| | | "@babel/runtime": "^7.3.1", |
| | | "highlight.js": "^10.4.1", |
| | | "lowlight": "^1.17.0", |
| | | "prismjs": "^1.27.0", |
| | | "refractor": "^3.6.0" |
| | | }, |
| | | "peerDependencies": { |
| | | "react": ">= 0.14.0" |
| | | } |
| | | }, |
| | | "node_modules/react-transition-group": { |
| | | "version": "4.4.5", |
| | | "resolved": "https://registry.npmmirror.com/react-transition-group/-/react-transition-group-4.4.5.tgz", |
| | |
| | | }, |
| | | "funding": { |
| | | "url": "https://github.com/sponsors/ljharb" |
| | | } |
| | | }, |
| | | "node_modules/refractor": { |
| | | "version": "3.6.0", |
| | | "resolved": "https://registry.npmmirror.com/refractor/-/refractor-3.6.0.tgz", |
| | | "integrity": "sha512-MY9W41IOWxxk31o+YvFCNyNzdkc9M20NoZK5vq6jkv4I/uh2zkWcfudj0Q1fovjUQJrNewS9NMzeTtqPf+n5EA==", |
| | | "dependencies": { |
| | | "hastscript": "^6.0.0", |
| | | "parse-entities": "^2.0.0", |
| | | "prismjs": "~1.27.0" |
| | | }, |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/refractor/node_modules/prismjs": { |
| | | "version": "1.27.0", |
| | | "resolved": "https://registry.npmmirror.com/prismjs/-/prismjs-1.27.0.tgz", |
| | | "integrity": "sha512-t13BGPUlFDR7wRB5kQDG4jjl7XeuH6jbJGt11JHPL96qwsEHNX2+68tFXqc1/k+/jALsbSWJKUOT/hcYAZ5LkA==", |
| | | "engines": { |
| | | "node": ">=6" |
| | | } |
| | | }, |
| | | "node_modules/regenerator-runtime": { |
| | |
| | | "dev": true, |
| | | "engines": { |
| | | "node": ">=0.10.0" |
| | | } |
| | | }, |
| | | "node_modules/space-separated-tokens": { |
| | | "version": "1.1.5", |
| | | "resolved": "https://registry.npmmirror.com/space-separated-tokens/-/space-separated-tokens-1.1.5.tgz", |
| | | "integrity": "sha512-q/JSVd1Lptzhf5bkYm4ob4iWPjx0KiRe3sRFBNrVqbJkFaBm5vbbowy1mymoPNLRa52+oadOhJ+K49wsSeSjTA==", |
| | | "funding": { |
| | | "type": "github", |
| | | "url": "https://github.com/sponsors/wooorm" |
| | | } |
| | | }, |
| | | "node_modules/split-on-first": { |
| | |
| | | "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", |
| | | "dev": true |
| | | }, |
| | | "node_modules/xtend": { |
| | | "version": "4.0.2", |
| | | "resolved": "https://registry.npmmirror.com/xtend/-/xtend-4.0.2.tgz", |
| | | "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==", |
| | | "engines": { |
| | | "node": ">=0.4" |
| | | } |
| | | }, |
| | | "node_modules/yallist": { |
| | | "version": "3.1.1", |
| | | "resolved": "https://registry.npmmirror.com/yallist/-/yallist-3.1.1.tgz", |
| | |
| | | "date-fns": "^3.6.0", |
| | | "papaparse": "^5.4.1", |
| | | "pixi.js": "^7.4.0", |
| | | "tweedle.js": "^2.1.0", |
| | | "three": "^0.155.0", |
| | | "react": "^18.3.0", |
| | | "react-admin": "^5.1.0", |
| | | "react-dom": "^18.3.0", |
| | | "react-hook-form": "^7.53.0", |
| | | "react-router-dom": "^6.26.1" |
| | | "react-router-dom": "^6.26.1", |
| | | "react-syntax-highlighter": "^15.5.0", |
| | | "three": "^0.155.0", |
| | | "tweedle.js": "^2.1.0" |
| | | }, |
| | | "devDependencies": { |
| | | "@types/node": "^20.10.7", |
| | |
| | | "vite": "^5.3.5" |
| | | }, |
| | | "name": "cool-admin-flow" |
| | | } |
| | | } |
| | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { Box, Typography, Paper, useTheme } from '@mui/material'; |
| | | import { Light as SyntaxHighlighter } from 'react-syntax-highlighter'; |
| | | import jsonLang from 'react-syntax-highlighter/dist/esm/languages/hljs/json'; |
| | | import { xcode, atomOneDark, a11yLight } from 'react-syntax-highlighter/dist/esm/styles/hljs'; |
| | | |
| | | // https://react-syntax-highlighter.github.io/react-syntax-highlighter/demo/ |
| | | |
| | | const parseJson = (jsonStr) => { |
| | | let json = ''; |
| | |
| | | json = 'Invalid JSON'; |
| | | } |
| | | return json; |
| | | } |
| | | |
| | | SyntaxHighlighter.registerLanguage('json', jsonLang); |
| | | |
| | | const JsonShow = ({ data, height = 500 }) => { |
| | | const theme = useTheme(); |
| | | const themeMode = theme.palette.mode; |
| | | |
| | | let json = parseJson(data); |
| | | |
| | | return ( |
| | | <Paper |
| | | elevation={3} |
| | | sx={{ |
| | | padding: 2, |
| | | maxHeight: height, |
| | | overflow: 'auto', |
| | | backgroundColor: theme.palette.background.paper, |
| | | borderRadius: 2, |
| | | }} |
| | | > |
| | | <pre style={{ margin: 0, fontFamily: 'monospace', whiteSpace: 'pre-wrap' }}> |
| | | {json === 'Invalid JSON' ? ( |
| | | <Typography color="error">Invalid JSON</Typography> |
| | | ) : ( |
| | | |
| | | <SyntaxHighlighter |
| | | language="json" |
| | | style={themeMode === 'dark' ? atomOneDark : xcode} |
| | | customStyle={{ |
| | | backgroundColor: 'transparent', |
| | | padding: 0, |
| | | fontSize: '0.875rem', // 14px |
| | | fontFamily: 'monospace', |
| | | whiteSpace: 'pre-wrap', |
| | | wordBreak: 'break-word', |
| | | // fontWeight: 'bold', |
| | | }} |
| | | showLineNumbers |
| | | > |
| | | {json} |
| | | </SyntaxHighlighter> |
| | | // renderFormattedJson(json) |
| | | )} |
| | | </pre> |
| | | </Paper> |
| | | ); |
| | | } |
| | | |
| | | const renderFormattedJson = (json) => { |
| | |
| | | |
| | | }; |
| | | |
| | | const JsonShow = ({ data, height = 500 }) => { |
| | | const theme = useTheme(); |
| | | const themeMode = theme.palette.mode; |
| | | |
| | | let json = parseJson(data); |
| | | |
| | | return ( |
| | | <Paper |
| | | elevation={3} |
| | | sx={{ |
| | | padding: 2, |
| | | maxHeight: height, |
| | | overflow: 'auto', |
| | | backgroundColor: theme.palette.background.paper, |
| | | borderRadius: 2, |
| | | }} |
| | | > |
| | | <pre style={{ margin: 0, fontFamily: 'monospace', whiteSpace: 'pre-wrap' }}> |
| | | {json === 'Invalid JSON' ? ( |
| | | <Typography color="error">Invalid JSON</Typography> |
| | | ) : ( |
| | | renderFormattedJson(json) |
| | | )} |
| | | </pre> |
| | | </Paper> |
| | | ); |
| | | |
| | | } |
| | | |
| | | export default JsonShow; |
| | |
| | | <Batch |
| | | open={batchSelectionVisible} |
| | | onCancel={() => { |
| | | setBatchSprites([]); |
| | | setBatchSelectionVisible(false); |
| | | }} |
| | | batchSprites={batchSprites} |
| | |
| | | import React, { useState, useRef, useEffect } from 'react'; |
| | | import { useTranslate } from "react-admin"; |
| | | import { Box, Typography, IconButton, Stack, useTheme, Card, CardContent, Divider } from '@mui/material'; |
| | | import { Box, Typography, Toolbar, Stack, useTheme, Card, Divider, Button } from '@mui/material'; |
| | | import JsonShow from '../JsonShow'; |
| | | |
| | | import CheckOutlinedIcon from '@mui/icons-material/CheckOutlined'; |
| | | import ClearOutlinedIcon from '@mui/icons-material/ClearOutlined'; |
| | | import * as Tool from '../tool'; |
| | | |
| | | const BatchSettings = (props) => { |
| | | const { data } = props; |
| | | const theme = useTheme(); |
| | | const themeMode = theme.palette.mode; |
| | | const translate = useTranslate(); |
| | | const { batchSprites, drawerClose } = props; |
| | | |
| | | return ( |
| | | <Box> |
| | | <JsonShow |
| | | data={data} |
| | | height={600} |
| | | data={ |
| | | batchSprites?.map(item => { |
| | | return item.data?.type + '-' + item.data?.no; |
| | | }) |
| | | } |
| | | height={550} |
| | | /> |
| | | <Box mt={2}> |
| | | <Divider sx={{ |
| | | marginBottom: '16px' |
| | | }} /> |
| | | <Toolbar sx={{ |
| | | display: 'flex', |
| | | justifyContent: 'space-between', |
| | | minHeight: { sm: 0 }, |
| | | }}> |
| | | <Button |
| | | variant="outlined" |
| | | color="primary" |
| | | onClick={drawerClose} |
| | | sx={{ borderColor: theme => theme.palette.success.main }} |
| | | startIcon={ |
| | | <CheckOutlinedIcon sx={{ color: theme => theme.palette.success.main }} /> |
| | | } |
| | | > |
| | | {translate('ra.action.confirm')} |
| | | </Button> |
| | | |
| | | <Button |
| | | variant="outlined" |
| | | color="primary" |
| | | onClick={() => { |
| | | batchSprites?.forEach((sprite) => { |
| | | Tool.getMapContainer().removeChild(sprite); |
| | | drawerClose(); |
| | | }) |
| | | }} |
| | | sx={{ borderColor: theme => theme.palette.error.main }} |
| | | startIcon={ |
| | | <ClearOutlinedIcon sx={{ color: theme => theme.palette.error.main }} /> |
| | | } |
| | | > |
| | | {translate('ra.action.delete')} |
| | | </Button> |
| | | </Toolbar> |
| | | </Box> |
| | | </Box> |
| | | ) |
| | | } |
| | |
| | | {mode === MAP_MODE.OBSERVER_MODE && ( |
| | | <> |
| | | <BatchSettings |
| | | data={ |
| | | batchSprites?.map(item => { |
| | | return item.data?.type + '-' + item.data?.no; |
| | | }) |
| | | } |
| | | batchSprites={batchSprites} |
| | | drawerClose={handleClose} |
| | | /> |
| | | </> |
| | | )} |
| | |
| | | {mode === MAP_MODE.SETTINGS_MODE && ( |
| | | <> |
| | | <BatchSettings |
| | | data={ |
| | | batchSprites?.map(item => { |
| | | return item.data?.type + '-' + item.data?.no; |
| | | }) |
| | | } |
| | | batchSprites={batchSprites} |
| | | drawerClose={handleClose} |
| | | /> |
| | | </> |
| | | )} |