Browse Source

changes

pull/282/head
Chris 6 years ago
parent
commit
2b2d51cb6f
  1. 11
      app/Application.php
  2. 14
      app/Http/Controllers/ItemController.php
  3. 18
      app/Item.php
  4. 5
      app/SupportedApps.php
  5. 2
      config/app.php
  6. 32
      database/migrations/2018_10_23_132008_add_class_to_items_table.php
  7. 4599
      package-lock.json
  8. 2
      package.json
  9. 7
      resources/views/items/form.blade.php
  10. 1
      resources/views/items/scripts.blade.php
  11. 4
      vendor/composer/autoload_classmap.php
  12. 4
      vendor/composer/autoload_static.php

11
app/Application.php

@ -30,5 +30,16 @@ class Application extends Model
return $class; return $class;
} }
public static function applist()
{
$list = [];
$all = self::all();
$list['null'] = 'None';
foreach($all as $app) {
$list['\App\SupportedApps\\'.$app->name.'\\'.$app->name] = $app->name;
}
return $list;
}
} }

14
app/Http/Controllers/ItemController.php

@ -155,6 +155,12 @@ class ItemController extends Controller
'user_id' => $current_user->id 'user_id' => $current_user->id
]); ]);
if($request->input('class') === 'null') {
$request->merge([
'class' => null,
]);
}
//die(print_r($request->input('config'))); //die(print_r($request->input('config')));
@ -223,6 +229,13 @@ class ItemController extends Controller
'user_id' => $current_user->id 'user_id' => $current_user->id
]); ]);
if($request->input('class') === 'null') {
$request->merge([
'class' => null,
]);
}
$item = Item::find($id); $item = Item::find($id);
$item->update($request->all()); $item->update($request->all());
@ -293,6 +306,7 @@ class ItemController extends Controller
$output['icon'] = $app_details->icon(); $output['icon'] = $app_details->icon();
$output['iconview'] = $app_details->iconView(); $output['iconview'] = $app_details->iconView();
$output['colour'] = $app_details->defaultColour(); $output['colour'] = $app_details->defaultColour();
$output['class'] = $appclass;
// live details // live details
if($app instanceof \App\EnhancedApps) { if($app instanceof \App\EnhancedApps) {

18
app/Item.php

@ -24,7 +24,7 @@ class Item extends Model
// //
protected $fillable = [ protected $fillable = [
'title', 'url', 'colour', 'icon', 'description', 'pinned', 'order', 'type', 'user_id' 'title', 'url', 'colour', 'icon', 'description', 'pinned', 'order', 'type', 'class', 'user_id'
]; ];
/** /**
@ -140,18 +140,28 @@ class Item extends Model
public function enhanced() public function enhanced()
{ {
$details = $this->getconfig(); if(isset($this->class) && !empty($this->class)) {
$class = $details->type; $app = new $this->class;
$app = new $class; } else {
$details = $this->getconfig();
if($details === false) return false;
$class = $details->type;
$app = new $class;
}
return (bool)($app instanceof \App\EnhancedApps); return (bool)($app instanceof \App\EnhancedApps);
} }
public function getconfig() public function getconfig()
{ {
if(!isset($this->description) || empty($this->description)) return false;
$config = json_decode($this->description); $config = json_decode($this->description);
$explode = explode('\\', $config->type); $explode = explode('\\', $config->type);
$config->name = end($explode); $config->name = end($explode);
$config->url = $this->url; $config->url = $this->url;

5
app/SupportedApps.php

@ -70,6 +70,10 @@ abstract class SupportedApps
$client = new Client(['http_errors' => false, 'timeout' => 60, 'connect_timeout' => 15]); $client = new Client(['http_errors' => false, 'timeout' => 60, 'connect_timeout' => 15]);
$res = $client->request('GET', $zipurl); $res = $client->request('GET', $zipurl);
if(!file_exists(app_path('SupportedApps'))) {
mkdir(app_path('SupportedApps'), 0777, true);
}
$src = app_path('SupportedApps/'.$app->name.'.zip'); $src = app_path('SupportedApps/'.$app->name.'.zip');
file_put_contents($src, $res->getBody()); file_put_contents($src, $res->getBody());
@ -86,6 +90,7 @@ abstract class SupportedApps
{ {
$img_src = app_path('SupportedApps/'.$details->name.'/'.$details->icon); $img_src = app_path('SupportedApps/'.$details->name.'/'.$details->icon);
$img_dest = public_path('storage/supportedapps/'.$details->icon); $img_dest = public_path('storage/supportedapps/'.$details->icon);
//die("i: ".$img_src);
copy($img_src, $img_dest); copy($img_src, $img_dest);
$app->name = $details->name; $app->name = $details->name;

2
config/app.php

@ -14,7 +14,7 @@ return [
*/ */
'name' => env('APP_NAME', 'Heimdall'), 'name' => env('APP_NAME', 'Heimdall'),
'version' => '2.0.100', 'version' => '2.0.101',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

32
database/migrations/2018_10_23_132008_add_class_to_items_table.php

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddClassToItemsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('items', function (Blueprint $table) {
$table->string('class')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('items', function (Blueprint $table) {
$table->dropColumn(['class']);
});
}
}

4599
package-lock.json

File diff suppressed because it is too large

2
package.json

@ -13,7 +13,7 @@
"bootstrap-sass": "^3.3.7", "bootstrap-sass": "^3.3.7",
"cross-env": "^5.2.0", "cross-env": "^5.2.0",
"jquery": "^3.2", "jquery": "^3.2",
"laravel-mix": "^2.0" "laravel-mix": "^2.1.14"
}, },
"dependencies": { "dependencies": {
"select2": "^4.0.6-rc.1" "select2": "^4.0.6-rc.1"

7
resources/views/items/form.blade.php

@ -8,7 +8,7 @@
</header> </header>
<div id="create" class="create"> <div id="create" class="create">
{!! csrf_field() !!} {!! csrf_field() !!}
{!! Form::hidden('class', '') !!}
<div class="input"> <div class="input">
<label>{{ __('app.apps.application_name') }} *</label> <label>{{ __('app.apps.application_name') }} *</label>
{!! Form::text('title', null, array('placeholder' => __('app.apps.title'), 'id' => 'appname', 'class' => 'form-control')) !!} {!! Form::text('title', null, array('placeholder' => __('app.apps.title'), 'id' => 'appname', 'class' => 'form-control')) !!}
@ -30,6 +30,9 @@
</div> </div>
<div class="input"> <div class="input">
<label>{{ __('app.apps.apptype') }} *</label>
{!! Form::select('class', App\Application::applist(), null, array('class' => 'form-control')) !!}
<hr />
<label>{{ __('app.apps.colour') }} *</label> <label>{{ __('app.apps.colour') }} *</label>
{!! Form::text('colour', null, array('placeholder' => __('app.apps.hex'),'class' => 'form-control color-picker')) !!} {!! Form::text('colour', null, array('placeholder' => __('app.apps.hex'),'class' => 'form-control color-picker')) !!}
<hr /> <hr />
@ -58,7 +61,7 @@
</div> </div>
</div> </div>
@if($item->enhanced()) @if(isset($item) && $item->enhanced())
<div id="sapconfig" style="display: block;"> <div id="sapconfig" style="display: block;">
@if(isset($item)) @if(isset($item))
@include('SupportedApps::'.$item->getconfig()->name.'.config') @include('SupportedApps::'.$item->getconfig()->name.'.config')

1
resources/views/items/scripts.blade.php

@ -15,6 +15,7 @@
$.post('/appload', { app: ui.item.value }, function(data) { $.post('/appload', { app: ui.item.value }, function(data) {
$('#appimage').html("<img src='"+data.iconview+"' /><input type='hidden' name='icon' value='"+data.icon+"' />"); $('#appimage').html("<img src='"+data.iconview+"' /><input type='hidden' name='icon' value='"+data.icon+"' />");
$('input[name=colour]').val(data.colour); $('input[name=colour]').val(data.colour);
$('select[name=class]').val(data.class);
hueb.setColor( data.colour ); hueb.setColor( data.colour );
$('input[name=pinned]').prop('checked', true); $('input[name=pinned]').prop('checked', true);
if(data.config != null) { if(data.config != null) {

4
vendor/composer/autoload_classmap.php

@ -8,6 +8,7 @@ $baseDir = dirname($vendorDir);
return array( return array(
'App\\Application' => $baseDir . '/app/Application.php', 'App\\Application' => $baseDir . '/app/Application.php',
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php', 'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
'App\\EnhancedApps' => $baseDir . '/app/EnhancedApps.php',
'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php', 'App\\Exceptions\\Handler' => $baseDir . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => $baseDir . '/app/Http/Controllers/Auth/ForgotPasswordController.php', 'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => $baseDir . '/app/Http/Controllers/Auth/ForgotPasswordController.php',
'App\\Http\\Controllers\\Auth\\LoginController' => $baseDir . '/app/Http/Controllers/Auth/LoginController.php', 'App\\Http\\Controllers\\Auth\\LoginController' => $baseDir . '/app/Http/Controllers/Auth/LoginController.php',
@ -36,6 +37,9 @@ return array(
'App\\SettingGroup' => $baseDir . '/app/SettingGroup.php', 'App\\SettingGroup' => $baseDir . '/app/SettingGroup.php',
'App\\SettingUser' => $baseDir . '/app/SettingUser.php', 'App\\SettingUser' => $baseDir . '/app/SettingUser.php',
'App\\SupportedApps' => $baseDir . '/app/SupportedApps.php', 'App\\SupportedApps' => $baseDir . '/app/SupportedApps.php',
'App\\SupportedApps\\Bookstack\\Bookstack' => $baseDir . '/app/SupportedApps/Bookstack/Bookstack.php',
'App\\SupportedApps\\Deluge\\Deluge' => $baseDir . '/app/SupportedApps/Deluge/Deluge.php',
'App\\SupportedApps\\Nzbget\\Nzbget' => $baseDir . '/app/SupportedApps/Nzbget/Nzbget.php',
'App\\User' => $baseDir . '/app/User.php', 'App\\User' => $baseDir . '/app/User.php',
'Carbon\\Carbon' => $vendorDir . '/nesbot/carbon/src/Carbon/Carbon.php', 'Carbon\\Carbon' => $vendorDir . '/nesbot/carbon/src/Carbon/Carbon.php',
'Carbon\\CarbonInterval' => $vendorDir . '/nesbot/carbon/src/Carbon/CarbonInterval.php', 'Carbon\\CarbonInterval' => $vendorDir . '/nesbot/carbon/src/Carbon/CarbonInterval.php',

4
vendor/composer/autoload_static.php

@ -437,6 +437,7 @@ class ComposerStaticInit4b6fb9210a1ea37c2db27b8ff53a1ecf
public static $classMap = array ( public static $classMap = array (
'App\\Application' => __DIR__ . '/../..' . '/app/Application.php', 'App\\Application' => __DIR__ . '/../..' . '/app/Application.php',
'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php', 'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
'App\\EnhancedApps' => __DIR__ . '/../..' . '/app/EnhancedApps.php',
'App\\Exceptions\\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php', 'App\\Exceptions\\Handler' => __DIR__ . '/../..' . '/app/Exceptions/Handler.php',
'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/ForgotPasswordController.php', 'App\\Http\\Controllers\\Auth\\ForgotPasswordController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/ForgotPasswordController.php',
'App\\Http\\Controllers\\Auth\\LoginController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/LoginController.php', 'App\\Http\\Controllers\\Auth\\LoginController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/LoginController.php',
@ -465,6 +466,9 @@ class ComposerStaticInit4b6fb9210a1ea37c2db27b8ff53a1ecf
'App\\SettingGroup' => __DIR__ . '/../..' . '/app/SettingGroup.php', 'App\\SettingGroup' => __DIR__ . '/../..' . '/app/SettingGroup.php',
'App\\SettingUser' => __DIR__ . '/../..' . '/app/SettingUser.php', 'App\\SettingUser' => __DIR__ . '/../..' . '/app/SettingUser.php',
'App\\SupportedApps' => __DIR__ . '/../..' . '/app/SupportedApps.php', 'App\\SupportedApps' => __DIR__ . '/../..' . '/app/SupportedApps.php',
'App\\SupportedApps\\Bookstack\\Bookstack' => __DIR__ . '/../..' . '/app/SupportedApps/Bookstack/Bookstack.php',
'App\\SupportedApps\\Deluge\\Deluge' => __DIR__ . '/../..' . '/app/SupportedApps/Deluge/Deluge.php',
'App\\SupportedApps\\Nzbget\\Nzbget' => __DIR__ . '/../..' . '/app/SupportedApps/Nzbget/Nzbget.php',
'App\\User' => __DIR__ . '/../..' . '/app/User.php', 'App\\User' => __DIR__ . '/../..' . '/app/User.php',
'Carbon\\Carbon' => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon/Carbon.php', 'Carbon\\Carbon' => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon/Carbon.php',
'Carbon\\CarbonInterval' => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon/CarbonInterval.php', 'Carbon\\CarbonInterval' => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon/CarbonInterval.php',

Loading…
Cancel
Save