Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
6cc56da
Rebrand landing page
Dec 4, 2024
f86691e
Update navbar
Dec 4, 2024
54b2fe7
Modify base components
Dec 4, 2024
8ca886c
Rebrand signup page
Dec 4, 2024
98f3b4e
Merge branch 'development' into development_ui
Dec 5, 2024
e5cb155
init login page
Dec 5, 2024
8a3833c
ui changes
Dec 5, 2024
8cb7361
Remove old code
Dec 5, 2024
d808923
Remove scroll from Signup page
Dec 5, 2024
c4c5d92
Fix conflicts
Dec 8, 2024
ac8b753
init deploy page
Dec 8, 2024
5b276d3
init account management page
Dec 10, 2024
a530b56
Restyle base btn
Dec 10, 2024
59c90b4
Merge pull request #645 from codescalers/development_ui_deploy
Dec 10, 2024
0d91b2b
Restyle datatable header
Dec 10, 2024
e4d5ec8
Merge branch 'development_ui' into development_ui_account_management
Dec 10, 2024
fa3a24d
Merge pull request #643 from codescalers/development_ui_login
Dec 10, 2024
44d6413
Merge pull request #646 from codescalers/development_ui_account_manag…
Dec 10, 2024
96c73f8
Fix vm page
Dec 10, 2024
9fc4c1b
Fix toasts
Dec 10, 2024
c673e49
Fix deployment flow
Dec 10, 2024
3985957
Update VM page
Dec 10, 2024
48e4e99
Init forget password page
Dec 11, 2024
a5afde0
Update signup and signin pages imgs
Dec 11, 2024
ae99f2b
Init OTP page
Dec 11, 2024
c5b414a
Update maintenance page ui
Dec 11, 2024
ae55b65
Update 404 page ui
Dec 11, 2024
8e3fe4b
Merge pull request #648 from codescalers/development_ui_forgetpassword
Dec 12, 2024
f8634c8
Merge pull request #649 from codescalers/development_ui_otp
Dec 12, 2024
38a78f6
Merge pull request #650 from codescalers/development_ui_maintenance
Dec 12, 2024
cd62fc9
Merge pull request #651 from codescalers/development_ui_404_page
Dec 12, 2024
dbff850
Update navbar and footer ui
Dec 12, 2024
e96e50a
UI fixes
Dec 12, 2024
53a9a17
Fix logout
Dec 12, 2024
f6d51da
Fix redirect when we habve no token
Dec 12, 2024
d60e662
Fix delete toast color
Dec 12, 2024
97e2ff4
flat payment and swagger update
rawdaGastan Dec 17, 2024
dafb981
Update VM page
Dec 19, 2024
7855fb1
fix tests
rawdaGastan Dec 19, 2024
26eee9d
Fix containers
Dec 19, 2024
6da828f
Update signup page
Dec 19, 2024
adda9d2
Rm old profile page
Dec 19, 2024
6e48f23
Update OTP
Dec 19, 2024
a5c7780
Update change password page
Dec 19, 2024
ad80a1b
Update changes to login page and improve ui
Dec 19, 2024
39734c8
Implement login in the client
Dec 19, 2024
647d82b
rm useless divider
Dec 19, 2024
bd03b05
rm home page
Dec 19, 2024
feb9ddd
Update changes to forgotpassword page
Dec 19, 2024
99801fd
Update changes on deploy page
Dec 19, 2024
7fff027
rm old imgs
Dec 22, 2024
7ce25bf
Update account tab info
Dec 22, 2024
944501c
rm unwanted log
Dec 22, 2024
c5619aa
handle logs foolter when no data
Dec 22, 2024
bdaf48a
Apply regions
Dec 22, 2024
015e2a4
Apply invoices
Dec 22, 2024
791071f
init change password tab
Dec 22, 2024
81fcd11
Implement delete account tab
Dec 22, 2024
943eadc
update invoices table ui
Dec 22, 2024
c442dba
Rn account tab
Dec 22, 2024
f8e4ad5
Fix account link
Dec 22, 2024
4a180e7
support listing regions
rawdaGastan Dec 22, 2024
0da930f
Implement delete account function
Dec 24, 2024
e6b5478
Handle invoices
Dec 24, 2024
b3bfa98
Add payments endpoints
Dec 29, 2024
613205e
Handle server err in saved cards
Dec 30, 2024
54963be
Add Voucher part
Dec 30, 2024
73d2079
Implement endpoints in fe client
Dec 30, 2024
3467e9f
Fix navbar and hide menu in small screens
Dec 30, 2024
0a8c76e
Fix otp page
Jan 6, 2025
4fb9768
Fix logout and remove change password link from navbar
Jan 6, 2025
26ced02
add delete user endpoint
rawdaGastan Dec 23, 2024
049abd9
rm repeated requests
Jan 6, 2025
b2a52ac
rm useless requwsts
Jan 6, 2025
c7e7ab3
Fix validate VM name
Jan 6, 2025
89f5d47
fix msg
Jan 6, 2025
f6406d4
add table loader
Jan 6, 2025
d9182f3
fix vm link
Jan 6, 2025
eefbd65
rm unwanted requests
Jan 6, 2025
4059e9d
remove fontawesome package
Jan 6, 2025
70768d9
add a pdf generator for invoices
rawdaGastan Jan 8, 2025
9825bac
support an endpoint to seen all notifications
rawdaGastan Jan 13, 2025
fc295c0
support sending notifications using SSE
rawdaGastan Jan 14, 2025
8f86730
add delete user endpoint
rawdaGastan Dec 23, 2024
d16bb83
Merge branch 'development_flat_payment' of github.com:codescalers/clo…
rawdaGastan Jan 14, 2025
c59af84
Merge branch 'development_flat_payment' of github.com:codescalers/clo…
rawdaGastan Jan 14, 2025
0f918f5
explain why type field exists in notification
rawdaGastan Jan 15, 2025
262861a
add mailer struct, fix download endpoint and make logo path generic
rawdaGastan Jan 15, 2025
f234bc4
- Add home page
Jan 15, 2025
511dcf1
Fix routes
Jan 15, 2025
abda415
Add public ip to deployment cards
Jan 15, 2025
820d46a
Add public ip to deployment cards
Jan 15, 2025
71ebc19
Fix public ip call
Jan 16, 2025
8daf790
Add cards behavior and voucher activates
Jan 16, 2025
772d49e
implement cards
Jan 19, 2025
426f144
- Implement Next launch page
Jan 20, 2025
bc1103b
enforce creating pdfs if not exist in invoice object
rawdaGastan Jan 21, 2025
d591ab0
add audit logs
rawdaGastan Jan 21, 2025
8fe14c7
Create download link for the single and all invoices
Jan 22, 2025
ecfafd1
add audit events
rawdaGastan Jan 21, 2025
5a5fe95
fix wrong rendered dates and overfloating numbers
rawdaGastan Jan 29, 2025
2cb54fb
- Add pinia
Jan 29, 2025
4df2a2d
Merge pull request #673 from codescalers/development_flat_payment
rawdaGastan Feb 2, 2025
b5d32b5
Merge pull request #674 from codescalers/development_invoices_pdf
rawdaGastan Feb 2, 2025
5ec100c
Merge pull request #675 from codescalers/development_notifications_up…
rawdaGastan Feb 2, 2025
59dbe12
Merge pull request #676 from codescalers/development_audit
rawdaGastan Feb 2, 2025
de2e392
Fix conflicts
Feb 2, 2025
bfedbec
Handle 401 status
Feb 3, 2025
4525d85
support listing notifications
rawdaGastan Feb 3, 2025
5d1c852
Merge pull request #677 from codescalers/development_notifications_up…
rawdaGastan Feb 3, 2025
eacab4a
Merge branch 'development_v2' into development_ui
Feb 3, 2025
f156a95
implement notifications
Feb 3, 2025
f44454b
Implement Audits
Feb 3, 2025
219ae70
Fix stream call
Feb 4, 2025
e51fa19
Fill logs with events
Feb 4, 2025
df2ad77
Fix infinite get user request
Feb 5, 2025
e158b73
Fix states loading
Feb 5, 2025
28a1709
Fix signUp scenario
Feb 5, 2025
172c24d
UI improvments
Feb 6, 2025
c5e8c38
Fix disabled btns
Feb 6, 2025
56be91b
Fix axios interceptors
Feb 6, 2025
8d9d069
Fix layouts
Feb 6, 2025
d843d91
Add amount validation
Feb 6, 2025
ee32c46
Implement SSE globally
Feb 6, 2025
6304530
Fix app loading
Feb 6, 2025
8540409
Handle login error
Feb 6, 2025
741dc02
Add public ip to the total cost
Feb 9, 2025
755b255
Update audit logs metadata
Feb 9, 2025
5e1f8aa
Rm mitt
Feb 9, 2025
754848f
Upddate payment btn text
Feb 9, 2025
a27a1e6
rm mitt registeration
Feb 9, 2025
26927fe
Handle 401 in SEE
Feb 9, 2025
1a431da
Fix layout flush
Feb 9, 2025
dcfeca3
add vms and clusters per user while listing all
rawdaGastan Feb 10, 2025
4fa8c10
Merge pull request #682 from codescalers/development_flat_payment
rawdaGastan Feb 11, 2025
d8d57b3
make voucher balance fixed
rawdaGastan Feb 11, 2025
5a6ce5a
Merge pull request #683 from codescalers/development_flat_payment
rawdaGastan Feb 11, 2025
9112cdc
Merge branch 'development_v2' into development_ui
Feb 12, 2025
da94fa0
make voucher balance fixed
rawdaGastan Feb 11, 2025
51173b8
Merge pull request #684 from codescalers/development_flat_payment
rawdaGastan Feb 12, 2025
e5fe010
Merge branch 'development_v2' into development_ui
Feb 12, 2025
a24994c
Merge branch 'development_flat_payment' of github.com:codescalers/clo…
rawdaGastan Feb 12, 2025
e2919d0
fixed balance in vouchers
rawdaGastan Feb 12, 2025
aebc353
Merge branch 'development_flat_payment' of github.com:codescalers/clo…
rawdaGastan Feb 12, 2025
3e55b11
Merge branch 'development_invoices_pdf' of github.com:codescalers/clo…
rawdaGastan Feb 12, 2025
0182b93
Merge pull request #685 from codescalers/development_audit
rawdaGastan Feb 12, 2025
59921b6
Merge branch 'development_v2' into development_ui
Feb 12, 2025
c75afcd
make voucher balance fixed
rawdaGastan Feb 11, 2025
e5a7eae
Merge pull request #686 from codescalers/development_flat_payment
rawdaGastan Feb 12, 2025
1d17c27
Merge branch 'development_v2' into development_ui
Feb 12, 2025
545bad8
Fix axios interceptors
Feb 13, 2025
6a2183e
Prevent many overlays that fire when delete vm
Feb 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
PWD := $(shell pwd)

