From 52c61fbd6865d1e208e3fdb3795512206be7d2bc Mon Sep 17 00:00:00 2001 From: Lucas ONeil Date: Mon, 5 Dec 2022 21:24:54 -0800 Subject: [PATCH 1/9] WIP Signed-off-by: Lucas ONeil --- .../tenant-ui/frontend/src/assets/style.scss | 31 +++++++++++++++++++ .../frontend/src/components/Login.vue | 21 +++++++++++-- .../src/components/reservation/Reserve.vue | 13 ++++++++ services/tenant-ui/frontend/src/main.ts | 1 - services/tenant-ui/frontend/src/style.css | 29 ----------------- 5 files changed, 63 insertions(+), 32 deletions(-) create mode 100644 services/tenant-ui/frontend/src/components/reservation/Reserve.vue delete mode 100644 services/tenant-ui/frontend/src/style.css diff --git a/services/tenant-ui/frontend/src/assets/style.scss b/services/tenant-ui/frontend/src/assets/style.scss index c5fec5aab..8d8020693 100644 --- a/services/tenant-ui/frontend/src/assets/style.scss +++ b/services/tenant-ui/frontend/src/assets/style.scss @@ -4,3 +4,34 @@ @import 'tenantuiComponents.scss'; @import 'primevueComponents.scss'; @import 'toast.scss'; + +// General HTML +html, +body, +#app { + height: 100vh; + padding: 0; + margin: 0; +} + +:root { + font-family: Inter, Avenir, Helvetica, Arial, sans-serif; + font-size: 14px; + line-height: 24px; + font-weight: 400; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +a { + color: $tenant-ui-link-color; +} diff --git a/services/tenant-ui/frontend/src/components/Login.vue b/services/tenant-ui/frontend/src/components/Login.vue index 9e4491f6d..f4f0e7f83 100644 --- a/services/tenant-ui/frontend/src/components/Login.vue +++ b/services/tenant-ui/frontend/src/components/Login.vue @@ -11,8 +11,19 @@ /> -
+
+
+

+ Don't have an account? + +

+
@@ -26,10 +37,16 @@ \ No newline at end of file diff --git a/services/tenant-ui/frontend/src/main.ts b/services/tenant-ui/frontend/src/main.ts index 96aea537e..7b6303252 100644 --- a/services/tenant-ui/frontend/src/main.ts +++ b/services/tenant-ui/frontend/src/main.ts @@ -1,7 +1,6 @@ import router from './router'; import { createApp } from 'vue'; import createI18n from './plugins/i18n/i18n'; -import './style.css'; import App from './App.vue'; import { createPinia } from 'pinia'; diff --git a/services/tenant-ui/frontend/src/style.css b/services/tenant-ui/frontend/src/style.css deleted file mode 100644 index fd513b2e8..000000000 --- a/services/tenant-ui/frontend/src/style.css +++ /dev/null @@ -1,29 +0,0 @@ -html, -body, -#app { - height: 100vh; - padding: 0; - margin: 0; -} - -:root { - font-family: Inter, Avenir, Helvetica, Arial, sans-serif; - font-size: 14px; - line-height: 24px; - font-weight: 400; - - font-synthesis: none; - text-rendering: optimizeLegibility; - -webkit-font-smoothing: antialiased; - -moz-osx-font-smoothing: grayscale; - -webkit-text-size-adjust: 100%; -} - -h1 { - font-size: 3.2em; - line-height: 1.1; -} - -.card { - padding: 2em; -} From 01b08e919d78930a2daa89e3922d39f5ba65c63d Mon Sep 17 00:00:00 2001 From: Lucas ONeil Date: Mon, 5 Dec 2022 22:25:47 -0800 Subject: [PATCH 2/9] reservation form Signed-off-by: Lucas ONeil --- .../frontend/src/components/Login.vue | 28 ++- .../src/components/reservation/Reserve.vue | 159 +++++++++++++++++- .../frontend/src/helpers/constants.ts | 2 + .../tenant-ui/frontend/src/store/index.ts | 1 + .../frontend/src/store/reservationStore.ts | 53 ++++++ 5 files changed, 237 insertions(+), 6 deletions(-) create mode 100644 services/tenant-ui/frontend/src/store/reservationStore.ts diff --git a/services/tenant-ui/frontend/src/components/Login.vue b/services/tenant-ui/frontend/src/components/Login.vue index f4f0e7f83..3ef2ad15d 100644 --- a/services/tenant-ui/frontend/src/components/Login.vue +++ b/services/tenant-ui/frontend/src/components/Login.vue @@ -11,20 +11,32 @@ /> -
+ +

