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,
"version": "0.0.0",
"scripts": {
"dev": "vite",
"dev": "vite --host",
"build": "vue-tsc --noEmit && vite build",
"lint": "eslint -c .eslintrc.js src/",
"preview": "vite preview"

View file

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

View file

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

View file

@ -1,5 +1,20 @@
<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
v-if="data"
:table-headers="tableHeaders"
@ -33,7 +48,10 @@ import { PlusIcon } from '@heroicons/vue/outline';
import MoleculeAddAccountModal from '../molecules/MoleculeAddAccountModal.vue';
import MoleculeContactModal from '../molecules/MoleculeContactModal.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 contactName = ref('');
const contact = ref<string[]>([]);
@ -50,31 +68,31 @@ const tableHeaders = [
key: 'name',
type: TableHeaderType.STRING,
},
{
title: 'Geburtsdatum',
key: 'birthday',
type: TableHeaderType.STRING,
},
// {
// title: 'Geburtsdatum',
// key: 'birthday',
// type: TableHeaderType.STRING,
// },
{
title: 'Kontostand',
key: 'balance',
type: TableHeaderType.CURRENCY,
},
{
title: 'Adresse',
key: 'address',
type: TableHeaderType.STRING,
},
// {
// title: 'Adresse',
// key: 'address',
// type: TableHeaderType.STRING,
// },
{
title: 'Letzter Login',
key: 'lastCheckIn',
type: TableHeaderType.DATETIME,
},
{
title: 'Kontakt',
key: '',
type: TableHeaderType.BUTTON_CONTACT,
},
// {
// title: 'Kontakt',
// key: '',
// type: TableHeaderType.BUTTON_CONTACT,
// },
{
title: 'Trans.',
key: '',
@ -94,6 +112,12 @@ function openContactModal(data: { name: string, contact: string[] }) {
function addAccount(account: IAccountData) {
data.value.push(account);
}
function inputEvent(event: Event) {
if((event.target as HTMLInputElement).value == ACCESS_PIN_KEY) {
pinCorrect.value = true;
}
}
</script>
<style lang="scss" scoped>