From c221c68db3800ed47d7b56948d8ecbb2b545ed53 Mon Sep 17 00:00:00 2001 From: Kekskurse Date: Thu, 25 Apr 2019 12:03:34 +0200 Subject: [PATCH] App Setting Page --- app/Http/Controllers/GUI/AppController.php | 43 ++++++-- resources/views/app/details.php | 114 ++++++++++++++++++--- resources/views/app/list.php | 2 +- resources/views/layout/bottom.php | 2 +- routes/web.php | 1 + 5 files changed, 135 insertions(+), 27 deletions(-) diff --git a/app/Http/Controllers/GUI/AppController.php b/app/Http/Controllers/GUI/AppController.php index 36a36f3..f6ce2f7 100644 --- a/app/Http/Controllers/GUI/AppController.php +++ b/app/Http/Controllers/GUI/AppController.php @@ -50,42 +50,69 @@ class AppController extends Controller return view('app/details', ["msg"=>"", "app" => $app]); } + public function updateApp(Request $request, $id) { + $this->validate($request, [ + 'name' => 'required|max:255|min:3|regex:@^[a-zA-Z0-9]*$@', + 'description' => 'required|min:3', + 'url' => 'required|url', + 'direct_url' => 'url' + ]); + + // ToDO Unique App Name + + + $app = App::query()->where("id", "=", $id)->first(); + + if($app->user_id != Auth::user()->id) { + abort(401); + } + + $app->name = $request->input("name"); + $app->description = $request->input("description"); + $app->url = $request->input("url"); + $app->direct_url = $request->input("direct_url"); + + $app->saveOrFail(); + return redirect('/gui/apps/'.$id); + } + public function changeIcon(Request $request, $id) { // Todo: Replace prove of concept with better code $newTmp = tempnam("", "icon_upload"); $request->file("icon")->move("/tmp", $newTmp); $info = getimagesize($newTmp); if($info["0"] != $info["1"]) { - echo "Icon is not a squader";exit(); + echo "Icon is not a squader. Zurück";exit(); } if($info[0] > 500) { - echo "Icon is to big, max 500 px";exit(); + echo "Icon is to big, max 500 px. Zurück";exit(); } if($info[0] < 50) { - echo "Icon is to small, min 50px";exit(); + echo "Icon is to small, min 50px. Zurück";exit(); } $app = App::query()->where("id", "=", $id)->firstOrFail(); if($app->user_id != Auth::user()->id) { - echo "Its not your app";exit(); + echo "Its not your app. Zurück";exit(); } $app->icon = file_get_contents($newTmp); $app->saveOrFail(); - echo "OK"; + return redirect('/gui/apps/'.$id); } public function getAppIcon($id) { $app = App::query()->where("id", "=", $id)->firstOrFail(); + if(empty($app->icon)) { + $app->icon = file_get_contents(resource_path("images/app.png")); + } + $r = getimagesizefromstring($app->icon); return response($app->icon) ->header('Content-Type',$r["mime"]); } - - - } diff --git a/resources/views/app/details.php b/resources/views/app/details.php index 15386f2..3649591 100644 --- a/resources/views/app/details.php +++ b/resources/views/app/details.php @@ -1,23 +1,103 @@
-

App name; ?>

-

description; ?>

- url; ?> -
-

Settings

- Icon - You can change the Icon of the App by uploading a square Pic. -
-
- -
-
-

API Access

- API-Key - - API-Secret - + +
+
+
+
+

App name; ?>

+

description; ?>

+ url; ?> +
+
+ +
+
+ +
+
+

API Access

+ API-Key + + API-Secret + +
+
+

Settings

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name
URL
Description
Direct Login URL
Testing testing_warning) { echo 'checked'; } ?>>
Untrusted untrusted_warning) { echo 'checked'; } ?>>
Auto Accept auto_accept) { echo 'checked'; } ?>>
Show on Webpage show_on_webpage) { echo 'checked'; } ?>>
+ +
+
+
+ Icon
+ You can change the Icon of the App by uploading a square Pic. +
+
+ +
+
+
+
+
...
+
+ + \ No newline at end of file diff --git a/resources/views/app/list.php b/resources/views/app/list.php index 89477f1..d57b4ca 100644 --- a/resources/views/app/list.php +++ b/resources/views/app/list.php @@ -10,7 +10,7 @@ ?>
- name; ?> + name; ?>
-