Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions .github/ISSUE_TEMPLATE/01-feature-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Feature Request
description: Create a feature request
labels: ['feature']
body:
- type: markdown
attributes:
value: Thanks for taking the time to file a feature request! Please fill out this form as completely as possible.
- type: markdown
attributes:
value: 'Feature requests will be converted to the GitHub Discussions "Ideas" section.'
- type: textarea
attributes:
label: Describe the feature you'd like to request
description: A clear and concise description of what you want and what your use case is.
validations:
required: true
- type: textarea
attributes:
label: Describe the solution you'd like
description: A clear and concise description of what you want to happen.
validations:
required: true
- type: textarea
attributes:
label: Describe alternatives you've considered
description: A clear and concise description of any alternative solutions or features you've considered.
validations:
required: true
52 changes: 52 additions & 0 deletions .github/ISSUE_TEMPLATE/02-bug-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Bug Report
description: Create a bug report
labels: ['bug']
body:
- type: markdown
attributes:
value: Thanks for taking the time to file a bug report! Please fill out this form as completely as possible.
- type: input
attributes:
label: What version of Stackpress are you using?
description: 'For example: 0.1.1'
validations:
required: true
- type: input
attributes:
label: What OS are you experiencing this issue?
description: 'For example: Windows 10 Pro, MacOS Monterey, Ubuntu 23.10'
validations:
required: true
- type: textarea
attributes:
label: Describe the Bug
description: A clear and concise description of what the bug is.
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: A clear and concise description of what you expected to happen.
validations:
required: true
- type: textarea
attributes:
label: To Reproduce
description: Steps to reproduce the behavior, please provide a clear code snippets that always reproduces the issue or a GitHub repository. Screenshots can be provided in the issue body below.
validations:
required: true
- type: input
attributes:
label: Include git repo/fork so we can easily reproduce the issue
description: 'For example: https://github.com/username/repo.git'
validations:
required: false
- type: markdown
attributes:
value: Before posting the issue go through the steps you've written down to make sure the steps provided are detailed and clear.
- type: markdown
attributes:
value: Contributors should be able to follow the steps provided in order to reproduce the bug.
- type: markdown
attributes:
value: These steps are used to add integration tests to ensure the same issue does not happen again. Thanks in advance!
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
32 changes: 32 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--
Thanks for opening a PR! Your contribution is much appreciated.
Please make sure you have followed our contributing guidelines. If you
haven't done so in your commits, please reference the issue numbers as
well as the time you spent on this in the comments below so we can track
time. example `fixed button #1001 3h`. In order to make sure your PR is
handled as smoothly as possible we request that you follow the checklist
sections below. Choose the right checklist for the change that you're
making:
-->

## What is this PR for?

- [ ] Just updating content and/or documentation
- [ ] This fixes issue #_____
- [ ] Spot fix *(no issue #)*
- [ ] Merging WIP feature #_____
- [ ] Merging done feature #_____
- [ ] This is a merge from a version branch
- [ ] Adding/Updating tests
- [ ] This is a conflict resolution
- [ ] This is a branch cleanup
- [ ] Other: ________________

## I verify that...

- [ ] I have logged my time in the commits
- [ ] I have logged my time in this PR
- [ ] I have tagged all the relevant issues
- [ ] I am using VS Code for type checks and linting, or
- [ ] I have ran `npm run test` with no errors
- [ ] I have manually checked that this bug or feature is working
2 changes: 2 additions & 0 deletions packages/stackpress-src/src/plugins/admin/pages/detail.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export default function AdminDetailPageFactory(model: Model) {
logo: admin.logo || '/images/logo-square.png',
menu: admin.menu || []
});
req.data.set('columns', model.query);

