Skip to content

Commit

Permalink
work-in-progress: Backoffice file ingestion custom page
Browse files Browse the repository at this point in the history
  • Loading branch information
alepefe committed Dec 10, 2024
1 parent 268e52e commit 84d5bf7
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 12 deletions.
13 changes: 12 additions & 1 deletion backoffice/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ import { UserUploadRestorationInputs } from "@shared/entities/users/user-upload-
import { GLOBAL_COMMON_PROPERTIES } from "./resources/common/common.resources.js";
import { BACKOFFICE_SESSIONS_TABLE } from "@shared/entities/users/backoffice-session.js";
import { CountryResource } from "./resources/countries/country.resource.js";
import { DataIngestionResource } from "backoffice/resources/data-ingestion/data-ingestion.resource.js";
import { FileUploadResource } from "backoffice/resources/data-ingestion/file-upload.resource.js";
import { DataIngestionAdapter } from "backoffice/resources/data-ingestion/data-ingestion.adapter.js";

AdminJS.registerAdapter({
Database: AdminJSTypeorm.Database,
Expand All @@ -54,6 +57,7 @@ const componentLoader = new ComponentLoader();

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

Expand Down Expand Up @@ -160,6 +164,7 @@ const start = async () => {
BaseIncreaseResource,
ModelAssumptionResource,
CountryResource,
DataIngestionResource
],
locale: {
language: "en",
Expand All @@ -181,6 +186,12 @@ const start = async () => {
},
},
},
pages: {
fileIngestion: {
icon: 'Upload',
component: Components.FileIngestion,
}
}
});

const customRouter = express.Router();
Expand Down Expand Up @@ -212,7 +223,7 @@ const start = async () => {
},
},
);

admin.watch()
app.use(admin.options.rootPath, adminRouter);

app.listen(PORT, () => {
Expand Down
3 changes: 3 additions & 0 deletions backoffice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"@adminjs/express": "^6.1.0",
"@adminjs/typeorm": "^5.0.1",
"adminjs": "^7.8.13",
"axios": "^1.7.9",
"connect-pg-simple": "^10.0.0",
"cookie": "^1.0.2",
"cookie-parser": "^1.4.7",
Expand All @@ -23,7 +24,9 @@
"express-session": "^1.18.0",
"nodemon": "^3.1.7",
"pg": "catalog:",
"react": "^18",
"reflect-metadata": "catalog:",
"styled-components": "^6.1.13",
"tslib": "^2.7.0",
"typeorm": "catalog:",
"typescript": "catalog:"
Expand Down
20 changes: 20 additions & 0 deletions backoffice/pages/file-ingestion.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { ThemeProvider } from 'styled-components';
import {
theme,
Box,
Header,
} from '@adminjs/design-system';
import { ActionHeader, BreadcrumbLink, Breadcrumbs } from 'adminjs';

function FileIngestion() {
return (
<ThemeProvider theme={theme}>
<Box variant="grey">
<Header.H2>File Ingestion</Header.H2>
</Box>
</ThemeProvider>
);
}

export default FileIngestion;
1 change: 1 addition & 0 deletions backoffice/providers/auth.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class AuthProvider extends BaseAuthProvider {
res.setHeader('Set-Cookie', [
`backoffice=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly`,
`next-auth.session-token=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly`,
`__Secure-next-auth.session-token=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly`,
]);
}
}
29 changes: 29 additions & 0 deletions backoffice/resources/data-ingestion/data-ingestion.resource.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ApiEventsEntity } from "@api/modules/api-events/api-events.entity.js";
import { ResourceWithOptions } from "adminjs";

export const DataIngestionResource: ResourceWithOptions = {
resource: ApiEventsEntity,
options: {
id: "EventsLog",
navigation: {
name: "Data Management",
icon: "Database",
},
actions: {
new: {
isAccessible: false,
},
edit: {
isAccessible: false,
},
delete: {
isAccessible: false,
},
list: { isAccessible: true },
show: { isAccessible: true },
},
properties: {
'*': {isDisabled: true},
}
}
};
2 changes: 1 addition & 1 deletion backoffice/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
},
"include": ["./**/*.ts", "../shared/**/*.ts", "../api/**/*.ts"],
"include": ["./**/*.ts", "../shared/**/*.ts", "../api/**/*.ts", "./**/*.tsx"],
"exclude": ["node_modules"]
}
Loading

0 comments on commit 84d5bf7

Please sign in to comment.