diff --git a/apps/adminpanel/public/images/templates/dashboard-dark.png b/apps/adminpanel/public/images/templates/dashboard-dark.png new file mode 100644 index 000000000..2e4c0eac5 Binary files /dev/null and b/apps/adminpanel/public/images/templates/dashboard-dark.png differ diff --git a/apps/adminpanel/public/images/templates/dashboard-light.png b/apps/adminpanel/public/images/templates/dashboard-light.png new file mode 100644 index 000000000..320fd2ed9 Binary files /dev/null and b/apps/adminpanel/public/images/templates/dashboard-light.png differ diff --git a/apps/next/public/images/templates/dashboard-dark.png b/apps/next/public/images/templates/dashboard-dark.png new file mode 100644 index 000000000..2e4c0eac5 Binary files /dev/null and b/apps/next/public/images/templates/dashboard-dark.png differ diff --git a/apps/next/public/images/templates/dashboard-light.png b/apps/next/public/images/templates/dashboard-light.png new file mode 100644 index 000000000..320fd2ed9 Binary files /dev/null and b/apps/next/public/images/templates/dashboard-light.png differ diff --git a/packages/protolib/src/bundles/pages/templates/admindashboard.tpl b/packages/protolib/src/bundles/pages/templates/admindashboard.tpl index 88b9cd0c0..9cbe98dd4 100644 --- a/packages/protolib/src/bundles/pages/templates/admindashboard.tpl +++ b/packages/protolib/src/bundles/pages/templates/admindashboard.tpl @@ -70,7 +70,7 @@ const layouts = { ] } -Protofy("pageType", "admin") +Protofy("pageType", "admindashboard") diff --git a/packages/protolib/src/bundles/pages/templates/dashboard.tpl b/packages/protolib/src/bundles/pages/templates/dashboard.tpl new file mode 100644 index 000000000..cffa5f292 --- /dev/null +++ b/packages/protolib/src/bundles/pages/templates/dashboard.tpl @@ -0,0 +1,90 @@ +/* @my/ui is wrapper for tamagui. Any component in tamagui can be imported through @my/ui +use result = await API.get(url) or result = await API.post(url, data) to send requests +API.get/API.post will return a PendingResult, with properties like isLoaded, isError and a .data property with the result +if you call paginated apis, you will need to wait for result.isLoaded and look into result.data.items, since result.data is an object with the pagination. +Paginated apis return an object like: {"itemsPerPage": 25, "items": [...], "total": 20, "page": 0, "pages": 1} +*/ + +import { Protofy, API } from 'protobase' +import { SSR } from 'protolib/lib/SSR'; +import { Page } from 'protolib/components/Page' +import { DashboardGrid } from 'protolib/components/DashboardGrid'; +import { withSession } from 'protolib/lib/Session'; +import { XStack, YStack } from '@my/ui'; +import { BigTitle } from 'protolib/components/BigTitle' +import { ServiceMemoryUsageChart, TotalMemoryUsage, TotalCPUUsage, TotalUsers, LastEvents, ListPages, TotalObjects, ListLatestUsers, TotalGroups, ListGroups, TotalEvents } from 'protolib/bundles/widgets'; + +const isProtected = Protofy("protected", {{protected}}) + +const itemsContent = [ + { key: 'servicememorychart', content: }, + { key: 'totalmemory', content: }, + { key: 'totalcpu', content: }, + { key: 'totalusers', content: }, + { key: 'lastevents', content: }, + { key: 'listpages', content: }, + { key: 'listgroups', content: }, + { key: 'totalobjects', content: }, + { key: 'listlatestusers', content: }, + { key: 'totalgroups', content: }, + { key: 'totalevents', content: }, +] +const layouts = { + "lg": [ + { "i": "totalcpu", "x": 0, "y": 0, "w": 3, "h": 6, "isResizable": true }, + { "i": "totalmemory", "x": 3, "y": 0, "w": 3, "h": 6, "isResizable": true }, + { "i": "totalusers", "x": 6, "y": 0, "w": 2, "h": 6, "isResizable": true }, + { "i": "listlatestusers", "x": 9, "y": 0, "w": 4, "h": 6, "isResizable": true }, + { "i": "servicememorychart", "x": 0, "y": 6, "w": 6, "h": 14, "isResizable": true }, + { "i": "lastevents", "x": 6, "y": 6, "w": 6, "h": 14, "isResizable": true }, + { "i": "totalgroups", "x": 0, "y": 20, "w": 2, "h": 6, "isResizable": true }, + { "i": "listgroups", "x": 2, "y": 20, "w": 3, "h": 6, "isResizable": true }, + { "i": "totalevents", "x": 5, "y": 20, "w": 2, "h": 6, "isResizable": true }, + { "i": "totalobjects", "x": 7, "y": 20, "w": 2, "h": 6, "isResizable": true }, + { "i": "listpages", "x": 9, "y": 20, "w": 3, "h": 6, "isResizable": true } + ], + "md": [ + { "i": "totalcpu", "x": 0, "y": 0, "w": 3, "h": 6, "isResizable": true }, + { "i": "totalmemory", "x": 3, "y": 0, "w": 4, "h": 6, "isResizable": true }, + { "i": "totalusers", "x": 7, "y": 0, "w": 3, "h": 6, "isResizable": true }, + { "i": "listlatestusers", "x": 0, "y": 6, "w": 12, "h": 6, "isResizable": true }, + { "i": "servicememorychart", "x": 0, "y": 12, "w": 12, "h": 12, "isResizable": true }, + { "i": "lastevents", "x": 0, "y": 24, "w": 12, "h": 12, "isResizable": true }, + { "i": "totalgroups", "x": 0, "y": 36, "w": 3, "h": 6, "isResizable": true }, + { "i": "listgroups", "x": 3, "y": 36, "w": 6, "h": 6, "isResizable": true }, + { "i": "totalevents", "x": 9, "y": 36, "w": 3, "h": 6, "isResizable": true }, + { "i": "totalobjects", "x": 0, "y": 42, "w": 3, "h": 6, "isResizable": true }, + { "i": "listpages", "x": 3, "y": 42, "w": 9, "h": 6, "isResizable": true } + ], + "sm": [ + { "i": "totalcpu", "x": 0, "y": 0, "w": 6, "h": 6, "isResizable": true }, + { "i": "totalmemory", "x": 0, "y": 6, "w": 6, "h": 6, "isResizable": true }, + { "i": "totalusers", "x": 0, "y": 12, "w": 6, "h": 6, "isResizable": true }, + { "i": "listlatestusers", "x": 0, "y": 18, "w": 6, "h": 6, "isResizable": true }, + { "i": "servicememorychart", "x": 0, "y": 24, "w": 6, "h": 12, "isResizable": true }, + { "i": "lastevents", "x": 0, "y": 36, "w": 6, "h": 12, "isResizable": true }, + { "i": "totalgroups", "x": 0, "y": 48, "w": 6, "h": 6, "isResizable": true }, + { "i": "listgroups", "x": 0, "y": 54, "w": 6, "h": 6, "isResizable": true }, + { "i": "totalevents", "x": 0, "y": 60, "w": 6, "h": 6, "isResizable": true }, + { "i": "totalobjects", "x": 0, "y": 66, "w": 6, "h": 6, "isResizable": true }, + { "i": "listpages", "x": 0, "y": 72, "w": 6, "h": 6, "isResizable": true } + ] +} + +Protofy("pageType", "dashboard") + +export default { + route: Protofy("route", "{{route}}"), + component: ({ pageState, initialItems, pageSession, extraData }: any) => { + return ( + + {{name}} + + + + + + ) + }, + getServerSideProps: SSR(async (context) => withSession(context, isProtected ? Protofy("permissions", []) : undefined)) +} \ No newline at end of file diff --git a/packages/protolib/src/bundles/templates.ts b/packages/protolib/src/bundles/templates.ts index 2ab59b0af..4b692e946 100644 --- a/packages/protolib/src/bundles/templates.ts +++ b/packages/protolib/src/bundles/templates.ts @@ -118,14 +118,18 @@ export const pageTemplates = { id: "adminblank", name: "Admin blank" }, - "landing": { - id: "landing", - name: "Landing" - }, "admindashboard": { id: "admindashboard", name: "Admin dashboard" }, + "dashboard": { + id: "dashboard", + name: "Dashboard" + }, + "landing": { + id: "landing", + name: "Landing" + }, "iot": { id: "iot", name: "IoT Panel"