release v2.0.0 #4
|
@ -14,6 +14,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { useStore } from 'vuex';
|
||||||
import { computed, defineComponent } from 'vue';
|
import { computed, defineComponent } from 'vue';
|
||||||
import { hasPermissions } from 'src/utils/permission';
|
import { hasPermissions } from 'src/utils/permission';
|
||||||
|
|
||||||
|
@ -44,19 +45,21 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
setup(props, { root }) {
|
setup(props) {
|
||||||
let title = computed<string>(() => {
|
let title = computed<string>(() => {
|
||||||
if (props.title.includes('loadFromStore')) {
|
if (props.title.includes('loadFromStore')) {
|
||||||
|
const store = useStore();
|
||||||
|
|
||||||
const startIndex = props.title.indexOf('(') + 1;
|
const startIndex = props.title.indexOf('(') + 1;
|
||||||
const endIndex = props.title.indexOf(')');
|
const endIndex = props.title.indexOf(')');
|
||||||
const substring = props.title.substring(startIndex, endIndex).replace(/"/g, '');
|
const substring = props.title.substring(startIndex, endIndex).replace(/"/g, '');
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
||||||
return <string>root.$store.getters[substring];
|
return <string>store.getters[substring];
|
||||||
}
|
}
|
||||||
return props.title;
|
return props.title;
|
||||||
});
|
});
|
||||||
|
|
||||||
const isGranted = computed(() => hasPermissions(props.permissions || [], root.$store));
|
const isGranted = computed(() => hasPermissions(props.permissions || []));
|
||||||
|
|
||||||
return { realTitle: title, isGranted };
|
return { realTitle: title, isGranted };
|
||||||
},
|
},
|
||||||
|
|
|
@ -21,8 +21,8 @@ export default defineComponent({
|
||||||
default: undefined,
|
default: undefined,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props, { root }) {
|
setup(props) {
|
||||||
const isGranted = computed(() => hasPermissions(props.permissions || [], root.$store));
|
const isGranted = computed(() => hasPermissions(props.permissions || []));
|
||||||
return { isGranted };
|
return { isGranted };
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -38,6 +38,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent, ref } from 'vue';
|
import { computed, defineComponent, ref } from 'vue';
|
||||||
import { date } from 'quasar';
|
import { date } from 'quasar';
|
||||||
|
import { exception } from 'console';
|
||||||
interface Props {
|
interface Props {
|
||||||
value?: Date;
|
value?: Date;
|
||||||
label?: string;
|
label?: string;
|
||||||
|
@ -49,26 +50,25 @@ interface Props {
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'IsoDateInput',
|
name: 'IsoDateInput',
|
||||||
props: {
|
props: {
|
||||||
value: {
|
value: { type: String, required: true },
|
||||||
required: true,
|
type: {
|
||||||
|
type: String,
|
||||||
|
default: 'date',
|
||||||
|
validator: (value: string) => ['date', 'time', 'datetime'].indexOf(value) !== -1,
|
||||||
},
|
},
|
||||||
label: {},
|
label: String,
|
||||||
readonly: {
|
readonly: {
|
||||||
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
type: {
|
|
||||||
default: 'date',
|
|
||||||
validator: function (value: string) {
|
|
||||||
return ['date', 'time', 'datetime'].indexOf(value) !== -1;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
rules: {
|
rules: {
|
||||||
default: () => {
|
default: () => {
|
||||||
return [];
|
return [];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
setup(props: Props, { emit }: { emit: any }) {
|
setup(props, { emit }) {
|
||||||
function getDateTime() {
|
function getDateTime() {
|
||||||
if (typeof props.value == 'object') {
|
if (typeof props.value == 'object') {
|
||||||
switch (props.type) {
|
switch (props.type) {
|
||||||
|
@ -107,6 +107,7 @@ export default defineComponent({
|
||||||
case 'datetime':
|
case 'datetime':
|
||||||
return 'YYYY-MM-DD HH:mm';
|
return 'YYYY-MM-DD HH:mm';
|
||||||
}
|
}
|
||||||
|
throw exception;
|
||||||
});
|
});
|
||||||
|
|
||||||
function dateChanged(dateString: string) {
|
function dateChanged(dateString: string) {
|
||||||
|
|
|
@ -11,18 +11,18 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, onMounted, ref } from 'vue';
|
import { Component, defineComponent, onMounted, inject, ref } from 'vue';
|
||||||
import { hasPermissions } from 'src/utils/permission';
|
import { hasPermissions } from 'src/utils/permission';
|
||||||
import { AsyncComponentPromise } from 'vue/types/options';
|
import { FG_Plugin } from 'src/plugins';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Dashboard',
|
name: 'Dashboard',
|
||||||
setup(_, { root }) {
|
setup() {
|
||||||
const widgets = ref<Array<AsyncComponentPromise>>([]);
|
const widgets = ref<Array<Component>>([]);
|
||||||
|
const flaschengeistPlugins = inject<FG_Plugin.LoadedPlugins>('flaschengeistPlugins');
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
root.$flaschengeistPlugins.widgets.forEach((widget) => {
|
flaschengeistPlugins?.widgets.forEach((widget) => {
|
||||||
if (hasPermissions(widget.permissions, root.$store)) widgets.value.push(widget.widget);
|
if (hasPermissions(widget.permissions)) widgets.value.push(widget.widget);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -54,20 +54,25 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref } from 'vue';
|
import { useStore } from 'vuex';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
import { Loading, Notify } from 'quasar';
|
import { Loading, Notify } from 'quasar';
|
||||||
import { setBaseUrl } from 'boot/axios';
|
import { defineComponent, ref } from 'vue';
|
||||||
|
import { setBaseUrl, api } from 'boot/axios';
|
||||||
|
import { UserSessionState } from 'src/plugins/user/store';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
// name: 'PageName'
|
// name: 'PageName'
|
||||||
setup(_, { root }) {
|
setup() {
|
||||||
|
const store = useStore<UserSessionState>();
|
||||||
|
const router = useRouter();
|
||||||
const mainRoute = { name: 'dashboard' };
|
const mainRoute = { name: 'dashboard' };
|
||||||
|
|
||||||
/* Stuff for the real login page */
|
/* Stuff for the real login page */
|
||||||
const userid = ref('');
|
const userid = ref('');
|
||||||
const password = ref('');
|
const password = ref('');
|
||||||
const rules = [(val: string) => (val && val.length > 0) || 'Feld darf nicht leer sein!'];
|
const rules = [(val: string) => (val && val.length > 0) || 'Feld darf nicht leer sein!'];
|
||||||
const server = ref<string | undefined>(root.$axios.defaults.baseURL);
|
const server = ref<string | undefined>(api.defaults.baseURL);
|
||||||
const visible = ref(false);
|
const visible = ref(false);
|
||||||
|
|
||||||
function openServerSettings() {
|
function openServerSettings() {
|
||||||
|
@ -84,15 +89,14 @@ export default defineComponent({
|
||||||
Loading.show({
|
Loading.show({
|
||||||
message: 'Du wirst angemeldet',
|
message: 'Du wirst angemeldet',
|
||||||
});
|
});
|
||||||
root.$store
|
store
|
||||||
.dispatch('session/login', {
|
.dispatch('session/login', {
|
||||||
userid: userid.value,
|
userid: userid.value,
|
||||||
password: password.value,
|
password: password.value,
|
||||||
})
|
})
|
||||||
.then(async (finished) => {
|
.then(() => {
|
||||||
await finished;
|
const x = router.currentRoute.value.query['redirect'];
|
||||||
const x = root.$route.query['redirect'];
|
void router.push(typeof x === 'string' ? { path: x } : mainRoute);
|
||||||
void root.$router.push(typeof x === 'string' ? { path: x } : mainRoute);
|
|
||||||
})
|
})
|
||||||
.catch((error: { status: number } | undefined) => {
|
.catch((error: { status: number } | undefined) => {
|
||||||
if (error && error.status === 401) {
|
if (error && error.status === 401) {
|
||||||
|
@ -124,7 +128,7 @@ export default defineComponent({
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
void root.$store
|
void store
|
||||||
.dispatch('session/requestPasswordReset', {
|
.dispatch('session/requestPasswordReset', {
|
||||||
userid: userid.value,
|
userid: userid.value,
|
||||||
})
|
})
|
||||||
|
|
|
@ -36,16 +36,18 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref, onUnmounted } from 'vue';
|
import { defineComponent, ref, onUnmounted } from 'vue';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Offline',
|
name: 'Offline',
|
||||||
setup(_, { root }) {
|
setup() {
|
||||||
|
const router = useRouter();
|
||||||
const reload = ref(10);
|
const reload = ref(10);
|
||||||
const ival = setInterval(() => {
|
const ival = setInterval(() => {
|
||||||
reload.value -= 1;
|
reload.value -= 1;
|
||||||
if (reload.value === 0) {
|
if (reload.value === 0) {
|
||||||
const path = <string | null>root.$route.query.redirect || '/login';
|
const path = <string | null>router.currentRoute.value.query.redirect || '/login';
|
||||||
void root.$router.replace({ path: path });
|
void router.replace({ path: path });
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
onUnmounted(() => clearInterval(ival));
|
onUnmounted(() => clearInterval(ival));
|
||||||
|
|
|
@ -34,13 +34,18 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { defineComponent, ref } from 'vue';
|
import { useStore } from 'vuex';
|
||||||
import { Loading, Notify } from 'quasar';
|
|
||||||
import { AxiosResponse } from 'axios';
|
import { AxiosResponse } from 'axios';
|
||||||
|
import { useRouter } from 'vue-router';
|
||||||
|
import { Loading, Notify } from 'quasar';
|
||||||
|
import { defineComponent, ref } from 'vue';
|
||||||
|
import { UserSessionState } from 'src/plugins/user/store';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
// name: 'PageName'
|
// name: 'PageName'
|
||||||
setup(_, { root }) {
|
setup() {
|
||||||
|
const store = useStore<UserSessionState>();
|
||||||
|
const router = useRouter();
|
||||||
const password = ref('');
|
const password = ref('');
|
||||||
const password2 = ref('');
|
const password2 = ref('');
|
||||||
|
|
||||||
|
@ -66,10 +71,10 @@ export default defineComponent({
|
||||||
Loading.show({
|
Loading.show({
|
||||||
message: 'Das Passwort wird zurückgesetzt',
|
message: 'Das Passwort wird zurückgesetzt',
|
||||||
});
|
});
|
||||||
root.$store
|
store
|
||||||
.dispatch('session/resetPassword', {
|
.dispatch('session/resetPassword', {
|
||||||
password: password.value,
|
password: password.value,
|
||||||
token: root.$route.query.token,
|
token: router.currentRoute.value.query.token,
|
||||||
})
|
})
|
||||||
.catch((error: AxiosResponse) => {
|
.catch((error: AxiosResponse) => {
|
||||||
if (error.status == 403) {
|
if (error.status == 403) {
|
||||||
|
@ -85,7 +90,7 @@ export default defineComponent({
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
Loading.hide();
|
Loading.hide();
|
||||||
void root.$router.replace({ name: 'login' });
|
void router.replace({ name: 'login' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -191,7 +191,7 @@ const getters: GetterTree<SessionStateInterface, UserSessionState> = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const sessions: Module<SessionStateInterface, UserSessionState> = {
|
const sessionsStore: Module<SessionStateInterface, UserSessionState> = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state,
|
state,
|
||||||
mutations,
|
mutations,
|
||||||
|
@ -199,4 +199,4 @@ const sessions: Module<SessionStateInterface, UserSessionState> = {
|
||||||
getters,
|
getters,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default sessions;
|
export default sessionsStore;
|
||||||
|
|
|
@ -264,7 +264,7 @@ const getters: GetterTree<UserStateInterface, UserSessionState> = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const userStore: Module<UserStateInterface, UserSessionState> = {
|
const usersStore: Module<UserStateInterface, UserSessionState> = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
actions,
|
actions,
|
||||||
getters,
|
getters,
|
||||||
|
@ -272,4 +272,4 @@ const userStore: Module<UserStateInterface, UserSessionState> = {
|
||||||
state,
|
state,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default userStore;
|
export default usersStore;
|
||||||
|
|
|
@ -1,16 +1,19 @@
|
||||||
import { Store } from 'vuex';
|
import { useStore } from 'vuex';
|
||||||
import { StateInterface } from 'src/store';
|
import { UserSessionState } from 'src/plugins/user/store';
|
||||||
|
|
||||||
export function hasPermission(permission: string, store: Store<StateInterface>) {
|
export function hasPermission(permission: string) {
|
||||||
return store.state.user.currentPermissions.includes(permission);
|
const store = useStore<UserSessionState>();
|
||||||
|
return store.state.users.currentPermissions.includes(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hasPermissions(needed: string[], store: Store<StateInterface>) {
|
export function hasPermissions(needed: string[]) {
|
||||||
const permissions = store.state.user.currentPermissions;
|
const store = useStore<UserSessionState>();
|
||||||
|
const permissions = store.state.users.currentPermissions;
|
||||||
return needed.every((value) => permissions.includes(value));
|
return needed.every((value) => permissions.includes(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hasSomePermissions(needed: string[], store: Store<StateInterface>) {
|
export function hasSomePermissions(needed: string[]) {
|
||||||
const permissions = store.state.user.currentPermissions;
|
const store = useStore<UserSessionState>();
|
||||||
|
const permissions = store.state.users.currentPermissions;
|
||||||
return needed.some((value) => permissions.includes(value));
|
return needed.some((value) => permissions.includes(value));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue