diff --git a/.env.example b/.env.example index ea6aeaa..2f97d5d 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,6 @@ APP_URL=//tethys.at VUE_API=//www.tethys.at -SOLR_HOST=tethys.at -SOLR_CORE=rdr_data \ No newline at end of file +# SOLR_HOST=tethys.at +# SOLR_CORE=rdr_data +OPEN_HOST=192.168.21.18 +OPEN_CORE=tethys-records \ No newline at end of file diff --git a/OpenSearch queries.txt b/OpenSearch queries.txt new file mode 100644 index 0000000..5a84e5e --- /dev/null +++ b/OpenSearch queries.txt @@ -0,0 +1,9 @@ +Get all documents in the index ("core" in solr) +---------------------------------------------------- +curl -XGET "http://192.168.21.18/tethys-records/_search?pretty" -H 'Content-Type: application/json' -d' +{ + "query": { + "match_all": {} + } +}' + diff --git a/SOLR queries.txt b/SOLR queries.txt new file mode 100644 index 0000000..30d17b7 --- /dev/null +++ b/SOLR queries.txt @@ -0,0 +1,60 @@ +Search by a specific value for one of the fields +https://tethys.at/solr/rdr_data/select?&q=year:2024 + +Search within a specific range of values for one of the fields +https://tethys.at/solr/rdr_data/select?&q=year:2023%20TO%202024 years 2023 to 2024 + +Search for a term (search done in predefined field?) +https://tethys.at/solr/rdr_data/select?&q=linz + +Predefined Tethys Search +https://tethys.at/solr/rdr_data/select?&0=fl%3Did%2Clicence%2Cserver_date_published%2Cabstract_output%2Cidentifier%2Ctitle_output%2Ctitle_additional%2Cauthor%2Csubject%2Cdoctype&q=%2A&q.op=or&defType=edismax&qf=title%5E3%20author%5E2%20subject%5E1&indent=on&wt=json&rows=10&start=0&sort=server_date_published%20desc&facet=on&json.facet.language=%7B%20type%3A%20%22terms%22%2C%20field%3A%20%22language%22%20%7D&json.facet.subject=%7B%20type%3A%20%22terms%22%2C%20field%3A%20%22subject%22%2C%20limit%3A%20-1%20%7D&json.facet.year=%7B%20type%3A%20%22terms%22%2C%20field%3A%20%22year%22%20%7D&json.facet.author=%7B%20type%3A%20%22terms%22%2C%20field%3A%20%22author_facet%22%2C%20limit%3A%20-1%20%7D + +Predefined Tethys search changing the last facet to "doctype" +https://tethys.at/solr/rdr_data/select?&0=fl%3Did%2Clicence%2Cserver_date_published%2Cabstract_output%2Cidentifier%2Ctitle_output%2Ctitle_additional%2Cauthor%2Csubject%2Cdoctype&q=*&q.op=or&defType=edismax&qf=title^3%20author^2%20subject^1&indent=on&wt=json&rows=10&start=0&sort=server_date_published%20desc&facet=on&json.facet.language={%20type%3A%20%22terms%22%2C%20field%3A%20%22language%22%20}&json.facet.subject={%20type%3A%20%22terms%22%2C%20field%3A%20%22subject%22%2C%20limit%3A%20-1%20}&json.facet.author={%20type%3A%20%22terms%22%2C%20field%3A%20%22author_facet%22%2C%20limit%3A%20-1%20}&json.facet.doctype={%20type%3A%20%22terms%22%2C%20field%3A%20%22doctype%22%2C%20limit%3A%20-1%20} + +Giving a value for only one facet => Author: Coric, Stjepan (16) +https://tethys.at/solr/rdr_data/select?&0=fl%3Did%2Clicence%2Cserver_date_published%2Cabstract_output%2Cidentifier%2Ctitle_output%2Ctitle_additional%2Cauthor%2Csubject%2Cdoctype&q=%2A&q.op=or&defType=edismax&qf=title%5E3%20author%5E2%20subject%5E1&indent=on&wt=json&rows=10&fq=author%3A%28%22Coric%2C%20Stjepan%22%29&start=0&sort=server_date_published%20desc&facet=on&json.facet.language=%7B%20type%3A%20%22terms%22%2C%20field%3A%20%22language%22%20%7D&json.facet.subject=%7B%20type%3A%20%22terms%22%2C%20field%3A%20%22subject%22%2C%20limit%3A%20-1%20%7D&json.facet.year=%7B%20type%3A%20%22terms%22%2C%20field%3A%20%22year%22%20%7D&json.facet.author=%7B%20type%3A%20%22terms%22%2C%20field%3A%20%22author_facet%22%2C%20limit%3A%20-1%20%7D + + + +ASCII ++----+-----+----+-----+----+-----+----+-----+ +| Hx | Chr | Hx | Chr | Hx | Chr | Hx | Chr | ++----+-----+----+-----+----+-----+----+-----+ +| 00 | NUL | 20 | SPC | 40 | @ | 60 | ` | +| 01 | SOH | 21 | ! | 41 | A | 61 | a | +| 02 | STX | 22 | " | 42 | B | 62 | b | +| 03 | ETX | 23 | # | 43 | C | 63 | c | +| 04 | EOT | 24 | $ | 44 | D | 64 | d | +| 05 | ENQ | 25 | % | 45 | E | 65 | e | +| 06 | ACK | 26 | & | 46 | F | 66 | f | +| 07 | BEL | 27 | ' | 47 | G | 67 | g | +| 08 | BS | 28 | ( | 48 | H | 68 | h | +| 09 | TAB | 29 | ) | 49 | I | 69 | i | +| 0A | LF | 2A | * | 4A | J | 6A | j | +| 0B | VT | 2B | + | 4B | K | 6B | k | +| 0C | FF | 2C | , | 4C | L | 6C | l | +| 0D | CR | 2D | - | 4D | M | 6D | m | +| 0E | SO | 2E | . | 4E | N | 6E | n | +| 0F | SI | 2F | / | 4F | O | 6F | o | +| 10 | DLE | 30 | 0 | 50 | P | 70 | p | +| 11 | DC1 | 31 | 1 | 51 | Q | 71 | q | +| 12 | DC2 | 32 | 2 | 52 | R | 72 | r | +| 13 | DC3 | 33 | 3 | 53 | S | 73 | s | +| 14 | DC4 | 34 | 4 | 54 | T | 74 | t | +| 15 | NAK | 35 | 5 | 55 | U | 75 | u | +| 16 | SYN | 36 | 6 | 56 | V | 76 | v | +| 17 | ETB | 37 | 7 | 57 | W | 77 | w | +| 18 | CAN | 38 | 8 | 58 | X | 78 | x | +| 19 | EM | 39 | 9 | 59 | Y | 79 | y | +| 1A | SUB | 3A | : | 5A | Z | 7A | z | +| 1B | ESC | 3B | ; | 5B | [ | 7B | { | +| 1C | FS | 3C | < | 5C | \ | 7C | | | +| 1D | GS | 3D | = | 5D | ] | 7D | } | +| 1E | RS | 3E | > | 5E | ^ | 7E | ~ | +| 1F | US | 3F | ? | 5F | _ | 7F | DEL | ++----+-----+----+-----+----+-----+----+-----+ +https://www.asciitable.com/ see Hx + +If you write encodeURIComponent(",") in your JavaScript console, then you will also get %2C. And with decodeURIComponent("%2C") you will get back the "," \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index dd1474d..fd2d521 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "axios": "^1.2.2", "class-transformer": "^0.5.1", "dayjs": "^1.10.7", + "dompurify": "^3.1.6", "leaflet": "^1.9.4", "qs": "^6.10.1", "rxjs": "^7.5.5", @@ -29,6 +30,7 @@ "@babel/plugin-proposal-decorators": "^7.22.5", "@babel/preset-env": "^7.22.5", "@tailwindcss/forms": "^0.5.7", + "@types/dompurify": "^3.0.5", "@types/leaflet": "^1.7.9", "@typescript-eslint/eslint-plugin": "^7.2.0", "@typescript-eslint/parser": "^7.2.0", @@ -2497,6 +2499,16 @@ "@types/node": "*" } }, + "node_modules/@types/dompurify": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@types/dompurify/-/dompurify-3.0.5.tgz", + "integrity": "sha512-1Wg0g3BtQF7sSb27fJQAKck1HECM6zV1EB66j8JH9i3LCjYabJa0FSdiSgsD5K/RbrsR0SiraKacLB+T8ZVYAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/trusted-types": "*" + } + }, "node_modules/@types/eslint": { "version": "8.56.7", "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.56.7.tgz", @@ -2694,6 +2706,12 @@ "@types/node": "*" } }, + "node_modules/@types/trusted-types": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz", + "integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==", + "dev": true + }, "node_modules/@types/webpack-env": { "version": "1.18.4", "resolved": "https://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.18.4.tgz", @@ -3955,10 +3973,11 @@ "peer": true }, "node_modules/assert-never": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/assert-never/-/assert-never-1.2.1.tgz", - "integrity": "sha512-TaTivMB6pYI1kXwrFlEhLeGfOqoDNdTxjCdwRfFFkEA30Eu+k48W34nlok2EYWJfFFzqaEmichdNM7th6M5HNw==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/assert-never/-/assert-never-1.3.0.tgz", + "integrity": "sha512-9Z3vxQ+berkL/JJo0dK+EY3Lp0s3NtSnP3VCLsh5HDcZPrh0M+KQRK5sWhUeyPPH+/RCxZqOxLMR+YC6vlviEQ==", "dev": true, + "license": "MIT", "peer": true }, "node_modules/async": { @@ -4126,6 +4145,7 @@ "resolved": "https://registry.npmjs.org/babel-walk/-/babel-walk-3.0.0-canary-5.tgz", "integrity": "sha512-GAwkz0AihzY5bkwIY5QDR+LvsRQgB/B+1foMPvi0FZPMl5fjD7ICiznUiBdLYMH1QYe6vqu4gWYytZOccLouFw==", "dev": true, + "license": "MIT", "peer": true, "dependencies": { "@babel/types": "^7.9.6" @@ -4293,12 +4313,13 @@ } }, "node_modules/braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", "dev": true, + "license": "MIT", "dependencies": { - "fill-range": "^7.0.1" + "fill-range": "^7.1.1" }, "engines": { "node": ">=8" @@ -5565,6 +5586,7 @@ "resolved": "https://registry.npmjs.org/doctypes/-/doctypes-1.1.0.tgz", "integrity": "sha512-LLBi6pEqS6Do3EKQ3J0NqHWV5hhb78Pi8vvESYwyOy2c31ZEZVdtitdzsQsKb7878PEERhzUk0ftqGhG6Mz+pQ==", "dev": true, + "license": "MIT", "peer": true }, "node_modules/dom-converter": { @@ -5626,6 +5648,12 @@ "url": "https://github.com/fb55/domhandler?sponsor=1" } }, + "node_modules/dompurify": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.1.6.tgz", + "integrity": "sha512-cTOAhc36AalkjtBpfG6O8JimdTMWNXjiePT2xQH/ppBGi/4uIpmj8eKyIkMJErXWARyINV/sB38yf8JCLF5pbQ==", + "license": "(MPL-2.0 OR Apache-2.0)" + }, "node_modules/domutils": { "version": "2.8.0", "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.8.0.tgz", @@ -6636,10 +6664,11 @@ } }, "node_modules/fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", "dev": true, + "license": "MIT", "dependencies": { "to-regex-range": "^5.0.1" }, @@ -7816,6 +7845,7 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", "dev": true, + "license": "MIT", "engines": { "node": ">=0.12.0" } @@ -8026,6 +8056,7 @@ "resolved": "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz", "integrity": "sha512-rtS5ATOo2Q5k1G+DADISilDA6lv79zIiwFd6CcjuIxGKLFm5C+RLImRscVap9k55i+MOZwgliw+NejvkLuGD5g==", "dev": true, + "license": "MIT", "peer": true }, "node_modules/js-tokens": { @@ -10394,13 +10425,14 @@ "dev": true }, "node_modules/pug": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/pug/-/pug-3.0.2.tgz", - "integrity": "sha512-bp0I/hiK1D1vChHh6EfDxtndHji55XP/ZJKwsRqrz6lRia6ZC2OZbdAymlxdVFwd1L70ebrVJw4/eZ79skrIaw==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/pug/-/pug-3.0.3.tgz", + "integrity": "sha512-uBi6kmc9f3SZ3PXxqcHiUZLmIXgfgWooKWXcwSGwQd2Zi5Rb0bT14+8CJjJgI8AB+nndLaNgHGrcc6bPIB665g==", "dev": true, + "license": "MIT", "peer": true, "dependencies": { - "pug-code-gen": "^3.0.2", + "pug-code-gen": "^3.0.3", "pug-filters": "^4.0.0", "pug-lexer": "^5.0.1", "pug-linker": "^4.0.0", @@ -10415,6 +10447,7 @@ "resolved": "https://registry.npmjs.org/pug-attrs/-/pug-attrs-3.0.0.tgz", "integrity": "sha512-azINV9dUtzPMFQktvTXciNAfAuVh/L/JCl0vtPCwvOA21uZrC08K/UnmrL+SXGEVc1FwzjW62+xw5S/uaLj6cA==", "dev": true, + "license": "MIT", "peer": true, "dependencies": { "constantinople": "^4.0.1", @@ -10423,27 +10456,29 @@ } }, "node_modules/pug-code-gen": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/pug-code-gen/-/pug-code-gen-3.0.2.tgz", - "integrity": "sha512-nJMhW16MbiGRiyR4miDTQMRWDgKplnHyeLvioEJYbk1RsPI3FuA3saEP8uwnTb2nTJEKBU90NFVWJBk4OU5qyg==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/pug-code-gen/-/pug-code-gen-3.0.3.tgz", + "integrity": "sha512-cYQg0JW0w32Ux+XTeZnBEeuWrAY7/HNE6TWnhiHGnnRYlCgyAUPoyh9KzCMa9WhcJlJ1AtQqpEYHc+vbCzA+Aw==", "dev": true, + "license": "MIT", "peer": true, "dependencies": { "constantinople": "^4.0.1", "doctypes": "^1.1.0", "js-stringify": "^1.0.2", "pug-attrs": "^3.0.0", - "pug-error": "^2.0.0", - "pug-runtime": "^3.0.0", + "pug-error": "^2.1.0", + "pug-runtime": "^3.0.1", "void-elements": "^3.1.0", "with": "^7.0.0" } }, "node_modules/pug-error": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pug-error/-/pug-error-2.0.0.tgz", - "integrity": "sha512-sjiUsi9M4RAGHktC1drQfCr5C5eriu24Lfbt4s+7SykztEOwVZtbFk1RRq0tzLxcMxMYTBR+zMQaG07J/btayQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/pug-error/-/pug-error-2.1.0.tgz", + "integrity": "sha512-lv7sU9e5Jk8IeUheHata6/UThZ7RK2jnaaNztxfPYUY+VxZyk/ePVaNZ/vwmH8WqGvDz3LrNYt/+gA55NDg6Pg==", "dev": true, + "license": "MIT", "peer": true }, "node_modules/pug-filters": { @@ -10522,6 +10557,7 @@ "resolved": "https://registry.npmjs.org/pug-runtime/-/pug-runtime-3.0.1.tgz", "integrity": "sha512-L50zbvrQ35TkpHwv0G6aLSuueDRwc/97XdY8kL3tOT0FmhgG7UypU3VztfV/LATAvmUfYi4wNxSajhSAeNN+Kg==", "dev": true, + "license": "MIT", "peer": true }, "node_modules/pug-strip-comments": { @@ -11987,6 +12023,7 @@ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", "dev": true, + "license": "MIT", "dependencies": { "is-number": "^7.0.0" }, @@ -12384,6 +12421,7 @@ "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz", "integrity": "sha512-Dhxzh5HZuiHQhbvTW9AMetFfBHDMYpo23Uo9btPXgdYP+3T5S+p+jgNy7spra+veYhBP2dCSgxR/i2Y02h5/6w==", "dev": true, + "license": "MIT", "peer": true, "engines": { "node": ">=0.10.0" @@ -12961,10 +12999,11 @@ } }, "node_modules/webpack-dev-server/node_modules/ws": { - "version": "8.16.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.16.0.tgz", - "integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "dev": true, + "license": "MIT", "engines": { "node": ">=10.0.0" }, @@ -13124,6 +13163,7 @@ "resolved": "https://registry.npmjs.org/with/-/with-7.0.2.tgz", "integrity": "sha512-RNGKj82nUPg3g5ygxkQl0R937xLyho1J24ItRCBTr/m1YnZkzJy1hUiHUJrc/VlsDQzsCnInEGSg3bci0Lmd4w==", "dev": true, + "license": "MIT", "peer": true, "dependencies": { "@babel/parser": "^7.9.6", @@ -13243,10 +13283,11 @@ "dev": true }, "node_modules/ws": { - "version": "7.5.9", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz", - "integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==", + "version": "7.5.10", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", + "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", "dev": true, + "license": "MIT", "engines": { "node": ">=8.3.0" }, diff --git a/package.json b/package.json index 9c2e95f..e0ef097 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "axios": "^1.2.2", "class-transformer": "^0.5.1", "dayjs": "^1.10.7", + "dompurify": "^3.1.6", "leaflet": "^1.9.4", "qs": "^6.10.1", "rxjs": "^7.5.5", @@ -32,6 +33,7 @@ "@babel/plugin-proposal-decorators": "^7.22.5", "@babel/preset-env": "^7.22.5", "@tailwindcss/forms": "^0.5.7", + "@types/dompurify": "^3.0.5", "@types/leaflet": "^1.7.9", "@typescript-eslint/eslint-plugin": "^7.2.0", "@typescript-eslint/parser": "^7.2.0", diff --git a/src/api/api.ts b/src/api/api.ts index 662b705..639d35b 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -1,46 +1,37 @@ -import initializeAxios from "./axiosSetup"; -import { axiosRequestConfiguration } from "./config"; -import { map } from "rxjs/operators"; -// import { Observable } from "@reactivex/rxjs/compat"; -import { defer, Observable } from "rxjs"; -import { AxiosResponse } from "axios"; -// https://ichi.pro/de/so-wickeln-sie-axios-mit-typescript-und-react-in-rxjs-ein-118892823169891 +// Import the necessary modules and functions +import initializeAxios from "./axiosSetup"; // Function to initialize the Axios instance +import { axiosRequestConfiguration } from "./config"; // Axios configuration settings +import { map } from "rxjs/operators"; // Operator to transform the items emitted by an Observable +import { defer, Observable } from "rxjs"; // RxJS utilities for creating and working with Observables +import { AxiosResponse } from "axios"; // Axios response type +// Initialize the Axios instance with the provided configuration const axiosInstance = initializeAxios(axiosRequestConfiguration); +// Function to make a GET request using Axios wrapped in an Observable // eslint-disable-next-line const get = (url: string, queryParams?: any): Observable => { - return defer(() => axiosInstance.get(url, { params: queryParams })).pipe(map((result: AxiosResponse) => result.data)); + // Use defer to create an Observable that makes the Axios GET request when subscribed to + return defer(() => axiosInstance.get(url, { params: queryParams })) + // Use map to transform the Axios response to extract the data property + .pipe(map((result: AxiosResponse) => result.data)); }; -// const post = (url: string, body: object, queryParams?: any): Observable => { -// return defer(() => axiosInstance.post(url, body, { params: queryParams })).pipe(map((result: AxiosResponse) => result.data)); -// }; +// Function to make a POST request using Axios wrapped in an Observable +const post = (url: string, body: any, queryParams?: any): Observable => { + // Use defer to create an Observable that makes the Axios POST request when subscribed to + // console.log(body); + // console.log(queryParams); + + return defer(() => axiosInstance.post(url, body, { + params: queryParams, + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + } + })) + .pipe(map((result: AxiosResponse) => result.data)); // Use map to transform the Axios response to extract the data property +}; -// const put = ( -// url: string, -// body: object, -// queryParams?: object -// ): Observable => { -// return defer(() => -// axiosInstance.put(url, body, { params: queryParams }) -// ).pipe(map((result) => result.data)); -// }; - -// const patch = ( -// url: string, -// body: object, -// queryParams?: object -// ): Observable => { -// return defer(() => -// axiosInstance.patch(url, body, { params: queryParams }) -// ).pipe(map((result) => result.data)); -// }; - -// const deleteR = (url: string, id: number): Observable => { -// return defer(() => axiosInstance.delete(`${url}/${id}`)).pipe( -// map((result) => result.data) -// ); -// }; - -export default { get }; +// Export the get and post functions as part of the default export +export default { get, post }; \ No newline at end of file diff --git a/src/api/axiosSetup.ts b/src/api/axiosSetup.ts index 93cfbbc..f284001 100644 --- a/src/api/axiosSetup.ts +++ b/src/api/axiosSetup.ts @@ -1,20 +1,12 @@ import axios, { AxiosRequestConfig, AxiosInstance } from "axios"; const initialization = (config: AxiosRequestConfig): AxiosInstance => { - //axios.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest"; + delete axios.defaults.headers.common["X-Requested-With"]; - // axios.defaults.withCredentials = true; - // const token = document.head.querySelector('meta[name="csrf-token"]'); - // if (token) { - // axios.defaults.headers.common["X-CSRF-TOKEN"] = token.innerHTML; - // } - const axiosInstance = axios.create(config); - /* - Add default headers, interceptors etc.. - */ + const axiosInstance = axios.create(config); return axiosInstance; }; -export default initialization; +export default initialization; \ No newline at end of file diff --git a/src/api/config.ts b/src/api/config.ts index b58a88a..57de462 100644 --- a/src/api/config.ts +++ b/src/api/config.ts @@ -1,31 +1,16 @@ import { AxiosRequestConfig } from "axios"; import { stringify } from "qs"; -// let headers: AxiosRequestConfig['headers'] = -// headers['Content-Type'] = 'multipart/form-data'; - +/* This file configures Axios to send requests with the specified headers and parameters serialization format for URL-encoded form data */ export const axiosRequestConfiguration: AxiosRequestConfig = { - // responseType: "text", - // headers: { - // // "Content-Type": "text/plain", - // "Content-Type": "application/x-www-form-urlencoded", - // // "Content-Type": "application/x-www-form-urlencoded", - // // credentials: "same-origin", - // // "Access-Control-Allow-Credentials": "true", - // // "Access-Control-Allow-Origin": "*", - // }, + headers: { - //: AxiosHeaders | Partial | undefined "Content-Type": "application/x-www-form-urlencoded", }, - // headers: { - // "Content-type": "application/json; charset=UTF-8", - // }, - // paramsSerializer: { - // indexes: null, // by default: false - // }, paramsSerializer: { + /* The serialize function takes an object of key-value pairs as input and uses the qs.stringify method to convert it into a URL-encoded string. + The arrayFormat: "repeat" option specifies how arrays should be serialized in the URL parameters. */ serialize: (params: Record) => { return stringify(params, { arrayFormat: "repeat" }); }, diff --git a/src/components/PaginationComponent.vue b/src/components/PaginationComponent.vue index fd4db10..244eac8 100644 --- a/src/components/PaginationComponent.vue +++ b/src/components/PaginationComponent.vue @@ -86,7 +86,7 @@ const prevClick = () => {