swagger:
swagger validate swagger.yml
docker run -i yousan/swagger-yaml-to-html < swagger.yml > docs/swagger.html

run:
docker compose up
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cloud4students aims to help students deploy their projects on Threefold Grid.
- First create `config.json` check [configuration](#configuration)

- Change `VITE_API_ENDPOINT` in docker-compose.yml to server api url for example `http://localhost:3000/v1`
- Change `STRIPE_PUBLISHER_KEY` in docker-compose.yml to your stripe publisher key (can get it from stripe dashboard)

To build backend and frontend images

Expand Down
25 changes: 12 additions & 13 deletions client/index.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<script src="./config.js"></script>

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cloud for Students</title>
</head>

<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
<head>
<meta charset="UTF-8">
<link rel="icon" href="/favicon.ico">
<script src="./config.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Cloud for All</title>
<script src="https://js.stripe.com/v3/"></script>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
</body>
</html>
11 changes: 5 additions & 6 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@
"lint": "eslint . --fix --ignore-path .gitignore"
},
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-brands-svg-icons": "^6.4.2",
"@fortawesome/free-regular-svg-icons": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/vue-fontawesome": "^3.0.8",
"@mdi/font": "7.4.47",
"@stripe/stripe-js": "^5.4.0",
"@vue-stripe/vue-stripe": "^4.5.0",
"axios": "^1.7.2",
"core-js": "^3.33.2",
"mitt": "^3.0.1",
"file-saver": "^2.0.5",
"jszip": "^3.10.1",
"mosha-vue-toastify": "^1.0.23",
"pinia": "^2.3.1",
"roboto-fontface": "*",
"vite-plugin-eslint": "^1.8.1",
"vue": "^3.5.10",
Expand Down
7 changes: 7 additions & 0 deletions client/scripts/build-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@ then
exit 64
fi

