diff --git a/src/app/cobalt.ts b/src/app/cobalt.ts index 172d5ad..9a525db 100644 --- a/src/app/cobalt.ts +++ b/src/app/cobalt.ts @@ -1,3 +1,4 @@ +import {OrderDirection} from '@extollo/lib' export enum FieldType { text = 'text', @@ -58,6 +59,8 @@ export interface ResourceConfiguration { key: string, collection: string, primaryKey: string, + orderField?: string, + orderDirection?: OrderDirection, generateKeyOnInsert?: () => string|number, display: { field?: string, diff --git a/src/app/configs/cobalt.config.ts b/src/app/configs/cobalt.config.ts index b66f869..15724a4 100644 --- a/src/app/configs/cobalt.config.ts +++ b/src/app/configs/cobalt.config.ts @@ -3,6 +3,53 @@ import {allResourceActions, FieldType, Renderer, ResourceAction, ResourceConfigu export default { resources: [ + { + key: 'pageView', + primaryKey: 'page_view_id', + collection: 'page_views', + display: { + field: 'endpoint', + singular: 'Raw Page View', + plural: 'Raw Page Views', + }, + orderField: 'visited_at', + orderDirection: 'desc', + supportedActions: [ResourceAction.read, ResourceAction.readOne], + fields: [ + { + key: 'visited_at', + display: 'Date', + type: FieldType.date, + renderer: Renderer.datetime, + }, + { + key: 'endpoint', + display: 'Route', + type: FieldType.text, + }, + { + key: 'ip', + display: 'IP Address', + type: FieldType.text, + }, + { + key: 'hostname', + display: 'Hostname', + type: FieldType.text, + }, + { + key: 'method', + display: 'Method', + type: FieldType.text, + }, + { + key: 'xhr', + display: 'XHR?', + type: FieldType.bool, + renderer: Renderer.bool, + }, + ], + }, { key: 'workItem', primaryKey: 'work_item_id', diff --git a/src/app/http/controllers/cobalt/ResourceAPI.controller.ts b/src/app/http/controllers/cobalt/ResourceAPI.controller.ts index 24c9508..f9164c4 100644 --- a/src/app/http/controllers/cobalt/ResourceAPI.controller.ts +++ b/src/app/http/controllers/cobalt/ResourceAPI.controller.ts @@ -42,6 +42,8 @@ export class ResourceAPI extends Controller { const result = await this.make(Builder) .select(config.primaryKey, ...config.fields.map(x => x.key)) .from(config.collection) + .limit(500) + .orderBy(config.orderField || config.primaryKey, config.orderDirection || 'asc') .connection(this.db.get()) .get() .all() diff --git a/src/app/resources/views/dash/template.pug b/src/app/resources/views/dash/template.pug index 3321f60..2aa9498 100644 --- a/src/app/resources/views/dash/template.pug +++ b/src/app/resources/views/dash/template.pug @@ -44,6 +44,9 @@ head a.nav-link(href=route('dash/cobalt/listing/contactSubmission')) i.fas.fa-fw.fa-comment-alt span Contact Form + a.nav-link(href=route('dash/cobalt/listing/pageView')) + i.fas.fa-fw.fa-chart-bar + span Raw Page Views #content-wrapper.d-flex.flex-column #content nav.navbar.navbar-expand.navbar-light.bg-white.topbar.mb-4.static-top.shadow