Compare commits

..

3 Commits

Author SHA1 Message Date
Ferdinand Thiessen e8c0001d17 fix(ci): Fix build step
continuous-integration/woodpecker the build was successful Details
2021-12-08 15:32:31 +01:00
Ferdinand Thiessen 5c8637965a feat(ci): More testing
continuous-integration/woodpecker the build failed Details
2021-12-08 15:29:41 +01:00
Ferdinand Thiessen 308d348755 feat(ci): Added woodpecker CI
continuous-integration/woodpecker the build was successful Details
2021-12-08 15:17:25 +01:00
23 changed files with 120 additions and 296 deletions

View File

@ -1,3 +0,0 @@
yarn-error.log
.woodpecker/

View File

@ -1,15 +0,0 @@
pipeline:
deploy:
when:
event: tag
tag: "@flaschengeist/api-v*"
image: node:lts-alpine
commands:
- cd api
- echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" > .npmrc
- yarn publish --non-interactive
secrets: [ node_auth_token ]
depends_on:
- lint

View File

@ -1,9 +1,16 @@
pipeline:
lint:
when:
branch: [main, develop]
install:
image: node:lts-alpine
commands:
- yarn install
lint:
image: node:lts-alpine
commands:
- yarn lint
build:
image: node:lts-alpine
commands:
- yarn quasar build
branches: [main, develop]

View File

