mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-10 15:58:38 +01:00
refactoring
This commit is contained in:
@@ -19,6 +19,8 @@ const router = useRouter();
|
||||
|
||||
const { token, setToken } = useAccessToken();
|
||||
|
||||
const { createErrorAlert } = useAlert();
|
||||
|
||||
async function handleOnSuccess(response: any) {
|
||||
|
||||
try {
|
||||
@@ -97,7 +99,7 @@ function goBackToEmailLogin() {
|
||||
|
||||
async function signInSelfhosted() {
|
||||
try {
|
||||
const result = await $fetch(`/api/auth/no_auth`, {
|
||||
const result: any = await $fetch(`/api/auth/no_auth`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ email: email.value, password: password.value })
|
||||
@@ -124,7 +126,7 @@ async function signInSelfhosted() {
|
||||
}
|
||||
|
||||
} catch (ex: any) {
|
||||
alert('Error during login.' + ex.message);
|
||||
createErrorAlert('Error', 'Error during login.' + ex.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +139,7 @@ async function signInWithCredentials() {
|
||||
body: JSON.stringify({ email: email.value, password: password.value })
|
||||
})
|
||||
|
||||
if (result.error) return alert(result.message);
|
||||
if (result.error) return createErrorAlert('Error', result.message);
|
||||
|
||||
setToken(result.access_token);
|
||||
|
||||
@@ -156,8 +158,8 @@ async function signInWithCredentials() {
|
||||
}
|
||||
|
||||
|
||||
} catch (ex) {
|
||||
alert('Something went wrong.');
|
||||
} catch (ex: any) {
|
||||
createErrorAlert('Error', 'Something went wrong.' + ex.message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -258,7 +260,7 @@ async function signInWithCredentials() {
|
||||
|
||||
|
||||
|
||||
<div v-if="isNoAuth" @click="loginWithoutAuth"
|
||||
<div v-if="isNoAuth"
|
||||
class="flex text-[1.3rem] flex-col gap-4 items-center px-8 py-3 relative z-[2]">
|
||||
<div class="flex flex-col gap-4 z-[100] w-[20vw] min-w-[20rem]">
|
||||
<LyxUiInput class="px-3 py-2" placeholder="Email" v-model="email"></LyxUiInput>
|
||||
|
||||
@@ -22,6 +22,8 @@ const showAddMember = ref<boolean>(false);
|
||||
|
||||
const addMemberEmail = ref<string>("");
|
||||
|
||||
const { createErrorAlert } = useAlert();
|
||||
|
||||
async function kickMember(email: string) {
|
||||
const sure = confirm('Are you sure to kick ' + email + ' ?');
|
||||
if (!sure) return;
|
||||
@@ -34,7 +36,7 @@ async function kickMember(email: string) {
|
||||
}),
|
||||
body: JSON.stringify({ email }),
|
||||
onResponseError({ request, response, options }) {
|
||||
alert(response.statusText);
|
||||
createErrorAlert('Error', response.statusText);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -58,7 +60,7 @@ async function addMember() {
|
||||
}),
|
||||
body: JSON.stringify({ email: addMemberEmail.value }),
|
||||
onResponseError({ request, response, options }) {
|
||||
alert(response.statusText);
|
||||
createErrorAlert('Error', response.statusText);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -101,12 +103,25 @@ function permissionToString(permission: TPermission) {
|
||||
}
|
||||
return result.join('');
|
||||
}
|
||||
|
||||
async function leaveProject() {
|
||||
try {
|
||||
await $fetch('/api/project/members/leave', {
|
||||
headers: useComputedHeaders({}).value
|
||||
});
|
||||
location.reload();
|
||||
} catch (ex: any) {
|
||||
alert(ex.message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="p-6 pt-10">
|
||||
|
||||
<div class="flex flex-col gap-8">
|
||||
<div v-if="!isGuest" class="flex flex-col gap-8">
|
||||
|
||||
<div class="flex flex-col">
|
||||
<div class="flex gap-4 items-center">
|
||||
@@ -144,7 +159,9 @@ function permissionToString(permission: TPermission) {
|
||||
<div v-if="e.row.role !== 'OWNER' && !isGuest">
|
||||
<LyxUiButton class="!px-2" type="secondary"
|
||||
@click="openPermissionManagerDialog(e.row.id.toString())">
|
||||
<i class="far fa-gear"></i>
|
||||
<UTooltip text="Manage permissions">
|
||||
<i class="far fa-gear"></i>
|
||||
</UTooltip>
|
||||
</LyxUiButton>
|
||||
</div>
|
||||
|
||||
@@ -181,6 +198,12 @@ function permissionToString(permission: TPermission) {
|
||||
|
||||
</div>
|
||||
|
||||
<div v-if="isGuest" class="flex flex-col gap-8 mt-[10vh]">
|
||||
<div class="flex flex-col gap-4 items-center">
|
||||
<div class="text-[1.2rem]"> Leave this project </div>
|
||||
<LyxUiButton @click="leaveProject()" type="primary"> Leave </LyxUiButton>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -23,7 +23,7 @@ onMounted(() => {
|
||||
|
||||
|
||||
async function createProject() {
|
||||
if (projectName.value.length < 2) return;
|
||||
if (projectName.value.trim().length < 2) return;
|
||||
|
||||
Lit.event('create_project');
|
||||
|
||||
@@ -34,7 +34,7 @@ async function createProject() {
|
||||
await $fetch('/api/project/create', {
|
||||
method: 'POST',
|
||||
...signHeaders({ 'Content-Type': 'application/json' }),
|
||||
body: JSON.stringify({ name: projectName.value })
|
||||
body: JSON.stringify({ name: projectName.value.trim() })
|
||||
});
|
||||
|
||||
await actions.refreshProjectsList();
|
||||
@@ -89,7 +89,7 @@ async function createProject() {
|
||||
|
||||
<div>
|
||||
|
||||
<LyxUiButton type="primary" @click="createProject()" :disabled="projectName.length < 2">
|
||||
<LyxUiButton type="primary" @click="createProject()" :disabled="projectName.trim().length < 2">
|
||||
Create
|
||||
</LyxUiButton>
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ const items = [
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="lg:px-10 lg:py-8 h-dvh overflow-y-auto overflow-x-hidden hide-scrollbars !pb-[10rem]">
|
||||
<div class="lg:px-10 h-full lg:py-8 overflow-hidden hide-scrollbars">
|
||||
|
||||
<div class="poppins font-semibold text-[1.3rem] lg:px-0 px-4 lg:py-0 py-4"> Settings </div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user