mirror of
https://github.com/linuxserver/Heimdall.git
synced 2026-02-24 21:50:32 +09:00
Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43f9b76ff3 | ||
|
|
85c68c1f46 | ||
|
|
ffcfef8d1c | ||
|
|
fc2191b8db | ||
|
|
03edaea99a | ||
|
|
ee36a0cfae | ||
|
|
a868a6cac1 | ||
|
|
574756b236 | ||
|
|
f9599079e5 | ||
|
|
10afffb71d | ||
|
|
79d53af339 | ||
|
|
8cc6a9cc63 | ||
|
|
18001fbdd0 |
105
app/Http/Controllers/ApiItemController.php
Normal file
105
app/Http/Controllers/ApiItemController.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Item;
|
||||
use App\SettingUser;
|
||||
use App\User;
|
||||
|
||||
class ApiItemController extends Controller
|
||||
{
|
||||
protected $api_key;
|
||||
protected $user;
|
||||
|
||||
function __construct(Request $request) {
|
||||
$this->middleware('apikey');
|
||||
|
||||
$key = $request->input('api_key');
|
||||
if ($key) {
|
||||
$details = SettingUser::where('setting_id', 12)->where('uservalue', $key)->first();
|
||||
$this->api_key = $key;
|
||||
$this->user = User::find($details->user_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return $this->user->items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$request->merge([
|
||||
'user_id' => $this->user->id
|
||||
]);
|
||||
// die(print_r($request->all()));
|
||||
Item::create($request->all());
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@@ -145,11 +145,38 @@ class ItemController extends Controller
|
||||
//
|
||||
$data['tags'] = Item::ofType('tag')->orderBy('title', 'asc')->pluck('title', 'id');
|
||||
$data['tags']->prepend(__('app.dashboard'), 0);
|
||||
$data['current_tags'] = collect([0 => __('app.dashboard')]);
|
||||
$data['current_tags'] = '0';
|
||||
return view('items.create', $data);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
// Get the item
|
||||
$item = Item::find($id);
|
||||
if($item->appid === null && $item->class !== null) { // old apps wont have an app id so set it
|
||||
$app = Application::where('class', $item->class)->first();
|
||||
if($app) {
|
||||
$item->appid = $app->appid;
|
||||
}
|
||||
}
|
||||
$data['item'] = $item;
|
||||
$data['tags'] = Item::ofType('tag')->orderBy('title', 'asc')->pluck('title', 'id');
|
||||
$data['tags']->prepend(__('app.dashboard'), 0);
|
||||
$data['current_tags'] = $data['item']->tags();
|
||||
//$data['current_tags'] = $data['item']->parent;
|
||||
//die(print_r($data['current_tags']));
|
||||
// show the edit form and pass the nerd
|
||||
return view('items.edit', $data);
|
||||
}
|
||||
|
||||
|
||||
public function storelogic($request, $id = null)
|
||||
{
|
||||
$application = Application::single($request->input('appid'));
|
||||
@@ -238,31 +265,6 @@ class ItemController extends Controller
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
// Get the item
|
||||
$item = Item::find($id);
|
||||
if($item->appid === null && $item->class !== null) { // old apps wont have an app id so set it
|
||||
$app = Application::where('class', $item->class)->first();
|
||||
if($app) {
|
||||
$item->appid = $app->appid;
|
||||
}
|
||||
}
|
||||
$data['item'] = $item;
|
||||
$data['tags'] = Item::ofType('tag')->orderBy('title', 'asc')->pluck('title', 'id');
|
||||
$data['tags']->prepend(__('app.dashboard'), 0);
|
||||
$data['current_tags'] = $data['item']->tags();
|
||||
//$data['current_tags'] = $data['item']->parent;
|
||||
//die(print_r($data['current_tags']));
|
||||
// show the edit form and pass the nerd
|
||||
return view('items.edit', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
@@ -358,9 +360,10 @@ class ItemController extends Controller
|
||||
$app = Application::single($appid);
|
||||
$output = (array)$app;
|
||||
|
||||
$appdetails = Application::getApp($appid);
|
||||
|
||||
if((boolean)$app->enhanced === true) {
|
||||
// if(!isset($app->config)) { // class based config
|
||||
$appdetails = Application::getApp($appid);
|
||||
$output['custom'] = className($appdetails->name).'.config';
|
||||
// }
|
||||
}
|
||||
@@ -378,8 +381,8 @@ class ItemController extends Controller
|
||||
{
|
||||
$data = $request->input('data');
|
||||
//$url = $data[array_search('url', array_column($data, 'name'))]['value'];
|
||||
|
||||
$app = $data['type'];
|
||||
$single = Application::single($data['type']);
|
||||
$app = $single->class;
|
||||
|
||||
$app_details = new $app();
|
||||
$app_details->config = (object)$data;
|
||||
|
||||
@@ -8,6 +8,7 @@ use App\SettingGroup;
|
||||
use App\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SettingsController extends Controller
|
||||
{
|
||||
@@ -77,7 +78,8 @@ class SettingsController extends Controller
|
||||
$path = $request->file('value')->store('backgrounds');
|
||||
$setting_value = $path;
|
||||
}
|
||||
|
||||
} elseif ($setting->type == 'apikey') {
|
||||
$setting_value = Str::random(40);
|
||||
} else {
|
||||
$setting_value = $data->value;
|
||||
}
|
||||
|
||||
@@ -58,5 +58,6 @@ class Kernel extends HttpKernel
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
|
||||
'apikey' => \App\Http\Middleware\UserApiKey::class,
|
||||
];
|
||||
}
|
||||
|
||||
30
app/Http/Middleware/UserApiKey.php
Normal file
30
app/Http/Middleware/UserApiKey.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use \App\SettingUser;
|
||||
|
||||
class UserApiKey
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
$key = $request->input('api_key');
|
||||
$details = SettingUser::where('setting_id', 12)->where('uservalue', $key)->first();
|
||||
// die(var_dump($details));
|
||||
if($details === null) {
|
||||
return response()->json([
|
||||
'status' => 401,
|
||||
'message' => 'invalid api key'
|
||||
], 401);
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use App\Application;
|
||||
use App\SupportedApps;
|
||||
use App\Item;
|
||||
|
||||
class ProcessApps implements ShouldQueue
|
||||
{
|
||||
@@ -42,5 +43,13 @@ class ProcessApps implements ShouldQueue
|
||||
$app->save();
|
||||
}
|
||||
|
||||
$items = Item::whereNotNull('class')->get();
|
||||
foreach($items as $item) {
|
||||
if(!file_exists(app_path('SupportedApps/'.Item::nameFromClass($item->class)))) {
|
||||
$app = Application::where('class', $item->class)->first();
|
||||
Application::getApp($app->appid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,7 +134,15 @@ class Setting extends Model
|
||||
$value = Form::select('value', $options, null, ['class' => 'form-control']);
|
||||
break;
|
||||
case 'textarea':
|
||||
$value = Form::textarea('value', null, ['class' => 'form-control', 'cols' => '44', 'rows' => '15']);
|
||||
$value = Form::textarea('value', null, ['class' => 'form-control', 'cols' => '44', 'rows' => '15', 'style' => 'width: 100%;']);
|
||||
break;
|
||||
case 'apikey':
|
||||
if (isset($this->value) && !empty($this->value)) {
|
||||
$value = Form::text('value', null, ['class' => 'form-control']);
|
||||
} else {
|
||||
$value = '<div>'.$current.'</div>';
|
||||
}
|
||||
$value .= '<small style="margin-top: 10px; display: block">'.__('app.settings.click_generate').'</small>';
|
||||
break;
|
||||
default:
|
||||
$value = Form::text('value', null, ['class' => 'form-control']);
|
||||
|
||||
@@ -14,7 +14,7 @@ return [
|
||||
*/
|
||||
|
||||
'name' => env('APP_NAME', 'Heimdall'),
|
||||
'version' => '2.4.0',
|
||||
'version' => '2.5.0-beta1',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -237,6 +237,22 @@ class SettingsSeeder extends Seeder
|
||||
$setting->save();
|
||||
}
|
||||
|
||||
if(!$setting = Setting::find(12)) {
|
||||
$setting = new Setting;
|
||||
$setting->id = 12;
|
||||
$setting->group_id = 1;
|
||||
$setting->key = 'api_key';
|
||||
$setting->type = 'apikey';
|
||||
$setting->label = 'app.settings.apikey';
|
||||
$setting->value = '';
|
||||
$setting->save();
|
||||
} else {
|
||||
$setting->type = 'apikey';
|
||||
$setting->group_id = 1;
|
||||
$setting->label = 'app.settings.apikey';
|
||||
$setting->save();
|
||||
}
|
||||
|
||||
if(!$home_tag = \App\Item::find(0)) {
|
||||
$home_tag = new \App\Item;
|
||||
$home_tag->id = 0;
|
||||
|
||||
1
public/css/app.css
vendored
1
public/css/app.css
vendored
@@ -1,4 +1,3 @@
|
||||
@charset "UTF-8";
|
||||
/*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */
|
||||
html {
|
||||
font-family: sans-serif;
|
||||
|
||||
6
public/js/app.js
vendored
6
public/js/app.js
vendored
@@ -620,14 +620,14 @@ $.when($.ready).then(function () {
|
||||
drop: function( event, ui ) {
|
||||
var tag = $( this ).data('id');
|
||||
var item = $( ui.draggable ).data('id');
|
||||
$.get('tag/add/'+tag+'/'+item, function(data) {
|
||||
$.get('tag/add/'+tag+'/'+item, function(data) {
|
||||
if(data == 1) {
|
||||
$( ui.draggable ).remove();
|
||||
} else {
|
||||
alert('not added');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});*/
|
||||
|
||||
$('#sortable').sortable({
|
||||
@@ -716,7 +716,7 @@ $.when($.ready).then(function () {
|
||||
}).on('click', '#test_config', function (e) {
|
||||
e.preventDefault();
|
||||
var apiurl = $('#create input[name=url]').val();
|
||||
var override_url = $('#create input[name="config[override_url]"]').val();
|
||||
var override_url = $('#sapconfig input[name="config[override_url]"]').val();
|
||||
|
||||
if (override_url.length && override_url != '') {
|
||||
apiurl = override_url;
|
||||
|
||||
4
public/mix-manifest.json
generated
4
public/mix-manifest.json
generated
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"/css/app.css": "/css/app.css?id=bc18c3a0e8475fe00a5a",
|
||||
"/js/app.js": "/js/app.js?id=c95edea425171c6ce8f6"
|
||||
"/css/app.css": "/css/app.css?id=ad45b1705b7f7906db0b",
|
||||
"/js/app.js": "/js/app.js?id=5446aeb4aa754e641c77"
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ $.when( $.ready ).then(function() {
|
||||
e.preventDefault();
|
||||
var apiurl = $('#create input[name=url]').val();
|
||||
|
||||
var override_url = $('#create input[name="config[override_url]"]').val();
|
||||
var override_url = $('#sapconfig input[name="config[override_url]"]').val();
|
||||
if(override_url.length && override_url != '') {
|
||||
apiurl = override_url;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,9 @@ return [
|
||||
'settings.custom_css' => 'Custom CSS',
|
||||
'settings.custom_js' => 'Custom JavaScript',
|
||||
|
||||
'settings.apikey' => 'API Key',
|
||||
'settings.click_generate' => 'Clicking the save button will generate a new API key.',
|
||||
|
||||
'options.none' => '- not set -',
|
||||
'options.google' => 'Google',
|
||||
'options.ddg' => 'DuckDuckGo',
|
||||
|
||||
@@ -6,6 +6,7 @@ return array (
|
||||
'settings.miscellaneous' => 'Divers',
|
||||
'settings.support' => 'Support',
|
||||
'settings.donate' => 'Contribuer',
|
||||
'settings.advanced' => 'Options avancées',
|
||||
|
||||
'settings.version' => 'Version',
|
||||
'settings.background_image' => 'Image d\'arrière-plan',
|
||||
@@ -71,6 +72,8 @@ return array (
|
||||
'apps.preview' => 'Aperçu',
|
||||
'apps.apptype' => 'Type d\'application ',
|
||||
'apps.only_admin_account' => 'Seulement si vous avez un compte administrateur!',
|
||||
'apps.autologin_url' => 'URL de connexion automatique',
|
||||
'apps.show_deleted' => 'Afficher les applications supprimées',
|
||||
|
||||
'dashboard' => 'Tableau de bord',
|
||||
|
||||
|
||||
@@ -3,11 +3,13 @@
|
||||
?>
|
||||
<section class="item-container" data-id="">
|
||||
<div class="item set-bg-elem" style="background-color: {{ $item->colour ?? '#222' }}">
|
||||
@if(isset($item->icon) && !empty($item->icon))
|
||||
<img class="app-icon" src="{{ asset('/storage/'.$item->icon) }}" />
|
||||
@else
|
||||
<img class="app-icon" src="{{ asset('/img/heimdall-icon-small.png') }}" />
|
||||
@endif
|
||||
<div class="app-icon-container">
|
||||
@if(isset($item->icon) && !empty($item->icon))
|
||||
<img class="app-icon" src="{{ asset('/storage/'.$item->icon) }}" />
|
||||
@else
|
||||
<img class="app-icon" src="{{ asset('/img/heimdall-icon-small.png') }}" />
|
||||
@endif
|
||||
</div>
|
||||
<div class="details">
|
||||
<div class="title{{ title_color($item->colour) ?? 'white' }}">{{ $item->title ?? '' }}</div>
|
||||
@if($item->enhanced())
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
{!! Form::select('supported', \App\Item::supportedOptions(), array('placeholder' => 'Title','class' => 'form-control')) !!}
|
||||
</div>*/ ?>
|
||||
|
||||
<div class="input">
|
||||
<div class="input" style="width: 100%">
|
||||
{!! $setting->edit_value !!}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -13,3 +13,4 @@ use Illuminate\Http\Request;
|
||||
|
|
||||
*/
|
||||
|
||||
Route::resource('items', 'ApiItemController');
|
||||
Reference in New Issue
Block a user