Skip to content

Commit

Permalink
Merge pull request #99 from linuxserver/v1.4
Browse files Browse the repository at this point in the history
V1.4
  • Loading branch information
KodeStar authored Feb 18, 2018
2 parents 90e613a + 38f8143 commit a7563ab
Show file tree
Hide file tree
Showing 35 changed files with 5,623 additions and 33 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Release Notes

## v1.4.0 (2018-02-18)

### Added
- Tag(folder) support
- Image preview for uploading icons
- A load of supported apps, full list of apps https://github.com/linuxserver/Heimdall/projects/1

### Changed
- Edited vendor/laravelcollective/html/src/FormBuilder.php to allow relative links #3369de9
- Changed links to use relative links for reverse proxy support
- Links open in new tab

### Fixed
- adds all the fixes in the 1.3.x point releases and on master

## v1.3.0 (2018-02-09)

### Added
Expand Down
27 changes: 17 additions & 10 deletions app/Http/Controllers/ItemController.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class ItemController extends Controller
*/
public function dash()
{
$data['apps'] = Item::pinned()->orderBy('order', 'asc')->get();
$data['all_apps'] = Item::all();
$data['apps'] = Item::doesntHave('parents')->pinned()->orderBy('order', 'asc')->get();
$data['all_apps'] = Item::doesntHave('parents')->get();
return view('welcome', $data);
}

