2019-07-04 11:32:51 +02:00
|
|
|
module.exports = {
|
|
|
|
getGeneralSettings: ctx => {
|
|
|
|
const generalSettings = {
|
2019-07-05 09:41:14 +02:00
|
|
|
bulkable: true,
|
2019-07-04 11:32:51 +02:00
|
|
|
filters: true,
|
2019-07-05 10:54:34 +02:00
|
|
|
pageSize: 20,
|
2019-07-04 11:32:51 +02:00
|
|
|
search: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
ctx.body = { generalSettings };
|
|
|
|
},
|
|
|
|
getGroups: ctx => {
|
|
|
|
const groups = [
|
|
|
|
{
|
|
|
|
name: 'ingredient',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'car',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
ctx.body = { groups };
|
|
|
|
},
|
|
|
|
|
2019-07-05 09:41:14 +02:00
|
|
|
getLayout: ctx => {
|
|
|
|
const layouts = {
|
2019-07-08 20:27:38 +02:00
|
|
|
tag: {
|
|
|
|
uid: 'article',
|
|
|
|
schema: {
|
|
|
|
// good old schema
|
|
|
|
connection: 'default',
|
|
|
|
collectionName: 'articles',
|
|
|
|
options: {},
|
|
|
|
infos: {
|
|
|
|
name: 'article',
|
|
|
|
description: '',
|
|
|
|
},
|
|
|
|
attributes: {
|
|
|
|
title: {
|
|
|
|
type: 'string',
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
type: 'text',
|
|
|
|
},
|
|
|
|
json: {
|
|
|
|
type: 'string',
|
|
|
|
},
|
|
|
|
number: {
|
|
|
|
type: 'integer',
|
|
|
|
},
|
|
|
|
date: {
|
|
|
|
type: 'date',
|
|
|
|
},
|
|
|
|
enum: {
|
|
|
|
enum: ['morning,', 'noon'],
|
|
|
|
type: 'enumeration',
|
|
|
|
},
|
|
|
|
pic: {
|
|
|
|
model: 'file',
|
|
|
|
via: 'related',
|
|
|
|
plugin: 'upload',
|
|
|
|
},
|
|
|
|
bool: {
|
|
|
|
type: 'boolean',
|
|
|
|
},
|
|
|
|
tags: {
|
|
|
|
collection: 'tag',
|
|
|
|
via: 'articles',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
settings: {
|
|
|
|
mainField: 'id',
|
|
|
|
defaultSortBy: 'id',
|
|
|
|
defaultSortOrder: 'ASC',
|
|
|
|
searchable: true,
|
|
|
|
filterable: true,
|
2019-07-09 16:56:40 +02:00
|
|
|
bulkable: true,
|
2019-07-08 20:27:38 +02:00
|
|
|
pageSize: 10,
|
|
|
|
},
|
|
|
|
metadata: {
|
|
|
|
id: {
|
|
|
|
edit: {},
|
|
|
|
list: {
|
|
|
|
label: 'Id',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
title: {
|
|
|
|
edit: {
|
|
|
|
label: 'title',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'title',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
edit: {
|
|
|
|
label: 'content',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'content',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
json: {
|
|
|
|
edit: {
|
|
|
|
label: 'json',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {},
|
|
|
|
},
|
|
|
|
number: {
|
|
|
|
edit: {
|
|
|
|
label: 'number',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'number',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
date: {
|
|
|
|
edit: {
|
|
|
|
label: 'date',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'date',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
enum: {
|
|
|
|
edit: {
|
|
|
|
label: 'enum',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'enum',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
pic: {
|
|
|
|
edit: {
|
|
|
|
label: 'pic',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {},
|
|
|
|
},
|
|
|
|
tags: {
|
|
|
|
edit: {
|
|
|
|
label: 'tags',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {},
|
|
|
|
},
|
|
|
|
bool: {
|
|
|
|
edit: {
|
|
|
|
label: 'bool',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'bool',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
layouts: {
|
|
|
|
list: ['id', 'title', 'content'],
|
|
|
|
editRelations: [],
|
|
|
|
edit: [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
name: 'title',
|
|
|
|
size: 6,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'content',
|
|
|
|
size: 6,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2019-07-05 09:41:14 +02:00
|
|
|
article: {
|
|
|
|
uid: 'article',
|
|
|
|
schema: {
|
|
|
|
// good old schema
|
|
|
|
connection: 'default',
|
|
|
|
collectionName: 'articles',
|
|
|
|
options: {},
|
|
|
|
infos: {
|
|
|
|
name: 'article',
|
|
|
|
description: '',
|
|
|
|
},
|
|
|
|
attributes: {
|
|
|
|
title: {
|
|
|
|
type: 'string',
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
type: 'text',
|
|
|
|
},
|
2019-07-05 14:59:31 +02:00
|
|
|
json: {
|
|
|
|
type: 'string',
|
|
|
|
},
|
|
|
|
number: {
|
|
|
|
type: 'integer',
|
|
|
|
},
|
|
|
|
date: {
|
|
|
|
type: 'date',
|
|
|
|
},
|
|
|
|
enum: {
|
|
|
|
enum: ['morning,', 'noon'],
|
|
|
|
type: 'enumeration',
|
|
|
|
},
|
|
|
|
pic: {
|
|
|
|
model: 'file',
|
|
|
|
via: 'related',
|
|
|
|
plugin: 'upload',
|
|
|
|
},
|
|
|
|
bool: {
|
|
|
|
type: 'boolean',
|
|
|
|
},
|
|
|
|
tags: {
|
|
|
|
collection: 'tag',
|
|
|
|
via: 'articles',
|
|
|
|
},
|
2019-07-05 09:41:14 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
settings: {
|
|
|
|
mainField: 'id',
|
|
|
|
defaultSortBy: 'id',
|
2019-07-05 10:54:34 +02:00
|
|
|
defaultSortOrder: 'ASC',
|
2019-07-05 09:41:14 +02:00
|
|
|
searchable: true,
|
|
|
|
filterable: true,
|
2019-07-09 16:56:40 +02:00
|
|
|
bulkable: true,
|
2019-07-05 09:41:14 +02:00
|
|
|
pageSize: 10,
|
|
|
|
},
|
|
|
|
metadata: {
|
2019-07-05 14:59:31 +02:00
|
|
|
id: {
|
|
|
|
edit: {},
|
|
|
|
list: {
|
|
|
|
label: 'Id',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
2019-07-05 09:41:14 +02:00
|
|
|
title: {
|
|
|
|
edit: {
|
|
|
|
label: 'title',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'title',
|
|
|
|
searchable: true,
|
2019-07-09 16:56:40 +02:00
|
|
|
sortable: false,
|
2019-07-05 09:41:14 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
content: {
|
|
|
|
edit: {
|
|
|
|
label: 'content',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'content',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
2019-07-05 14:59:31 +02:00
|
|
|
json: {
|
|
|
|
edit: {
|
|
|
|
label: 'json',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {},
|
|
|
|
},
|
|
|
|
number: {
|
|
|
|
edit: {
|
|
|
|
label: 'number',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'number',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
date: {
|
|
|
|
edit: {
|
|
|
|
label: 'date',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'date',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
enum: {
|
|
|
|
edit: {
|
|
|
|
label: 'enum',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'enum',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
pic: {
|
|
|
|
edit: {
|
|
|
|
label: 'pic',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {},
|
|
|
|
},
|
|
|
|
tags: {
|
|
|
|
edit: {
|
|
|
|
label: 'tags',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {},
|
|
|
|
},
|
|
|
|
bool: {
|
|
|
|
edit: {
|
|
|
|
label: 'bool',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'bool',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
2019-07-05 09:41:14 +02:00
|
|
|
},
|
|
|
|
layouts: {
|
|
|
|
list: ['id', 'title', 'content'],
|
|
|
|
editRelations: [],
|
|
|
|
edit: [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
name: 'title',
|
|
|
|
size: 6,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'content',
|
|
|
|
size: 6,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
user: {
|
|
|
|
uid: 'user',
|
|
|
|
schema: {
|
|
|
|
// good old schema
|
|
|
|
connection: 'default',
|
|
|
|
collectionName: 'users-permissions_user',
|
|
|
|
info: {
|
|
|
|
name: 'user',
|
|
|
|
description: '',
|
|
|
|
},
|
|
|
|
attributes: {
|
|
|
|
username: {
|
|
|
|
type: 'string',
|
|
|
|
minLength: 3,
|
|
|
|
unique: true,
|
|
|
|
configurable: false,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
email: {
|
|
|
|
type: 'email',
|
|
|
|
minLength: 6,
|
|
|
|
configurable: false,
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
type: 'string',
|
|
|
|
configurable: false,
|
|
|
|
},
|
|
|
|
password: {
|
|
|
|
type: 'password',
|
|
|
|
minLength: 6,
|
|
|
|
configurable: false,
|
|
|
|
private: true,
|
|
|
|
},
|
|
|
|
resetPasswordToken: {
|
|
|
|
type: 'string',
|
|
|
|
configurable: false,
|
|
|
|
private: true,
|
|
|
|
},
|
|
|
|
confirmed: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: false,
|
|
|
|
configurable: false,
|
|
|
|
},
|
|
|
|
blocked: {
|
|
|
|
type: 'boolean',
|
|
|
|
default: false,
|
|
|
|
configurable: false,
|
|
|
|
},
|
|
|
|
role: {
|
|
|
|
model: 'role',
|
|
|
|
via: 'users',
|
|
|
|
plugin: 'users-permissions',
|
|
|
|
configurable: false,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
settings: {
|
|
|
|
mainField: 'id',
|
|
|
|
defaultSortBy: 'id',
|
2019-07-05 10:54:34 +02:00
|
|
|
defaultSortOrder: 'ASC',
|
2019-07-05 09:41:14 +02:00
|
|
|
searchable: true,
|
|
|
|
filterable: true,
|
2019-07-09 16:56:40 +02:00
|
|
|
bulkable: true,
|
2019-07-05 09:41:14 +02:00
|
|
|
pageSize: 10,
|
|
|
|
},
|
|
|
|
metadata: {
|
2019-07-05 14:59:31 +02:00
|
|
|
id: {
|
|
|
|
edit: {},
|
|
|
|
list: {
|
|
|
|
label: 'Id',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
2019-07-05 09:41:14 +02:00
|
|
|
username: {
|
|
|
|
edit: {
|
|
|
|
label: 'username',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'username',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
email: {
|
|
|
|
edit: {
|
|
|
|
label: 'email',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'email',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
provider: {
|
|
|
|
edit: {
|
|
|
|
label: 'provider',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'provider',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
confirmed: {
|
|
|
|
edit: {
|
|
|
|
label: 'confirmed',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'confirmed',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
blocked: {
|
|
|
|
edit: {
|
|
|
|
label: 'blocked',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
|
|
|
list: {
|
|
|
|
label: 'blocked',
|
|
|
|
searchable: true,
|
|
|
|
sortable: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
role: {
|
|
|
|
edit: {
|
|
|
|
label: 'role',
|
|
|
|
description: '....',
|
|
|
|
editable: true,
|
|
|
|
visible: true,
|
|
|
|
},
|
2019-07-05 14:59:31 +02:00
|
|
|
list: {},
|
2019-07-05 09:41:14 +02:00
|
|
|
},
|
|
|
|
},
|
2019-07-09 16:56:40 +02:00
|
|
|
},
|
|
|
|
layouts: {
|
|
|
|
list: ['id', 'username', 'email'],
|
|
|
|
editRelations: ['role'],
|
|
|
|
edit: [
|
|
|
|
[
|
|
|
|
{
|
|
|
|
name: 'username',
|
|
|
|
size: 6,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'email',
|
|
|
|
size: 6,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'provider',
|
|
|
|
size: 6,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'password',
|
|
|
|
size: 6,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'confirmed',
|
|
|
|
size: 4,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'blocked',
|
|
|
|
size: 4,
|
|
|
|
},
|
2019-07-05 09:41:14 +02:00
|
|
|
],
|
2019-07-09 16:56:40 +02:00
|
|
|
],
|
2019-07-05 09:41:14 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
ctx.body = { layout: layouts[ctx.params.uid] };
|
|
|
|
},
|
|
|
|
|
2019-07-04 11:32:51 +02:00
|
|
|
getModels: ctx => {
|
|
|
|
const models = [
|
|
|
|
{
|
|
|
|
name: 'article',
|
|
|
|
label: 'Article',
|
|
|
|
destination: 'article',
|
|
|
|
},
|
2019-07-08 20:27:38 +02:00
|
|
|
{
|
|
|
|
name: 'tag',
|
|
|
|
label: 'Tag',
|
|
|
|
destination: 'tag',
|
|
|
|
},
|
2019-07-04 11:32:51 +02:00
|
|
|
{
|
|
|
|
name: 'administrator',
|
|
|
|
label: 'Administrator',
|
|
|
|
destination: 'administrator',
|
|
|
|
source: 'admin', // this should be removed at some point
|
|
|
|
isDisplayed: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'user',
|
|
|
|
label: 'Users',
|
|
|
|
destination: 'user',
|
|
|
|
source: 'users-permissions', // this should be removed at some point
|
|
|
|
isDisplayed: true,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
ctx.body = { models };
|
|
|
|
},
|
2019-07-04 13:08:31 +02:00
|
|
|
|
|
|
|
updateGeneralSettings: ctx => {
|
2019-07-04 15:39:20 +02:00
|
|
|
// Here it should update all the other settings
|
2019-07-04 13:08:31 +02:00
|
|
|
ctx.body = { ok: true };
|
|
|
|
},
|
2019-07-05 10:54:34 +02:00
|
|
|
|
|
|
|
updateLayout: ctx => {
|
|
|
|
// Update specific layout
|
|
|
|
ctx.body = { ok: true };
|
|
|
|
},
|
2019-07-04 11:32:51 +02:00
|
|
|
};
|