Skip to content

Commit

Permalink
Merge pull request #18 from linuxserver/v1.2
Browse files Browse the repository at this point in the history
V1.2
  • Loading branch information
KodeStar authored Feb 7, 2018
2 parents a5e9954 + 1d390d7 commit 7b5bc24
Show file tree
Hide file tree
Showing 54 changed files with 1,091 additions and 155 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

storage/app/public/.DS_Store
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Release Notes

## v1.1.2 (2018-02-05)

### Added
- Translation support
- Initial "Supported" application support

### Changed
- button layout and behaviour

### Fixed
- Bottom of button too short in some browsers
- Icon not loading back in when required fields not filled in


## v1.1.0 (2018-02-05)

### Added
Expand Down
37 changes: 33 additions & 4 deletions app/Http/Controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,20 @@ public function store(Request $request)
'icon' => $path
]);
}

$config = json_encode($request->input('config'));
if($config) {
$request->merge([
'description' => $config
]);
}

//die(print_r($request->input('config')));

Item::create($request->all());

return redirect()->route('dash')
->with('success','Item created successfully');
->with('success', __('alert.success.item_created'));
}

/**
Expand Down Expand Up @@ -197,7 +206,7 @@ public function update(Request $request, $id)
Item::find($id)->update($request->all());

return redirect()->route('dash')
->with('success','Item updated successfully');
->with('success',__('alert.success.item_updated'));
}

/**
Expand All @@ -219,7 +228,7 @@ public function destroy(Request $request, $id)
}

return redirect()->route('items.index')
->with('success','Item deleted successfully');
->with('success',__('alert.success.item_deleted'));
}

/**
Expand All @@ -235,6 +244,26 @@ public function restore($id)
->where('id', $id)
->restore();
return redirect()->route('items.index')
->with('success','Item restored successfully');
->with('success',__('alert.success.item_restored'));
}

/**
* Return details for supported apps
*
* @return Json
*/
public function appload(Request $request)
{
$app = $request->input('app');
if($app) {
$all_supported = Item::supportedList();
$app_details = new $all_supported[$app];
}
$output['icon'] = $app_details->icon();
$output['colour'] = $app_details->defaultColour();
$output['config'] = $app_details->configDetails();
return json_encode($output);
}


}
8 changes: 4 additions & 4 deletions app/Http/Controllers/SettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function edit($id)
]);
} else {
return redirect()->route('settings.list')->with([
'error' => 'This Setting does not exist.',
'error' => __('app.alert.error.not_exist'),
]);
}
}
Expand Down Expand Up @@ -74,11 +74,11 @@ public function update(Request $request, $id)
$setting->save();

return redirect()->route('settings.index')->with([
'success' => 'You have successfully edited this Setting!',
'success' => __('app.alert.success.setting_updated'),
]);
} else {
return redirect()->route('settings.index')->with([
'error' => 'This Setting does not exist.',
'error' => __('app.alert.error.not_exist'),
]);
}
}
Expand All @@ -95,7 +95,7 @@ public function clear($id)
$setting->save();
}
return redirect()->route('settings.index')->with([
'success' => 'You have successfully edited this Setting!',
'success' => __('app.alert.success.setting_updated'),
]);

}
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class VerifyCsrfToken extends Middleware
*/
protected $except = [
//
'order'
'order',
'appload'
];
}
25 changes: 23 additions & 2 deletions app/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ class Item extends Model
public static function supportedList()
{
return [
'NZBGet' => App\SupportedApps\Nzbget::class,
'Plex' => App\SupportedApps\Plex::class,
'Duplicati' => \App\SupportedApps\Duplicati::class,
'Emby' => \App\SupportedApps\Emby::class,
'NZBGet' => \App\SupportedApps\Nzbget::class,
'pFsense' => \App\SupportedApps\Pfsense::class,
'Pihole' => \App\SupportedApps\Pihole::class,
'Plex' => \App\SupportedApps\Plex::class,
'UniFi' => \App\SupportedApps\Unifi::class,
'Portainer' => \App\SupportedApps\Portainer::class,
];
}
public static function supportedOptions()
Expand All @@ -45,4 +51,19 @@ public function scopePinned($query)
{
return $query->where('pinned', 1);
}

public function getConfigAttribute()
{
$output = null;
if(isset($this->description) && !empty($this->description)){
$output = json_decode($this->description);
if(isset($output->type) && !empty($output->type)) {
$class = $output->type;
$sap = new $class();
$view = $sap->configDetails();
}
$output->view = $view;
}
return (object)$output;
}
}
3 changes: 3 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function boot()
} else {
Artisan::call('migrate', array('--path' => 'database/migrations', '--force' => true, '--seed' => true));
}
$lang = Setting::fetch('language');
\App::setLocale($lang);

}
view()->share('alt_bg', $alt_bg);

Expand Down
29 changes: 18 additions & 11 deletions app/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class Setting extends Model
*/
protected $table = 'settings';

protected $fillable = [
'id', 'group_id', 'key', 'type', 'options', 'label', 'value', 'order', 'system'
];