Don't have an account?

+ + +
+
@@ -37,13 +49,25 @@ +const toast = useToast(); - \ No newline at end of file +// State setup +const reservationStore = useReservationStore(); +const { loading, reservation } = storeToRefs(useReservationStore()); + +// Form submission +const submitted = ref(false); +const handleSubmit = async (isFormValid: boolean) => { + submitted.value = true; + + if (!isFormValid) { + return; + } + try { + await reservationStore.makeReservation(formFields); + } catch (err) { + console.error(err); + toast.error(`Failure making request: ${err}`); + } +}; + diff --git a/services/tenant-ui/frontend/src/helpers/constants.ts b/services/tenant-ui/frontend/src/helpers/constants.ts index c262725c4..c2515b9e2 100644 --- a/services/tenant-ui/frontend/src/helpers/constants.ts +++ b/services/tenant-ui/frontend/src/helpers/constants.ts @@ -58,4 +58,6 @@ export const API_PATH = { TENANT_SELF: '/tenant/v1/admin/self', TENANT_MAKE_ISSUER: '/tenant/v1/admin/make-issuer', TENANT_CONFIGURATION: '/tenant/v1/admin/configuration', + + MULTITENANCY_RESERVATION: '/multitenancy/reservations' }; diff --git a/services/tenant-ui/frontend/src/store/index.ts b/services/tenant-ui/frontend/src/store/index.ts index 936c84fcd..7873e7433 100644 --- a/services/tenant-ui/frontend/src/store/index.ts +++ b/services/tenant-ui/frontend/src/store/index.ts @@ -8,6 +8,7 @@ export { useTenantStore } from './tenantStore'; export { useTokenStore } from './tokenStore'; export { useVerifierStore } from './verifierStore'; export { useMessageStore } from './messageStore'; +export { useReservationStore } from './reservationStore'; // Innkeeper export { useInnkeeperTokenStore } from './innkeeper/innkeeperTokenStore'; diff --git a/services/tenant-ui/frontend/src/store/reservationStore.ts b/services/tenant-ui/frontend/src/store/reservationStore.ts new file mode 100644 index 000000000..ed98fc2f9 --- /dev/null +++ b/services/tenant-ui/frontend/src/store/reservationStore.ts @@ -0,0 +1,53 @@ +import { API_PATH } from '@/helpers/constants'; +import { defineStore } from 'pinia'; +import { ref } from 'vue'; +import { useAcapyApi } from './acapyApi'; + +export const useReservationStore = defineStore('reservation', () => { + // state + const loading: any = ref(false); + const error: any = ref(null); + const reservation: any = ref(null); + + const acapyApi = useAcapyApi(); + + // actions + async function makeReservation(payload: any = {}) { + console.log('> reservationStore.makeReservation'); + error.value = null; + loading.value = true; + console.log(payload); + await acapyApi + .putHttp(API_PATH.MULTITENANCY_RESERVATION, payload) + .then((res) => { + console.log(res); + reservation.value = res.data.item; + }) + .catch((err) => { + error.value = err; + console.log(error.value); + }) + .finally(() => { + loading.value = false; + }); + console.log('< reservationStore.makeReservation'); + + if (error.value != null) { + // throw error so $onAction.onError listeners can add their own handler + throw error.value; + } + // return data so $onAction.after listeners can add their own handler + return reservation.value; + } + + return { + reservation, + loading, + error, + makeReservation + }; +}); + +export default { + useReservationStore, +}; From c72f1f8ced02d9dd4034a37c49ef7b2ca08d0d82 Mon Sep 17 00:00:00 2001 From: Lucas ONeil Date: Mon, 5 Dec 2022 22:29:52 -0800 Subject: [PATCH 3/9] lint Signed-off-by: Lucas ONeil --- services/tenant-ui/frontend/src/components/Login.vue | 8 ++++---- services/tenant-ui/frontend/src/helpers/constants.ts | 2 +- services/tenant-ui/frontend/src/store/reservationStore.ts | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/services/tenant-ui/frontend/src/components/Login.vue b/services/tenant-ui/frontend/src/components/Login.vue index 3ef2ad15d..55d27b7ee 100644 --- a/services/tenant-ui/frontend/src/components/Login.vue +++ b/services/tenant-ui/frontend/src/components/Login.vue @@ -12,15 +12,15 @@ -
+

Don't have an account?

