Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/bit of love to backoffice #128

Merged
merged 11 commits into from
Dec 2, 2024
21 changes: 21 additions & 0 deletions admin/components/dashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Box, H1, Text } from "@adminjs/design-system";

const Dashboard = () => {
return (
<Box variant="grey">
<Box
variant="white"
flex
flexDirection="column"
justifyContent="center"
alignItems="center"
p="xxl"
>
<H1>Welcome to Blue Carbon Cost Admin Panel</H1>
<Text>Manage your data effectively and efficiently</Text>
</Box>
</Box>
);
};

export default Dashboard;
1 change: 1 addition & 0 deletions admin/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,4 +85,5 @@ export const dataSource = new DataSource({
process.env.NODE_ENV === "production"
? { rejectUnauthorized: false }
: false,
logging: false,
});
31 changes: 22 additions & 9 deletions admin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import * as AdminJSTypeorm from "@adminjs/typeorm";
import { dataSource } from "./datasource.js";
import { AuthProvider } from "./providers/auth.provider.js";
import { UserResource } from "./resources/users/user.resource.js";
import { Country } from "@shared/entities/country.entity.js";
import { FeasibilityAnalysisResource } from "./resources/feasability-analysis/feasability-analysis.resource.js";
import { ConservationAndPlanningAdminResource } from "./resources/conservation-and-planning-admin/conservation-and-planning-admin.resource.js";
import { CommunityRepresentationResource } from "./resources/community-representation/community-representation.resource.js";
Expand Down Expand Up @@ -37,6 +36,7 @@ import { UserUploadCostInputs } from "@shared/entities/users/user-upload-cost-in
import { UserUploadConservationInputs } from "@shared/entities/users/user-upload-conservation-inputs.entity.js";
import { UserUploadRestorationInputs } from "@shared/entities/users/user-upload-restoration-inputs.entity.js";
import { GLOBAL_COMMON_PROPERTIES } from "./resources/common/common.resources.js";
import { CountryResource } from "./resources/countries/country.resource.js";