/**
* Tell the Model this Table doesn't support timestamps.
*
Expand Down Expand Up @@ -45,28 +49,28 @@ public function getListValueAttribute()
switch($this->type) {
case 'image':
if(!empty($this->value)) {
$value = '<a href="'.asset('storage/'.$this->value).'" title="View" target="_blank">View</a>';
$value = '<a href="'.asset('storage/'.$this->value).'" title="'.__('app.settings.view').'" target="_blank">'.__('app.settings.view').'</a>';
} else {
$value = '- not set -';
$value = __('app.options.none');
}
break;
case 'boolean':
if((bool)$this->value === true) {
$value = 'Yes';
$value = __('app.options.yes');
} else {
$value = 'No';
$value = __('app.options.no');
}
break;
case 'select':
if(!empty($this->value) && $this->value !== 'none') {
$options = (array)json_decode($this->options);
$value = $options[$this->value];
$value = __($options[$this->value]);
} else {
$value = '- not set -';
$value = __('app.options.none');
}
break;
default:
$value = $this->value;
$value = __($this->value);
break;
}

Expand All @@ -80,11 +84,11 @@ public function getEditValueAttribute()
case 'image':
$value = '';
if(isset($this->value) && !empty($this->value)) {
$value .= '<a class="setting-view-image" href="'.asset('storage/'.$this->value).'" title="View" target="_blank"><img src="'.asset('storage/'.$this->value).'" /></a>';
$value .= '<a class="setting-view-image" href="'.asset('storage/'.$this->value).'" title="'.__('app.settings.view').'" target="_blank"><img src="'.asset('storage/'.$this->value).'" /></a>';
}
$value .= Form::file('value', ['class' => 'form-control']);
if(isset($this->value) && !empty($this->value)) {
$value .= '<a class="settinglink" href="'.route('settings.clear', $this->id).'" title="Remove">Reset back to default</a>';
$value .= '<a class="settinglink" href="'.route('settings.clear', $this->id).'" title="'.__('app.settings.remove').'">'.__('app.settings.reset').'</a>';
}

break;
Expand All @@ -102,6 +106,9 @@ public function getEditValueAttribute()
break;
case 'select':
$options = json_decode($this->options);
foreach($options as $key => $opt) {
$options->$key = __($opt);
}
$value = Form::select('value', $options, null, ['class' => 'form-control']);
break;
default:
Expand Down Expand Up @@ -199,8 +206,8 @@ public static function search()
$output .= '<div class="searchform">';
$output .= Form::open(['url' => $url, 'method' => 'get']);
$output .= '<div class="input-container">';
$output .= Form::text($var, null, ['class' => 'homesearch', 'placeholder' => $name.' search...']);
$output .= '<button type="submit">Search</button>';
$output .= Form::text($var, null, ['class' => 'homesearch', 'placeholder' => __($name).' '.__('app.settings.search').'...']);
$output .= '<button type="submit">'.ucwords(__('app.settings.search')).'</button>';
$output .= '</div>';
$output .= Form::close();
$output .= '</div>';
Expand Down
4 changes: 4 additions & 0 deletions app/SupportedApps/Contracts/Applications.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
interface Applications {

public function defaultColour();

public function icon();

public function configDetails();

}
16 changes: 16 additions & 0 deletions app/SupportedApps/Duplicati.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php namespace App\SupportedApps;

class Duplicati implements Contracts\Applications {
public function defaultColour()
{
return '#222';
}
public function icon()
{
return 'supportedapps/duplicati.png';
}
public function configDetails()
{
return null;
}
}
16 changes: 16 additions & 0 deletions app/SupportedApps/Emby.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php namespace App\SupportedApps;

class Emby implements Contracts\Applications {
public function defaultColour()
{
return '#222';
}
public function icon()
{
return 'supportedapps/emby.png';
}
public function configDetails()
{
return null;
}
}
13 changes: 12 additions & 1 deletion app/SupportedApps/Nzbget.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<?php namespace App\SupportedApps;

class Nzbget implements Contracts\Applications {

public function defaultColour()
{
return '#ccc';
return '#124019';
}
public function icon()
{
return 'supportedapps/nzbget.png';
}
public function configDetails()
{
//return 'nzbget';
return null;
}

}
16 changes: 16 additions & 0 deletions app/SupportedApps/Pfsense.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php namespace App\SupportedApps;

class Pfsense implements Contracts\Applications {
public function defaultColour()
{
return '#222';
}
public function icon()
{
return 'supportedapps/pfsense.png';
}
public function configDetails()
{
return null;
}
}
16 changes: 16 additions & 0 deletions app/SupportedApps/Pihole.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php namespace App\SupportedApps;

class Pihole implements Contracts\Applications {
public function defaultColour()
{
return '#222';
}
public function icon()
{
return 'supportedapps/pihole.png';
}
public function configDetails()
{
return null;
}
}
10 changes: 9 additions & 1 deletion app/SupportedApps/Plex.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
class Plex implements Contracts\Applications {
public function defaultColour()
{
return '#ccc';
return '#222';
}
public function icon()
{
return 'supportedapps/plex.png';
}
public function configDetails()
{
return null;
}
}
Loading

0 comments on commit 7b5bc24

Please sign in to comment.