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() public function __construct()
{ {
parent::__construct(); parent::__construct();
BackendMenu::setContext('GermanAirlinesVa.Graphql', 'menu', 'playground');
} }
public function index() 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> <script type="text/javascript" src="/plugins/germanairlinesva/graphql/assets/js/graphiql.js"></script>

View File

@ -1,33 +1,33 @@
<?php return [ <?php return [
'plugin' => [ 'plugin' => [
'name' => 'GA GraphQL', 'name' => 'GA GraphQL',
'description' => '', 'description' => '',
],
'menu' => [
'playground' => 'GA GraphiQL',
],
'permission' => [
'tab' => [
'schemas' => 'German Airlines VA - GraphQL',
], ],
'label' => [ 'menu' => [
'schemas' => 'Access GraphiQL', 'main' => 'GA GraphQL',
'keys' => 'GraphQL Keys',
'playground' => 'GraphiQL',
], ],
], 'permission' => [
'settings' => [ 'tab' => [
'label' => 'German Airlines VA - GraphQL', 'schemas' => 'German Airlines VA - GraphQL',
'description' => 'Configure GrapQL', ],
'general' => 'General', 'label' => [
'engine' => 'Engine', 'schemas' => 'Access GraphiQL',
'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' => [ 'settings' => [
'label' => 'Batched Queries', 'label' => 'German Airlines VA - GraphQL',
'comment' => 'description' => 'Configure GrapQL',
'GraphQL query batching means sending multiple queries to the server in one request. You may set this flag to process/deny batched queries.', '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: plugin:
name: 'germanairlinesva.graphql::lang.plugin.name' name: 'germanairlinesva.graphql::lang.plugin.name'
description: 'germanairlinesva.graphql::lang.plugin.description' description: 'germanairlinesva.graphql::lang.plugin.description'
author: 'German Airlines VA' author: 'German Airlines VA'
icon: oc-icon-database icon: oc-icon-database
homepage: '' homepage: ''
permissions: permissions:
schemas: schemas:
tab: 'germanairlinesva.graphql::lang.permission.tab.schemas' tab: 'germanairlinesva.graphql::lang.permission.tab.schemas'
label: 'germanairlinesva.graphql::lang.permission.label.schemas' label: 'germanairlinesva.graphql::lang.permission.label.schemas'
navigation: navigation:
menu: menu:
label: 'germanairlinesva.graphql::lang.menu.playground' label: 'germanairlinesva.graphql::lang.menu.main'
url: germanairlinesva/graphql/playground url: /
icon: icon-database icon: icon-database
permissions: permissions:
- schemas - 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 DB;
use Schema; use Schema;
use October\Rain\Database\Updates\Migration; use October\Rain\Database\Updates\Migration;
class BuilderTableCreateGermanAirlinesVaGraphQlGraphQlKeys extends Migration class BuilderTableCreateGermanAirlinesVaGraphqlGraphqlKeys extends Migration
{ {
public function up() public function up()
{ {
Schema::connection('germanairlinesva_graphql')->create('graphql_keys', function ($table) { Schema::connection('germanairlinesva_graphql')->create('graphql_keys', function ($table) {
$table->engine = 'InnoDB'; $table->engine = 'InnoDB';
$table->bigIncrements('id')->unsigned(); $table->bigIncrements('id')->unsigned();
$table->bigInteger('member_id')->unsigned();
$table->datetime('valid_from')->default(DB::raw('NOW()')); $table->datetime('valid_from')->default(DB::raw('NOW()'));
$table->datetime('valid_to')->default(DB::raw('NOW()'));
$table->string('key'); $table->string('key');
}); });
} }