Compare commits

..

19 Commits

Author SHA1 Message Date
Kilian 172128b37b Relations 2021-08-16 11:34:24 +02:00
Kilian 8bb522ec33 Create Exams 2021-08-16 10:36:55 +02:00
Kilian f32d3a4877 MID based exams 2021-08-15 23:24:15 +02:00
Kilian 0fe449538e Grouping issues 2021-08-15 23:06:15 +02:00
Kilian c797cb9f24 Basic schooling GQL 2021-08-15 19:05:54 +02:00
Kilian e884b0e97d Unecrypted Cookie 2021-08-15 13:46:06 +02:00
Kilian 9b153dacd8 Controller Permission 2021-08-14 21:44:41 +02:00
Kilian fdf7e89afe Member FK 2021-08-14 18:28:24 +02:00
Kilian 7baa903f7a Namespace Permission 2021-08-14 14:18:31 +02:00
Kilian 3e0ba5f209 Dynamic host 2021-08-14 13:15:45 +02:00
Kilian a5598130db remove require 2021-08-04 19:51:38 +02:00
Kilian e6ceea1b1b Unused use removed 2021-08-04 19:14:52 +02:00
Your Name 064e8a8054 Formating .htm removed 2021-08-04 12:34:53 +02:00
Your Name 52ecda573b Updated 2021-08-04 01:59:47 +02:00
Your Name a88999cd18 Yarn 2021-08-04 01:54:23 +02:00
Your Name 40d396908d Hooks 2021-08-04 01:30:47 +02:00
Your Name f01509cab1 Format 2021-08-04 00:56:18 +02:00
Your Name 51941b88ee Lockfile 2021-08-04 00:53:59 +02:00
Your Name 222194e554 Key Controller + list 2021-08-04 00:49:21 +02:00
27 changed files with 322 additions and 100 deletions
+12
View File
@@ -0,0 +1,12 @@
#!/bin/sh
FILES=$(git diff --cached --name-only --diff-filter=ACMR -- '*.php' '*.html' '*.yaml' | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0
# Prettify all selected files
echo "$FILES" | xargs ./node_modules/.bin/prettier --ignore-unknown --write
# Add back the modified/prettified files to staging
echo "$FILES" | xargs git add
exit 0
-25
View File
@@ -1,25 +0,0 @@
<?php namespace GermanAirlinesVa\Graphql;
use Closure;
class Authentication
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->input('gql_session') === 'SUPER_SECRET_TOKEN') {
return "false";
}
else {
return "true";
}
return $next($request);
}
}
+6 -2
View File
@@ -5,6 +5,7 @@ use System\Classes\PluginBase;
use App;
use Config;
use Illuminate\Database\DatabaseManager;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Foundation\AliasLoader;
use GermanAirlinesVa\Graphql\Classes\GraphqlServiceProvider;
use Nuwave\Lighthouse\Subscriptions\SubscriptionServiceProvider;
@@ -43,10 +44,13 @@ class Plugin extends PluginBase
$this->app->singleton(DatabaseManager::class, function ($app) {
return $app->make('db');
});
\Illuminate\Support\Facades\Broadcast::routes(['prefix' => '', 'middleware' => 'GermanAirlinesVA\\Graphql\\Classes\\Authentication']);
require("channels/channels.php");
Broadcast::routes([
'prefix' => '',
'middleware' => 'GermanAirlinesVA\\Graphql\\Classes\\Authentication',
]);
Config::set('database.connections.germanairlinesva_graphql', Config::get('germanairlinesva.graphql::connection'));
Config::push('system.unencrypt_cookies', 'graphql-session-id');
}
public function bootPackages()
+1 -1
View File
@@ -2,4 +2,4 @@
## GraphQLKeys
- **TODO** BelongsTo Member (External DB)
- BelongsTo Member (External DB, creation in Social Plugin)
+1 -1
View File
@@ -32920,7 +32920,7 @@ var _validUrl = __webpack_require__(429);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var options = { method: 'post', headers: { 'Content-Type': 'application/json' } };
var endpoint = 'http://localhost/graphql/'; // Initial
var endpoint = 'http://' + window.location.host + '/graphql/'; // Initial
var defaultQuery = '\n# Welcome to GraphiQL\n#\n# GraphiQL is an in-browser tool for writing, validating, and\n# testing GraphQL queries.\n#\n# Type queries into this side of the screen, and you will see intelligent\n# typeaheads aware of the current GraphQL type schema and live syntax and\n# validation errors highlighted within the text.\n#\n# GraphQL queries typically start with a "{" character. Lines that starts\n# with a # are ignored.\n#\n# An example GraphQL query might look like:\n#\n# {\n# field(arg: "value") {\n# subField\n# }\n# }\n#\n# Keyboard shortcuts:\n#\n# Run Query: Ctrl-Enter (or press the play button above)\n#\n# Auto Complete: Ctrl-Space (or just start typing)\n#\n# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n# Default endpoint is an instance of https://www.graph.cool/\n# # # # # # # # # # # # # # # # # # # # # # # # # # # # # #\n\nquery {\n countries {\n name\n }\n}\n';
Binary file not shown.
-18
View File
@@ -1,18 +0,0 @@
<?php
use Illuminate\Support\Facades\Broadcast;
/*
|--------------------------------------------------------------------------
| Broadcast Channels
|--------------------------------------------------------------------------
|
| Here you may register all of the event broadcasting channels that your
| application supports. The given channel authorization callbacks are
| used to check if an authenticated user can listen to the channel.
|
*/
Broadcast::channel('lighthouse-*', function ($user) {
return true;
});
+3 -4
View File
@@ -15,10 +15,9 @@ class Authentication
public function handle($request, Closure $next)
{
if ($request->header('Gql-Session') === 'SUPER_SECRET_KEY_HEADER') {
return "";
}
else {
throw new AccessDeniedHttpException;
return '';
} else {
throw new AccessDeniedHttpException();
}
return $next($request);
+1 -1
View File
@@ -69,6 +69,6 @@ class Dummy extends GraphQLSubscription
*/
public function resolve($root, array $args, GraphQLContext $context, ResolveInfo $resolveInfo): array
{
return array($root);
return [$root];
}
}
+17
View File
@@ -0,0 +1,17 @@
<?php namespace GermanAirlinesVa\Graphql\Controllers;
use Backend\Classes\Controller;
class GraphqlKey extends Controller
{
public $implement = ['Backend\Behaviors\ListController'];
public $listConfig = 'config_list.yaml';
public $requiredPermissions = ['germanairlinesva.graphql.master'];
public function __construct()
{
parent::__construct();
}
}
+2 -3
View File
@@ -1,17 +1,16 @@
<?php namespace GermanAirlinesVa\Graphql\Controllers;
use Backend\Classes\Controller;
use BackendMenu;
class Playground extends Controller
{
public function __construct()
{
parent::__construct();
BackendMenu::setContext('GermanAirlinesVa.Graphql', 'menu', 'playground');
}
public $requiredPermissions = ['germanairlinesva.graphql.master'];
public function index()
{
$this->pageTitle = 'germanairlinesva.graphql::lang.menu.playground';
+18
View File
@@ -0,0 +1,18 @@
<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>
+11
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'
+1
View File
@@ -0,0 +1 @@
<?= $this->listRender() ?>
+11 -3
View File
@@ -1,4 +1,3 @@
title = "CMS"
==
<?php
use Cms\Classes\Theme;
@@ -14,8 +13,17 @@ function resolveCmsContent($root, $args) {
?>
==
# Content
extend type Query { cmsContent(name: String!): CmsContent! }
type CmsContent { fileName: String! content: String markup: String parsedMarkup: String }
extend type Query {
cmsContent(name: String!): CmsContent!
}
type CmsContent {
fileName: String!
content: String
markup: String
parsedMarkup: String
}
# CMS-wide types
# Backend\Models\User
type BackendUser { id: ID! }
+7 -12
View File
@@ -1,4 +1,3 @@
title = "Fleet"
==
==
# Content
@@ -6,19 +5,12 @@ extend type Query {
aircraft: [Aircraft] @all(model: "GermanAirlinesVa\\Fleet\\Models\\Aircraft")
aircraftType: [AircraftType] @all(model: "GermanAirlinesVa\\Fleet\\Models\\AircraftType")
}
extend type Subscription {
aircraftAdded: Aircraft @subscription(class: "GermanAirlinesVa\\Fleet\\Classes\\AircraftAdded")
aircraftAdded: Aircraft @subscription(class: "GermanAirlinesVa\\Fleet\\Classes\\AircraftAdded")
}
extend type Mutation {
addAircraft(
aircraft_type_id: ID!,
home_airport_id: ID!,
name: String!,
registration: String!
): Aircraft
@create(model: "GermanAirlinesVa\\Fleet\\Models\\Aircraft")
addAircraft(aircraft_type_id: ID!, home_airport_id: ID!, name: String!, registration: String! ): Aircraft
@create(model:"GermanAirlinesVa\\Fleet\\Models\\Aircraft")
@broadcast(subscription: "aircraftAdded")
}
@@ -29,4 +21,7 @@ type Aircraft {
name: String!
registration: String!
}
type AircraftType { type: String! aircrafts: [Aircraft] @hasMany }
type AircraftType {
type: String!
aircrafts: [Aircraft] @hasMany
}
+150
View File
@@ -0,0 +1,150 @@
==
<?php
function resolveExamMemberRanks($root, $args) {
$exams = \GermanAirlinesVa\Schooling\Models\ExamMemberRank::where('member_id', $args['memberID'])->get();
foreach($exams as $exam) {
$exam->load([
'exam_questions' => function ($query) {
$query->groupBy('id');
}
]);
}
return $exams;
}
function resolveExamTyperatings($root, $args) {
$exams = \GermanAirlinesVa\Schooling\Models\ExamTyperating::where('member_id', $args['memberID'])->get();
foreach($exams as $exam) {
$exam->load([
'exam_questions' => function ($query) {
$query->groupBy('id');
}
]);
}
return $exams;
}
function resolveTyperatings() {
$typeratings = GermanAirlinesVa\Schooling\Models\Typerating::all();
foreach($typeratings as $typerating) {
$typerating->load([
'exam_questions' => function($query) {
$query->groupBy('id');
}
]);
}
return $typeratings;
}
function resolveMemberRanks() {
$ranks = GermanAirlinesVa\Schooling\Models\MemberRank::all();
foreach($ranks as $rank) {
$rank->load([
'exam_questions' => function($query) {
$query->groupBy('id');
}
]);
}
return $rank;
}
function createExamMemberRank($root, $args) {
return GermanAirlinesVa\Schooling\Models\ExamMemberRank::createNew($args['memberID'], $args['memberRankID']);
}
function resolveCreateExamTyperating($root, $args) {
return GermanAirlinesVa\Schooling\Models\ExamTyperating::createNew($args['memberID'], $args['typeratingID']);
}
==
# Content
extend type Query {
memberRanks: [MemberRank]!
typeratings: [Typerating]!
examMemberRanks(memberID: ID!): [ExamMemberRank]!
examTyperatings(memberID: ID!): [ExamTyperating]!
}
extend type Mutation {
createExamMemberRank(memberID: ID!, memberRankID: ID!): ExamMemberRank!
createExamTyperating(memberID: ID!, typeratingID: ID!): ExamTyperating!
}
type MemberRank {
id: ID!
name: String!
description: String!
points: Int!
price: Int!
badge: String!
region: String!
exam_questions: [ExamMemberRankQuestion]! @hasMany
exams: [ExamMemberRank]! @hasMany
}
type Typerating {
id: ID!
name: String!
price: Int!
exam_questions: [ExamTyperatingQuestion]! @hasMany
exams: [ExamTyperating]! @hasMany
}
type ExamMemberRank {
id: ID!
member_id: ID!
member_rank: MemberRank! @belongsTo
start: DateTime!
status: ExamStatus!
exam_questions: [ExamMemberRankQuestion]! @belongsToMany
exam_answers: [ExamMemberRankAnswer]! @belongsToMany
}
type ExamTyperating {
id: ID!
member_id: ID!
typerating: Typerating! @belongsTo
start: DateTime!
status: ExamStatus!
exam_questions: [ExamTyperatingQuestion]! @belongsToMany
exam_answers: [ExamTyperatingAnswer]! @belongsToMany
}
type ExamMemberRankQuestion {
id: ID!
member_rank: MemberRank! @belongsTo
in_use: Boolean!
mandatory: Boolean!
text: String!
picture: String!
exam_answers: [ExamMemberRankAnswer]! @hasMany
exam_member_ranks: [ExamMemberRank]! @belongsToMany
}
type ExamTyperatingQuestion {
id: ID!
typerating: Typerating! @belongsTo
in_use: Boolean!
mandatory: Boolean!
text: String!
picture: String!
exam_answers: [ExamTyperatingAnswer]! @hasMany
exma_typeratings: [ExamTyperating]! @belongsToMany
}
type ExamMemberRankAnswer {
id: ID!
exam_question: ExamMemberRankQuestion! @belongsTo
text: String!
is_correct: Boolean!
exam_member_ranks: [ExamMemberRank]! @belongsToMany
}
type ExamTyperatingAnswer {
id: ID!
exam_question: ExamTyperatingQuestion! @belongsTo
text: String!
is_correct: Boolean!
exam_typeratings: [ExamTyperating]! @belongsToMany
}
enum ExamStatus {
open
pending
closed
validated
}
scalar DateTime
@scalar(class: "Nuwave\\Lighthouse\\Schema\\Types\\Scalars\\DateTime")
+3 -1
View File
@@ -4,7 +4,9 @@
'description' => '',
],
'menu' => [
'playground' => 'GA GraphiQL',
'main' => 'GA GraphQL',
'keys' => 'GraphQL Keys',
'playground' => 'GraphiQL',
],
'permission' => [
'tab' => [
+32
View File
@@ -0,0 +1,32 @@
<?php namespace GermanAirlinesVa\Graphql\Models;
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',
];
public $belongsTo = [
'member' => 'GermanAirlinesVa\Social\Models\Member',
];
}
-1
View File
@@ -1,6 +1,5 @@
<?php namespace GermanAirlinesVa\Graphql\Models;
use Cms\Classes\Theme;
use Model;
class Settings extends Model
+15
View File
@@ -0,0 +1,15 @@
columns:
id:
label: id
type: number
member:
label: member
type: text
relation: member
valueFrom: name
valid_from:
label: valid_from
type: datetime
key:
label: key
type: text
+4 -3
View File
@@ -6,10 +6,11 @@
"author": "German Airlines VA",
"license": "MIT",
"devDependencies": {
"@prettier/plugin-php": "^0.16.3",
"prettier": "^2.3.0"
"@prettier/plugin-php": "^0.17.3",
"prettier": "^2.3.2"
},
"scripts": {
"format": "prettier --write './**/*.{php,html,htm,yaml}'"
"preinstall": "git config core.hooksPath .hooks",
"format": "prettier --write './**/*.{php,html,yaml}'"
}
}
+13 -4
View File
@@ -5,13 +5,22 @@ plugin:
icon: oc-icon-database
homepage: ''
permissions:
schemas:
germanairlinesva.graphql.master:
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
label: 'germanairlinesva.graphql::lang.menu.main'
url: /
icon: icon-database
permissions:
- schemas
- germanairlinesva.graphql.master
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
-5
View File
@@ -1,5 +0,0 @@
# Relations
## GraphQLKeys
- **TODO** BelongsTo Member (External DB)
@@ -1,6 +1,5 @@
<?php namespace GermanAirlinesVa\GraphQl\Updates;
use Config;
use Schema;
use October\Rain\Database\Updates\Migration;
@@ -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');
});
}
+11 -12
View File
@@ -2,14 +2,14 @@
# yarn lockfile v1
"@prettier/plugin-php@^0.16.3":
version "0.16.3"
resolved "https://registry.yarnpkg.com/@prettier/plugin-php/-/plugin-php-0.16.3.tgz#74867210079ba3c0c3ae843029d76e25ff0aadf3"
integrity sha512-DNidzeGpP+/wmcCAZNSHxgoAnhEosYG+no4jJRqln19e1o3Okpuir/2JMxb07VCwdG50IWjtNgVwNPVl4uj0Hg==
"@prettier/plugin-php@^0.17.3":
version "0.17.3"
resolved "https://registry.yarnpkg.com/@prettier/plugin-php/-/plugin-php-0.17.3.tgz#193a18e308db7416f26f6e1dc0d2605d1ff01416"
integrity sha512-kD5IrGyKWF/p3XActVZ+GfbMl9knoK3XKBTG2bytpOtCO0+Q8eozimSgk/493rgFkXL3W2Ap/4GKgZf7u64+ow==
dependencies:
linguist-languages "^7.5.1"
mem "^8.0.0"
php-parser "3.0.2"
php-parser "https://github.com/glayzzle/php-parser#e61e26102144f267ecf5e09020865a9baa6ca2f1"
linguist-languages@^7.5.1:
version "7.15.0"
@@ -41,12 +41,11 @@ p-defer@^1.0.0:
resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c"
integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww=
php-parser@3.0.2:
"php-parser@https://github.com/glayzzle/php-parser#e61e26102144f267ecf5e09020865a9baa6ca2f1":
version "3.0.2"
resolved "https://registry.yarnpkg.com/php-parser/-/php-parser-3.0.2.tgz#a86dbbc110e57378cba71ab4cd9b0d18f3872ac3"
integrity sha512-a7y1+odEGsceLDLpu7oNyspZ0pK8FMWJOoim4/yd82AtnEZNLdCLZ67arnOQZ9K0lHJiSp4/7lVUpGELVxE14w==
resolved "https://github.com/glayzzle/php-parser#e61e26102144f267ecf5e09020865a9baa6ca2f1"
prettier@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.0.tgz#b6a5bf1284026ae640f17f7ff5658a7567fc0d18"
integrity sha512-kXtO4s0Lz/DW/IJ9QdWhAf7/NmPWQXkFr/r/WkR3vyI+0v8amTDxiaQSLzs8NBlytfLWX/7uQUMIW677yLKl4w==
prettier@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d"
integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==