AdminJS.registerAdapter({
Database: AdminJSTypeorm.Database,
Expand All @@ -47,6 +47,10 @@ const PORT = 1000;
export const API_URL = process.env.API_URL || "http://localhost:4000";

const componentLoader = new ComponentLoader();

const Components = {
Dashboard: componentLoader.add("Dashboard", "./components/dashboard"),
};
const authProvider = new AuthProvider();

const start = async () => {
Expand All @@ -59,6 +63,14 @@ const start = async () => {
};

const admin = new AdminJS({
branding: {
companyName: "Blue Carbon Cost",
withMadeWithLove: false,
logo: false,
},
dashboard: {
component: Components.Dashboard,
},
rootPath: "/admin",
componentLoader,
resources: [
Expand Down Expand Up @@ -128,14 +140,7 @@ const start = async () => {
BaseSizeResource,
BaseIncreaseResource,
ModelAssumptionResource,
{
resource: Country,
name: "Country",
options: {
parent: databaseNavigation,
icon: "Globe",
},
},
CountryResource,
],
locale: {
language: "en",
Expand All @@ -145,6 +150,14 @@ const start = async () => {
User: "Users",
Country: "Countries",
Project: "Projects",
ProjectSize: "Project Sizes",
},
resources: {
ProjectSize: {
properties: {
countryCode: "Country",
},
},
},
},
},
Expand Down
1 change: 1 addition & 0 deletions admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@adminjs/design-system": "^4.1.1",
"@adminjs/express": "^6.1.0",
"@adminjs/typeorm": "^5.0.1",
"adminjs": "^7.8.13",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const BaselineReassessmentResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
baselineReassessmentCost: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,18 @@ export const BlueCarbonProjectPlanningResource: ResourceWithOptions = {
resource: BlueCarbonProjectPlanning,
options: {
properties: {
id: {
isVisible: { list: false, show: false, edit: false, filter: false },
},
country: {
isVisible: { list: true, show: true, edit: true, filter: true },
},
inputSelection: {
isVisible: { list: true, show: true, edit: true, filter: true },
},
...GLOBAL_COMMON_PROPERTIES,
input1: {
isVisible: { list: true, show: true, edit: true, filter: true },
isVisible: { show: false, edit: true, filter: false, list: true },
},
input2: {
isVisible: { list: true, show: true, edit: true, filter: true },
isVisible: { show: false, edit: true, filter: false, list: true },
},
input3: {
isVisible: { list: true, show: true, edit: true, filter: true },
isVisible: { show: false, edit: true, filter: false, list: true },
},
blueCarbon: {
isVisible: { list: true, show: true, edit: false, filter: true },
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
isVisible: { show: true, edit: true, filter: false, list: true },
},
},
sort: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const CarbonStandardFeesResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
carbonStandardFee: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
},
},
};
3 changes: 3 additions & 0 deletions admin/resources/carbon-righs/carbon-rights.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const CarbonRightsResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
carbonRightsCost: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const CommunityBenefitResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
communityBenefitSharingFund: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const CommunityRepresentationResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
liaisonCost: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { GLOBAL_COMMON_PROPERTIES } from "../common/common.resources.js";
export const ConservationAndPlanningAdminResource: ResourceWithOptions = {
resource: ConservationPlanningAndAdmin,
options: {
properties: {...GLOBAL_COMMON_PROPERTIES},
properties: {
...GLOBAL_COMMON_PROPERTIES,
planningCost: {
isVisible: { list: true, show: true, edit: true, filter: false },
},
},
sort: {
sortBy: "planningCost",
direction: "desc",
Expand Down
23 changes: 23 additions & 0 deletions admin/resources/countries/country.resource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ResourceWithOptions } from "adminjs";
import { GLOBAL_COMMON_PROPERTIES } from "../common/common.resources.js";
import { Country } from "@shared/entities/country.entity.js";

export const CountryResource: ResourceWithOptions = {
resource: Country,
options: {
properties: {
...GLOBAL_COMMON_PROPERTIES,
geometry: {
isVisible: { list: false, edit: false, show: false, filter: false },
},
},
sort: {
sortBy: "name",
direction: "asc",
},
navigation: {
name: "Data Management",
icon: "Database",
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const DataCollectionAndFieldCostResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
fieldCost: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
},
},
};
3 changes: 3 additions & 0 deletions admin/resources/ecosystem-loss/ecosystem-loss.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const EcosystemLossResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
ecosystemLossRate: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
},
},
};
20 changes: 19 additions & 1 deletion admin/resources/emission-factors/emission-factors.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,24 @@ export const EmissionFactorsResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
},
emissionFactor: {
isVisible: { show: true, edit: true, list: true, filter: false },
},
AGB: {
isVisible: { show: true, edit: true, list: true, filter: false },
},
SOC: {
isVisible: { show: true, edit: true, list: true, filter: false },
},
global: {
isVisible: { show: true, edit: true, list: true, filter: false },
},
t2CountrySpecificAGB: {
isVisible: { show: true, edit: true, list: true, filter: false },
},
t2CountrySpecificSOC: {
isVisible: { show: true, edit: true, list: true, filter: false },
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const FeasibilityAnalysisResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
analysisCost: {
isVisible: { list: true, show: true, edit: true, filter: false },
},
},
},
};
3 changes: 3 additions & 0 deletions admin/resources/financing-cost/financing-cost.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const FinancingCostResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
financingCostCapexPercent: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ export const ImplementationLaborCostResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
plantingCost: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
hybridCost: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
hydrologyCost: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const LongTermProjectOperatingResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
longTermProjectOperatingCost: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
},
},
};
3 changes: 3 additions & 0 deletions admin/resources/maintenance/maintenance.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const MaintenanceResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
monitoringCost: {
isVisible: { show: true, edit: true, list: true, filter: false },
},
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const ModelAssumptionResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
name: {
isVisible: { list: true, show: true, filter: true, edit: false },
},
},
},
};
3 changes: 3 additions & 0 deletions admin/resources/monitoring-cost/monitoring-cost.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export const MonitoringCostResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
monitoringCost: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
},
},
};
3 changes: 3 additions & 0 deletions admin/resources/mrv/mrv.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ export const MRVResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
mrvCost: {
isVisible: { list: true, show: true, filter: false, edit: true },
},
},
},
};
5 changes: 5 additions & 0 deletions admin/resources/project-size/project-size.resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export const ProjectSizeResource: ResourceWithOptions = {
},
properties: {
...GLOBAL_COMMON_PROPERTIES,
sizeHa: {
type: "number",
isVisible: { list: true, show: true, edit: true, filter: false },
description: "Size in hectares",
},
},
},
};
Loading
Loading