fix pin toggle and get homepage dash working

This commit is contained in:
Kode 2019-06-13 18:59:01 +01:00
parent e452d3b5f6
commit 21b1ef5e4b
13 changed files with 6435 additions and 18 deletions

View file

@ -13,6 +13,7 @@ use Illuminate\Support\Facades\Storage;
use App\SupportedApps;
use App\Jobs\ProcessApps;
use App\Search;
use Illuminate\Support\Facades\Route;
class ItemController extends Controller
{
@ -88,14 +89,19 @@ class ItemController extends Controller
*
* @return \Illuminate\Http\Response
*/
public function pinToggle($id, $ajax=false)
public function pinToggle($id, $ajax=false, $tag=false)
{
$item = Item::findOrFail($id);
$new = ((bool)$item->pinned === true) ? false : true;
$item->pinned = $new;
$item->save();
if($ajax) {
$data['apps'] = Item::pinned()->get();
if(is_numeric($tag) && $tag > 0) {
$item = Item::whereId($tag)->first();
$data['apps'] = $item->children()->pinned()->orderBy('order', 'asc')->get();
} else {
$data['apps'] = Item::pinned()->orderBy('order', 'asc')->get();
}
$data['ajax'] = true;
return view('sortable', $data);
} else {

View file

@ -90,6 +90,7 @@ class TagController extends Controller
$item = Item::whereUrl($slug)->first();
//print_r($item);
$data['apps'] = $item->children()->pinned()->orderBy('order', 'asc')->get();
$data['tag'] = $item->id;
$data['all_apps'] = $item->children;
return view('welcome', $data);
}

View file

@ -20,7 +20,7 @@ class Item extends Model
static::addGlobalScope('user_id', function (Builder $builder) {
$current_user = User::currentUser();
$builder->where('user_id', $current_user->id);
$builder->where('user_id', $current_user->id)->orWhere('user_id', 0);
});
}

View file

@ -14,7 +14,7 @@ return [
*/
'name' => env('APP_NAME', 'Heimdall'),
'version' => '2.2.0',
'version' => '2.2.1',
/*
|--------------------------------------------------------------------------

View file

@ -198,9 +198,17 @@ class SettingsSeeder extends Seeder
$home_tag = new \App\Item;
$home_tag->id = 0;
$home_tag->title = 'app.dashboard';
$home_tag->pinned = 1;
$home_tag->pinned = 0;
$home_tag->url = '';
$home_tag->type = 1;
$home_tag->user_id = 0;
$home_tag->save();
$homeapps = \App\Item::withoutGlobalScope('user_id')->doesntHave('parents')->get();
foreach($homeapps as $app) {
if($app->id === 0) continue;
$app->parents()->attach(0);
}
}
}

View file

@ -13,7 +13,9 @@
"bootstrap-sass": "^3.4.1",
"cross-env": "^5.2.0",
"jquery": "^3.4.1",
"laravel-mix": "^4.0.16"
"laravel-mix": "^4.0.16",
"sass": "^1.21.0",
"sass-loader": "7.*"
},
"dependencies": {
"select2": "^4.0.7"

5
public/css/app.css vendored

File diff suppressed because one or more lines are too long

2
public/js/app.js vendored

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
{
"/css/app.css": "/css/app.css?id=c067b0b68e4516e903e1",
"/js/app.js": "/js/app.js?id=8dc4a6ea723d0df7469d"
"/css/app.css": "/css/app.css?id=62b46d36567ec0e3418f",
"/js/app.js": "/js/app.js?id=d8215a9716aec5f9e409"
}

View file

@ -182,7 +182,8 @@ $.when( $.ready ).then(function() {
e.preventDefault();
var current = $(this);
var id = current.data('id');
$.get('items/pintoggle/'+id+'/true', function(data) {
var tag = current.data('tag');
$.get('/items/pintoggle/'+id+'/true/'+tag, function(data) {
var inner = $(data).filter('#sortable').html();
$('#sortable').html(inner);
current.toggleClass('active');

View file

@ -26,7 +26,7 @@
<meta name="theme-color" content="#ffffff">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="{{ asset('css/app.css') }}" type="text/css" />
<link rel="stylesheet" href="{{ asset('css/app.css?v=2') }}" type="text/css" />
<script src="{{ asset('js/fontawesome.js') }}"></script>
</head>
<body>
@ -40,7 +40,7 @@
<?php
$active = ((bool)$app->pinned === true) ? 'active' : '';
?>
<li>{{ $app->title }}<a class="{{ $active }}" data-id="{{ $app->id }}" href="{{ route('items.pintoggle', [$app->id], false) }}"><i class="fas fa-thumbtack"></i></a></li>
<li>{{ $app->title }}<a class="{{ $active }}" data-tag="{{ $tag ?? 0 }}" data-id="{{ $app->id }}" href="{{ route('items.pintoggle', [$app->id], false, false) }}"><i class="fas fa-thumbtack"></i></a></li>
@endforeach
</ul>
@ -105,7 +105,7 @@
</div>
<script src="{{ asset('js/jquery-3.3.1.min.js') }}"></script>
<script src="{{ asset('js/jquery-ui.min.js') }}"></script>
<script src="{{ asset('js/app.js?v=2') }}"></script>
<script src="{{ asset('js/app.js?v=4') }}"></script>
@yield('scripts')
</body>

View file

@ -35,7 +35,7 @@ Route::get('tag/restore/{id}', 'TagController@restore')->name('tags.restore');
Route::get('items/pin/{id}', 'ItemController@pin')->name('items.pin');
Route::get('items/restore/{id}', 'ItemController@restore')->name('items.restore');
Route::get('items/unpin/{id}', 'ItemController@unpin')->name('items.unpin');
Route::get('items/pintoggle/{id}/{ajax?}', 'ItemController@pinToggle')->name('items.pintoggle');
Route::get('items/pintoggle/{id}/{ajax?}/{tag?}', 'ItemController@pinToggle')->name('items.pintoggle');
Route::post('order', 'ItemController@setOrder')->name('items.order');
Route::post('appload', 'ItemController@appload')->name('appload');

6400
yarn.lock Normal file

File diff suppressed because it is too large Load diff