1
0
Fork 0
forked from Kispi/Core

feat(webapp): protect data view with pin

This commit is contained in:
Simon Giesel 2022-08-04 11:48:29 +02:00
parent 46d0ad8770
commit 8c1878d4aa
4 changed files with 61 additions and 35 deletions

View file

@ -3,7 +3,7 @@
"private": true, "private": true,
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite --host",
"build": "vue-tsc --noEmit && vite build", "build": "vue-tsc --noEmit && vite build",
"lint": "eslint -c .eslintrc.js src/", "lint": "eslint -c .eslintrc.js src/",
"preview": "vite preview" "preview": "vite preview"

View file

@ -25,7 +25,6 @@ const navigationEntries: INavigationEntry[] = [
name: 'Stammdaten', name: 'Stammdaten',
icon: UserIcon, icon: UserIcon,
to: '/data', to: '/data',
disabled: true,
}, },
{ {
name: 'Einstempeln', name: 'Einstempeln',

View file

@ -16,23 +16,26 @@ const database = new Databases(sdk, DATABASE_ID);
export const DataService = { export const DataService = {
async getAllData(): Promise<IAccountData[]> { async getAllData(): Promise<IAccountData[]> {
const accounts = (await AccountService.getAllAccounts()) as IAccountData[]; const accounts = (await AccountService.getAllAccounts()) as IAccountData[];
let offset = 0, accounts.forEach(account => {
personalInformationDocuments: Models.DocumentList<IPersonalInformation & Models.Document>; account.name = `${account.firstName} ${account.lastName}`;
do { });
personalInformationDocuments = await database.listDocuments<IPersonalInformation & Models.Document>( // let offset = 0,
PERSONAL_INFORMATION_COLLECTION_ID, [], 100, offset); // personalInformationDocuments: Models.DocumentList<IPersonalInformation & Models.Document>;
personalInformationDocuments.documents.forEach(personalInformation => { // do {
const account = accounts.find(account => account.accountNumber === personalInformation.accountNumber); // personalInformationDocuments = await database.listDocuments<IPersonalInformation & Models.Document>(
if(account) { // PERSONAL_INFORMATION_COLLECTION_ID, [], 100, offset);
account.name = `${account.firstName} ${account.lastName}`; // personalInformationDocuments.documents.forEach(personalInformation => {
account.birthday = personalInformation.birthday; // const account = accounts.find(account => account.accountNumber === personalInformation.accountNumber);
account.address = personalInformation.address; // if(account) {
account.contact = personalInformation.contact; // account.name = `${account.firstName} ${account.lastName}`;
} // account.birthday = personalInformation.birthday;
}, // account.address = personalInformation.address;
); // account.contact = personalInformation.contact;
offset += 100; // }
} while(personalInformationDocuments.total > offset); // },
// );
// offset += 100;
// } while(personalInformationDocuments.total > offset);
return accounts; return accounts;
}, },
async addAccount(account: ICreateAccount): Promise<IAccountData> { async addAccount(account: ICreateAccount): Promise<IAccountData> {

View file

@ -1,5 +1,20 @@
<template> <template>
<div class="lg:p-6"> <div
v-show="!pinCorrect"
class="hero min-h-full"
>
<div class="hero-content flex-col text-center">
<AtomInput
placeholder="Bitte PIN eingeben"
type="password"
@input="inputEvent"
/>
</div>
</div>
<div
v-show="pinCorrect"
class="lg:p-6"
>
<MoleculeDataTable <MoleculeDataTable
v-if="data" v-if="data"
:table-headers="tableHeaders" :table-headers="tableHeaders"
@ -33,7 +48,10 @@ import { PlusIcon } from '@heroicons/vue/outline';
import MoleculeAddAccountModal from '../molecules/MoleculeAddAccountModal.vue'; import MoleculeAddAccountModal from '../molecules/MoleculeAddAccountModal.vue';
import MoleculeContactModal from '../molecules/MoleculeContactModal.vue'; import MoleculeContactModal from '../molecules/MoleculeContactModal.vue';
import MoleculeDataTable, { TableHeaderType } from '../molecules/MoleculeDataTable.vue'; import MoleculeDataTable, { TableHeaderType } from '../molecules/MoleculeDataTable.vue';
import AtomInput from '../atoms/AtomInput.vue';
const ACCESS_PIN_KEY = '1337';
const pinCorrect = ref(false);
const data = ref<IAccountData[]>([]); const data = ref<IAccountData[]>([]);
const contactName = ref(''); const contactName = ref('');
const contact = ref<string[]>([]); const contact = ref<string[]>([]);
@ -50,31 +68,31 @@ const tableHeaders = [
key: 'name', key: 'name',
type: TableHeaderType.STRING, type: TableHeaderType.STRING,
}, },
{ // {
title: 'Geburtsdatum', // title: 'Geburtsdatum',
key: 'birthday', // key: 'birthday',
type: TableHeaderType.STRING, // type: TableHeaderType.STRING,
}, // },
{ {
title: 'Kontostand', title: 'Kontostand',
key: 'balance', key: 'balance',
type: TableHeaderType.CURRENCY, type: TableHeaderType.CURRENCY,
}, },
{ // {
title: 'Adresse', // title: 'Adresse',
key: 'address', // key: 'address',
type: TableHeaderType.STRING, // type: TableHeaderType.STRING,
}, // },
{ {
title: 'Letzter Login', title: 'Letzter Login',
key: 'lastCheckIn', key: 'lastCheckIn',
type: TableHeaderType.DATETIME, type: TableHeaderType.DATETIME,
}, },
{ // {
title: 'Kontakt', // title: 'Kontakt',
key: '', // key: '',
type: TableHeaderType.BUTTON_CONTACT, // type: TableHeaderType.BUTTON_CONTACT,
}, // },
{ {
title: 'Trans.', title: 'Trans.',
key: '', key: '',
@ -94,6 +112,12 @@ function openContactModal(data: { name: string, contact: string[] }) {
function addAccount(account: IAccountData) { function addAccount(account: IAccountData) {
data.value.push(account); data.value.push(account);
} }
function inputEvent(event: Event) {
if((event.target as HTMLInputElement).value == ACCESS_PIN_KEY) {
pinCorrect.value = true;
}
}
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>