feat: support the listing of private apps

This commit is contained in:
Attila Kerekes 2022-10-28 13:21:25 +00:00
parent 6907695c5d
commit fe0109494e
2 changed files with 18 additions and 1 deletions

View file

@ -5,6 +5,7 @@ namespace App\Console\Commands;
use App\Application; use App\Application;
use App\SupportedApps; use App\SupportedApps;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Support\Facades\Storage;
class RegisterApp extends Command class RegisterApp extends Command
{ {
@ -65,6 +66,7 @@ class RegisterApp extends Command
} else { } else {
// Doesn't exist so add it // Doesn't exist so add it
SupportedApps::saveApp($app, new Application); SupportedApps::saveApp($app, new Application);
$this->saveIcon($folder, $app->icon);
$this->info('Application Added - '.$app->name.' - '.$app->appid); $this->info('Application Added - '.$app->name.' - '.$app->appid);
} }
} else { } else {
@ -74,4 +76,10 @@ class RegisterApp extends Command
$this->error('Could not find '.$json); $this->error('Could not find '.$json);
} }
} }
private function saveIcon($appFolder, $icon) {
$iconPath = app_path('SupportedApps/' . $appFolder . '/' . $icon);
$contents = file_get_contents($iconPath);
Storage::disk('public')->put('icons/'.$icon, $contents);
}
} }

View file

@ -209,6 +209,11 @@ class ItemController extends Controller
$icon .= '.'.$path_parts['extension']; $icon .= '.'.$path_parts['extension'];
} }
$path = 'icons/'.$icon; $path = 'icons/'.$icon;
// Private apps could have here duplicated icons folder
if (strpos($path, 'icons/icons/') !== false) {
$path = str_replace('icons/icons/','icons/',$path);
}
Storage::disk('public')->put($path, $contents); Storage::disk('public')->put($path, $contents);
$request->merge([ $request->merge([
'icon' => $path, 'icon' => $path,
@ -377,9 +382,13 @@ class ItemController extends Controller
} }
$output['colour'] = ($app->tile_background == 'light') ? '#fafbfc' : '#161b1f'; $output['colour'] = ($app->tile_background == 'light') ? '#fafbfc' : '#161b1f';
if(strpos($app->icon, 'icons/') !== false) {
if(strpos($app->icon, '://') !== false) {
$output['iconview'] = $app->icon;
} elseif(strpos($app->icon, 'icons/') !== false) {
// Private apps have the icon locally // Private apps have the icon locally
$output['iconview'] = URL::to('/').'/storage/'.$app->icon; $output['iconview'] = URL::to('/').'/storage/'.$app->icon;
$output['icon'] = str_replace('icons/', '', $output['icon']);
} else { } else {
$output['iconview'] = config('app.appsource').'icons/'.$app->icon; $output['iconview'] = config('app.appsource').'icons/'.$app->icon;
} }