Skip to content

Commit

Permalink
improve loading comm and tagger pages
Browse files Browse the repository at this point in the history
  • Loading branch information
secondl1ght committed Dec 13, 2023
1 parent 8db4524 commit b195ae0
Show file tree
Hide file tree
Showing 8 changed files with 1,165 additions and 956 deletions.
2 changes: 1 addition & 1 deletion src/components/LatestTagger.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export let location: string;
export let action: EventType;
export let user: User | '';
export let user: User | undefined = undefined;
export let time: string;
export let latest: boolean;
export let merchantId: string;
Expand Down
8 changes: 4 additions & 4 deletions src/components/ProfileStat.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import tippy from 'tippy.js';
export let title: string;
export let stat: number;
export let percent: string;
export let border: string;
export let stat: number | undefined;
export let percent: string | undefined = undefined;
export let border: string | undefined = undefined;
export let tooltip: undefined | string = undefined;
let tooltipElement: HTMLButtonElement;
Expand All @@ -27,7 +27,7 @@
</h3>

<div class="flex justify-center md:justify-start">
{#if stat >= 0}
{#if stat !== undefined}
<span class="text-5xl font-semibold text-primary dark:text-white">{stat}</span>
{#if percent}
<span class="ml-1 text-lg text-body dark:text-white">({percent}%)</span>
Expand Down
41 changes: 26 additions & 15 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type Area = {
export type AreaTags = {
type: 'community' | 'country';
name: string;
continent: 'africa' | 'asia' | 'europe' | 'north-america' | 'oceania' | 'south-america';
continent: Continents;
url_alias: string;
geo_json: GeoJSON;
['icon:square']: string;
Expand Down Expand Up @@ -50,6 +50,14 @@ export type AreaTags = {
['box:west']?: string;
};

export type Continents =
| 'africa'
| 'asia'
| 'europe'
| 'north-america'
| 'oceania'
| 'south-america';

export type Element = {
id: string;
osm_json: ElementOSM;
Expand Down Expand Up @@ -94,25 +102,27 @@ export type Report = {
id: number;
area_id: string;
date: string;
tags: {
total_elements: number;
total_elements_onchain: number;
total_elements_lightning: number;
total_elements_lightning_contactless: number;
total_atms: number;
up_to_date_elements: number;
up_to_date_percent: number;
outdated_elements: number;
legacy_elements: number;
avg_verification_date: string;
grade: Grade;
};
tags: ReportTags;
created_at: string;
updated_at: string;
deleted_at: string;
};

export type Grade = 0 | 1 | 2 | 3 | 4 | 5;
export type ReportTags = {
total_elements: number;
total_elements_onchain: number;
total_elements_lightning: number;
total_elements_lightning_contactless: number;
total_atms: number;
up_to_date_elements: number;
up_to_date_percent: number;
outdated_elements: number;
legacy_elements: number;
avg_verification_date: string;
grade: Grade;
};

export type Grade = 1 | 2 | 3 | 4 | 5;

export type User = {
id: number;
Expand Down Expand Up @@ -203,6 +213,7 @@ export enum TipType {
export interface ActivityEvent extends Event {
location: string;
merchantId: string;
tagger?: User;
}

// misc
Expand Down
25 changes: 14 additions & 11 deletions src/routes/activity/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,15 @@
let elementsLoading: boolean;
let supertaggers: ActivityEvent[];
const findUser = (tagger: Event) => {
let foundUser = $users.find((user) => user.id == tagger['user_id']);
if (foundUser) {
return foundUser;
} else {
return undefined;
}
};
const supertaggerSync = (
status: boolean,
users: User[],
Expand All @@ -53,10 +62,13 @@
? elementMatch['osm_json'].tags.name
: undefined;
let tagger = findUser(event);
supertaggers.push({
...event,
location: location || 'Unnamed element',
merchantId: elementMatch.id
merchantId: elementMatch.id,
tagger
});
}
});
Expand All @@ -69,15 +81,6 @@
$: supertaggerSync($syncStatus, $users, $events, $elements);
$: latestTaggers = supertaggers && supertaggers.length && !elementsLoading ? true : false;
const findUser = (tagger: ActivityEvent) => {
let foundUser = $users.find((user) => user.id == tagger['user_id']);
if (foundUser) {
return foundUser;
} else {
return '';
}
};
</script>

<svelte:head>
Expand Down Expand Up @@ -131,7 +134,7 @@
<LatestTagger
location={tagger.location}
action={tagger.type}
user={findUser(tagger)}
user={tagger.tagger}
time={tagger['created_at']}
latest={tagger === supertaggers[0] ? true : false}
merchantId={tagger.merchantId}
Expand Down
41 changes: 0 additions & 41 deletions src/routes/community/[area]/+layout.svelte

This file was deleted.

Loading

0 comments on commit b195ae0

Please sign in to comment.