From 8beb5da494c8f5a4de1198b1f2ccaba2c8420e2f Mon Sep 17 00:00:00 2001 From: Danila_Mochalov Date: Mon, 3 Apr 2023 01:00:37 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D1=80=D0=BE=D0=BD=D1=82.=20=D0=9D=D0=B0?= =?UTF-8?q?=D1=87=D0=B0=D0=BB=D0=BE=20+=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B5?= =?UTF-8?q?=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D1=8B=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=82=D1=80=D0=BE=D0=BB=D0=BB=D0=B5=D1=80=D0=BE=D0=B2=20DLC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/examresult.controller.js | 5 + .../controllers/request.controller.js | 5 + abitur_list_client/index.js | 7 + abitur_list_client/package-lock.json | 100 +++++++++++- abitur_list_client/package.json | 3 +- .../routes/examresult.routes.js | 1 + abitur_list_client/routes/request.routes.js | 1 + abitur_list_client/src/App.vue | 8 +- .../src/components/AbiturMain.vue | 154 ++++++++++++++++++ abitur_list_client/src/components/Auth.vue | 83 ++++++++++ abitur_list_client/src/components/Request.vue | 13 ++ abitur_list_client/src/main.js | 25 ++- 12 files changed, 396 insertions(+), 9 deletions(-) create mode 100644 abitur_list_client/src/components/AbiturMain.vue create mode 100644 abitur_list_client/src/components/Auth.vue create mode 100644 abitur_list_client/src/components/Request.vue diff --git a/abitur_list_client/controllers/examresult.controller.js b/abitur_list_client/controllers/examresult.controller.js index 97cba9b..c60a6ca 100644 --- a/abitur_list_client/controllers/examresult.controller.js +++ b/abitur_list_client/controllers/examresult.controller.js @@ -27,6 +27,11 @@ class ExamResultController extends ExamResultControllerInterface { const results = await db.query('DELETE FROM exam_result WHERE id=$1', [id]) res.json(results.rows[0]) } + async getAbiturExamResults(req, res) { + const id = req.params.id + const results = await db.query('SELECT * FROM exam_result WHERE abitur_id=$1', [id]) + res.json(results.rows) + } } module.exports = new ExamResultController() \ No newline at end of file diff --git a/abitur_list_client/controllers/request.controller.js b/abitur_list_client/controllers/request.controller.js index c93621a..c3b353a 100644 --- a/abitur_list_client/controllers/request.controller.js +++ b/abitur_list_client/controllers/request.controller.js @@ -27,6 +27,11 @@ class RequestController extends RequestControllerInterface { const requests = await db.query('DELETE FROM request WHERE id=$1', [id]) res.json(requests.rows[0]) } + async getAbiturRequests(req, res) { + const id = req.params.id + const requests = await db.query('SELECT * FROM request WHERE abitur_id=$1', [id]) + res.json(requests.rows) + } } module.exports = new RequestController() \ No newline at end of file diff --git a/abitur_list_client/index.js b/abitur_list_client/index.js index 635083e..d816afe 100644 --- a/abitur_list_client/index.js +++ b/abitur_list_client/index.js @@ -12,6 +12,13 @@ const PORT = process.env.PORT || 8080 const app = express() +app.use(function(req, res, next) { + res.setHeader('Access-Control-Allow-Origin', '*'); + res.header("Access-Control-Allow-Methods", "GET, PUT, POST, DELETE"); + res.setHeader('Access-Control-Allow-Headers', 'origin, content-type, accept'); + next(); +}); + app.use(express.json()) app.use('/api', abiturRouter) app.use('/api', examResultRouter) diff --git a/abitur_list_client/package-lock.json b/abitur_list_client/package-lock.json index 743ac86..29326e0 100644 --- a/abitur_list_client/package-lock.json +++ b/abitur_list_client/package-lock.json @@ -8,6 +8,7 @@ "name": "abitur_list_client", "version": "0.1.0", "dependencies": { + "axios": "^1.3.4", "core-js": "^3.8.3", "express": "^4.18.2", "pg": "^8.10.0", @@ -3256,6 +3257,11 @@ "lodash": "^4.17.14" } }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, "node_modules/at-least-node": { "version": "1.0.0", "resolved": "https://registry.npmmirror.com/at-least-node/-/at-least-node-1.0.0.tgz", @@ -3288,6 +3294,16 @@ "postcss": "^8.1.0" } }, + "node_modules/axios": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz", + "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==", + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "node_modules/babel-loader": { "version": "8.3.0", "resolved": "https://registry.npmmirror.com/babel-loader/-/babel-loader-8.3.0.tgz", @@ -3870,6 +3886,17 @@ "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==", "dev": true }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/commander": { "version": "8.3.0", "resolved": "https://registry.npmmirror.com/commander/-/commander-8.3.0.tgz", @@ -4557,6 +4584,14 @@ "node": ">= 0.4" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" + } + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz", @@ -5120,7 +5155,6 @@ "version": "1.15.2", "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.2.tgz", "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", - "dev": true, "engines": { "node": ">=4.0" }, @@ -5130,6 +5164,19 @@ } } }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmmirror.com/forwarded/-/forwarded-0.2.0.tgz", @@ -7946,6 +7993,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmmirror.com/pseudomap/-/pseudomap-1.0.2.tgz", @@ -12486,6 +12538,11 @@ "lodash": "^4.17.14" } }, + "asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, "at-least-node": { "version": "1.0.0", "resolved": "https://registry.npmmirror.com/at-least-node/-/at-least-node-1.0.0.tgz", @@ -12506,6 +12563,16 @@ "postcss-value-parser": "^4.2.0" } }, + "axios": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.3.4.tgz", + "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==", + "requires": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, "babel-loader": { "version": "8.3.0", "resolved": "https://registry.npmmirror.com/babel-loader/-/babel-loader-8.3.0.tgz", @@ -12986,6 +13053,14 @@ "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==", "dev": true }, + "combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "requires": { + "delayed-stream": "~1.0.0" + } + }, "commander": { "version": "8.3.0", "resolved": "https://registry.npmmirror.com/commander/-/commander-8.3.0.tgz", @@ -13514,6 +13589,11 @@ "object-keys": "^1.1.1" } }, + "delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==" + }, "depd": { "version": "2.0.0", "resolved": "https://registry.npmmirror.com/depd/-/depd-2.0.0.tgz", @@ -13993,8 +14073,17 @@ "follow-redirects": { "version": "1.15.2", "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", - "dev": true + "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" + }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } }, "forwarded": { "version": "0.2.0", @@ -16141,6 +16230,11 @@ } } }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmmirror.com/pseudomap/-/pseudomap-1.0.2.tgz", diff --git a/abitur_list_client/package.json b/abitur_list_client/package.json index f79d700..1a4cafd 100644 --- a/abitur_list_client/package.json +++ b/abitur_list_client/package.json @@ -5,9 +5,10 @@ "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", - "start": "nodemon index.js" + "start": "pm2 start index.js --watch" }, "dependencies": { + "axios": "^1.3.4", "core-js": "^3.8.3", "express": "^4.18.2", "pg": "^8.10.0", diff --git a/abitur_list_client/routes/examresult.routes.js b/abitur_list_client/routes/examresult.routes.js index ef6fe95..73fc103 100644 --- a/abitur_list_client/routes/examresult.routes.js +++ b/abitur_list_client/routes/examresult.routes.js @@ -8,5 +8,6 @@ router.get('/examresult', examResultController.getExamResults) router.get('/examresult/:id', examResultController.getOneExamResult) router.put('/examresult', examResultController.updateExamResult) router.delete('/examresult/:id', examResultController.deleteExamResult) +router.get('/examresult/abitur/:id', examResultController.getAbiturExamResults) module.exports = router \ No newline at end of file diff --git a/abitur_list_client/routes/request.routes.js b/abitur_list_client/routes/request.routes.js index a11f8c4..f3473b3 100644 --- a/abitur_list_client/routes/request.routes.js +++ b/abitur_list_client/routes/request.routes.js @@ -8,5 +8,6 @@ router.get('/request', requestController.getRequests) router.get('/request/:id', requestController.getRequests) router.put('/request', requestController.updateRequest) router.delete('/request/:id', requestController.deleteRequest) +router.get('/request/abitur/:id', requestController.getAbiturRequests) module.exports = router \ No newline at end of file diff --git a/abitur_list_client/src/App.vue b/abitur_list_client/src/App.vue index 6a0fbc6..48aa158 100644 --- a/abitur_list_client/src/App.vue +++ b/abitur_list_client/src/App.vue @@ -1,11 +1,11 @@ \ No newline at end of file diff --git a/abitur_list_client/src/components/Auth.vue b/abitur_list_client/src/components/Auth.vue new file mode 100644 index 0000000..7c56df8 --- /dev/null +++ b/abitur_list_client/src/components/Auth.vue @@ -0,0 +1,83 @@ + + + \ No newline at end of file diff --git a/abitur_list_client/src/components/Request.vue b/abitur_list_client/src/components/Request.vue new file mode 100644 index 0000000..a6cbbba --- /dev/null +++ b/abitur_list_client/src/components/Request.vue @@ -0,0 +1,13 @@ + + + \ No newline at end of file diff --git a/abitur_list_client/src/main.js b/abitur_list_client/src/main.js index 01433bc..61610d3 100644 --- a/abitur_list_client/src/main.js +++ b/abitur_list_client/src/main.js @@ -1,4 +1,27 @@ import { createApp } from 'vue' import App from './App.vue' +import { createRouter, createWebHistory } from "vue-router" -createApp(App).mount('#app') +import Auth from './components/Auth' +import AbiturMain from './components/AbiturMain' + +const routes = [ + { + path: '/', + component: Auth, + name: 'Auth' + }, + { + path: '/abitur/:abiturId', + name: 'AbiturMain', + component: AbiturMain, + props: true + } +] + +const router = createRouter({ + routes, + history: createWebHistory() +}) + +createApp(App).use(router).mount('#app')