Skip to content

Commit

Permalink
..
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiog1901 committed Sep 22, 2023
1 parent b49debd commit b354f44
Show file tree
Hide file tree
Showing 10 changed files with 14,235 additions and 17,184 deletions.
31,147 changes: 14,103 additions & 17,044 deletions webapp/db.json

Large diffs are not rendered by default.

27 changes: 0 additions & 27 deletions webapp/src/stores/contactsStore.ts

This file was deleted.

62 changes: 62 additions & 0 deletions webapp/src/stores/modelStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { ref, computed } from "vue";
import { defineStore } from "pinia";

import axios from "axios";

import type { Model } from "@/types";

export const useStore = defineStore("model", () => {
const worst_models: { [key: string]: any } = ref<{}>({});
const model_instances = ref<Model[]>([]);

const selectedOwners = ref<string[]>([]);

const fetch_all_worst_models = async () => {
const r = await axios.get<{}>(`${import.meta.env.VITE_APP_API_URL}/models`);
console.info("modelStore: fetched all worst_models");
worst_models.value = r.data;
};

const fetch_all_instances = async (model_name: string) => {
const r = await axios.get<Model[]>(
`${import.meta.env.VITE_APP_API_URL}/${model_name}`
);
console.info(
`modelStore: fetched all model instances for model ${model_name}`
);
model_instances.value = r.data;
};

const add_selected_owners = (owners: string[]) => {
selectedOwners.value = owners;
};
const get_unique_owners = computed(() => {
const s = new Set<string>();
model_instances.value.forEach((instance) => s.add(instance.owned_by));
return Array.from(s).sort();
});

const clear_filters = () => {
selectedOwners.value = [];
};

const include_models_by_owners = (x: Model) => {
if (selectedOwners.value.length === 0) return true;
return selectedOwners.value.includes(x.owned_by);
};

const get_filtered_models = () => {
return model_instances.value.filter((x) => include_models_by_owners(x));
};

return {
get_filtered_models,
clear_filters,
add_selected_owners,
get_unique_owners,
fetch_all_worst_models,
worst_models,
fetch_all_instances,
model_instances,
};
});
27 changes: 0 additions & 27 deletions webapp/src/stores/opportunitiesStore.ts

This file was deleted.