if [ -z ${STRIPE_PUBLISHER_KEY+x} ]
then
echo 'Error! $STRIPE_PUBLISHER_KEY is required.'
exit 64
fi


configs="
window.configs = window.configs || {};
window.configs.vite_app_endpoint = '$VITE_API_ENDPOINT';
window.configs.stripe_publisher_key = '$STRIPE_PUBLISHER_KEY';
"

if [ -e $file ]
Expand Down
6 changes: 6 additions & 0 deletions client/scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,16 @@ then
exit 64
fi

if [ -z ${STRIPE_PUBLISHER_KEY+x} ]
then
echo 'Error! $STRIPE_PUBLISHER_KEY is required.'
exit 64
fi

configs="
window.configs = window.configs || {};
window.configs.vite_app_endpoint = '$VITE_API_ENDPOINT';
window.configs.stripe_publisher_key = '$STRIPE_PUBLISHER_KEY';
"

if [ -e $file ]
Expand Down
26 changes: 15 additions & 11 deletions client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,22 @@
</component>
</template>

<script>
<script setup>
import { computed } from "vue";
import { useRoute } from "vue-router";

export default {
setup() {
const route = useRoute();
const layout = computed(() => {
const NoNavbar_layout = "No-Navbar";
return (route.meta.layout || NoNavbar_layout) + "-Layout";
});
return { layout };
},
};
const route = useRoute();

