Merge pull request #1290 from KodeStar/feature/add_columns

Add alternate tag types
This commit is contained in:
KodeStar
2024-02-18 18:35:43 +00:00
committed by GitHub
11 changed files with 141 additions and 18 deletions

View File

@@ -35,6 +35,21 @@ class ItemController extends Controller
*/ */
public function dash(): View public function dash(): View
{ {
$treat_tags_as = \App\Setting::fetch('treat_tags_as');
$data["treat_tags_as"] = $treat_tags_as;
if ($treat_tags_as == 'categories') {
$data['categories'] = Item::whereHas('children')->with('children', function ($query) {
$query->pinned()->orderBy('order', 'asc');
})->pinned()->orderBy('order', 'asc')->get();
} elseif ($treat_tags_as == 'tags') {
$data['apps'] = Item::with('parents')->where('type', 0)->pinned()->orderBy('order', 'asc')->get();
$data['all_apps'] = Item::where('type', 0)->orderBy('order', 'asc')->get();
$data['taglist'] = Item::where('type', 1)->pinned()->orderBy('order', 'asc')->get();
} else {
$data['apps'] = Item::whereHas('parents', function ($query) { $data['apps'] = Item::whereHas('parents', function ($query) {
$query->where('id', 0); $query->where('id', 0);
})->orWhere('type', 1)->pinned()->orderBy('order', 'asc')->get(); })->orWhere('type', 1)->pinned()->orderBy('order', 'asc')->get();
@@ -42,9 +57,10 @@ class ItemController extends Controller
$data['all_apps'] = Item::whereHas('parents', function ($query) { $data['all_apps'] = Item::whereHas('parents', function ($query) {
$query->where('id', 0); $query->where('id', 0);
})->orWhere('type', 1)->orderBy('order', 'asc')->get(); })->orWhere('type', 1)->orderBy('order', 'asc')->get();
}
//$data['all_apps'] = Item::doesntHave('parents')->get(); //$data['all_apps'] = Item::doesntHave('parents')->get();
//die(print_r($data['apps'])); // die(print_r($data));
return view('welcome', $data); return view('welcome', $data);
} }

View File

@@ -327,5 +327,28 @@ class SettingsSeeder extends Seeder
$app->parents()->attach(0); $app->parents()->attach(0);
} }
} }
$tag_options = json_encode([
'folders' => 'app.settings.folders',
'tags' => 'app.settings.tags',
'categories' => 'app.settings.categories',
]);
if (! $setting = Setting::find(14)) {
$setting = new Setting;
$setting->id = 14;
$setting->group_id = 2;
$setting->key = 'treat_tags_as';
$setting->type = 'select';
$setting->options = $tag_options;
$setting->value = 'folders';
$setting->label = 'app.settings.treat_tags_as';
$setting->save();
} else {
$setting->options = $tag_options;
$setting->label = 'app.settings.treat_tags_as';
$setting->save();
}
} }
} }

View File

@@ -28,6 +28,10 @@ return array (
'settings.view' => 'View', 'settings.view' => 'View',
'settings.custom_css' => 'Custom CSS', 'settings.custom_css' => 'Custom CSS',
'settings.custom_js' => 'Custom JavaScript', 'settings.custom_js' => 'Custom JavaScript',
'settings.treat_tags_as' => 'Treat Tags As:',
'settings.folders' => 'Folders',
'settings.tags' => 'Tags',
'settings.categories' => 'Categories',
'options.none' => '- not set -', 'options.none' => '- not set -',
'options.google' => 'Google', 'options.google' => 'Google',
'options.ddg' => 'DuckDuckGo', 'options.ddg' => 'DuckDuckGo',

2
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=55e02812d34a73b4386802d27fbcd6e8", "/css/app.css": "/css/app.css?id=9ac09de3efefe57251cba47c5747c556",
"/js/app.js": "/js/app.js?id=3377b9b80073713e4dc54937c94aa6ad" "/js/app.js": "/js/app.js?id=3e28afce465cda43c0b0da9d29ad69a1"
} }

