add new workspace settings for users
This commit is contained in:
BIN
backend/gagag.dbaa
Normal file
BIN
backend/gagag.dbaa
Normal file
Binary file not shown.
@@ -3,7 +3,7 @@ module backend
|
|||||||
go 1.25.4
|
go 1.25.4
|
||||||
|
|
||||||
require (
|
require (
|
||||||
gitea.tecamino.com/paadi/access-handler v1.0.48
|
gitea.tecamino.com/paadi/access-handler v1.0.51
|
||||||
gitea.tecamino.com/paadi/memberDB v1.1.30
|
gitea.tecamino.com/paadi/memberDB v1.1.30
|
||||||
gitea.tecamino.com/paadi/tecamino-dbm v1.0.0
|
gitea.tecamino.com/paadi/tecamino-dbm v1.0.0
|
||||||
gitea.tecamino.com/paadi/tecamino-logger v0.2.1
|
gitea.tecamino.com/paadi/tecamino-logger v0.2.1
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
gitea.tecamino.com/paadi/access-handler v1.0.48 h1:PYZvOwR9HCORAFpm7Nd5ZXvWwT5w04OvbcHhVHmPJlw=
|
gitea.tecamino.com/paadi/access-handler v1.0.51 h1:kTPwN+0Zw/Uyfo6el1jl5ORzIrjQdC8PUlczoN9mBS4=
|
||||||
gitea.tecamino.com/paadi/access-handler v1.0.48/go.mod h1:0kUGU4Jw2jSvopCCwecuX/2QnVKS09Ec1KQNrBXvsFs=
|
gitea.tecamino.com/paadi/access-handler v1.0.51/go.mod h1:0kUGU4Jw2jSvopCCwecuX/2QnVKS09Ec1KQNrBXvsFs=
|
||||||
gitea.tecamino.com/paadi/dbHandler v1.1.12 h1:F1ARSTUm0MZmF84FfD/g5RQNMYyDYXHYrB3cXPSi4qw=
|
gitea.tecamino.com/paadi/dbHandler v1.1.12 h1:F1ARSTUm0MZmF84FfD/g5RQNMYyDYXHYrB3cXPSi4qw=
|
||||||
gitea.tecamino.com/paadi/dbHandler v1.1.12/go.mod h1:y/xn/POJg1DO++67uKvnO23lJQgh+XFQq7HZCS9Getw=
|
gitea.tecamino.com/paadi/dbHandler v1.1.12/go.mod h1:y/xn/POJg1DO++67uKvnO23lJQgh+XFQq7HZCS9Getw=
|
||||||
gitea.tecamino.com/paadi/memberDB v1.1.30 h1:N+3V9A/+OAGIoJeUNVHj1qUuBcy6ADLYFIgCnp2Ggk4=
|
gitea.tecamino.com/paadi/memberDB v1.1.30 h1:N+3V9A/+OAGIoJeUNVHj1qUuBcy6ADLYFIgCnp2Ggk4=
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
:label="$t('workspaces')"
|
:label="$t('workspaces')"
|
||||||
:options="localUser?.workspaces"
|
:options="localUser?.workspaces"
|
||||||
option-label="name"
|
option-label="name"
|
||||||
v-model="settings.workspace"
|
v-model="localWorkspace"
|
||||||
@update:model-value="changeWorkspace"
|
@update:model-value="changeWorkspace"
|
||||||
></q-select>
|
></q-select>
|
||||||
<q-select
|
<q-select
|
||||||
@@ -187,7 +187,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { logo, appName, databaseName, workspace } from 'src/vueLib/models/settings';
|
import { logo, appName } from 'src/vueLib/models/settings';
|
||||||
import { onMounted, reactive, ref, watch } from 'vue';
|
import { onMounted, reactive, ref, watch } from 'vue';
|
||||||
import { appApi } from 'src/boot/axios';
|
import { appApi } from 'src/boot/axios';
|
||||||
import { useNotify } from 'src/vueLib/general/useNotify';
|
import { useNotify } from 'src/vueLib/general/useNotify';
|
||||||
@@ -195,9 +195,11 @@ import type { Settings } from 'src/vueLib/models/settings';
|
|||||||
import { useUserStore } from 'src/vueLib/login/userStore';
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
import { setLocalSettings } from 'src/localstorage/localStorage';
|
import { setLocalSettings } from 'src/localstorage/localStorage';
|
||||||
import SiteTitle from 'src/vueLib/general/SiteTitle.vue';
|
import SiteTitle from 'src/vueLib/general/SiteTitle.vue';
|
||||||
import type { User } from 'src/vueLib/models/user';
|
import { type User } from 'src/vueLib/models/user';
|
||||||
import { i18n } from 'src/boot/lang';
|
import { i18n } from 'src/boot/lang';
|
||||||
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
import DialogFrame from 'src/vueLib/dialog/DialogFrame.vue';
|
||||||
|
import type { Workspace } from 'src/vueLib/models/workspaces';
|
||||||
|
import { openDatabase } from '../vueLib/components/DatabaseCall';
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const colorGroup = ref(false);
|
const colorGroup = ref(false);
|
||||||
@@ -207,11 +209,11 @@ const newDatabase = ref<string>('');
|
|||||||
const foundDatabases = ref<number>(0);
|
const foundDatabases = ref<number>(0);
|
||||||
const localUser = ref<User>();
|
const localUser = ref<User>();
|
||||||
const databases = ref<string[]>([]);
|
const databases = ref<string[]>([]);
|
||||||
|
const localWorkspace = ref<Workspace>();
|
||||||
|
|
||||||
const settings = reactive<Settings>({
|
const settings = reactive<Settings>({
|
||||||
appName: appName.value,
|
appName: appName.value,
|
||||||
icon: logo.value,
|
icon: logo.value,
|
||||||
databaseName: databaseName.value,
|
|
||||||
workspace: { name: '', description: '', uuid: workspace.value },
|
|
||||||
primaryColor: document.documentElement.style.getPropertyValue('--q-primary'),
|
primaryColor: document.documentElement.style.getPropertyValue('--q-primary'),
|
||||||
primaryColorText: document.documentElement.style.getPropertyValue('--q-primary-text'),
|
primaryColorText: document.documentElement.style.getPropertyValue('--q-primary-text'),
|
||||||
secondaryColor: document.documentElement.style.getPropertyValue('--q-secondary'),
|
secondaryColor: document.documentElement.style.getPropertyValue('--q-secondary'),
|
||||||
@@ -224,11 +226,15 @@ onMounted(async () => {
|
|||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (!resp.data) return;
|
if (!resp.data) return;
|
||||||
localUser.value = resp.data[0];
|
localUser.value = resp.data[0];
|
||||||
settings.workspace = localUser.value?.settings?.workspace || null;
|
localWorkspace.value = localUser.value?.workspaces?.find(
|
||||||
|
(w) => w.id === localUser.value?.workspaceId,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (localUser.value) {
|
||||||
|
settings.databaseName = localUser.value.settings?.databaseName || '';
|
||||||
|
|
||||||
if (settings.workspace) {
|
|
||||||
appApi
|
appApi
|
||||||
.post('workspaces/data', settings.workspace)
|
.post('workspaces/data', localWorkspace.value)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (!resp.data) {
|
if (!resp.data) {
|
||||||
settings.databaseName = '';
|
settings.databaseName = '';
|
||||||
@@ -239,8 +245,6 @@ onMounted(async () => {
|
|||||||
foundDatabases.value = resp.data.data.length;
|
foundDatabases.value = resp.data.data.length;
|
||||||
})
|
})
|
||||||
.catch((err) => NotifyResponse(err, 'error'));
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
} else {
|
|
||||||
settings.databaseName = '';
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => NotifyResponse(err, 'error'));
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
@@ -249,7 +253,6 @@ onMounted(async () => {
|
|||||||
watch(settings, (newSettings) => {
|
watch(settings, (newSettings) => {
|
||||||
logo.value = newSettings.icon;
|
logo.value = newSettings.icon;
|
||||||
appName.value = newSettings.appName;
|
appName.value = newSettings.appName;
|
||||||
databaseName.value = newSettings.databaseName;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function resetColors() {
|
function resetColors() {
|
||||||
@@ -265,7 +268,7 @@ function resetColors() {
|
|||||||
|
|
||||||
function changeWorkspace() {
|
function changeWorkspace() {
|
||||||
appApi
|
appApi
|
||||||
.post('workspaces/data', settings.workspace)
|
.post('workspaces/data', localWorkspace.value)
|
||||||
.then((resp) => {
|
.then((resp) => {
|
||||||
if (resp.data) {
|
if (resp.data) {
|
||||||
databases.value = [i18n.global.t('addNewDatabase')];
|
databases.value = [i18n.global.t('addNewDatabase')];
|
||||||
@@ -277,10 +280,12 @@ function changeWorkspace() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function changeDatabase() {
|
function changeDatabase() {
|
||||||
|
if (settings.databaseName) {
|
||||||
if (databases.value.indexOf(settings.databaseName) === 0) {
|
if (databases.value.indexOf(settings.databaseName) === 0) {
|
||||||
addDatabaseRef.value?.open();
|
addDatabaseRef.value?.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function removeItem(index: number) {
|
function removeItem(index: number) {
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
@@ -297,7 +302,7 @@ function addNewDatabase() {
|
|||||||
addDatabaseRef.value.close();
|
addDatabaseRef.value.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function save() {
|
async function save() {
|
||||||
document.documentElement.style.setProperty('--q-primary', settings.primaryColor);
|
document.documentElement.style.setProperty('--q-primary', settings.primaryColor);
|
||||||
document.documentElement.style.setProperty('--q-primary-text', settings.primaryColorText);
|
document.documentElement.style.setProperty('--q-primary-text', settings.primaryColorText);
|
||||||
document.documentElement.style.setProperty('--q-secondary', settings.secondaryColor);
|
document.documentElement.style.setProperty('--q-secondary', settings.secondaryColor);
|
||||||
@@ -309,8 +314,12 @@ function save() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setLocalSettings(settings);
|
setLocalSettings(settings);
|
||||||
|
if (localUser.value) {
|
||||||
|
await user.setUser(localUser.value);
|
||||||
|
localUser.value.workspaceId = localWorkspace.value?.id;
|
||||||
|
}
|
||||||
|
|
||||||
appApi
|
await appApi
|
||||||
.post('users/update', localUser.value)
|
.post('users/update', localUser.value)
|
||||||
.then(() =>
|
.then(() =>
|
||||||
NotifyResponse(
|
NotifyResponse(
|
||||||
@@ -324,5 +333,7 @@ function save() {
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
.catch((err) => NotifyResponse(err, 'error'));
|
.catch((err) => NotifyResponse(err, 'error'));
|
||||||
|
|
||||||
|
await openDatabase().catch((err) => console.error(err));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ export const useUserStore = defineStore('user', {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
getWorkspaceUuid: (state: UserState) => {
|
||||||
|
return state.user?.workspaces?.find((w) => w.id === state.user?.workspaceId)?.uuid;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
setFirstLogin(b: boolean) {
|
setFirstLogin(b: boolean) {
|
||||||
|
|||||||
@@ -1,16 +1,12 @@
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import type { Workspace } from './workspaces';
|
|
||||||
|
|
||||||
export const logo = ref<string>('');
|
export const logo = ref<string>('');
|
||||||
export const appName = ref<string>('Attendance Records');
|
export const appName = ref<string>('Attendance Records');
|
||||||
export const databaseName = ref<string>('members.dba');
|
|
||||||
export const workspace = ref<string>('');
|
|
||||||
|
|
||||||
export type Settings = {
|
export type Settings = {
|
||||||
appName: string;
|
appName: string;
|
||||||
icon: string;
|
icon: string;
|
||||||
databaseName: string;
|
databaseName?: string;
|
||||||
workspace: Workspace | null;
|
|
||||||
primaryColor: string;
|
primaryColor: string;
|
||||||
primaryColorText: string;
|
primaryColorText: string;
|
||||||
secondaryColor: string;
|
secondaryColor: string;
|
||||||
@@ -21,8 +17,6 @@ export function DefaultSettings(): Settings {
|
|||||||
return {
|
return {
|
||||||
appName: 'Attendance Records',
|
appName: 'Attendance Records',
|
||||||
icon: '',
|
icon: '',
|
||||||
databaseName: 'members.dba',
|
|
||||||
workspace: { name: '', description: '', uuid: workspace.value },
|
|
||||||
primaryColor: document.documentElement.style.getPropertyValue('--q-primary-text'),
|
primaryColor: document.documentElement.style.getPropertyValue('--q-primary-text'),
|
||||||
primaryColorText: document.documentElement.style.getPropertyValue('--q-primary'),
|
primaryColorText: document.documentElement.style.getPropertyValue('--q-primary'),
|
||||||
secondaryColor: document.documentElement.style.getPropertyValue('--q-secondary'),
|
secondaryColor: document.documentElement.style.getPropertyValue('--q-secondary'),
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import type { Permissions } from '../checkboxes/permissions';
|
import type { Permissions } from '../checkboxes/permissions';
|
||||||
import type { Role } from './roles';
|
import type { Role } from './roles';
|
||||||
import type { Settings } from './settings';
|
import type { Settings } from './settings';
|
||||||
|
import type { Workspaces } from './workspaces';
|
||||||
|
|
||||||
export interface User {
|
export interface User {
|
||||||
id: number;
|
id: number;
|
||||||
@@ -9,7 +10,8 @@ export interface User {
|
|||||||
permissions?: Permissions;
|
permissions?: Permissions;
|
||||||
settings?: Settings;
|
settings?: Settings;
|
||||||
newDatabase?: boolean;
|
newDatabase?: boolean;
|
||||||
workspaces?: string[];
|
workspaceId?: number | undefined;
|
||||||
|
workspaces?: Workspaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserState {
|
export interface UserState {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export interface User {
|
|||||||
password?: string;
|
password?: string;
|
||||||
newPassword?: string;
|
newPassword?: string;
|
||||||
settings?: Settings;
|
settings?: Settings;
|
||||||
|
workspaceId?: number;
|
||||||
workspaces?: Workspace[];
|
workspaces?: Workspace[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -129,8 +129,7 @@ import { i18n } from 'src/boot/lang';
|
|||||||
import { QTable } from 'quasar';
|
import { QTable } from 'quasar';
|
||||||
import { useUserStore } from 'src/vueLib/login/userStore';
|
import { useUserStore } from 'src/vueLib/login/userStore';
|
||||||
import SearchableInput from '../components/SearchableInput.vue';
|
import SearchableInput from '../components/SearchableInput.vue';
|
||||||
import type { User } from 'src/vueLib/models/user';
|
import { type User } from 'src/vueLib/models/user';
|
||||||
import { workspace } from 'src/vueLib/models/settings';
|
|
||||||
|
|
||||||
const { NotifyResponse } = useNotify();
|
const { NotifyResponse } = useNotify();
|
||||||
const editOneDialog = ref();
|
const editOneDialog = ref();
|
||||||
@@ -179,8 +178,11 @@ function openRemoveDialog(...workspaces: Workspaces) {
|
|||||||
function removeWorkspace(...removeWorkspaces: Workspaces) {
|
function removeWorkspace(...removeWorkspaces: Workspaces) {
|
||||||
const workspaces: Workspace[] = [];
|
const workspaces: Workspace[] = [];
|
||||||
|
|
||||||
|
const user = useUserStore().user;
|
||||||
|
const usedWorkspaceId = user?.workspaces?.find((w) => w.uuid === user.workspaceId)?.id;
|
||||||
|
|
||||||
removeWorkspaces.forEach((workspace: Workspace) => {
|
removeWorkspaces.forEach((workspace: Workspace) => {
|
||||||
if (workspace.id === currentUser.value?.settings?.workspace) {
|
if (workspace.id === usedWorkspaceId) {
|
||||||
NotifyResponse(i18n.global.t('notPossibleToDeleteUsedWorkspace'), 'error');
|
NotifyResponse(i18n.global.t('notPossibleToDeleteUsedWorkspace'), 'error');
|
||||||
} else if (workspace.id) {
|
} else if (workspace.id) {
|
||||||
workspaces.push(workspace);
|
workspaces.push(workspace);
|
||||||
@@ -192,11 +194,6 @@ function removeWorkspace(...removeWorkspaces: Workspaces) {
|
|||||||
workspaces: workspaces,
|
workspaces: workspaces,
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
const storageWorkspace = localStorage.getItem('workspace');
|
|
||||||
if (workspaces.some((w) => w.uuid === storageWorkspace)) {
|
|
||||||
workspace.value = '';
|
|
||||||
localStorage.removeItem('workspace');
|
|
||||||
}
|
|
||||||
updateWorkspaces().catch((err) => NotifyResponse(err, 'error'));
|
updateWorkspaces().catch((err) => NotifyResponse(err, 'error'));
|
||||||
if (workspaces.length === 1) {
|
if (workspaces.length === 1) {
|
||||||
NotifyResponse("'" + workspaces[0]?.name + "' " + i18n.global.t('deleted'), 'warning');
|
NotifyResponse("'" + workspaces[0]?.name + "' " + i18n.global.t('deleted'), 'warning');
|
||||||
|
|||||||
Reference in New Issue
Block a user