Expand Down Expand Up @@ -95,8 +95,8 @@ public function index(Request $request)
{
$trash = (bool)$request->input('trash');

$data['apps'] = Item::orderBy('title', 'asc')->get();
$data['trash'] = Item::onlyTrashed()->get();
$data['apps'] = Item::ofType('item')->orderBy('title', 'asc')->get();
$data['trash'] = Item::ofType('item')->onlyTrashed()->get();
if($trash) {
return view('items.trash', $data);
} else {
Expand All @@ -113,7 +113,8 @@ public function index(Request $request)
public function create()
{
//
$data = [];
$data['tags'] = Item::ofType('tag')->orderBy('title', 'asc')->pluck('title', 'id');
$data['current_tags'] = [];
return view('items.create', $data);

}
Expand Down Expand Up @@ -146,7 +147,9 @@ public function store(Request $request)

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

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

$item->parents()->sync($request->tags);

return redirect()->route('dash')
->with('success', __('app.alert.success.item_created'));
Expand All @@ -172,11 +175,12 @@ public function show($id)
public function edit($id)
{
// Get the item
$item = Item::find($id);
$data['item'] = Item::find($id);
$data['tags'] = Item::ofType('tag')->orderBy('title', 'asc')->pluck('title', 'id');
$data['current_tags'] = $data['item']->parents;

// show the edit form and pass the nerd
return view('items.edit')
->with('item', $item);
return view('items.edit', $data);
}

/**
Expand Down Expand Up @@ -205,7 +209,10 @@ public function update(Request $request, $id)
'description' => $config
]);

Item::find($id)->update($request->all());
$item = Item::find($id);
$item->update($request->all());

$item->parents()->sync($request->tags);

return redirect()->route('dash')
->with('success',__('app.alert.success.item_updated'));
Expand Down
189 changes: 189 additions & 0 deletions app/Http/Controllers/TagController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\Item;
use DB;

class TagController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Request $request)
{
$trash = (bool)$request->input('trash');

$data['apps'] = Item::ofType('tag')->orderBy('title', 'asc')->get();
$data['trash'] = Item::ofType('tag')->onlyTrashed()->get();
if($trash) {
return view('tags.trash', $data);
} else {
return view('tags.list', $data);
}
}

/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$data = [];
return view('tags.create', $data);
}

/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$validatedData = $request->validate([
'title' => 'required|max:255',
]);

if($request->hasFile('file')) {
$path = $request->file('file')->store('icons');
$request->merge([
'icon' => $path
]);
}

$slug = str_slug($request->title, '-');

// set item type to tag
$request->merge([
'type' => '1',
'url' => $slug
]);
//die(print_r($request->all()));
Item::create($request->all());

return redirect()->route('dash')
->with('success', __('app.alert.success.tag_created'));
}

/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($slug)
{
$item = Item::whereUrl($slug)->first();
//print_r($item);
$data['apps'] = $item->children()->pinned()->orderBy('order', 'asc')->get();
$data['all_apps'] = $item->children;
return view('welcome', $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);

// show the edit form and pass the nerd
return view('tags.edit')
->with('item', $item);
}

/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
$validatedData = $request->validate([
'title' => 'required|max:255',
]);

if($request->hasFile('file')) {
$path = $request->file('file')->store('icons');
$request->merge([
'icon' => $path
]);
}

$slug = str_slug($request->title, '-');
// set item type to tag
$request->merge([
'url' => $slug
]);

Item::find($id)->update($request->all());

return redirect()->route('dash')
->with('success',__('app.alert.success.tag_updated'));
}

/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy(Request $request, $id)
{
//
$force = (bool)$request->input('force');
if($force) {
Item::withTrashed()
->where('id', $id)
->forceDelete();
} else {
Item::find($id)->delete();
}

return redirect()->route('tags.index')
->with('success',__('app.alert.success.item_deleted'));
}

/**
* Restore the specified resource from soft deletion.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function restore($id)
{
//
Item::withTrashed()
->where('id', $id)
->restore();
return redirect()->route('tags.index')
->with('success',__('app.alert.success.item_restored'));
}

public function add($tag, $item)
{
$output = 0;
$tag = Item::find($tag);
$item = Item::find($item);
if($tag && $item) {
// only add items, not cats
if((int)$item->type === 0) {
$tag->children()->attach($item);
return 1;
}
}
return $output;
}

}
71 changes: 70 additions & 1 deletion app/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Item extends Model

//
protected $fillable = [
'title', 'url', 'colour', 'icon', 'description', 'pinned', 'order'
'title', 'url', 'colour', 'icon', 'description', 'pinned', 'order', 'type'
];

/**
Expand Down Expand Up @@ -116,4 +116,73 @@ public static function checkConfig($config)
return $config;

}

public function parents()
{
return $this->belongsToMany('App\Item', 'item_tag', 'item_id', 'tag_id');
}
public function children()
{
return $this->belongsToMany('App\Item', 'item_tag', 'tag_id', 'item_id');
}

public function getLinkAttribute()
{
if((int)$this->type === 1) {
return '/tag/'.$this->url;
} else {
return $this->url;
}
}

public function getDroppableAttribute()
{
if((int)$this->type === 1) {
return ' droppable';
} else {
return '';
}
}

public function getTargetAttribute()
{
if((int)$this->type === 1) {
return '';
} else {
return ' target="_blank"';
}
}

public function getLinkIconAttribute()
{
if((int)$this->type === 1) {
return 'fa-tag';
} else {
return 'fa-arrow-alt-to-right';
}
}
public function getLinkTypeAttribute()
{
if((int)$this->type === 1) {
return 'tags';
} else {
return 'items';
}
}

public function scopeOfType($query, $type)
{
switch($type) {
case 'item':
$typeid = 0;
break;
case 'tag':
$typeid = 1;
break;
}

return $query->where('type', $typeid);
}


}
2 changes: 1 addition & 1 deletion app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function boot()
if(is_file(database_path('app.sqlite'))) {
if(Schema::hasTable('settings')) {
if($bg_image = Setting::fetch('background_image')) {
$alt_bg = ' style="background-image: url('.asset('storage/'.$bg_image).')"';
$alt_bg = ' style="background-image: url(/storage/'.$bg_image.')"';
}

// check version to see if an upgrade is needed
Expand Down
2 changes: 1 addition & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

'name' => env('APP_NAME', 'Heimdall'),
'version' => '1.3.4',
'version' => '1.4.0',

/*
|--------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit a7563ab

Please sign in to comment.