@ -1,6 +1,6 @@
# Flaschengeist (frontend)
![status-badge](https://ci.os-sc.org/api/badges/Flaschengeist/flaschengeist-frontend/status.svg)
![status-badge](http://os-sc.org:8000/api/badges/ferfissimo/flaschengeist-frontend/status.svg)
Modular student club administration system, licensed under the MIT license.

View File

@ -1,6 +1,6 @@
<template>
<q-avatar>
<slot :avatar-u-r-l="avatarURL(modelValue)">
<slot :avatarURL="avatarURL(modelValue)">
<q-img :src="avatarURL(modelValue)" style="min-width: 100%; min-height: 100%">
<template #error>
<img :src="fallback" style="height: 100%" />

View File

@ -1,6 +1,6 @@
{
"license": "MIT",
"version": "1.0.0",
"version": "1.0.0-alpha.7",
"name": "@flaschengeist/api",
"author": "Tim Gröger <flaschengeist@wu5.de>",
"homepage": "https://flaschengeist.dev/Flaschengeist",
@ -10,14 +10,14 @@
},
"main": "./src/index.ts",
"peerDependencies": {
"@quasar/app-webpack": "^3.7.2",
"flaschengeist": "^2.0.0",
"pinia": "^2.0.8"
"@quasar/app": "^3.2.4",
"flaschengeist": "^2.0.0-alpha.1",
"pinia": "^2.0.6"
},
"devDependencies": {
"@flaschengeist/types": "^1.0.0",
"@types/node": "^14.18.0",
"typescript": "^4.5.4"
"@flaschengeist/types": "^1.0.0-alpha.10",
"@types/node": "^14.18.00",
"typescript": "^4.5.2"
},
"prettier": {
"singleQuote": true,

View File

@ -4,7 +4,7 @@ import { AxiosResponse } from 'axios';
import { api } from '../internal';
import { defineStore } from 'pinia';
import { PersistentStorage } from '../utils/persistent';
import { LocalStorage, SessionStorage } from 'quasar';
function reviveSession() {
return PersistentStorage.get<FG.Session>('fg_session').then((s) => fixSession(s || undefined));
}
@ -154,8 +154,6 @@ export const useMainStore = defineStore({
handleLoggedOut() {
this.$reset();
void clearPersistant();
LocalStorage.clear();
SessionStorage.clear();
},
},
});

View File

@ -1,7 +1,6 @@
import { defineStore } from 'pinia';
import { api } from '../internal';
import { isAxiosError, useMainStore } from '.';
import { DisplayNameMode } from '@flaschengeist/users';
export function fixUser(u?: FG.User) {
return !u ? u : Object.assign(u, { birthday: u.birthday ? new Date(u.birthday) : undefined });
@ -23,7 +22,6 @@ export const useUserStore = defineStore({
state: () => ({
roles: [] as FG.Role[],
permissions: [] as FG.Permission[],
userSettings: {} as FG.UserSettings,
// list of all users, include deleted ones, use `users` getter for list of active ones
_users: [] as FG.User[],
// Internal flags for deciding if lists need to force-loaded
@ -33,42 +31,7 @@ export const useUserStore = defineStore({
getters: {
users(state) {
const u = state._users.filter((u) => !u.deleted);
switch (this.userSettings['display_name']) {
case DisplayNameMode.FIRSTNAME_LASTNAME || DisplayNameMode.FIRSTNAME:
u.sort((a, b) => {
const a_lastname = a.lastname.toLowerCase();
const b_lastname = b.lastname.toLowerCase();
const a_firstname = a.firstname.toLowerCase();
const b_firstname = b.firstname.toLowerCase();
if (a_firstname === b_firstname) {
return a_lastname < b_lastname ? -1 : 1;
}
return a_firstname < b_firstname ? -1 : 1;
});
break;
case <string>DisplayNameMode.DISPLAYNAME:
u.sort((a, b) => {
const a_displayname = a.display_name.toLowerCase();
const b_displayname = b.display_name.toLowerCase();
return a_displayname < b_displayname ? -1 : 1;
});
break;
default:
u.sort((a, b) => {
const a_lastname = a.lastname.toLowerCase();
const b_lastname = b.lastname.toLowerCase();
const a_firstname = a.firstname.toLowerCase();
const b_firstname = b.firstname.toLowerCase();
if (a_lastname === b_lastname) {
return a_firstname < b_firstname ? -1 : 1;
}
return a_lastname < b_lastname ? -1 : 1;
});
}
return u;
return state._users.filter((u) => !u.deleted);
},
},
@ -244,35 +207,5 @@ export const useUserStore = defineStore({
await api.delete(`/roles/${role}`);
this.roles = this.roles.filter((r) => r.id !== role);
},
/** Get Settings for display name mode
* @param force If set to true a fresh list is loaded from backend even when a local copy is available
* @throws Probably an AxiosError if request failed
* @returns Settings for display name mode
*/
async getDisplayNameModeSetting(force = false): Promise<string> {
const mainStore = useMainStore();
if (force) {
const { data } = await api.get<{ data: string }>(
`users/${mainStore.currentUser.userid}/setting/display_name_mode`
);
this.userSettings['display_name'] = data.data;
}
return this.userSettings['display_name'];
},
/** Set Settings for display name mode
* @param mode New display name mode
* @throws Probably an AxiosError if request failed
* @returns Settings for display name mode
*/
async setDisplayNameModeSetting(mode: string): Promise<string> {
const mainStore = useMainStore();
await api.put(`users/${mainStore.currentUser.userid}/setting/display_name_mode`, {
data: mode,
});
this.userSettings['display_name'] = mode;
return mode;
},
},
});

View File

@ -1,35 +1,35 @@
import { LocalStorage, Platform } from 'quasar';
import { Preferences } from '@capacitor/preferences';
import { Storage } from '@capacitor/storage';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type PersitentTypes = Date | RegExp | number | boolean | string | object;
export class PersistentStorage {
static clear() {
if (Platform.is.capacitor) return Preferences.clear();
if (Platform.is.capacitor) return Storage.clear();
else return Promise.resolve(LocalStorage.clear());
}
static remove(key: string) {
if (Platform.is.capacitor) return Preferences.remove({ key: key });
if (Platform.is.capacitor) return Storage.remove({ key: key });
else return Promise.resolve(LocalStorage.remove(key));
}
static set(key: string, value: PersitentTypes) {
if (Platform.is.capacitor) return Preferences.set({ key, value: JSON.stringify(value) });
if (Platform.is.capacitor) return Storage.set({ key, value: JSON.stringify(value) });
else return Promise.resolve(LocalStorage.set(key, value));
}
static get<T extends PersitentTypes>(key: string) {
if (Platform.is.capacitor)
return Preferences.get({ key }).then((v) =>
return Storage.get({ key }).then((v) =>
v.value === null ? null : (JSON.parse(v.value) as T)
);
else return Promise.resolve(LocalStorage.getItem<T>(key));
}
static keys() {
if (Platform.is.capacitor) return Preferences.keys().then((v) => v.keys);
if (Platform.is.capacitor) return Storage.keys().then((v) => v.keys);
else return Promise.resolve(LocalStorage.getAllKeys());
}
}

View File

@ -3,7 +3,14 @@
"target": "esnext",
"compilerOptions": {
"baseUrl": "./",
"lib": ["es2020", "dom"],
"types": ["@flaschengeist/types", "@quasar/app", "node"]
}
"lib": [
"es2020",
"dom"
],
"types": [
"@flaschengeist/types",
"@quasar/app",
"node"
]
}
}

View File

@ -1,7 +1,7 @@
{
"private": true,
"license": "MIT",
"version": "2.1.0",
"version": "2.0.0-alpha.1",
"productName": "flaschengeist-frontend",
"name": "flaschengeist",
"author": "Tim Gröger <flaschengeist@wu5.de>",
@ -15,37 +15,31 @@
"lint": "eslint --ext .js,.ts,.vue ./src ./api"
},
"dependencies": {
"@flaschengeist/api": "^1.0.0",
"@flaschengeist/balance": "^1.0.0",
"@flaschengeist/pricelist-old": "^1.0.0",
"@flaschengeist/schedule": "^1.0.0",
"@flaschengeist/users": "^1.0.0",
"axios": "^1.4.0",
"pinia": "^2.0.8",
"quasar": "^2.11.10",
"vue": "^3.0.0",
"vue-router": "^4.0.0"
"@flaschengeist/api": "file:./api",
"@flaschengeist/users": "^1.0.0-alpha.3",
"axios": "^0.24.0",
"pinia": "^2.0.6",
"quasar": "^2.3.3"
},
"devDependencies": {
"@capacitor/core": "^5.0.0",
"@capacitor/preferences": "^5.0.0",
"@flaschengeist/types": "^1.0.0",
"@quasar/app-webpack": "^3.7.2",
"@quasar/extras": "^1.16.3",
"@capacitor/core": "^3.3.2",
"@capacitor/storage": "^1.2.3",
"@flaschengeist/types": "^1.0.0-alpha.10",
"@quasar/app": "^3.2.4",
"@quasar/extras": "^1.12.2",
"@types/node": "^14.18.0",
"@types/webpack": "^5.28.0",
"@types/webpack-env": "^1.16.3",
"@typescript-eslint/eslint-plugin": "^5.8.0",
"@typescript-eslint/parser": "^5.8.0",
"@vue/devtools": "^6.5.0",
"eslint": "^8.5.0",
"@typescript-eslint/eslint-plugin": "^5.5.0",
"@typescript-eslint/parser": "^5.5.0",
"eslint": "^8.4.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^9.14.1",
"eslint-webpack-plugin": "^4.0.1",
"modify-source-webpack-plugin": "^4.1.0",
"eslint-plugin-vue": "^8.1.1",
"eslint-webpack-plugin": "^3.1.1",
"modify-source-webpack-plugin": "^3.0.0",
"prettier": "^2.5.1",
"typescript": "^4.5.4",
"typescript": "^4.5.2",
"vuedraggable": "^4.1.0"
},
"prettier": {

View File

@ -3,4 +3,4 @@ module.exports = [
// '@flaschengeist/balance',
// '@flaschengeist/schedule',
// '@flaschengeist/pricelist',
'@flaschengeist/schedule',
]

View File

@ -9,23 +9,9 @@
/* eslint-env node */
/* eslint-disable @typescript-eslint/no-var-requires */
const ESLintPlugin = require('eslint-webpack-plugin');
const { ModifySourcePlugin, ReplaceOperation } = require('modify-source-webpack-plugin');
const { ModifySourcePlugin } = require('modify-source-webpack-plugin');
const { configure } = require('quasar/wrappers');
const operation = () => {
const custom_plgns = require('./plugin.config.js');
const required_plgns = require('./src/vendor-plugin.config.js');
const plugins = [...custom_plgns, ...required_plgns].map(
(v) => `import("${v}").catch(() => "${v}")`
);
const replace = new ReplaceOperation(
'all',
`\\/\\* *INSERT_PLUGIN_LIST *\\*\\/`,
`${plugins.join(', ')}`
);
return replace;
};
module.exports = configure(function (/* ctx */) {
return {
// https://quasar.dev/quasar-cli/supporting-ts
@ -56,7 +42,7 @@ module.exports = configure(function (/* ctx */) {
// 'ionicons-v5',
// 'line-awesome',
// 'material-icons',
'mdi-v7',
'mdi-v6',
// 'themify',
// 'roboto-font-latin-ext', // this or either 'roboto-font', NEVER both!
@ -66,7 +52,7 @@ module.exports = configure(function (/* ctx */) {
// Full list of options: https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-build
build: {
vueRouterMode: 'history', // available values: 'hash', 'history'
//publicPath: 'flaschengeist2',
// transpile: false,
// Add dependencies for transpiling with Babel (Array of string/regex)
@ -95,7 +81,16 @@ module.exports = configure(function (/* ctx */) {
rules: [
{
test: /plugins\.ts$/,
operations: [operation()],
modify: (src, filename) => {
const custom_plgns = require('./plugin.config.js');
const required_plgns = require('./src/vendor-plugin.config.js');
return src.replace(
/\/\* *INSERT_PLUGIN_LIST *\*\//,
[...custom_plgns, ...required_plgns]
.map((v) => `import("${v}").catch(() => "${v}")`)
.join(',')
);
},
},
],
},
@ -220,8 +215,5 @@ module.exports = configure(function (/* ctx */) {
// chainWebpack also available besides this extendWebpack
},
},
bin: {
linuxAndroidStudio: '/home/crimsen/.local/share/JetBrains/Toolbox/scripts/studio',
},
};
});

View File

@ -4,9 +4,6 @@
"bundledWebRuntime": false,
"npmClient": "yarn",
"webDir": "www",
"android": {
"minWebViewVersion": 71
},
"ios": {
"allowsLinkPreview": false
}

View File

@ -1,35 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Quasar</title>
<meta charset="utf-8">
<meta name="description" content="Quasar Capacitor App">
<meta name="format-detection" content="telephone=no">
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, viewport-fit=cover">
<style>
.page {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
height: 100vh;
text-align: center;
}
</style>
</head>
<body>
<div class="page">
<div>
This file will be auto-generated. Do not edit.
</div>
<div>
Run "quasar dev" or "quasar build" with Capacitor mode.
</div>
</div>
</body>
</html>

View File

@ -1,16 +1,16 @@
{
"name": "flaschengeist",
"version": "2.0.0",
"version": "2.0.0-alpha.1",
"description": "Modular student club administration system",
"author": "Tim Gröger <flaschengeist@wu5.de>",
"private": true,
"dependencies": {
"@capacitor/android": "^5.0.0-beta.0",
"@capacitor/app": "^5.0.0",
"@capacitor/cli": "^5.0.0",
"@capacitor/core": "^5.0.0",
"@capacitor/ios": "^5.0.0",
"@capacitor/preferences": "^5.0.0",
"@capacitor/splash-screen": "^5.0.0"
"@capacitor/android": "^3.3.2",
"@capacitor/app": "^1.0.0",
"@capacitor/cli": "^3.0.0",
"@capacitor/core": "^3.0.0",
"@capacitor/ios": "^3.0.0-beta.0",
"@capacitor/splash-screen": "^1.0.0",
"@capacitor/storage": "^1.2.3"
}
}

View File

@ -21,8 +21,8 @@ async function loadBaseUrl() {
console.warn('Could not load BaseURL', e);
}
}
// eslint-disable-next-line
class BackendError extends Error { }
class BackendError extends Error {}
/**
* Loading backend information
@ -68,18 +68,8 @@ export default boot(async ({ app, router }) => {
// Handle errors from loading the backend information
if (error instanceof BackendError || isAxiosError(error)) {
router.isReady().finally(() => {
// if (Platform.is.capacitor) void router.push({ name: 'setup_backend' });
if (Platform.is.capacitor) {
//void router.push({ name: 'setup_backend' })
Notify.create({
type: 'negative',
message:
'Backend nicht erreichbar! Prüfe deine Internetverbindung oder probiere es später nochmal.',
timeout: 0,
icon: 'mdi-alert-circle-outline',
closeBtn: true,
});
} else void router.push({ name: 'offline', params: { refresh: 1 } });
if (Platform.is.capacitor) void router.push({ name: 'setup_backend' });
else void router.push({ name: 'offline', params: { refresh: 1 } });
});
} else if (typeof error === 'string') {
// Handle plugin not found errors

View File

@ -234,12 +234,6 @@ function loadPlugin(
Array.prototype.push.apply(loadedPlugins.widgets, plugin.widgets);
}
if (!plugin.settingWidgets) plugin.settingWidgets = [];
if (plugin.settingWidgets.length > 0) {
plugin.settingWidgets.forEach((widget) => (widget.name = plugin.id + '.' + widget.name));
Array.prototype.push.apply(loadedPlugins.settingWidgets, plugin.settingWidgets);
}
loadedPlugins.plugins.push({
id: plugin.id,
name: plugin.name,
@ -258,7 +252,6 @@ export async function loadPlugins(backend: FG.Backend, baseRoutes: RouteRecordRa
shortcuts: [],
outerShortcuts: [],
widgets: [],
settingWidgets: [],
};
// Wait for all plugins to be loaded

View File

@ -14,7 +14,7 @@
class="q-ma-xs"
title="Löschen"
style="position: absolute; top: 0; right: 0; z-index: 999"
@click.stop.prevent="dismiss"
@click="dismiss"
/>
<q-card-section class="q-pa-xs">
<div class="text-overline">{{ dateString }}</div>
@ -34,7 +34,7 @@
flat
dense
size="sm"
@click.stop.prevent="accept"
@click="accept"
/>
<q-btn
v-if="modelValue.reject"
@ -44,7 +44,7 @@
flat
dense
size="sm"
@click.stop.prevent="reject"
@click="reject"
/>
</q-card-actions>
</q-card>

View File

@ -2,7 +2,7 @@
<q-layout view="hHh Lpr lff">
<q-header elevated class="bg-primary text-white">
<q-toolbar>
<q-btn dense flat round icon="mdi-menu" @click="openMenu(true)" />
<q-btn dense flat round icon="mdi-menu" @click="openMenu" />
<q-toolbar-title>
<router-link :to="{ name: 'dashboard' }" style="text-decoration: none; color: inherit">
@ -56,44 +56,32 @@
side="left"
bordered
:mini="leftDrawerMini"
@click.capture="openMenuMini"
@click.capture="openMenu"
>
<!-- Plugins -->
<q-scroll-area class="fit">
<essential-expansion-link
v-for="(entry, index) in mainLinks"
:key="'plugin' + index"
:entry="entry"
@add-short-cut="addShortcut"
/>
<essential-expansion-link
v-for="(entry, index) in mainLinks"
:key="'plugin' + index"
:entry="entry"
@add-short-cut="addShortcut"
/>
<q-separator />
<essential-link
v-for="(entry, index) in essentials"
:key="'essential' + index"
:entry="entry"
/>
<div v-if="platform.is.capacitor">
<q-separator />
<essential-link
v-for="(entry, index) in essentials"
:key="'essential' + index"
:entry="entry"
/>
<div v-if="platform.is.capacitor">
<q-separator />
<q-item clickable tag="a" target="self" @click="logout">
<q-item-section avatar>
<q-icon name="mdi-exit-to-app" />
</q-item-section>
<q-item clickable tag="a" target="self" @click="logout">
<q-item-section avatar>
<q-icon name="mdi-exit-to-app" />
</q-item-section>
<q-item-section>
<q-item-label>Logout</q-item-label>
</q-item-section>
</q-item>
</div>
</q-scroll-area>
<div class="q-mini-drawer-hide absolute" style="top: 15px; right: -17px">
<q-btn
dense
round
unelevated
color="accent"
icon="mdi-chevron-left"
@click="openMenuMini(true)"
/>
<q-item-section>
<q-item-label>Logout</q-item-label>
</q-item-section>
</q-item>
</div>
</q-drawer>
<q-page-container>
@ -137,7 +125,7 @@ export default defineComponent({
const mainStore = useMainStore();
const flaschengeist = inject<FG_Plugin.Flaschengeist>('flaschengeist');
const leftDrawer = ref(!Platform.is.mobile);
const leftDrawerMini = ref(true);
const leftDrawerMini = ref(false);
const mainLinks = flaschengeist?.menuLinks || [];
const notifications = computed(() => mainStore.notifications.slice().reverse());
const polling = ref(NaN);
@ -150,11 +138,9 @@ export default defineComponent({
void mainStore.getShortcuts();
});
onBeforeUnmount(() => window.clearInterval(polling.value));
/*
function openMenu(event: { target: HTMLInputElement }) {
console.log(event.target.nodeName);
if (event.target.nodeName === 'DIV' || event.target.nodeName === 'I')
leftDrawerMini.value = false;
if (event.target.nodeName === 'DIV') leftDrawerMini.value = false;
else {
if (!leftDrawer.value || leftDrawerMini.value) {
leftDrawer.value = true;
@ -165,13 +151,7 @@ export default defineComponent({
}
}
}
*/
function openMenu(value = !leftDrawer.value) {
leftDrawer.value = value;
}
function openMenuMini(value = !leftDrawerMini.value) {
leftDrawerMini.value = value;
}
function logout() {
void router.push({ name: 'login', params: { logout: 'logout' } });
void mainStore.logout();
@ -234,7 +214,6 @@ export default defineComponent({
notifications,
noPermission,
openMenu,
openMenuMini,
remove,
requestPermission,
useNative,

View File

@ -2,9 +2,9 @@
<q-page
padding
style="grid-auto-rows: 1fr"
class="row justify-center content-center items-center q-col-gutter-lg"
class="fit row justify-around items-start q-col-gutter-sm"
>
<div v-for="(item, index) in widgets" :key="index" class="full-height col-sm-6 col-xs-12">
<div v-for="(item, index) in widgets" :key="index" class="col-4 full-height col-sm-6 col-xs-12">
<component :is="item.widget" />
</div>
</q-page>

View File

@ -121,24 +121,11 @@ export default defineComponent({
if (quasar.platform.is.capacitor)
await sessionStore.updateSession(14 * 24 * 60 * 60, mainStore.currentSession.token);
// Redirect user to previous page, if any.
// there are different redirects possible:
// 1. when explicitely entered
// a) http://localhost:8080/ -> should be redirected to mainRoute
// b) http://localhost:8080/in/user/settings -> should be redirected to in/user/settings
// 2. when automatically logged out:
// http://localhost:8080/login?redirect=/in/user/settings
// -> should be redirected to in/user/settings
var redirect;
if (router.currentRoute.value.redirectedFrom) {
redirect = router.currentRoute.value.redirectedFrom.path;
if (redirect === '/') {
redirect = mainRoute;
}
} else if ('redirect' in router.currentRoute.value.query) {
redirect = { path: router.currentRoute.value.query.redirect as string };
} else {
redirect = mainRoute;
}
const redirect =
router.currentRoute.value.redirectedFrom || 'redirect' in router.currentRoute.value.query
? { path: router.currentRoute.value.query.redirect as string }
: mainRoute;
void router.push(redirect);
} else {
// Login failed, notify and reset form

View File

@ -1,5 +1,5 @@
{
"extends": "@quasar/app-webpack/tsconfig-preset",
"extends": "@quasar/app/tsconfig-preset",
"target": "esnext",
"compilerOptions": {
"baseUrl": ".",