@@ -28,12 +28,12 @@
-
+
diff --git a/services/tenant-ui/frontend/src/helpers/constants.ts b/services/tenant-ui/frontend/src/helpers/constants.ts index c2515b9e2..6bacd465d 100644 --- a/services/tenant-ui/frontend/src/helpers/constants.ts +++ b/services/tenant-ui/frontend/src/helpers/constants.ts @@ -59,5 +59,5 @@ export const API_PATH = { TENANT_MAKE_ISSUER: '/tenant/v1/admin/make-issuer', TENANT_CONFIGURATION: '/tenant/v1/admin/configuration', - MULTITENANCY_RESERVATION: '/multitenancy/reservations' + MULTITENANCY_RESERVATION: '/multitenancy/reservations', }; diff --git a/services/tenant-ui/frontend/src/store/reservationStore.ts b/services/tenant-ui/frontend/src/store/reservationStore.ts index ed98fc2f9..246b44ba7 100644 --- a/services/tenant-ui/frontend/src/store/reservationStore.ts +++ b/services/tenant-ui/frontend/src/store/reservationStore.ts @@ -44,7 +44,7 @@ export const useReservationStore = defineStore('reservation', () => { reservation, loading, error, - makeReservation + makeReservation, }; }); From 9c059825275eb0ebe24b6c065ba3e5e4b2ed8bc9 Mon Sep 17 00:00:00 2001 From: Lucas ONeil Date: Mon, 5 Dec 2022 22:56:17 -0800 Subject: [PATCH 4/9] test Signed-off-by: Lucas ONeil --- plugins/docker/tenant-proxy.conf.template | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/plugins/docker/tenant-proxy.conf.template b/plugins/docker/tenant-proxy.conf.template index 6db283107..175dd6568 100644 --- a/plugins/docker/tenant-proxy.conf.template +++ b/plugins/docker/tenant-proxy.conf.template @@ -68,6 +68,43 @@ server { } } + location ~ ^/multitenancy/reservations$ { + proxy_set_header X-API-KEY ${ACAPY_ADMIN_URL_API_KEY}; + proxy_pass ${ACAPY_ADMIN_URL}; + allow all; + + proxy_set_header Proxy ''; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + proxy_hide_header Access-Control-Allow-Origin; + proxy_hide_header Access-Control-Allow-Credentials; + + set $CORS_CREDS true; + set $CORS_ORIGIN $http_origin; + set $CORS_PREFLIGHT_CACHE_AGE 600; + + if ($request_method = 'OPTIONS') { + add_header Access-Control-Allow-Origin $CORS_ORIGIN; + add_header Access-Control-Allow-Methods $http_access_control_request_methods; + add_header Access-Control-Allow-Headers $http_access_control_request_headers; + add_header Access-Control-Allow-Credentials $CORS_CREDS; + + add_header Access-Control-Max-Age $CORS_PREFLIGHT_CACHE_AGE; + add_header Content-Type 'text/plain; charset=utf-8'; + add_header Content-Length 0; + return 204; + } + if ($request_method != 'OPTIONS') { + add_header Access-Control-Allow-Origin $CORS_ORIGIN; + add_header Access-Control-Allow-Methods $http_access_control_request_methods; + add_header Access-Control-Allow-Headers $http_access_control_request_headers; + add_header Access-Control-Allow-Credentials $CORS_CREDS; + } + } + location ~ ^/status/(live|ready)$ { proxy_set_header X-API-KEY ${ACAPY_ADMIN_URL_API_KEY}; proxy_pass ${ACAPY_ADMIN_URL}; From 39a791fcb61eb01796b848f6906fa799b00da7ba Mon Sep 17 00:00:00 2001 From: Lucas ONeil Date: Tue, 6 Dec 2022 10:04:07 -0800 Subject: [PATCH 5/9] Correct field names Signed-off-by: Lucas ONeil --- .../src/components/reservation/Reserve.vue | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/services/tenant-ui/frontend/src/components/reservation/Reserve.vue b/services/tenant-ui/frontend/src/components/reservation/Reserve.vue index 0cc3b9773..bda70ad4d 100644 --- a/services/tenant-ui/frontend/src/components/reservation/Reserve.vue +++ b/services/tenant-ui/frontend/src/components/reservation/Reserve.vue @@ -2,12 +2,12 @@
- - - + + {{ error.$message }} - {{ - v$.email.required.$message + {{ + v$.contact_email.required.$message }}
@@ -29,35 +29,35 @@
- {{ - v$.fullName.required.$message + {{ + v$.contact_name.required.$message }}
- - {{ - v$.phone.required.$message + {{ + v$.contact_phone.required.$message }}
@@ -65,17 +65,17 @@
- {{ - v$.tenantName.required.$message + {{ + v$.tenant_name.required.$message }}
@@ -83,19 +83,19 @@