From 5a5bbd0dbd7ed579ac86008de5c901a3bb4f1658 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 25 May 2021 15:58:01 +0200 Subject: [PATCH] Transfered files from flaschengeist main tree --- package.json | 40 ++++ src/components/NewUser.vue | 39 ++++ src/components/UpdateUser.vue | 40 ++++ src/components/UserSelector.vue | 43 ++++ src/components/Widget.vue | 71 +++++++ src/components/settings/MainUserSettings.vue | 210 +++++++++++++++++++ src/components/settings/RoleSettings.vue | 160 ++++++++++++++ src/components/settings/Session.vue | 166 +++++++++++++++ src/index.ts | 21 ++ src/models.ts | 14 ++ src/pages/AdminSettings.vue | 93 ++++++++ src/pages/Settings.vue | 55 +++++ src/permissions.ts | 12 ++ src/routes/index.ts | 39 ++++ src/shims.d.ts | 4 + tsconfig.json | 16 ++ 16 files changed, 1023 insertions(+) create mode 100644 package.json create mode 100644 src/components/NewUser.vue create mode 100644 src/components/UpdateUser.vue create mode 100644 src/components/UserSelector.vue create mode 100644 src/components/Widget.vue create mode 100644 src/components/settings/MainUserSettings.vue create mode 100644 src/components/settings/RoleSettings.vue create mode 100644 src/components/settings/Session.vue create mode 100644 src/index.ts create mode 100644 src/models.ts create mode 100644 src/pages/AdminSettings.vue create mode 100644 src/pages/Settings.vue create mode 100644 src/permissions.ts create mode 100644 src/routes/index.ts create mode 100644 src/shims.d.ts create mode 100644 tsconfig.json diff --git a/package.json b/package.json new file mode 100644 index 0000000..d693749 --- /dev/null +++ b/package.json @@ -0,0 +1,40 @@ +{ + "private": true, + "license": "MIT", + "version": "1.0.0-alpha.1", + "name": "@flaschengeist/users", + "author": "Ferdinand ", + "homepage": "https://flaschengeist.dev/Flaschengeist", + "description": "Flaschengeist users plugin", + "bugs": { + "url": "https://flaschengeist.dev/Flaschengeist/flaschengeist/issues" + }, + "repository": { + "type": "git", + "url": "https://flaschengeist.dev/Flaschengeist/flaschengeist-users" + }, + "main": "src/index.ts", + "types": "src/index.ts", + "scripts": { + "valid": "tsc --noEmit", + "pretty": "prettier --config ./package.json --write '{,!(node_modules)/**/}*.ts'" + }, + "devDependencies": { + "prettier": "^2.3.0", + "typescript": "^4.2.4", + }, + "peerDependencies": { + "@flaschengeist/types": "^0.0.1-alpha.1", + "@flaschengeist/api": "^1.0.0-alpha.1", + "pinia": "^2.0.0-alpha.18", + "quasar": "^2.0.0-beta.17", + "@quasar/app": "^3.0.0-beta.25" + }, + "prettier": { + "singleQuote": true, + "semi": true, + "printWidth": 100, + "arrowParens": "always" + } + } + \ No newline at end of file diff --git a/src/components/NewUser.vue b/src/components/NewUser.vue new file mode 100644 index 0000000..a30221b --- /dev/null +++ b/src/components/NewUser.vue @@ -0,0 +1,39 @@ + + + + + diff --git a/src/components/UpdateUser.vue b/src/components/UpdateUser.vue new file mode 100644 index 0000000..e917959 --- /dev/null +++ b/src/components/UpdateUser.vue @@ -0,0 +1,40 @@ + + + + + diff --git a/src/components/UserSelector.vue b/src/components/UserSelector.vue new file mode 100644 index 0000000..f9f1e7d --- /dev/null +++ b/src/components/UserSelector.vue @@ -0,0 +1,43 @@ + + + diff --git a/src/components/Widget.vue b/src/components/Widget.vue new file mode 100644 index 0000000..567c55b --- /dev/null +++ b/src/components/Widget.vue @@ -0,0 +1,71 @@ + + + diff --git a/src/components/settings/MainUserSettings.vue b/src/components/settings/MainUserSettings.vue new file mode 100644 index 0000000..05f5309 --- /dev/null +++ b/src/components/settings/MainUserSettings.vue @@ -0,0 +1,210 @@ + + + diff --git a/src/components/settings/RoleSettings.vue b/src/components/settings/RoleSettings.vue new file mode 100644 index 0000000..cb4231f --- /dev/null +++ b/src/components/settings/RoleSettings.vue @@ -0,0 +1,160 @@ + + + + + \ No newline at end of file diff --git a/src/components/settings/Session.vue b/src/components/settings/Session.vue new file mode 100644 index 0000000..9fc5337 --- /dev/null +++ b/src/components/settings/Session.vue @@ -0,0 +1,166 @@ + + + diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..c66bf7f --- /dev/null +++ b/src/index.ts @@ -0,0 +1,21 @@ +import { FG_Plugin } from '@flaschengeist/types'; +import { defineAsyncComponent } from 'vue'; +import routes from './routes'; + +const plugin: FG_Plugin.Plugin = { + id: 'users', + name: 'User', + innerRoutes: routes, + requiredModules: [['auth'], ['users'], ['roles']], + version: '0.0.1', + widgets: [ + { + priority: 1, + name: 'greeting', + permissions: [], + widget: defineAsyncComponent(() => import('./components/Widget.vue')), + }, + ], +}; + +export default plugin diff --git a/src/models.ts b/src/models.ts new file mode 100644 index 0000000..b0d9a69 --- /dev/null +++ b/src/models.ts @@ -0,0 +1,14 @@ +export interface LoginData { + userid: string; + password: string; +} + +export interface LoginResponse { + user: FG.User; + session: FG.Session; + permissions: FG.Permission[]; +} + +export interface CurrentUserResponse extends FG.User { + permissions: FG.Permission[]; +} diff --git a/src/pages/AdminSettings.vue b/src/pages/AdminSettings.vue new file mode 100644 index 0000000..fda9869 --- /dev/null +++ b/src/pages/AdminSettings.vue @@ -0,0 +1,93 @@ + + + diff --git a/src/pages/Settings.vue b/src/pages/Settings.vue new file mode 100644 index 0000000..3d90e32 --- /dev/null +++ b/src/pages/Settings.vue @@ -0,0 +1,55 @@ + + + diff --git a/src/permissions.ts b/src/permissions.ts new file mode 100644 index 0000000..2ba1b10 --- /dev/null +++ b/src/permissions.ts @@ -0,0 +1,12 @@ +export const PERMISSIONS = { + // Kann andere Nutzer bearbeiten + EDIT_OTHER: 'users_edit_other', + // Kann Rollen von Nutzern setzen + SET_ROLES: 'users_set_roles', + // Kann Nutzer löschen + DELETE: 'users_delete_other', + // Kann neue Nutzer hinzufügen + REGISTER: 'users_register', + // Kann Rollen löschen oder bearbeiten, z.b. Rechte hinzufügen etc + ROLES_EDIT: 'roles_edit', +}; diff --git a/src/routes/index.ts b/src/routes/index.ts new file mode 100644 index 0000000..38e43ad --- /dev/null +++ b/src/routes/index.ts @@ -0,0 +1,39 @@ +import { pinia, useMainStore } from '@flaschengeist/api'; +import { FG_Plugin } from '@flaschengeist/types'; + +const mainRoutes: FG_Plugin.MenuRoute[] = [ + { + get title() { + return () => useMainStore(pinia.value).currentUser.display_name; + }, + icon: 'mdi-account', + permissions: ['user'], + route: { path: 'user', name: 'user', redirect: { name: 'user-settings' } }, + children: [ + { + title: 'Einstellungen', + icon: 'mdi-account-edit', + shortcut: true, + permissions: ['user'], + route: { + path: 'settings', + name: 'user-settings', + component: () => import('../pages/Settings.vue'), + }, + }, + { + title: 'Admin', + icon: 'mdi-cog', + shortcut: false, + permissions: ['users_edit_other'], + route: { + path: 'admin', + name: 'admin-settings', + component: () => import('../pages/AdminSettings.vue'), + }, + }, + ], + }, +]; + +export default mainRoutes; diff --git a/src/shims.d.ts b/src/shims.d.ts new file mode 100644 index 0000000..7237d6c --- /dev/null +++ b/src/shims.d.ts @@ -0,0 +1,4 @@ +declare module '*.vue' { + import Vue from 'vue'; + export default Vue; +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..eb38103 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "@quasar/app/tsconfig-preset", + "target": "esnext", + "compilerOptions": { + "baseUrl": "src/", + "lib": [ + "es2020", + "dom" + ], + "types": [ + "@flaschengeist/types", + "@quasar/app", + "node" + ] + } +}