From 772ffb2db53e7b0905fe03b3f2a685108f5e6b98 Mon Sep 17 00:00:00 2001 From: "selina.mail" Date: Mon, 22 Jan 2024 19:43:20 +0100 Subject: [PATCH 01/20] communication from client to nuxt server --- components/LoginForm.vue | 61 ++++++++++++++++++++++++++++++++++++++-- server/api/login.ts | 15 ++++++++++ 2 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 server/api/login.ts diff --git a/components/LoginForm.vue b/components/LoginForm.vue index ede85ec..371f95e 100644 --- a/components/LoginForm.vue +++ b/components/LoginForm.vue @@ -32,21 +32,76 @@ - + diff --git a/server/api/login.ts b/server/api/login.ts new file mode 100644 index 0000000..8e5504a --- /dev/null +++ b/server/api/login.ts @@ -0,0 +1,15 @@ +export default defineEventHandler(async (event) => { + const body = await readBody(event) + + if ((body.username == 'test') && (body.password == 'asd')) { + setResponseStatus(event, 202) + return { + login: 'successful' + } + } else { + throw createError({ + statusCode: 400, + statusMessage: 'Login failed', + }) + } +}) From 0c589e3ae02d444511eb59484eacb46e64e55631 Mon Sep 17 00:00:00 2001 From: "selina.mail" Date: Fri, 26 Jan 2024 18:25:46 +0100 Subject: [PATCH 02/20] tried it with axios --- axios.config.js | 15 ++++++++++ components/LoginForm.vue | 56 ++++++++++---------------------------- server/api/login.ts | 29 +++++++++++++++----- server/middleware/login.ts | 17 ++++++++++++ serversideConfig.js | 8 ++++++ 5 files changed, 76 insertions(+), 49 deletions(-) create mode 100644 axios.config.js create mode 100644 server/middleware/login.ts create mode 100644 serversideConfig.js diff --git a/axios.config.js b/axios.config.js new file mode 100644 index 0000000..1b22387 --- /dev/null +++ b/axios.config.js @@ -0,0 +1,15 @@ +import axios from 'axios'; +import serversideConfig from './serversideConfig.js' + +//create axios instance +const Axios = axios.create({ + baseURL: `http://${serversideConfig.url}:${serversideConfig.port}`, + headers: { + // 'Accept': 'application/json', + 'Content-Type': 'application/json', + //Authorization: `Bearer`, + Accept: "*", + }, +}) + +export default Axios; diff --git a/components/LoginForm.vue b/components/LoginForm.vue index 371f95e..61d3f4e 100644 --- a/components/LoginForm.vue +++ b/components/LoginForm.vue @@ -41,6 +41,7 @@ @@ -53,52 +54,23 @@ export default { const username = document.getElementById('username-input').value; const password = document.getElementById('password-input').value; - const { data, error } = await useFetch('/api/login', { - method: 'post', - body: { - username: username, - password: password - } - }) - if (!data.value) { - console.log(error.value) - } else { - console.log(data.value) + const requestBody = { + username: username, + password: password, } - // }).then(res => { - // const data = res.data.value - // const error = res.error.value - // if (error) { - // // dealing error - // // console.log(error) - // } else { - // console.log(data) - // } - // }, error => { - // console.log('exception...') - // console.log(error) - // }) - // console.log(data.value) - // console.log(error) - // } + try { + let res = await Axios.post('/api/login', requestBody); - // // const response = await LoginService.login(data); - // const { response } = await useFetch('/api/login') - // console.log(response) + // something to do with the res? + console.log(res) - - // Axios.post('/api/login', data, { - // headers: { - // 'Content-Type': 'application/json' - // } - // }) - // .then(function (response) { - // console.log(response); - // }) - // .catch(function (error) { - // console.log(error); - // }); + // sucessfully logged in + this.$router.push('/') + } catch (err) { + // handle the error + console.log(err.message) + } } } } diff --git a/server/api/login.ts b/server/api/login.ts index 8e5504a..42f79b5 100644 --- a/server/api/login.ts +++ b/server/api/login.ts @@ -1,15 +1,30 @@ +import { globalUserObject } from "../middleware/login"; + export default defineEventHandler(async (event) => { + const body = await readBody(event) - if ((body.username == 'test') && (body.password == 'asd')) { - setResponseStatus(event, 202) - return { - login: 'successful' - } - } else { + let correctUsername; + let correctPassword; + if (globalUserObject !== null) { + correctUsername = globalUserObject.username; + correctPassword = globalUserObject.password; + } + + let authorized = false; + + if (body.username == correctUsername && body.password == correctPassword) { + authorized = true; + } + + if (!authorized) { throw createError({ statusCode: 400, - statusMessage: 'Login failed', + statusMessage: 'Username or password not valid.', }) } + + setResponseStatus(event, 202) + return 'Successfully logged in.' + }) diff --git a/server/middleware/login.ts b/server/middleware/login.ts new file mode 100644 index 0000000..2ce49b5 --- /dev/null +++ b/server/middleware/login.ts @@ -0,0 +1,17 @@ +let globalUserObject: { [key: string]: any } | null = null; +// let globalUserObject = null; + +export default defineEventHandler((event) => { + + if (event.path.startsWith("/api/login")) { + + // get user object from backend + const userObject = { + username: "test", + password: "asd" + } + globalUserObject = userObject; + } +}) + +export { globalUserObject }; \ No newline at end of file diff --git a/serversideConfig.js b/serversideConfig.js new file mode 100644 index 0000000..427ae6f --- /dev/null +++ b/serversideConfig.js @@ -0,0 +1,8 @@ +const serversideConfig = { + // url: 'tueitapp.tueit.de', + // port: 8000, + url: 'localhost', + port: 3000, +}; + +export default serversideConfig; \ No newline at end of file From 2a4dc80efa22b148ea9196e57fb8a8effc42ffec Mon Sep 17 00:00:00 2001 From: "selina.mail" Date: Mon, 22 Jan 2024 19:43:20 +0100 Subject: [PATCH 03/20] communication from client to nuxt server --- components/LoginForm.vue | 61 ++++++++++++++++++++++++++++++++++++++-- server/api/login.ts | 15 ++++++++++ 2 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 server/api/login.ts diff --git a/components/LoginForm.vue b/components/LoginForm.vue index ede85ec..371f95e 100644 --- a/components/LoginForm.vue +++ b/components/LoginForm.vue @@ -32,21 +32,76 @@ - + diff --git a/server/api/login.ts b/server/api/login.ts new file mode 100644 index 0000000..8e5504a --- /dev/null +++ b/server/api/login.ts @@ -0,0 +1,15 @@ +export default defineEventHandler(async (event) => { + const body = await readBody(event) + + if ((body.username == 'test') && (body.password == 'asd')) { + setResponseStatus(event, 202) + return { + login: 'successful' + } + } else { + throw createError({ + statusCode: 400, + statusMessage: 'Login failed', + }) + } +}) From c5fbb12dfd2780bbfcab355cd50600b3a9daf2b2 Mon Sep 17 00:00:00 2001 From: "selina.mail" Date: Fri, 26 Jan 2024 18:25:46 +0100 Subject: [PATCH 04/20] tried it with axios --- axios.config.js | 15 ++++++++++ components/LoginForm.vue | 56 ++++++++++---------------------------- server/api/login.ts | 29 +++++++++++++++----- server/middleware/login.ts | 17 ++++++++++++ 4 files changed, 68 insertions(+), 49 deletions(-) create mode 100644 axios.config.js create mode 100644 server/middleware/login.ts diff --git a/axios.config.js b/axios.config.js new file mode 100644 index 0000000..1b22387 --- /dev/null +++ b/axios.config.js @@ -0,0 +1,15 @@ +import axios from 'axios'; +import serversideConfig from './serversideConfig.js' + +//create axios instance +const Axios = axios.create({ + baseURL: `http://${serversideConfig.url}:${serversideConfig.port}`, + headers: { + // 'Accept': 'application/json', + 'Content-Type': 'application/json', + //Authorization: `Bearer`, + Accept: "*", + }, +}) + +export default Axios; diff --git a/components/LoginForm.vue b/components/LoginForm.vue index 371f95e..61d3f4e 100644 --- a/components/LoginForm.vue +++ b/components/LoginForm.vue @@ -41,6 +41,7 @@ @@ -53,52 +54,23 @@ export default { const username = document.getElementById('username-input').value; const password = document.getElementById('password-input').value; - const { data, error } = await useFetch('/api/login', { - method: 'post', - body: { - username: username, - password: password - } - }) - if (!data.value) { - console.log(error.value) - } else { - console.log(data.value) + const requestBody = { + username: username, + password: password, } - // }).then(res => { - // const data = res.data.value - // const error = res.error.value - // if (error) { - // // dealing error - // // console.log(error) - // } else { - // console.log(data) - // } - // }, error => { - // console.log('exception...') - // console.log(error) - // }) - // console.log(data.value) - // console.log(error) - // } + try { + let res = await Axios.post('/api/login', requestBody); - // // const response = await LoginService.login(data); - // const { response } = await useFetch('/api/login') - // console.log(response) + // something to do with the res? + console.log(res) - - // Axios.post('/api/login', data, { - // headers: { - // 'Content-Type': 'application/json' - // } - // }) - // .then(function (response) { - // console.log(response); - // }) - // .catch(function (error) { - // console.log(error); - // }); + // sucessfully logged in + this.$router.push('/') + } catch (err) { + // handle the error + console.log(err.message) + } } } } diff --git a/server/api/login.ts b/server/api/login.ts index 8e5504a..42f79b5 100644 --- a/server/api/login.ts +++ b/server/api/login.ts @@ -1,15 +1,30 @@ +import { globalUserObject } from "../middleware/login"; + export default defineEventHandler(async (event) => { + const body = await readBody(event) - if ((body.username == 'test') && (body.password == 'asd')) { - setResponseStatus(event, 202) - return { - login: 'successful' - } - } else { + let correctUsername; + let correctPassword; + if (globalUserObject !== null) { + correctUsername = globalUserObject.username; + correctPassword = globalUserObject.password; + } + + let authorized = false; + + if (body.username == correctUsername && body.password == correctPassword) { + authorized = true; + } + + if (!authorized) { throw createError({ statusCode: 400, - statusMessage: 'Login failed', + statusMessage: 'Username or password not valid.', }) } + + setResponseStatus(event, 202) + return 'Successfully logged in.' + }) diff --git a/server/middleware/login.ts b/server/middleware/login.ts new file mode 100644 index 0000000..2ce49b5 --- /dev/null +++ b/server/middleware/login.ts @@ -0,0 +1,17 @@ +let globalUserObject: { [key: string]: any } | null = null; +// let globalUserObject = null; + +export default defineEventHandler((event) => { + + if (event.path.startsWith("/api/login")) { + + // get user object from backend + const userObject = { + username: "test", + password: "asd" + } + globalUserObject = userObject; + } +}) + +export { globalUserObject }; \ No newline at end of file From 73d0b89b4d14fc5d43e01e642369abe9e569e2e4 Mon Sep 17 00:00:00 2001 From: "selina.mail" Date: Tue, 6 Feb 2024 17:18:37 +0100 Subject: [PATCH 05/20] implemented connection to the backend --- axios.config.js | 3 +- backend/controller/issueVariants.js | 2 +- backend/index.js | 8 +- certs/server_ca.pem | 51 +++++++ components/LoginForm.vue | 211 ++++++++++++++++++++++++---- nuxt.config.ts | 8 +- server/api/login.ts | 24 +--- server/api/signup.ts | 14 ++ server/middleware/login.ts | 65 +++++++-- server/middleware/signUp.ts | 83 +++++++++++ serversideConfig.js | 2 +- 11 files changed, 409 insertions(+), 62 deletions(-) create mode 100644 certs/server_ca.pem create mode 100644 server/api/signup.ts create mode 100644 server/middleware/signUp.ts diff --git a/axios.config.js b/axios.config.js index 1b22387..dd8d5b5 100644 --- a/axios.config.js +++ b/axios.config.js @@ -1,9 +1,8 @@ import axios from 'axios'; -import serversideConfig from './serversideConfig.js' //create axios instance const Axios = axios.create({ - baseURL: `http://${serversideConfig.url}:${serversideConfig.port}`, + // baseURL: `https://${serversideConfig.url}:${serversideConfig.port}`, headers: { // 'Accept': 'application/json', 'Content-Type': 'application/json', diff --git a/backend/controller/issueVariants.js b/backend/controller/issueVariants.js index e209b49..8a4579c 100644 --- a/backend/controller/issueVariants.js +++ b/backend/controller/issueVariants.js @@ -8,7 +8,7 @@ import { deleteIssueVariantById, deleteIssueVariantByIssueSlipId, insertIssueVariant, -} from "../models/issuesModel.js"; +} from "../models/issueVariantsModel.js"; //get all issue variants export const showIssueVariants = (req, res) => { diff --git a/backend/index.js b/backend/index.js index ade66eb..b849d3e 100644 --- a/backend/index.js +++ b/backend/index.js @@ -20,7 +20,7 @@ const app = express(); //setup cors const corsOptions = { - origin: 'https://localhost:4173', + origin: 'https://localhost:3000', headers: 'authorization, content-type', methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', credentials: true, @@ -42,11 +42,11 @@ var certificate = fs.readFileSync('../certs/localhost.crt'); var server = https.createServer({ key: privateKey, - cert: certificate + cert: certificate, }, app); -// const PORT = process.env.PORT || 5172; -const PORT = process.env.PORT || config.port; +// const PORT = process.env.PORT || 4172; +const PORT = process.env.PORT || serversideConfig.port; //PORT server.listen(PORT, () => { diff --git a/certs/server_ca.pem b/certs/server_ca.pem new file mode 100644 index 0000000..2c38ee9 --- /dev/null +++ b/certs/server_ca.pem @@ -0,0 +1,51 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEogIBAAKCAQEAmhH63xr2TscMN+LXYWIiuDmoA71W4qTBd7Or3vwj1TnuOoXG +ikBBJbrdQ2ux3tAm1AeMtl664pFI5Qo/SmnJYt5I9uHKlfJ1//OZnKfwjFTtriyK +oyQ15dX84nmS5U7pWL6k1I5a4bCu8NZ+kfCKP+m0NBOY0edZD44xI2R6vRAoAIL+ +N112DyWkil8L+uNodW6SS3CMg/y8I8qOGsqeN9BllYg/VWo8nTwiNthRGCXIDurG +Z2NH/hoO+C4hA3C8qwjhD/urhs1WgV9570OLO7Hx3at0JRFan49Qu4Edj+tb4/tC +PviJHcGcalno4jO651ZB/TUJtNm0TgzGeKeh8wIDAQABAoIBABdXjAOLKS/sNiyt +YGYvoQT6LztJz0UNIwaIoQxqdN9UJISXSeoeLACUW/tf8JXKQWe0MRxcI8I5sqqI +r+gNOOaSuMk2kiO/lSMO/AHg66/HGi9eLi7jSIsmrWZ+dsPo/a9lSsGtQ5WX2BlC +1fA0Wi2usY+GPIvomfSiXU14ZqQH92lBrw4rD0vUVzaX5/J7eke7DD+Pjvwpyv8X +GF1lH/cz2g2lIr/+QuTf0mzGulO/8UAUo/aiUw+yaLd69yh7dMT8DkWVmmGAIYa7 +P6nCKUlsjP9I+CSSsRbZtOwZBj0PGW0gVVxqdf+yfcIvYraN1gf1JRGEyduYEgmg +ujs1SgkCgYEAyKAHFlnI51YnpXKpj4+yVzHyzp//C/E3vDugahlQSzaV19lFJfXv +qbqnd5UJHTDjnbdND1qlW7k5oxX72J952aRfE4p5nyN1oCl+fB2LRnAJrIIIuI/z +dBo11CNsin+8lOfc2Cw0I3gJLJtySaqYeRQdiYfzGapExFtFMtPg7T0CgYEAxJhu +SMMZHz1R+IUGqbWkZrQLOMlUttqUwWLP8JTrJEBtfo/pDfKfV+PTXPvdnOExRwnH +oxzFgtDXO2N0gMQ49loaDj8LzuSN2yOl8CdtXiamYL5pVCB6fwOC5nBFz7qFzvIs +OLSI4Qp+acHuozcTn4aqyLxe9a2O8HjHvC0hHu8CgYBLIdrlnOQm9lXMmN81Gyw/ +iT4T8UkTUNd9j5rogOhX8m41MnG54JtLJdKXbuHF48wqAT5DlL++VORn1dDF9Bsu +zWapq78WQLJJM6DhnDLPQx/sUZowfABBJ5unAUkhqOqXnSlQb2VrLwXIhcJMIi4N +keHp4lbA8snj+wY0HbLrRQKBgCuZOmv8iGe7K6CXr8CXPdxg9VQkohrjIrY4ebD6 +9aLWfvHgbGjhc6EEL22hlaYi8tC0RIfR66N1OSY8iiu8WH2ZwcmDBdVeLm942mYF ++GU24RL3Z1h203OzjaYZJAJLdT1Ny6zPrMNrlllR3uBnaHyqWtmlnNGTKe3+ex0q +TPwVAoGAO4rVc9aMEPLX0LWP2diqJR9WYuP3ctzocTUFNGb44Erc+aZ/cTw7wot5 +E98A2JbHB0cgi/CkH2NDTdrVQwkWvo4wmOXHKeRunvYLCPM4wmIJeYjMwGu1v5jY +MXl5VKJjejnMba4yr4eKUeBVWkE0a4NKysggG9TpfqVkWfdMjTg= +-----END RSA PRIVATE KEY----- +-----BEGIN CERTIFICATE----- +MIID9zCCAt+gAwIBAgIJSn3caCSNY4u+MA0GCSqGSIb3DQEBCwUAMGkxFDASBgNV +BAMTC2V4YW1wbGUub3JnMQswCQYDVQQGEwJVUzERMA8GA1UECBMIVmlyZ2luaWEx +EzARBgNVBAcTCkJsYWNrc2J1cmcxDTALBgNVBAoTBFRlc3QxDTALBgNVBAsTBFRl +c3QwHhcNMjMxMDE2MDk0MTI3WhcNMjMxMTE1MTA0MTI3WjBpMRQwEgYDVQQDEwtl +eGFtcGxlLm9yZzELMAkGA1UEBhMCVVMxETAPBgNVBAgTCFZpcmdpbmlhMRMwEQYD +VQQHEwpCbGFja3NidXJnMQ0wCwYDVQQKEwRUZXN0MQ0wCwYDVQQLEwRUZXN0MIIB +IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmhH63xr2TscMN+LXYWIiuDmo +A71W4qTBd7Or3vwj1TnuOoXGikBBJbrdQ2ux3tAm1AeMtl664pFI5Qo/SmnJYt5I +9uHKlfJ1//OZnKfwjFTtriyKoyQ15dX84nmS5U7pWL6k1I5a4bCu8NZ+kfCKP+m0 +NBOY0edZD44xI2R6vRAoAIL+N112DyWkil8L+uNodW6SS3CMg/y8I8qOGsqeN9Bl +lYg/VWo8nTwiNthRGCXIDurGZ2NH/hoO+C4hA3C8qwjhD/urhs1WgV9570OLO7Hx +3at0JRFan49Qu4Edj+tb4/tCPviJHcGcalno4jO651ZB/TUJtNm0TgzGeKeh8wID +AQABo4GhMIGeMAsGA1UdDwQEAwIC9DAxBgNVHSUEKjAoBggrBgEFBQcDAQYIKwYB +BQUHAwIGCCsGAQUFBwMDBggrBgEFBQcDCDBcBgNVHREEVTBTgglsb2NhbGhvc3SC +FWxvY2FsaG9zdC5sb2NhbGRvbWFpboIGbHZoLm1lgggqLmx2aC5tZYIFWzo6MV2H +BH8AAAGHEP6AAAAAAAAAAAAAAAAAAAEwDQYJKoZIhvcNAQELBQADggEBAD1JPu9a +eRd7j/VIuwxZf7Ex3S8Dcxoynm9btPm9F09w/AlftKmaikGyhFMhR1bu5DArKaxe +eQ8Qsp94DJHMBmEPxnjAnl1HB6FvVnG2u9ncpmflD352ZJDwMPaUx6FoBxmt5bFX +Dug2dnV1baj6ZfvsLcKROzxG6KvzB84wQDK1C0qEHHKfoJ3+FN/2BPZYnKSDiPMz +R5gfjsWOTbp7j0Amg8Mi4+LAGQ6VSYPdy7OfClcNsG4kFDrTzkojbsWT4o/JkzBl +XZ3D6UN1L4ONl0pwBblee6p/o6/qOzD86S+vctsY9Ee/4UkZrf7Sq3QEGsRr5rI1 +LQCaGcSTw6A7lDk= +-----END CERTIFICATE----- \ No newline at end of file diff --git a/components/LoginForm.vue b/components/LoginForm.vue index 61d3f4e..e713898 100644 --- a/components/LoginForm.vue +++ b/components/LoginForm.vue @@ -32,47 +32,198 @@ +
+ +
+ @@ -89,7 +240,7 @@ export default { align-items: center; justify-content: center; width: 31.25rem; - height: 31.25rem; + height: 33rem; border-radius: 0.625rem; padding: 2.5rem 1.875rem; gap: 1.875rem; @@ -165,6 +316,16 @@ export default { gap: 0.625rem; } +.form-field-error-msg { + display: flex; + flex-direction: column; + align-items: center; + justify-content: space-between; + width: 25rem; + height: 3rem; + gap: 0.4rem; +} + label { display: flex; flex-direction: row; diff --git a/nuxt.config.ts b/nuxt.config.ts index 8851e77..f604380 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,4 +1,10 @@ // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ - devtools: { enabled: true } + devtools: { enabled: true }, + devServer: { + https: { + key: './certs/localhost.key', + cert: './certs/localhost.crt' + } + }, }) diff --git a/server/api/login.ts b/server/api/login.ts index 42f79b5..f75609d 100644 --- a/server/api/login.ts +++ b/server/api/login.ts @@ -1,30 +1,14 @@ -import { globalUserObject } from "../middleware/login"; +import { loginSuccessful, errorMsg } from "../middleware/login"; export default defineEventHandler(async (event) => { - const body = await readBody(event) - - let correctUsername; - let correctPassword; - if (globalUserObject !== null) { - correctUsername = globalUserObject.username; - correctPassword = globalUserObject.password; - } - - let authorized = false; - - if (body.username == correctUsername && body.password == correctPassword) { - authorized = true; - } - - if (!authorized) { + if (!loginSuccessful) { throw createError({ statusCode: 400, - statusMessage: 'Username or password not valid.', + statusMessage: errorMsg, }) } - setResponseStatus(event, 202) + setResponseStatus(event, 200) return 'Successfully logged in.' - }) diff --git a/server/api/signup.ts b/server/api/signup.ts new file mode 100644 index 0000000..e8e706e --- /dev/null +++ b/server/api/signup.ts @@ -0,0 +1,14 @@ +import { registeringSuccessful, errorMsg } from "../middleware/signUp.js"; + +export default defineEventHandler(async (event) => { + + if (!registeringSuccessful) { + throw createError({ + statusCode: 400, + statusMessage: errorMsg, + }) + } + + setResponseStatus(event, 202) + return 'Successfully signed up.' +}) diff --git a/server/middleware/login.ts b/server/middleware/login.ts index 2ce49b5..73c542e 100644 --- a/server/middleware/login.ts +++ b/server/middleware/login.ts @@ -1,17 +1,66 @@ -let globalUserObject: { [key: string]: any } | null = null; -// let globalUserObject = null; +import axios, { AxiosError } from 'axios'; +import serversideConfig from '../../serversideConfig'; +import fs from 'fs'; +import https from 'https'; -export default defineEventHandler((event) => { +let loginSuccessful = false; +let errorMsg = ''; + +export default defineEventHandler(async (event) => { + loginSuccessful = false; if (event.path.startsWith("/api/login")) { + const body = await readBody(event) + + // read the certificate and create agent + const caCert = fs.readFileSync('./certs/server_ca.pem'); + // const httpsAgent = new https.Agent({ + // keepAlive: true, + // ca: caCert, + // rejectUnauthorized: true, + // }); + + const agent = new https.Agent({ + rejectUnauthorized: false, + }); + + const axiosInstance = axios.create({ + headers: { + 'Content-Type': 'application/json', + Accept: "*", + }, + httpsAgent: agent + }); + // get user object from backend - const userObject = { - username: "test", - password: "asd" + try { + let res = await axiosInstance.post(`https://${serversideConfig.url}:${serversideConfig.port}/login`, { + username: body.username, + password: body.password, + }); + loginSuccessful = true; + } catch (err) { + if (axios.isAxiosError(err)) { + const axiosError = err as AxiosError; + + if (axiosError.response) { + // Axios error + console.error(axiosError.response.data.message); + errorMsg = axiosError.response.data.message; + } else if (axiosError.request) { + // If error was caused by the request + console.error(axiosError.request); + } else { + // Other errors + console.error('Error', axiosError.message); + } + } else { + // No AxiosError + console.error('Error', err); + } } - globalUserObject = userObject; } }) -export { globalUserObject }; \ No newline at end of file +export { loginSuccessful, errorMsg }; \ No newline at end of file diff --git a/server/middleware/signUp.ts b/server/middleware/signUp.ts new file mode 100644 index 0000000..3ddef44 --- /dev/null +++ b/server/middleware/signUp.ts @@ -0,0 +1,83 @@ +import axios, { AxiosError } from 'axios'; +import serversideConfig from '../../serversideConfig'; +import fs from 'fs'; +import https from 'https'; + +let registeringSuccessful = false; +let errorMsg = ''; + +export default defineEventHandler(async (event) => { + registeringSuccessful = false; + + if (event.path.startsWith("/api/signup")) { + + const body = await readBody(event) + + // read the certificate and create agent + const caCert = fs.readFileSync('./certs/server_ca.pem'); + // const httpsAgent = new https.Agent({ + // keepAlive: true, + // ca: caCert, + // rejectUnauthorized: true, + // }); + + const agent = new https.Agent({ + rejectUnauthorized: false, + }); + + const axiosInstance = axios.create({ + headers: { + 'Content-Type': 'application/json', + Accept: "*", + }, + httpsAgent: agent + }); + + // do the post request in the backend + try { + let res = await axiosInstance.post(`https://${serversideConfig.url}:${serversideConfig.port}/signup`, { + username: body.username, + password: body.password, + password_repeat: body.password_repeat, + lastLogin: body.lastLogin, + fullName: body.fullName, + email: body.email, + phonenumber: body.phonenumber, + address: body.address, + city: body.city, + postcode: body.postcode, + adminBool: body.adminBool, + technician1Bool: body.technician1Bool, + technician2Bool: body.technician2Bool, + technicianMonitoringBool: body.technicianMonitoringBool, + merchantBool: body.merchantBool, + internBool: body.internBool, + }); + registeringSuccessful = true; + + } catch (err) { + if (axios.isAxiosError(err)) { + const axiosError = err as AxiosError; + + if (axiosError.response) { + // Axios error + console.error(axiosError.response.data.message); + errorMsg = axiosError.response.data.message; + } else if (axiosError.request) { + // If error was caused by the request + console.error(axiosError.request); + } else { + // Other errors + console.error('Error', axiosError.message); + } + } else { + // No AxiosError + console.error('Error', err); + } + } + } +}) + +export { registeringSuccessful, errorMsg }; + +registeringSuccessful = false; \ No newline at end of file diff --git a/serversideConfig.js b/serversideConfig.js index 427ae6f..8e35b21 100644 --- a/serversideConfig.js +++ b/serversideConfig.js @@ -2,7 +2,7 @@ const serversideConfig = { // url: 'tueitapp.tueit.de', // port: 8000, url: 'localhost', - port: 3000, + port: 4172, }; export default serversideConfig; \ No newline at end of file From c91f9a53b63d2acb243f14cf084f1c2af4a9da06 Mon Sep 17 00:00:00 2001 From: "selina.mail" Date: Thu, 8 Feb 2024 13:12:01 +0100 Subject: [PATCH 06/20] added get functions --- backend/models/configItemsModel.js | 4 +- components/LoginForm.vue | 87 +- components/server/Asset.vue | 39 +- components/server/AssetTable.vue | 39 +- components/server/HardwareSpecifications.vue | 43 +- components/server/IssueSlipTable.vue | 37 +- components/server/IssueTable.vue | 33 +- .../server/MaintenanceVisitsTemplateTable.vue | 32 +- components/server/NetworkSpecifications.vue | 53 +- .../server/ProductionOrdersTemplateTable.vue | 30 +- components/server/SoftwareSpecifications.vue | 37 +- components/server/SolutionTable.vue | 32 +- documentation/.$Datenbankmodell.drawio.bkp | 971 +++ documentation/.$Datenbankmodell.drawio.dtmp | 974 +++ documentation/Datenbankmodell.drawio | 19 +- package-lock.json | 6176 +++++++++++------ package.json | 10 +- routerFrontend/index.js | 4 +- server/api/getAllConfigItems.ts | 14 + server/api/getAllIssueSlips.ts | 14 + server/api/getAllIssues.ts | 14 + server/api/getAllMaintenanceVisitTemplates.ts | 14 + server/api/getAllProductionOrderTemplates.ts | 14 + server/api/getAllSolutions.ts | 14 + server/api/getConfigItem/[id].ts | 14 + server/middleware/configItems.ts | 83 + server/middleware/issueSlips.ts | 51 + server/middleware/issues.ts | 51 + .../middleware/maintenanceVisitTemplates.ts | 51 + server/middleware/productionOrderTemplates.ts | 51 + server/middleware/solutions.ts | 51 + 31 files changed, 6614 insertions(+), 2442 deletions(-) create mode 100644 documentation/.$Datenbankmodell.drawio.bkp create mode 100644 documentation/.$Datenbankmodell.drawio.dtmp create mode 100644 server/api/getAllConfigItems.ts create mode 100644 server/api/getAllIssueSlips.ts create mode 100644 server/api/getAllIssues.ts create mode 100644 server/api/getAllMaintenanceVisitTemplates.ts create mode 100644 server/api/getAllProductionOrderTemplates.ts create mode 100644 server/api/getAllSolutions.ts create mode 100644 server/api/getConfigItem/[id].ts create mode 100644 server/middleware/configItems.ts create mode 100644 server/middleware/issueSlips.ts create mode 100644 server/middleware/issues.ts create mode 100644 server/middleware/maintenanceVisitTemplates.ts create mode 100644 server/middleware/productionOrderTemplates.ts create mode 100644 server/middleware/solutions.ts diff --git a/backend/models/configItemsModel.js b/backend/models/configItemsModel.js index 01a9903..a88c26b 100644 --- a/backend/models/configItemsModel.js +++ b/backend/models/configItemsModel.js @@ -61,7 +61,7 @@ export const updateConfigItemById = async (data, result) => { const id = data.primaryID; try { let sql = `UPDATE changeDB SET assetName = ?, customerID = ?, customer = ?, location = ?, remoteLocation = ?, type = ?, description = ?, notes = ?, state = ?, lastView = ?, user = ?, hardwareBool = ?, model = ?, serialnumber = ?, CPU = ?, RAM = ?, storageConfiguration = ?, miscellaneous = ?, softwareBool = ?, software = ?, version = ?, networkBool = ?, IPv4 = ?, IPv6 = ?, MAC = ?, subnetmask = ? WHERE primaryID = ?`; - const results = await ownConn.query(sql, [data.assetName, data.customerID, data.customer, data.location, data.remoteLocation, data.type, data.description, data.notes, data.state, data.lastView, data.user, data.hardwareBool, data.model, data.serialnumber, data.CPU, data.RAM, data.storageConfiguration, data.miscellaneous, data.softwareBool, data.software, data.version, data.networkBool, data.IPv4, data.IPv6, data.MAC, data.subnetmask, id]); + const results = await ownConn.query(sql, [data.assetName, data.customerID, data.customer, data.location, data.remoteLocation, data.type, data.description, data.notes, data.state, data.lastView, data.user, data.hardwareBool, data.model, data.serialnumber, data.CPU, data.RAM, data.storageConfiguration, data.miscellaneous, data.softwareBool, data.software, data.version, data.license, data.networkBool, data.IPv4, data.IPv6, data.MAC, data.subnetmask, id]); result(null, results); } catch (err) { @@ -74,7 +74,7 @@ export const updateConfigItemById = async (data, result) => { //insert config item to databased export const insertConfigItem = async (data, result) => { try { - const results = await ownConn.query(`INSERT INTO changeDB(assetName, customerID, customer, location, remoteLocation, type, description, notes, state, lastView, user, hardwareBool, model, serialnumber, CPU, RAM, storageConfiguration, miscellaneous, softwareBool, software, version, networkBool, IPv4, IPv6, MAC, subnetmask) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [data.assetName, data.customerID, data.customer, data.location, data.remoteLocation, data.type, data.description, data.notes, data.state, data.lastView, data.user, data.hardwareBool, data.model, data.serialnumber, data.CPU, data.RAM, data.storageConfiguration, data.miscellaneous, data.softwareBool, data.software, data.version, data.networkBool, data.IPv4, data.IPv6, data.MAC, data.subnetmask]) + const results = await ownConn.query(`INSERT INTO changeDB(assetName, customerID, customer, location, remoteLocation, type, description, notes, state, lastView, user, hardwareBool, model, serialnumber, CPU, RAM, storageConfiguration, miscellaneous, softwareBool, software, version, license, networkBool, IPv4, IPv6, MAC, subnetmask) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, [data.assetName, data.customerID, data.customer, data.location, data.remoteLocation, data.type, data.description, data.notes, data.state, data.lastView, data.user, data.hardwareBool, data.model, data.serialnumber, data.CPU, data.RAM, data.storageConfiguration, data.miscellaneous, data.softwareBool, data.software, data.version, data.license, data.networkBool, data.IPv4, data.IPv6, data.MAC, data.subnetmask]) result(null, results); } catch (err) { diff --git a/components/LoginForm.vue b/components/LoginForm.vue index e713898..6571fd2 100644 --- a/components/LoginForm.vue +++ b/components/LoginForm.vue @@ -46,10 +46,12 @@ diff --git a/components/server/Asset.vue b/components/server/Asset.vue index cadb524..6055d3f 100644 --- a/components/server/Asset.vue +++ b/components/server/Asset.vue @@ -1,31 +1,31 @@ - - \ No newline at end of file +} + \ No newline at end of file diff --git a/components/server/IssueTable.vue b/components/server/IssueTable.vue index 3ca558b..460fa83 100644 --- a/components/server/IssueTable.vue +++ b/components/server/IssueTable.vue @@ -14,17 +14,18 @@ State Amount - + - ... + {{ issue.name }} - ... + {{ issue.type }} - ... - ... + {{ issue.state }} + {{ issue.amount }} @@ -32,9 +33,26 @@ diff --git a/nuxt.config.ts b/nuxt.config.ts index f604380..5f1f9ea 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,4 +1,5 @@ // https://nuxt.com/docs/api/configuration/nuxt-config + export default defineNuxtConfig({ devtools: { enabled: true }, devServer: { diff --git a/routerFrontend/index.js b/routerFrontend/index.js index 50229d5..6113f9f 100644 --- a/routerFrontend/index.js +++ b/routerFrontend/index.js @@ -33,6 +33,10 @@ const router = createRouter({ path: '/assets', component: AssetPage }, + { + path: '/chosenAsset', + component: AssetPage + }, { path: '/solutions', component: SolutionPage diff --git a/server/api/getAllConfigItems.ts b/server/api/getAllConfigItems.ts index db694f8..3870135 100644 --- a/server/api/getAllConfigItems.ts +++ b/server/api/getAllConfigItems.ts @@ -1,7 +1,15 @@ import { configItems, errorMsg } from "../middleware/configItems"; +import { OutgoingMessage } from 'http'; export default defineEventHandler(async (event) => { + const headers: Record[1]> = { + 'Access-Control-Allow-Origin': 'https://tueitapp.tueit.de', + 'Access-Control-Allow-Headers': 'authorization, content-type', + 'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE', + }; + setResponseHeaders(event, headers) + if (!(errorMsg === '')) { throw createError({ statusCode: 400, diff --git a/server/api/getAllIssueSlips.ts b/server/api/getAllIssueSlips.ts index 1b8cec2..5b2bce7 100644 --- a/server/api/getAllIssueSlips.ts +++ b/server/api/getAllIssueSlips.ts @@ -1,7 +1,15 @@ import { issueSlips, errorMsg } from "../middleware/issueSlips"; +import { OutgoingMessage } from 'http'; export default defineEventHandler(async (event) => { + const headers: Record[1]> = { + 'Access-Control-Allow-Origin': 'https://tueitapp.tueit.de', + 'Access-Control-Allow-Headers': 'authorization, content-type', + 'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE', + }; + setResponseHeaders(event, headers) + if (!(errorMsg === '')) { throw createError({ statusCode: 400, diff --git a/server/api/getAllIssues.ts b/server/api/getAllIssues.ts index 4901968..4ca945f 100644 --- a/server/api/getAllIssues.ts +++ b/server/api/getAllIssues.ts @@ -1,7 +1,15 @@ import { issues, errorMsg } from "../middleware/issues"; +import { OutgoingMessage } from 'http'; export default defineEventHandler(async (event) => { + const headers: Record[1]> = { + 'Access-Control-Allow-Origin': 'https://tueitapp.tueit.de', + 'Access-Control-Allow-Headers': 'authorization, content-type', + 'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE', + }; + setResponseHeaders(event, headers) + if (!(errorMsg === '')) { throw createError({ statusCode: 400, diff --git a/server/api/getAllMaintenanceVisitTemplates.ts b/server/api/getAllMaintenanceVisitTemplates.ts index 6eeacc1..52a052d 100644 --- a/server/api/getAllMaintenanceVisitTemplates.ts +++ b/server/api/getAllMaintenanceVisitTemplates.ts @@ -1,7 +1,15 @@ import { maintenanceVisitTemplates, errorMsg } from "../middleware/maintenanceVisitTemplates"; +import { OutgoingMessage } from 'http'; export default defineEventHandler(async (event) => { + const headers: Record[1]> = { + 'Access-Control-Allow-Origin': 'https://tueitapp.tueit.de', + 'Access-Control-Allow-Headers': 'authorization, content-type', + 'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE', + }; + setResponseHeaders(event, headers) + if (!(errorMsg === '')) { throw createError({ statusCode: 400, diff --git a/server/api/getAllProductionOrderTemplates.ts b/server/api/getAllProductionOrderTemplates.ts index 0f9e02f..bbc4520 100644 --- a/server/api/getAllProductionOrderTemplates.ts +++ b/server/api/getAllProductionOrderTemplates.ts @@ -1,7 +1,15 @@ import { productionOrderTemplates, errorMsg } from "../middleware/productionOrderTemplates"; +import { OutgoingMessage } from 'http'; export default defineEventHandler(async (event) => { + const headers: Record[1]> = { + 'Access-Control-Allow-Origin': 'https://tueitapp.tueit.de', + 'Access-Control-Allow-Headers': 'authorization, content-type', + 'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE', + }; + setResponseHeaders(event, headers) + if (!(errorMsg === '')) { throw createError({ statusCode: 400, diff --git a/server/api/getAllSolutions.ts b/server/api/getAllSolutions.ts index 0e5204d..0f5ec3f 100644 --- a/server/api/getAllSolutions.ts +++ b/server/api/getAllSolutions.ts @@ -1,7 +1,15 @@ import { solutions, errorMsg } from "../middleware/solutions"; +import { OutgoingMessage } from 'http'; export default defineEventHandler(async (event) => { + const headers: Record[1]> = { + 'Access-Control-Allow-Origin': 'https://tueitapp.tueit.de', + 'Access-Control-Allow-Headers': 'authorization, content-type', + 'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE', + }; + setResponseHeaders(event, headers) + if (!(errorMsg === '')) { throw createError({ statusCode: 400, diff --git a/server/api/getConfigItem/[id].ts b/server/api/getConfigItem/[id].ts index 0afed0b..7253901 100644 --- a/server/api/getConfigItem/[id].ts +++ b/server/api/getConfigItem/[id].ts @@ -1,7 +1,15 @@ import { configItem, errorMsg } from "../../middleware/configItems"; +import { OutgoingMessage } from 'http'; export default defineEventHandler(async (event) => { + const headers: Record[1]> = { + 'Access-Control-Allow-Origin': 'https://tueitapp.tueit.de', + 'Access-Control-Allow-Headers': 'authorization, content-type', + 'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE', + }; + setResponseHeaders(event, headers) + if (!(errorMsg === '')) { throw createError({ statusCode: 400, diff --git a/server/api/login.ts b/server/api/login.ts index f75609d..6eda633 100644 --- a/server/api/login.ts +++ b/server/api/login.ts @@ -1,7 +1,15 @@ import { loginSuccessful, errorMsg } from "../middleware/login"; +import { OutgoingMessage } from 'http'; export default defineEventHandler(async (event) => { + const headers: Record[1]> = { + 'Access-Control-Allow-Origin': 'https://tueitapp.tueit.de', + 'Access-Control-Allow-Headers': 'authorization, content-type', + 'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE', + }; + setResponseHeaders(event, headers) + if (!loginSuccessful) { throw createError({ statusCode: 400, diff --git a/server/api/signup.ts b/server/api/signup.ts index e8e706e..3afb384 100644 --- a/server/api/signup.ts +++ b/server/api/signup.ts @@ -1,7 +1,15 @@ import { registeringSuccessful, errorMsg } from "../middleware/signUp.js"; +import { OutgoingMessage } from 'http'; export default defineEventHandler(async (event) => { + const headers: Record[1]> = { + 'Access-Control-Allow-Origin': 'https://tueitapp.tueit.de', + 'Access-Control-Allow-Headers': 'authorization, content-type', + 'Access-Control-Allow-Methods': 'GET,HEAD,PUT,PATCH,POST,DELETE', + }; + setResponseHeaders(event, headers) + if (!registeringSuccessful) { throw createError({ statusCode: 400, diff --git a/server/middleware/configItems.ts b/server/middleware/configItems.ts index 83a71fb..0c00e5d 100644 --- a/server/middleware/configItems.ts +++ b/server/middleware/configItems.ts @@ -34,6 +34,7 @@ export default defineEventHandler(async (event) => { console.error(axiosError.response.data.message); errorMsg = axiosError.response.data.message; } else if (axiosError.request) { + console.log(err) // If error was caused by the request console.error(axiosError.request); } else { From 2ced6f82d1188313afcd877c7bf76b434d37661f Mon Sep 17 00:00:00 2001 From: "selina.mail" Date: Wed, 14 Feb 2024 09:36:49 +0100 Subject: [PATCH 08/20] fixed cors headers --- components/server/Asset.vue | 71 ++- components/server/HardwareSpecifications.vue | 39 +- components/server/NetworkSpecifications.vue | 1 - layouts/Actionbar.vue | 510 ++++++++++--------- pages/assets.vue | 2 +- routerFrontend/index.js | 24 +- server/api/login.ts | 5 +- 7 files changed, 387 insertions(+), 265 deletions(-) diff --git a/components/server/Asset.vue b/components/server/Asset.vue index 6055d3f..88f6558 100644 --- a/components/server/Asset.vue +++ b/components/server/Asset.vue @@ -1,31 +1,48 @@ diff --git a/components/server/ClientTable.vue b/components/server/ClientTable.vue index 50b521c..f2a9326 100644 --- a/components/server/ClientTable.vue +++ b/components/server/ClientTable.vue @@ -1,20 +1,25 @@ @@ -126,5 +131,4 @@ th { .Name { width: 60%; -} - \ No newline at end of file +} \ No newline at end of file diff --git a/components/server/HardwareSpecifications.vue b/components/server/HardwareSpecifications.vue index 1b0a68f..ae8832e 100644 --- a/components/server/HardwareSpecifications.vue +++ b/components/server/HardwareSpecifications.vue @@ -39,8 +39,9 @@

Storage configuration:

-
{{ item.storageConfiguration }}
+ @@ -49,8 +50,8 @@

Miscellaneous:

-
{{ item.miscellaneous }}
+
diff --git a/components/server/InstanceChecklist.vue b/components/server/InstanceChecklist.vue index 6570d0c..2707f3e 100644 --- a/components/server/InstanceChecklist.vue +++ b/components/server/InstanceChecklist.vue @@ -2,37 +2,39 @@
Checklist:
- - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
- Step - Asset - Task - CommentsDone
- ... - ... - ... - ...
+ Step + Asset + Task + CommentsDone
+ ... + ... + ... + ...
diff --git a/components/server/IssueSlipTable.vue b/components/server/IssueSlipTable.vue index 5dfc07a..db0e3a9 100644 --- a/components/server/IssueSlipTable.vue +++ b/components/server/IssueSlipTable.vue @@ -2,35 +2,40 @@
Last viewed:
- - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
- ClientID - - Ticket No. - Creation DateUser
- {{ issueSlip.customer }} - {{ issueSlip.primaryID }} - {{ issueSlip.ticketNo }} - {{ issueSlip.creationDate }} {{ issueSlip.user }}
+ Client + ID + + Ticket No. + Creation DateUser
+ {{ issueSlip.customer }} + {{ issueSlip.primaryID }} + {{ issueSlip.ticketNo }} + {{ issueSlip.creationDate }} {{ issueSlip.user }}
@@ -213,5 +218,4 @@ th { .label-lightmode { color: #000; -} - \ No newline at end of file +} \ No newline at end of file diff --git a/components/server/IssueSlipTableNoClient.vue b/components/server/IssueSlipTableNoClient.vue index 20990bf..54714e0 100644 --- a/components/server/IssueSlipTableNoClient.vue +++ b/components/server/IssueSlipTableNoClient.vue @@ -2,28 +2,33 @@
Issue slip:
- - - - - - - - - - - - + + + + + + + + + + + + + +
ID - - Ticket No. - Creation DateUser
- ... - ... - ......
+ ID + + Ticket No. + Creation DateUser
+ ... + ... + ......
diff --git a/components/server/IssueTable.vue b/components/server/IssueTable.vue index 460fa83..67697cc 100644 --- a/components/server/IssueTable.vue +++ b/components/server/IssueTable.vue @@ -2,31 +2,33 @@
Issues:
- - - - - - - - - - - - + + + + + + + + + + + + + +
- Name - Type - StateAmount
- {{ issue.name }} - {{ issue.type }} - {{ issue.state }}{{ issue.amount }}
+ Name + Type + StateAmount
+ {{ issue.name }} + {{ issue.type }} + {{ issue.state }}{{ issue.amount }}
diff --git a/components/server/IssueVariants.vue b/components/server/IssueVariants.vue index fa3af27..0bad0ef 100644 --- a/components/server/IssueVariants.vue +++ b/components/server/IssueVariants.vue @@ -2,36 +2,38 @@
Variants:
- - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
- Name - Properties - State - AmountPrice
- ... - ... - ... - ......
+ Name + Properties + State + AmountPrice
+ ... + ... + ... + ......
@@ -198,4 +200,5 @@ th { .label-lightmode { color: #000; -} \ No newline at end of file +} + \ No newline at end of file diff --git a/components/server/MaintenanceVisitsInstanceTable.vue b/components/server/MaintenanceVisitsInstanceTable.vue index e2c4776..0ad927e 100644 --- a/components/server/MaintenanceVisitsInstanceTable.vue +++ b/components/server/MaintenanceVisitsInstanceTable.vue @@ -2,40 +2,44 @@
Instances:
- - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + +
- ID - Maintenance type - State - Creation date - Completion dateUser
- ... - ... - ... - ... - ......
+ ID + Maintenance type + State + Creation date + Completion dateUser
+ ... + ... + ... + ... + ......
diff --git a/components/server/MaintenanceVisitsTemplateTable.vue b/components/server/MaintenanceVisitsTemplateTable.vue index c9d3564..902ce6c 100644 --- a/components/server/MaintenanceVisitsTemplateTable.vue +++ b/components/server/MaintenanceVisitsTemplateTable.vue @@ -2,35 +2,40 @@
Last viewed:
- - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
- Client - NameID - - TypeUser
- {{ template.customer }} - {{ template.name }} - {{ template.checklistID }} - {{ template.type }} {{ template.user }}
+ Client + Name + ID + + TypeUser
+ {{ template.customer }} + {{ template.name }} + {{ template.checklistID }} + {{ template.type }} {{ template.user }}
@@ -215,5 +220,4 @@ th { .label-lightmode { color: #000; -} - \ No newline at end of file +} \ No newline at end of file diff --git a/components/server/MaintenanceVisitsTemplateTableNoClient.vue b/components/server/MaintenanceVisitsTemplateTableNoClient.vue index 27ecfca..e4dc813 100644 --- a/components/server/MaintenanceVisitsTemplateTableNoClient.vue +++ b/components/server/MaintenanceVisitsTemplateTableNoClient.vue @@ -2,28 +2,33 @@
Templates:
- - - - - - - - - - - - + + + + + + + + + + + + + +
- NameID - - TypeUser
- ... - ... - ......
+ Name + ID + + TypeUser
+ ... + ... + ......
@@ -179,5 +184,4 @@ th { .label-lightmode { color: #000; -} - \ No newline at end of file +} \ No newline at end of file diff --git a/components/server/OrderingInformation.vue b/components/server/OrderingInformation.vue index 84b8abf..a7d932f 100644 --- a/components/server/OrderingInformation.vue +++ b/components/server/OrderingInformation.vue @@ -3,30 +3,32 @@
Ordering information:
- - - - - - - - - - - - + + + + + + + + + + + + + +
- Article - Amount - PriceComments
- ... - ... - ......
+ Article + Amount + PriceComments
+ ... + ... + ......
diff --git a/components/server/ProductionOrdersInstanceTable.vue b/components/server/ProductionOrdersInstanceTable.vue index 1160d8a..05f071f 100644 --- a/components/server/ProductionOrdersInstanceTable.vue +++ b/components/server/ProductionOrdersInstanceTable.vue @@ -2,46 +2,50 @@
Instances:
- - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + +
- ID - Ticket No. - Asset - State - Creation date - Completion dateUser
- ... - ... - ... - ... - ... - ......
+ ID + Ticket No. + Asset + State + Creation date + Completion dateUser
+ ... + ... + ... + ... + ... + ......
diff --git a/components/server/ProductionOrdersTemplateTable.vue b/components/server/ProductionOrdersTemplateTable.vue index 5c65f80..d71ed70 100644 --- a/components/server/ProductionOrdersTemplateTable.vue +++ b/components/server/ProductionOrdersTemplateTable.vue @@ -2,29 +2,34 @@
Last viewed:
- - - - - - - - - - - - + + + + + + + + + + + + + +
- Client - NameID - User
- {{ template.customer }} - {{ template.name }} - {{ template.templateID }} {{ template.user }}
+ Client + Name + ID + User
+ {{ template.customer }} + {{ template.name }} + {{ template.templateID }} {{ template.user }}
@@ -196,5 +201,4 @@ th { .label-lightmode { color: #000; -} - \ No newline at end of file +} \ No newline at end of file diff --git a/components/server/ProductionOrdersTemplateTableNoClient.vue b/components/server/ProductionOrdersTemplateTableNoClient.vue index b6e3053..01cbe48 100644 --- a/components/server/ProductionOrdersTemplateTableNoClient.vue +++ b/components/server/ProductionOrdersTemplateTableNoClient.vue @@ -2,22 +2,27 @@
Templates:
- - - - - - - - - - + + + + + + + + + + + +
- NameID - User
- ... - ......
+ Name + ID + User
+ ... + ......
@@ -160,5 +165,4 @@ th { .label-lightmode { color: #000; -} - \ No newline at end of file +} \ No newline at end of file diff --git a/components/server/SoftwareSpecifications.vue b/components/server/SoftwareSpecifications.vue index 2c20710..608aac0 100644 --- a/components/server/SoftwareSpecifications.vue +++ b/components/server/SoftwareSpecifications.vue @@ -3,24 +3,26 @@
Software specifications:
- - - - - - - - - - + + + + + + + + + + + +
- Software - VersionLicense
- {{ item.software }} - {{ item.version }}{{ item.license }}
+ Software + VersionLicense
+ {{ item.software }} + {{ item.version }}{{ item.license }}
@@ -201,4 +203,5 @@ th { .License { width: 25%; -} \ No newline at end of file +} + \ No newline at end of file diff --git a/components/server/SolutionChecklist.vue b/components/server/SolutionChecklist.vue index f06822c..0e503ed 100644 --- a/components/server/SolutionChecklist.vue +++ b/components/server/SolutionChecklist.vue @@ -2,30 +2,32 @@
Checklist:
- - - - - - - - - - - - + + + + + + + + + + + + + +
- Step - Asset - TaskComments
- ... - ... - ......
+ Step + Asset + TaskComments
+ ... + ... + ......
@@ -180,4 +182,5 @@ th { .label-lightmode { color: #000; -} \ No newline at end of file +} + \ No newline at end of file diff --git a/components/server/SolutionTable.vue b/components/server/SolutionTable.vue index 3d24632..4d7b800 100644 --- a/components/server/SolutionTable.vue +++ b/components/server/SolutionTable.vue @@ -2,37 +2,39 @@
Last viewed:
- - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
- Client - Name - Asset - TypeUser
- {{ sol.customer }} - {{ sol.solutionName }} - {{ sol.assetName }} - {{ sol.type }} {{ sol.user }}
+ Client + Name + Asset + TypeUser
+ {{ sol.customer }} + {{ sol.solutionName }} + {{ sol.assetName }} + {{ sol.type }} {{ sol.user }}
diff --git a/components/server/SolutionTableNoClient.vue b/components/server/SolutionTableNoClient.vue index 315ea65..7fb2c00 100644 --- a/components/server/SolutionTableNoClient.vue +++ b/components/server/SolutionTableNoClient.vue @@ -2,30 +2,32 @@
Solutions:
- - - - - - - - - - - - + + + + + + + + + + + + + +
- Name - Asset - TypeUser
- ... - ... - ......
+ Name + Asset + TypeUser
+ ... + ... + ......
@@ -180,4 +182,5 @@ th { .label-lightmode { color: #000; -} \ No newline at end of file +} + \ No newline at end of file diff --git a/components/server/TemplateChecklist.vue b/components/server/TemplateChecklist.vue index ee1a576..9b6be34 100644 --- a/components/server/TemplateChecklist.vue +++ b/components/server/TemplateChecklist.vue @@ -2,30 +2,32 @@
Checklist:
- - - - - - - - - - - - + + + + + + + + + + + + + +
- Step - Asset - TaskComments
- ... - ... - ......
+ Step + Asset + TaskComments
+ ... + ... + ......
@@ -180,4 +182,5 @@ th { .label-lightmode { color: #000; -} \ No newline at end of file +} + \ No newline at end of file diff --git a/components/server/UserRightsList.vue b/components/server/UserRightsList.vue index 5ca3dc4..19a52e2 100644 --- a/components/server/UserRightsList.vue +++ b/components/server/UserRightsList.vue @@ -2,40 +2,42 @@
Rights:
- - - - - - - - - - - - - - + + + + + + + + + + + + + + + +
- User - Admin - Edit/Delete - CreateView
- ... - - - - - -
+ User + Admin + Edit/Delete + CreateView
+ ... + + + + + +
diff --git a/documentation/.$Datenbankmodell.drawio.dtmp b/documentation/.$Datenbankmodell.drawio.dtmp deleted file mode 100644 index 51a6170..0000000 --- a/documentation/.$Datenbankmodell.drawio.dtmp +++ /dev/null @@ -1,974 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/documentation/Datenbankmodell.drawio b/documentation/Datenbankmodell.drawio index 9ebfbe2..3ada053 100644 --- a/documentation/Datenbankmodell.drawio +++ b/documentation/Datenbankmodell.drawio @@ -1,6 +1,6 @@ - + - + @@ -130,7 +130,7 @@ - + diff --git a/layouts/Actionbar.vue b/layouts/Actionbar.vue index dfc00c1..dc1ed3b 100644 --- a/layouts/Actionbar.vue +++ b/layouts/Actionbar.vue @@ -4,7 +4,7 @@
+ src="../icons/actionbar-icons/Indicator-Icon-Opened.svg"/>
- - - - - - - - - + + + + + + + + +
@@ -36,20 +36,27 @@ definePageMeta({ }) const darkMode = ref(true) - -// to render the right components -const onAssetlist = ref(true) -const onCustomerAssetlist = ref(false) -const onAsset = ref(true) -const onSolutionlistAsset = ref(false) - + \ No newline at end of file + diff --git a/nuxt.config.ts b/nuxt.config.ts index 5f1f9ea..c261123 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -4,8 +4,8 @@ export default defineNuxtConfig({ devtools: { enabled: true }, devServer: { https: { - key: './certs/localhost.key', - cert: './certs/localhost.crt' + key: './certs/privkey.pem', + cert: './certs/fullchain.pem' } }, }) diff --git a/server/middleware/cors.ts b/server/middleware/cors.ts new file mode 100644 index 0000000..c0c8a86 --- /dev/null +++ b/server/middleware/cors.ts @@ -0,0 +1,14 @@ +export default defineEventHandler((event) => { + event.headers.append('Access-Control-Allow-Origin', 'https://tueitapp.tueit.de'); + event.headers.append('Access-Control-Allow-Headers', 'content-type'); + event.headers.append('Access-Control-Allow-Methods', 'GET,HEAD,PUT,PATCH,POST,DELETE'); + event.headers.append('Access-Control-Allow-Credentials', 'true'); + event.headers.append('Access-Control-Options', 'true'); + event.headers.append('Access-Control-Expose-Headers', 'Content-Length,Content-Range'); + event.headers.append('Access-Control-Max-Age', '600'); + event.headers.append('crossOriginResourcePolicy', 'same-origin'); + event.headers.append('crossOriginOpenerPolicy', 'same-origin'); + event.headers.append('crossOriginEmbedderPolicy', 'require-corp'); + event.headers.append('contentSecurityPolicy', "default-src 'self';base-uri 'self';font-src 'self' https: data:;form-action 'self';frame-ancestors 'self';img-src 'self' data:;object-src 'none';script-src 'self';script-src-attr 'none';style-src 'self' https: 'unsafe-inline';upgrade-insecure-requests"); + event.headers.append('X-XSS-Protection', '1'); +}) From 03e4164b97f5e4c48bd14a60cd3c2f68727934af Mon Sep 17 00:00:00 2001 From: "selina.mail" Date: Fri, 16 Feb 2024 17:35:00 +0100 Subject: [PATCH 12/20] changed all urls --- README.md | 4 ++-- backend/index.js | 5 ++++- clientsideConfig.js | 2 +- components/LoginForm.vue | 6 +++--- components/server/Asset.vue | 6 +++--- components/server/AssetTable.vue | 4 ++-- components/server/HardwareSpecifications.vue | 4 ++-- components/server/IssueSlipTable.vue | 4 ++-- components/server/IssueTable.vue | 4 ++-- components/server/MaintenanceVisitsTemplateTable.vue | 4 ++-- components/server/NetworkSpecifications.vue | 4 ++-- components/server/ProductionOrdersTemplateTable.vue | 4 ++-- components/server/SoftwareSpecifications.vue | 4 ++-- components/server/SolutionTable.vue | 4 ++-- 14 files changed, 31 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index f5db2a2..976da46 100644 --- a/README.md +++ b/README.md @@ -22,11 +22,11 @@ bun install ## Development Server -Start the development server on `http://localhost:3000`: +Start the development server on `https://localhost:3000`: ```bash # npm -npm run dev +npm run dev -- --host 0.0.0.0 # pnpm pnpm run dev diff --git a/backend/index.js b/backend/index.js index 619515d..ee388a2 100644 --- a/backend/index.js +++ b/backend/index.js @@ -15,12 +15,15 @@ import fs from "fs"; //import routes import Router from "./routes/routes.js"; +import clientsideConfig from '~/clientsideConfig.js'; + //init express const app = express(); //setup cors const corsOptions = { - origin: 'https://localhost:3000', + // origin: `https://localhost:3000`, + origin: `https://${clientsideConfig.url}:${clientsideConfig.port}`, headers: 'authorization, content-type', methods: 'GET,HEAD,PUT,PATCH,POST,DELETE', credentials: true, diff --git a/clientsideConfig.js b/clientsideConfig.js index a618f85..3c793c4 100644 --- a/clientsideConfig.js +++ b/clientsideConfig.js @@ -1,6 +1,6 @@ const clientsideConfig = { + // later for the server // url: 'tueitapp.tueit.de', - // port: 8000, url: 'localhost', port: 3000, }; diff --git a/components/LoginForm.vue b/components/LoginForm.vue index 6571fd2..cd0fff3 100644 --- a/components/LoginForm.vue +++ b/components/LoginForm.vue @@ -49,7 +49,7 @@ import { useRouter } from 'vue-router'; import { ref } from 'vue'; import Axios from '../axios.config.js'; -import serversideConfig from '../serversideConfig.js'; +import clientsideConfig from '../clientsideConfig.js'; const router = useRouter(); const darkMode = ref(true); @@ -69,7 +69,7 @@ const handleLogin = async () => { } try { - let res = await Axios.post(`https://${serversideConfig.url}:3000/api/login`, requestBody); + let res = await Axios.post(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/login`, requestBody); // something to do with the res? console.log(res.data) @@ -123,7 +123,7 @@ const testFunctionSignup = async () => { } try { - let res = await Axios.post(`https://${serversideConfig.url}:3000/api/signup`, requestBody); + let res = await Axios.post(`https://${clientsideConfig.url}:${clientsideConfig.port}/api/signup`, requestBody); // something to do with the res? console.log(res.data) diff --git a/components/server/Asset.vue b/components/server/Asset.vue index ad3f49a..141c78a 100644 --- a/components/server/Asset.vue +++ b/components/server/Asset.vue @@ -76,7 +76,7 @@ @@ -162,14 +162,6 @@ onMounted(() => { diff --git a/components/server/AssetTable.vue b/components/server/AssetTable.vue index 98749b7..877096b 100644 --- a/components/server/AssetTable.vue +++ b/components/server/AssetTable.vue @@ -29,7 +29,8 @@ - {{ item.assetName }} @@ -51,6 +52,14 @@ import { ref, onMounted } from 'vue'; import Axios from '../axios.config.js'; import clientsideConfig from '../../clientsideConfig.js'; +import { useStore } from 'vuex'; + +// get accesss to the store +const store = useStore() +const goToChosenAsset = (id) => { + store.commit('setChosenAsset', id); + store.commit('changeToAsset'); +}; const darkMode = ref(true) const configItemList = ref([]); @@ -73,13 +82,6 @@ onMounted(async () => { @@ -233,4 +235,9 @@ th { .label-lightmode { color: #000; } + +#nuxt-link { + text-decoration: none; + color: white; +} diff --git a/components/server/HardwareSpecifications.vue b/components/server/HardwareSpecifications.vue index f00c87a..cbebc8c 100644 --- a/components/server/HardwareSpecifications.vue +++ b/components/server/HardwareSpecifications.vue @@ -39,10 +39,7 @@

Storage configuration:

- -
@@ -50,9 +47,7 @@

Miscellaneous:

- -
@@ -65,6 +60,12 @@ import { ref, onMounted } from 'vue'; import Axios from '../axios.config.js'; import clientsideConfig from '../../clientsideConfig.js'; +import { useStore } from 'vuex'; +import { computed } from 'vue'; + +const store = useStore(); +const editable = computed(() => store.state.assetEditable); +const chosenAssetId = computed(() => store.state.chosenAssetId); const darkMode = ref(true) const item = ref({}); @@ -72,11 +73,9 @@ const hardwareBoolean = ref(false) // get config item from id const getItemById = async () => { - // later itemIndex from route params - let itemIndex = 9; try { const response = await Axios.get( - `https://${clientsideConfig.url}:${clientsideConfig.port}/api/getConfigItem/${itemIndex}` + `https://${clientsideConfig.url}:${clientsideConfig.port}/api/getConfigItem/${chosenAssetId.value}` ); item.value = response.data; if ((item.value.hardwareBool == 1) && (item.value.model === (null | "")) && (item.value.serialnumber.trim() === "") && (item.value.CPU.trim() === "") && (item.value.RAM.trim() === "") && (item.value.storageConfiguration.trim() === "") && (item.value.miscellaneous.trim() === "")) { @@ -99,11 +98,6 @@ onMounted(() => { diff --git a/components/server/NetworkSpecifications.vue b/components/server/NetworkSpecifications.vue index 8ebb65c..2e0e9d2 100644 --- a/components/server/NetworkSpecifications.vue +++ b/components/server/NetworkSpecifications.vue @@ -5,21 +5,33 @@
IPv4:
-
{{ inputIPv4 }}
+
{{ inputIPv4 }}
+
MAC:
-
{{ item.MAC }}
+
{{ item.MAC }}
+
IPv6:
-
{{ inputIPv6 }}
+
{{ inputIPv6 }}
+
Subnetmask:
-
{{ item.subnetmask }}
+
{{ item.subnetmask }}
+
@@ -31,6 +43,12 @@ import { ref, onMounted } from 'vue'; import Axios from '../axios.config.js'; import clientsideConfig from '../../clientsideConfig.js'; +import { useStore } from 'vuex'; +import { computed } from 'vue'; + +const store = useStore(); +const editable = computed(() => store.state.assetEditable); +const chosenAssetId = computed(() => store.state.chosenAssetId); const darkMode = ref(true) const item = ref({}); @@ -40,11 +58,9 @@ const inputIPv6 = ref(''); // get config item from id const getItemById = async () => { - // later itemIndex from route params - let itemIndex = 9; try { const response = await Axios.get( - `https://${clientsideConfig.url}:${clientsideConfig.port}/api/getConfigItem/${itemIndex}` + `https://${clientsideConfig.url}:${clientsideConfig.port}/api/getConfigItem/${chosenAssetId.value}` ); item.value = response.data; if ((item.value.networkBool == 1) && (item.value.IPv4 === (null | "")) && (item.value.IPv6 === (null | "")) && (item.value.subnetmask === (null | "")) && (item.value.MAC === (null | ""))) { @@ -171,4 +187,8 @@ export default { padding: 0 0; border-radius: 0.3125rem; } + +.input { + border: none; +} \ No newline at end of file diff --git a/components/server/SoftwareSpecifications.vue b/components/server/SoftwareSpecifications.vue index bb3dca6..2c2d427 100644 --- a/components/server/SoftwareSpecifications.vue +++ b/components/server/SoftwareSpecifications.vue @@ -33,6 +33,12 @@ import { ref, onMounted } from 'vue'; import Axios from '../axios.config.js'; import clientsideConfig from '../../clientsideConfig.js'; +import { useStore } from 'vuex'; +import { computed } from 'vue'; + +const store = useStore(); +const editable = computed(() => store.state.assetEditable); +const chosenAssetId = computed(() => store.state.chosenAssetId); const darkMode = ref(true) const item = ref({}); @@ -40,11 +46,9 @@ const softwareBoolean = ref(false) // get config item from id const getItemById = async () => { - // later itemIndex from route params - let itemIndex = 9; try { const response = await Axios.get( - `https://${clientsideConfig.url}:${clientsideConfig.port}/api/getConfigItem/${itemIndex}` + `https://${clientsideConfig.url}:${clientsideConfig.port}/api/getConfigItem/${chosenAssetId.value}` ); item.value = response.data; if ((item.value.softwareBool == 1) && (item.value.version.trim() === "") && (item.value.software.trim() === "")) { diff --git a/layouts/Actionbar.vue b/layouts/Actionbar.vue index dc1ed3b..f5f33d5 100644 --- a/layouts/Actionbar.vue +++ b/layouts/Actionbar.vue @@ -4,7 +4,7 @@
+ src="../icons/actionbar-icons/Indicator-Icon-Opened.svg" />