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

18
app/Item.php

@ -24,7 +24,7 @@ class Item extends Model
//
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()
{
$details = $this->getconfig();
$class = $details->type;
$app = new $class;
if(isset($this->class) && !empty($this->class)) {
$app = new $this->class;
} else {
$details = $this->getconfig();
if($details === false) return false;
$class = $details->type;
$app = new $class;
}
return (bool)($app instanceof \App\EnhancedApps);
}
public function getconfig()
{
if(!isset($this->description) || empty($this->description)) return false;
$config = json_decode($this->description);
$explode = explode('\\', $config->type);
$config->name = end($explode);
$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]);
$res = $client->request('GET', $zipurl);
if(!file_exists(app_path('SupportedApps'))) {
mkdir(app_path('SupportedApps'), 0777, true);
}
$src = app_path('SupportedApps/'.$app->name.'.zip');
file_put_contents($src, $res->getBody());
@ -86,6 +90,7 @@ abstract class SupportedApps
{
$img_src = app_path('SupportedApps/'.$details->name.'/'.$details->icon);
$img_dest = public_path('storage/supportedapps/'.$details->icon);
//die("i: ".$img_src);
copy($img_src, $img_dest);
$app->name = $details->name;

2
config/app.php

@ -14,7 +14,7 @@ return [
*/
'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",
"cross-env": "^5.2.0",
"jquery": "^3.2",
"laravel-mix": "^2.0"
"laravel-mix": "^2.1.14"
},
"dependencies": {
"select2": "^4.0.6-rc.1"

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

@ -8,7 +8,7 @@
</header>
<div id="create" class="create">
{!! csrf_field() !!}
{!! Form::hidden('class', '') !!}
<div class="input">
<label>{{ __('app.apps.application_name') }} *</label>
{!! Form::text('title', null, array('placeholder' => __('app.apps.title'), 'id' => 'appname', 'class' => 'form-control')) !!}
@ -30,6 +30,9 @@
</div>
<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>
{!! Form::text('colour', null, array('placeholder' => __('app.apps.hex'),'class' => 'form-control color-picker')) !!}
<hr />
@ -58,7 +61,7 @@
</div>
</div>
@if($item->enhanced())
@if(isset($item) && $item->enhanced())
<div id="sapconfig" style="display: block;">
@if(isset($item))
@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) {
$('#appimage').html("<img src='"+data.iconview+"' /><input type='hidden' name='icon' value='"+data.icon+"' />");
$('input[name=colour]').val(data.colour);
$('select[name=class]').val(data.class);
hueb.setColor( data.colour );
$('input[name=pinned]').prop('checked', true);
if(data.config != null) {

4
vendor/composer/autoload_classmap.php

@ -8,6 +8,7 @@ $baseDir = dirname($vendorDir);
return array(
'App\\Application' => $baseDir . '/app/Application.php',
'App\\Console\\Kernel' => $baseDir . '/app/Console/Kernel.php',
'App\\EnhancedApps' => $baseDir . '/app/EnhancedApps.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\\LoginController' => $baseDir . '/app/Http/Controllers/Auth/LoginController.php',
@ -36,6 +37,9 @@ return array(
'App\\SettingGroup' => $baseDir . '/app/SettingGroup.php',
'App\\SettingUser' => $baseDir . '/app/SettingUser.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',
'Carbon\\Carbon' => $vendorDir . '/nesbot/carbon/src/Carbon/Carbon.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 (
'App\\Application' => __DIR__ . '/../..' . '/app/Application.php',
'App\\Console\\Kernel' => __DIR__ . '/../..' . '/app/Console/Kernel.php',
'App\\EnhancedApps' => __DIR__ . '/../..' . '/app/EnhancedApps.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\\LoginController' => __DIR__ . '/../..' . '/app/Http/Controllers/Auth/LoginController.php',
@ -465,6 +466,9 @@ class ComposerStaticInit4b6fb9210a1ea37c2db27b8ff53a1ecf
'App\\SettingGroup' => __DIR__ . '/../..' . '/app/SettingGroup.php',
'App\\SettingUser' => __DIR__ . '/../..' . '/app/SettingUser.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',
'Carbon\\Carbon' => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon/Carbon.php',
'Carbon\\CarbonInterval' => __DIR__ . '/..' . '/nesbot/carbon/src/Carbon/CarbonInterval.php',

Loading…
Cancel
Save