const layout = computed(() => {
const routeLayout = route.meta.layout;
return routeLayout === "Default" ? "Default-Layout" : "No-Navbar-Layout";
});
</script>
<style>
body {
background-color: #212121;
}
.v-container--fluid {
max-width: 100% !important;
}
</style>
Binary file added client/src/assets/404_page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed client/src/assets/about_us.png
Binary file not shown.
Binary file added client/src/assets/cards_logos/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/amex.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/diners.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/discover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/jcb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/mastercard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/src/assets/cards_logos/visa.png
Binary file removed client/src/assets/cpass.jpg
Diff not rendered.
Binary file removed client/src/assets/cpass.png
Diff not rendered.
Binary file added client/src/assets/home_header.png
Binary file added client/src/assets/key.png
Binary file added client/src/assets/lock.png
Binary file removed client/src/assets/login.png
Diff not rendered.
Binary file added client/src/assets/logo_c4all.png
Binary file added client/src/assets/maintainence.png
Binary file added client/src/assets/next_launch.png
Binary file removed client/src/assets/not_found.png
Diff not rendered.
Binary file modified client/src/assets/otp.png
Binary file added client/src/assets/sign-in.png
Binary file added client/src/assets/sign-up.png
Binary file removed client/src/assets/verification_code.png
Diff not rendered.
Binary file removed client/src/assets/welcome.png
Diff not rendered.
27 changes: 27 additions & 0 deletions client/src/components/AddPayment.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<v-dialog v-model="dialog" max-width="800">
<template v-slot:activator="{ props: activatorProps }">
<BaseButton
v-bind="activatorProps"
class="my-5"
text="+ Add Card"
variant="outlined"
/>
</template>

<PaymentCard @updateData="updateCards" @onClose="dialog = false" />
</v-dialog>
</template>
<script setup>
import { ref } from "vue";
import BaseButton from "@/components/Form/BaseButton.vue";
import PaymentCard from "./PaymentCard.vue";

const emit = defineEmits("updateData");
const dialog = ref(false);

function updateCards(data) {
if (!data) return;
emit("updateData", data);
}
</script>
34 changes: 34 additions & 0 deletions client/src/components/Alerts.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<template>
<v-alert
:density="density"
:text="text"
:title="title"
:type="type"
class="my-5 font-weight-bold"
:variant="variant"
v-bind="$attrs"
></v-alert>
</template>

