Key Controller + list

This commit is contained in:
Your Name 2021-08-04 00:49:21 +02:00
parent 78acb54845
commit 222194e554
11 changed files with 141 additions and 48 deletions

View File

@ -0,0 +1,16 @@
<?php namespace GermanAirlinesVa\Graphql\Controllers;
use Backend\Classes\Controller;
use BackendMenu;
class GraphqlKey extends Controller
{
public $implement = [ 'Backend\Behaviors\ListController' ];
public $listConfig = 'config_list.yaml';
public function __construct()
{
parent::__construct();
}
}

View File

@ -8,8 +8,6 @@ class Playground extends Controller
public function __construct()
{
parent::__construct();
BackendMenu::setContext('GermanAirlinesVa.Graphql', 'menu', 'playground');
}
public function index()

View File

@ -0,0 +1,17 @@
<div data-control="toolbar">
<button
class="btn btn-default oc-icon-trash-o"
disabled="disabled"
onclick="$(this).data('request-data', {
checked: $('.control-list').listWidget('getChecked')
})"
data-request="onDelete"
data-request-confirm="<?= e(trans('backend::lang.list.delete_selected_confirm')) ?>"
data-trigger-action="enable"
data-trigger=".control-list input[type=checkbox]"
data-trigger-condition="checked"
data-request-success="$(this).prop('disabled', true)"
data-stripe-load-indicator>
<?= e(trans('backend::lang.list.delete_selected')) ?>
</button>
</div>

View File

@ -0,0 +1,11 @@
list: $/germanairlinesva/graphql/models/graphqlkey/columns.yaml
modelClass: GermanAirlinesVa\Graphql\Models\GraphqlKey
title: GraphQL Keys
noRecordsMessage: 'backend::lang.list.no_records'
showSetup: true
showCheckboxes: true
recordsPerPage: 20
toolbar:
buttons: list_toolbar
search:
prompt: 'backend::lang.list.search_prompt'

View File

@ -0,0 +1 @@
<?= $this->listRender() ?>

View File

@ -1,2 +1 @@
<div id="mount"></div>
<script type="text/javascript" src="/plugins/germanairlinesva/graphql/assets/js/graphiql.js"></script>

View File

@ -1,33 +1,33 @@
<?php return [
'plugin' => [
'name' => 'GA GraphQL',
'description' => '',
],
'menu' => [
'playground' => 'GA GraphiQL',
],
'permission' => [
'tab' => [
'schemas' => 'German Airlines VA - GraphQL',
'plugin' => [
'name' => 'GA GraphQL',
'description' => '',
],
'label' => [
'schemas' => 'Access GraphiQL',
'menu' => [
'main' => 'GA GraphQL',
'keys' => 'GraphQL Keys',
'playground' => 'GraphiQL',
],
],
'settings' => [
'label' => 'German Airlines VA - GraphQL',
'description' => 'Configure GrapQL',
'general' => 'General',
'engine' => 'Engine',
'enable_cache' => [
'label' => 'Enable Schema Cache',
'comment' =>
'A large part of the Schema generation is parsing the various graph definition into an AST. These operations are pretty expensive so it is recommended to enable caching in production mode.',
'permission' => [
'tab' => [
'schemas' => 'German Airlines VA - GraphQL',
],
'label' => [
'schemas' => 'Access GraphiQL',
],
],
'batched_queries' => [
'label' => 'Batched Queries',
'comment' =>
'GraphQL query batching means sending multiple queries to the server in one request. You may set this flag to process/deny batched queries.',
'settings' => [
'label' => 'German Airlines VA - GraphQL',
'description' => 'Configure GrapQL',
'general' => 'General',
'engine' => 'Engine',
'enable_cache' => [
'label' => 'Enable Schema Cache',
'comment' => 'A large part of the Schema generation is parsing the various graph definition into an AST. These operations are pretty expensive so it is recommended to enable caching in production mode.',
],
'batched_queries' => [
'label' => 'Batched Queries',
'comment' => 'GraphQL query batching means sending multiple queries to the server in one request. You may set this flag to process/deny batched queries.',
],
],
],
];
];

29
models/GraphqlKey.php Normal file
View File

@ -0,0 +1,29 @@
<?php namespace GermanAirlinesVa\Graphql\Models;
use Cms\Classes\Theme;
use Model;
class GraphqlKey extends Model
{
use \October\Rain\Database\Traits\Validation;
/*
* Disable timestamps by default.
* Remove this line if timestamps are defined in the database table.
*/
public $timestamps = false;
/**
* @var string The database table used by the model.
*/
public $table = 'graphql_keys';
protected $connection = 'germanairlinesva_graphql';
/**
* @var array Validation rules
*/
public $rules = [
'member_id' => 'required',
'key' => 'required',
];
}

View File

@ -0,0 +1,13 @@
columns:
id:
label: id
type: number
member_id:
label: member_id
type: number
valid_from:
label: valid_from
type: datetime
key:
label: key
type: text

View File

@ -1,17 +1,26 @@
plugin:
name: 'germanairlinesva.graphql::lang.plugin.name'
description: 'germanairlinesva.graphql::lang.plugin.description'
author: 'German Airlines VA'
icon: oc-icon-database
homepage: ''
name: 'germanairlinesva.graphql::lang.plugin.name'
description: 'germanairlinesva.graphql::lang.plugin.description'
author: 'German Airlines VA'
icon: oc-icon-database
homepage: ''
permissions:
schemas:
tab: 'germanairlinesva.graphql::lang.permission.tab.schemas'
label: 'germanairlinesva.graphql::lang.permission.label.schemas'
schemas:
tab: 'germanairlinesva.graphql::lang.permission.tab.schemas'
label: 'germanairlinesva.graphql::lang.permission.label.schemas'
navigation:
menu:
label: 'germanairlinesva.graphql::lang.menu.playground'
url: germanairlinesva/graphql/playground
icon: icon-database
permissions:
- schemas
menu:
label: 'germanairlinesva.graphql::lang.menu.main'
url: /
icon: icon-database
permissions:
- schemas
sideMenu:
side-menu-item:
label: 'germanairlinesva.graphql::lang.menu.playground'
url: germanairlinesva/graphql/playground
icon: icon-database
side-menu-item2:
label: 'germanairlinesva.graphql::lang.menu.keys'
url: germanairlinesva/graphql/graphqlkey
icon: icon-key

View File

@ -1,18 +1,18 @@
<?php namespace GermanAirlinesVa\GraphQl\Updates;
<?php namespace GermanAirlinesVa\Graphql\Updates;
use DB;
use Schema;
use October\Rain\Database\Updates\Migration;
class BuilderTableCreateGermanAirlinesVaGraphQlGraphQlKeys extends Migration
class BuilderTableCreateGermanAirlinesVaGraphqlGraphqlKeys extends Migration
{
public function up()
{
Schema::connection('germanairlinesva_graphql')->create('graphql_keys', function ($table) {
$table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned();
$table->bigInteger('member_id')->unsigned();
$table->datetime('valid_from')->default(DB::raw('NOW()'));
$table->datetime('valid_to')->default(DB::raw('NOW()'));
$table->string('key');
});
}