-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs: closes #191 ## Summary Display dashboard.
- Loading branch information
1 parent
a8e875d
commit 5e08c9c
Showing
23 changed files
with
818 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,6 +68,7 @@ | |
] | ||
}, | ||
"dependencies": { | ||
"chart.js": "^4.4.3", | ||
"ol": "^9.1.0", | ||
"openapi-fetch": "^0.9.5" | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { | ||
Chart, | ||
LineElement, | ||
LineController, | ||
LinearScale, | ||
CategoryScale, | ||
PointElement, | ||
Tooltip, | ||
Legend, | ||
DoughnutController, | ||
ArcElement, | ||
BarElement, | ||
BarController, | ||
Filler, | ||
} from "chart.js"; | ||
import { getCssVariable } from "./cssVars"; | ||
|
||
/** | ||
* Set up Chart.js with the required components for the application and a | ||
* custom theme. | ||
*/ | ||
export function setupChart() { | ||
Chart.register( | ||
LineElement, | ||
LineController, | ||
LinearScale, | ||
CategoryScale, | ||
PointElement, | ||
Tooltip, | ||
Legend, | ||
DoughnutController, | ||
ArcElement, | ||
BarElement, | ||
BarController, | ||
Filler, | ||
); | ||
|
||
Chart.defaults.font.family = "Inter, sans-serif"; | ||
Chart.defaults.font.lineHeight = 1.5; | ||
Chart.defaults.color = getCssVariable("--gray-900"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* Retrieves a color with an opacity. | ||
* @param hex Color hexadecimal value. | ||
* @param opacity Value between 0 and 1. | ||
* @returns Hexadecimal color with an opacity. | ||
*/ | ||
export function getColorWithOpacity(hex: string, opacity: number) { | ||
return `${hex}${Math.floor(opacity * 255).toString(16)}`; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,70 @@ | ||
<script lang="ts"> | ||
import ecomapHttpClient from "../../../lib/clients/ecomap/http"; | ||
import { t } from "../../../lib/utils/i8n"; | ||
import { getBatchPaginatedResponse } from "../../../lib/utils/request"; | ||
import ContainersAdded from "./partials/ContainersAdded.svelte"; | ||
import ContainersByCategory from "./partials/ContainersByCategory.svelte"; | ||
import ContainersByMunicipality from "./partials/ContainersByMunicipality.svelte"; | ||
import TruckAmount from "./partials/TruckAmount.svelte"; | ||
import WarehouseAmount from "./partials/WarehouseAmount.svelte"; | ||
import ActiveEmployees from "./partials/ActiveEmployees.svelte"; | ||
/** | ||
* Retrieves the containers to be displayed in the charts. | ||
* @returns Containers. | ||
*/ | ||
async function getContainers() { | ||
const containers = await getBatchPaginatedResponse( | ||
async (limit, offset) => { | ||
const res = await ecomapHttpClient.GET("/containers", { | ||
params: { | ||
query: { | ||
offset, | ||
limit, | ||
sort: "createdAt", | ||
order: "asc", | ||
}, | ||
}, | ||
}); | ||
if (res.error) { | ||
return { total: 0, items: [] }; | ||
} | ||
return { total: res.data.total, items: res.data.containers }; | ||
}, | ||
); | ||
return containers; | ||
} | ||
let containersPromise = getContainers(); | ||
</script> | ||
|
||
<main>{$t("dashboard")}</main> | ||
<main class="page-layout"> | ||
<h1>{$t("dashboard")}</h1> | ||
<div class="dashboard-content"> | ||
<ActiveEmployees /> | ||
<WarehouseAmount /> | ||
<TruckAmount /> | ||
<ContainersAdded {containersPromise} /> | ||
<ContainersByCategory {containersPromise} /> | ||
<ContainersByMunicipality {containersPromise} /> | ||
</div> | ||
</main> | ||
|
||
<style> | ||
h1 { | ||
font: var(--text-2xl-semibold); | ||
} | ||
.dashboard-content { | ||
display: grid; | ||
grid-template-columns: 1fr 1fr 1fr; | ||
grid-template-areas: | ||
"activeEmployees warehouseAmount truckAmount" | ||
"containersAdded containersAdded containersByCategory" | ||
"containersByMunicipality containersByMunicipality containersByMunicipality"; | ||
gap: 1rem; | ||
} | ||
</style> |
Oops, something went wrong.