<script setup>
defineProps({
density: {
type: String,
default: "compact",
},
text: {
type: String,
default: "Lorem ipsum dolor sit amet consectetur adipisicing elit.",
},
title: {
type: String,
},
type: {
type: String,
},
variant: {
type: String,
default: "flat",
},
});
</script>
93 changes: 93 additions & 0 deletions client/src/components/ApplyVoucher.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<template>
<v-row justify="center">
<v-col cols="12" md="4">
<v-card class="mx-auto" flat>
<div class="d-flex flex-no-wrap align-center">
<v-card-actions class="d-flex align-center justify-center">
<p>
Looking for a voucher? Simply let us know
<BaseButton
variant="outlined"
text="Apply for voucher"
class="text-capitalize ml-5"
icon="mdi-ticket-percent"
@click="dialog = true"
/>
</p>
</v-card-actions>
</div>
</v-card>
</v-col>
<v-dialog v-model="dialog" max-width="550">
<v-card class="pa-3">
<v-card-title class="text-capitalize">Request new voucher</v-card-title>
<v-divider />
<v-card-text class="pa-3">
To help us process your request, please explain why you're applying
for the voucher
</v-card-text>
<v-form v-model="verify" @submit.prevent="getVoucher">
<BaseInput
class="my-2"
placeholder="Reason"
v-model="reason"
:rules="[required]"
/>
<div class="d-flex justify-end">
<BaseButton
variant="outlined"
text="Cancel"
class="mr-2"
@click="dialog = false"
/>
<BaseButton
type="submit"
color="secondary"
text="Request"
:rules="voucherRules"
:disabled="!verify"
/>
</div>
</v-form>
</v-card>
</v-dialog>
</v-row>
<Toast ref="toast" />
</template>

<script setup>
import { ref } from "vue";
import BaseButton from "./Form/BaseButton.vue";
import BaseInput from "./Form/BaseInput.vue";
import userService from "@/services/userService";
import Toast from "./Toast.vue";
import { storeToRefs } from "pinia";
import { useUserStore } from "@/store/UserStore";

const dialog = ref(false);
const reason = ref();
const { user } = storeToRefs(useUserStore());
const toast = ref();
const verify = ref(false);

function required(v) {
return !!v || "Field is required";
}

function getVoucher() {
if (!verify.value) return;
userService
.applyVoucher(user.value.balance, reason.value)
.then((response) => {
toast.value.toast(response.data.msg, "#4caf50");
})
.catch((response) => {
const { err } = response.response.data;
toast.value.toast(err, "#FF5252");
})
.finally(() => {
reason.value = "";
dialog.value = false
});
}
</script>
91 changes: 39 additions & 52 deletions client/src/components/Confirm.vue
Original file line number Diff line number Diff line change
@@ -1,57 +1,44 @@
<template>
<v-dialog
v-model="dialog"
:max-width="options.width"
:style="{ zIndex: options.zIndex }"
@keydown.esc="cancel"
>
<v-card>
<v-toolbar dark :color="options.color" dense flat>
<v-toolbar-title class="white--text">{{ title }}</v-toolbar-title>
</v-toolbar>
<v-card-text v-show="!!message" class="pa-4">{{ message }}</v-card-text>
<v-card-actions class="pt-0">
<v-spacer></v-spacer>
<v-btn color="danger darken-1" text @click="agree">Yes</v-btn>
<v-btn color="grey" text @click="cancel">Cancel</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
<v-card class="pa-2">
<v-card-title>{{ title }}</v-card-title>
<v-divider />
<v-card-text> {{ text }} </v-card-text>

<v-card-actions>
<v-spacer></v-spacer>

<BaseButton text="Cancel" @click="$emit('onClose')" variant="outlined" />

<BaseButton
:text="confirmText"
:color="color"
@click="$emit('confirm')"
:loading="loading"
/>
</v-card-actions>
</v-card>
</template>

<script>
export default {
data: () => ({
dialog: false,
resolve: null,
reject: null,
message: null,
title: null,
options: {
color: "primary",
width: 290,
zIndex: 999,
},
}),
methods: {
open(title, message, options) {
this.dialog = true;
this.title = title;
this.message = message;
this.options = Object.assign(this.options, options);
return new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
},
agree() {
this.resolve(true);
this.dialog = false;
},
cancel() {
this.resolve(false);
this.dialog = false;
},
<script setup>
import BaseButton from "@/components/Form/BaseButton.vue";

defineProps({
title: { type: String, default: "Title here.." },
text: {
type: String,
default: "Text here..",
},
confirmText: {
type: String,
default: "Confirm",
},
color: {
type: String,
default: "secondary",
},
loading: {
type: Boolean,
default: false,
},
};
});
</script>
Loading