View File

@@ -171,6 +171,16 @@ $.when($.ready).then(() => {
}, 350); }, 350);
} }
}) })
.on("click", ".tag", (e) => {
e.preventDefault();
const tag = $(e.target).data("tag");
$("#taglist .tag").removeClass("current");
$(e.target).addClass("current");
$("#sortable .item-container").show();
if (tag !== "all") {
$("#sortable .item-container:not(." + tag + ")").hide();
}
})
.on("click", "#add-item, #pin-item", (e) => { .on("click", "#add-item, #pin-item", (e) => {
e.preventDefault(); e.preventDefault();
const app = $("#app"); const app = $("#app");

View File

@@ -180,6 +180,22 @@ body {
list-style: none; list-style: none;
margin: 0; margin: 0;
} }
#sortable.categories {
align-items: flex-start;
.category {
margin:10px;
background-color: #00000038;
border-radius: 10px;
> .title {
padding: 20px 20px 0;
a {
color: white;
text-decoration: none;
}
}
}
}
} }
#config-buttons { #config-buttons {
position: fixed; position: fixed;
@@ -279,6 +295,9 @@ body {
z-index: 1; z-index: 1;
} }
} }
.categorytitle {
color: #fff!important;
}
.tooltip { .tooltip {
padding: 25px; padding: 25px;
border-radius: 5px; border-radius: 5px;
@@ -294,13 +313,32 @@ body {
opacity: 0; opacity: 0;
transform: translateY(-20px); transform: translateY(-20px);
transition: all 0.3s; transition: all 0.3s;
pointer-events: none;
&.active { &.active {
transform: translateY(0); transform: translateY(0);
opacity: 1; opacity: 1;
z-index: 4; z-index: 4;
} }
} }
.taglist {
display: flex;
flex-wrap: wrap;
gap: 5px;
.tag {
padding: 10px 20px;
background: rgba(0, 0, 0, 0.608);
border-radius: 6px;
font-size: 12px;
cursor: pointer;
opacity: 0.6;
&.current {
opacity: 1;
}
&:hover:not(.current) {
opacity: 0.8;
}
}
}
.tile-actions { .tile-actions {
position: absolute; position: absolute;
top: 0px; top: 0px;

View File

@@ -0,0 +1,13 @@
<?php
$treat_tags_as = \App\Setting::fetch('treat_tags_as');
?>
@if( $treat_tags_as == 'tags')
@if($taglist->first())
<div id="taglist" class="taglist">
<div class="tag white current" data-tag="all">All</div>
@foreach($taglist as $tag)
<div class="tag link{{ title_color($tag->colour) }}" style="background-color: {{ $tag->colour }}" data-tag="tag-{{ $tag->url }}">{{ $tag->title }}</div>
@endforeach
</div>
@endif
@endif

View File

@@ -1,6 +1,24 @@
<div id="sortable"> <div id="sortable" class="{{ $treat_tags_as ?? '' }}">
@if(isset($treat_tags_as) && $treat_tags_as == 'categories')
@foreach($categories as $category)
<?php $apps = $category->children; ?>
<div class="category item-container" data-name="{{ $category->title }}" data-id="{{ $category->id }}">
<div class="title"><a href="{{ $category->link }}" style="{{ $category->colour ? 'color: ' . $category->colour .';' : '' }}">{{ $category->title }}</a></div>
@foreach($apps as $app)
@include('item')
@endforeach
</div>
@endforeach
@else
@foreach($apps as $app) @foreach($apps as $app)
@include('item') @include('item')
@endforeach @endforeach
@include('add') @include('add')
@endif
</div> </div>

View File

@@ -1,9 +1,10 @@
@extends('layouts.app') @extends('layouts.app')
@section('content') @section('content')
@include('partials.taglist')
@include('partials.search') @include('partials.search')
@if($apps->first()) @if((isset($apps) && $apps->first()) || (isset($categories) && $categories->first()))
@include('sortable') @include('sortable')
@else @else
<div class="message-container2"> <div class="message-container2">