47 changes: 4 additions & 43 deletions webapp/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,59 +1,20 @@
export interface AccountOverview {
account_id: string;
export interface WorstModel {
name: string;
owned_by: string;
status: string;
due_date: string;
tags: string[];
created_at: string;
created_by: string;
updated_at: string;
updaded_by: string;
attachments: string[];
}

export interface Model {
field: string;
header: string;
visible: boolean;
type: string;
svg_path: string;
}

export interface Account {
account_id: string;
export interface Model {
id: string;
name: string;
owned_by: string;
status: string;
due_date: string;
tags: string[];
text: string;
created_at: string;
created_by: string;
updated_at: string;
updaded_by: string;
attachments: string[];
}

export interface OpportunityOverviewWithAccountName {
account_id: string;
opportunity_id: string;
name: string;
owned_by: string;
}

export interface ContactWithAccountName {
account_id: string;
account_name: string;
contact_id: string;
fname: string;
lname: string;
role_title: string;
email: string;
telephone_number: string;
tags: string[];
business_card: string;
created_at: string;
created_by: string;
updated_at: string;
updaded_by: string;
}
9 changes: 3 additions & 6 deletions webapp/src/views/AdminView.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
<template>
<div class="flex">
<ContextBarAdmin />
<ContentContainer />
</div>
<div class="flex">------------ADMINVIEW</div>
</template>

<script setup lang="ts">
import ContextBarAdmin from "@/components/ContextBarAdmin.vue";
import ContentContainer from "@/components/ContentContainer.vue";
// import ContextBarAdmin from "@/components/ContextBarAdmin.vue";
// import ContentContainer from "@/components/ContentContainer.vue";
</script>
7 changes: 4 additions & 3 deletions webapp/src/views/HomeView.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<template>
<div class="flex">
<ContextBarHome />
===================HOMEVIEW
<!-- <ContextBarHome /> -->
<!-- <ContentContainer /> -->
</div>
</template>

<script setup lang="ts">
import ContextBarHome from "@/components/ContextBarHome.vue";
import ContentContainer from "@/components/ContentContainer.vue";
// import ContextBarHome from "@/components/ContextBarHome.vue";
// import ContentContainer from "@/components/ContentContainer.vue";
</script>
20 changes: 12 additions & 8 deletions webapp/src/views/ModelDetailsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<h5
class="justify-center align-middle text-3xl tracking-wider text-gray-600 dark:text-gray-400"
>
{{ account.name }}
modelname: {{ model_name }} - id: {{ id }}
</h5>
</div>

Expand Down Expand Up @@ -189,7 +189,7 @@ import TopNav from "@/components/TopNav.vue";
import Button from "primevue/button";
import Chip from "primevue/button";
import type { Account } from "@/types";
import type { Model } from "@/types";
const store = useStore();
Expand All @@ -198,13 +198,17 @@ const value = ref("");
const router = useRouter();
const account_id = computed(() => {
return useRoute().params.account_id;
const id = computed(() => {
return useRoute().params.id;
});
const account = ref<Account>({});
onMounted(async () => {
account.value = await store.fetch_account(account_id.value);
const model_name = computed(() => {
return useRoute().params.model;
});
const m = ref<Model>({});
// onMounted(async () => {
// m.value = await store.fetch_model(id.value);
// });
</script>
42 changes: 23 additions & 19 deletions webapp/src/views/ModelView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<h5
class="justify-center align-middle text-3xl tracking-wider text-gray-600 dark:text-gray-400"
>
ModelViewh
{{ model_name.charAt(0).toUpperCase() + model_name.slice(1) }}
</h5>
</div>

Expand Down Expand Up @@ -48,7 +48,7 @@
v-on:change="store.add_selected_owners(store.selectedOwners)"
>
<option
v-for="x in store.get_unique_account_owners"
v-for="x in store.get_unique_model_owners"
v-bind:key="x"
v-bind:value="x"
>
Expand Down Expand Up @@ -169,11 +169,11 @@
<TopNav />

<FabTable
v-bind:data="store.get_filtered_accounts()"
v-bind:model="store.account_model"
v-on:row-clicked="accountLink($event)"
v-on:delete-clicked="deleteAccount($event)"
v-on:new-clicked="createNewAccount()"
v-bind:data="store.get_filtered_models()"
v-bind:model="store.worst_models[model_name]['kk']"
v-on:row-clicked="modelLink($event)"
v-on:delete-clicked="deleteModel($event)"
v-on:new-clicked="createNewModel()"
/>

<BottomNav />
Expand All @@ -182,34 +182,38 @@
</template>

<script setup lang="ts">
import { onMounted } from "vue";
import { useRouter } from "vue-router";
import { useStore } from "@/stores/accountsStore";
import { computed, onMounted } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useStore } from "@/stores/modelStore";
import BottomNav from "@/components/BottomNav.vue";
import FabTable from "@/components/FabTable.vue";
import TopNav from "@/components/TopNav.vue";
import type { AccountOverview } from "@/types";
import type { Model } from "@/types";
const store = useStore();
const router = useRouter();
const createNewAccount = () => {
console.log("new account");
const createNewModel = () => {
console.log(`new model ${model_name.value}`);
};
const deleteAccount = (acc: AccountOverview) => {
console.log(`delete account: ${acc.account_id}`);
const deleteModel = (m: Model) => {
console.log(`delete model: ${model_name.value}/${m.id}`);
};
const accountLink = (acc: AccountOverview) => {
router.push(`/accounts/${acc.account_id}`);
const modelLink = (m: Model) => {
router.push(`/${model_name.value}/${m.id}`);
};
const model_name = computed(() => {
return useRoute().params.model as string;
});
onMounted(async () => {
await store.fetch_all_accounts();
await store.fetch_account_model();
await store.fetch_all_instances(model_name.value);
});
</script>
Loading

0 comments on commit b354f44

Please sign in to comment.