//if there is a response body or there is an error code
if (res.body || (res.code && res.code !== 200)) {
//let the response pass through
Expand Down
39 changes: 25 additions & 14 deletions packages/stackpress-src/src/plugins/admin/pages/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,35 @@ export default function AdminSearchPageFactory(model: Model) {
//get the admin config
const admin = server.config<AdminConfig>('admin') || {};
//set data for template layer
res.data.set('admin', {
res.data.set('admin', {
root: admin.root || '/admin',
name: admin.name || 'Admin',
name: admin.name || 'Admin',
logo: admin.logo || '/images/logo-square.png',
menu: admin.menu || []
menu: admin.menu || [],
});
req.data.set('columns', model.query);
//if there is a response body or there is an error code
if (res.body || (res.code && res.code !== 200)) {
//let the response pass through
return;
}
//extract filters from url query
let { q, filter, span, sort, skip, take } = req.data<{
q?: string,
filter?: Record<string, string|number|boolean>,
span?: Record<string, (string|number|null|undefined)[]>,
sort?: Record<string, any>,
skip?: number,
take?: number
let {
q,
filter,
span,
sort,
skip,
take,
columns = [ '*' ],
} = req.data<{
q?: string;
filter?: Record<string, string | number | boolean>;
span?: Record<string, (string | number | null | undefined)[]>;
sort?: Record<string, any>;
skip?: number;
take?: number;
columns?: string[];
}>();

if (skip && !isNaN(Number(skip))) {
Expand All @@ -47,7 +57,7 @@ export default function AdminSearchPageFactory(model: Model) {
//search using the filters
const response = await server.call(
`${model.dash}-search`,
{ q, filter, span, sort, skip, take },
{ q, filter, span, sort, skip, take, columns },
res
);
//if error
Expand All @@ -64,14 +74,15 @@ export default function AdminSearchPageFactory(model: Model) {
//decrypt the data
for (const key in row) {
const column = model.column(key);

if (column && column.encrypted) {
const string = String(row[key]);
if (string.length > 0) {
try {
row[key] = decrypt(String(row[key]), seed);
} catch(e) {
//this can fail if the data was not encrypted
//using the same seed or not encrypted at all
//this can fail if the data was not encrypted
//using the same seed or not encrypted at all
}
}
}
Expand All @@ -80,4 +91,4 @@ export default function AdminSearchPageFactory(model: Model) {
});
res.setRows(rows, total || rows.length);
};
};
}
13 changes: 13 additions & 0 deletions packages/stackpress-src/src/schema/spec/Attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,19 @@ export default class Attributes extends Map<string, unknown> {
return 0;
}

/**
* Returns the table @query
* example: @query([ "*" ])
* example: @query([ "id", "name" ])
*/
public get query() {
const query = this.get('query');
if (Array.isArray(query)) {
return query[0] as string[];
}
return [ '*' ];
}

/**
* Returns relation information
*/
Expand Down
9 changes: 9 additions & 0 deletions packages/stackpress-src/src/schema/spec/Model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ export default class Model extends Fieldset {
);
}

/**
* Returns the table @query
* example: @query([ "*" ])
* example: @query([ "id", "name" ])
*/
public get query() {
return this.attributes.query;
}

/**
* Returns all the models with columns related to this model
*/
Expand Down
8 changes: 5 additions & 3 deletions packages/stackpress-src/stackpress.idea
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ model Profile
model Auth
@label("Auth" "Auth")
@template("{{token}}")
@icon("lock")
@icon("lock")
@query([ "*" "profile.*" ])
{
id String @label("ID")
@id @default("cuid()")
@list.overflow({ length 10 hellip true })

profileId String @label("Profile")
profileId String @label("Profile")
@field.relation({
href "/admin/profile/search"
key "profile"
Expand All @@ -92,7 +93,7 @@ model Auth
foreign "id"
template "{{name}}"
})
@list.template({ key "profile" template "{{name}}" })
@list.template({ key "profile" template "{{name}}" })
@view.template({ key "profile" template "{{name}}" })

type String @label("Type")
Expand Down Expand Up @@ -207,6 +208,7 @@ model Session
@label("Session" "Sessions")
@template("{{profile.name}}")
@icon("coffee")
@query([ "*" "profile.*" "application.*"])
{
id String @label("ID")
@id @default("cuid()")
Expand Down