-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Favorite feature #117
base: viewmodes
Are you sure you want to change the base?
Favorite feature #117
Conversation
19dfc74
to
942c6cd
Compare
ea8dcfc
to
3f467af
Compare
af500ea
to
570585b
Compare
f56cd0b
to
f0d7090
Compare
] | ||
); | ||
} | ||
} catch (\Exception $e) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Always catch Throwable
and import it.
); | ||
} | ||
} catch (\Exception $e) { | ||
die($e->getMessage()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log and rethrow.
} catch (\Exception $e) { | ||
die($e->getMessage()); | ||
} | ||
$this->getResponse()->setHeader('X-Icinga-Container', 'ignore', true)->sendResponse(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why sendResponse()
? A little comment block about the 3 lines explaining their purpose would be great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed superfluous sendResponse()
and disableLayout()
.
])); | ||
} | ||
|
||
public function createRelations(Relations $relations) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed as it's empty.
@@ -110,6 +114,28 @@ protected function assembleTitle(BaseHtmlElement $title): void | |||
|
|||
protected function assembleVisual(BaseHtmlElement $visual): void | |||
{ | |||
$visual->addHtml(new StateBall('none', StateBall::SIZE_MEDIUM)); | |||
$size = match ($this->getViewMode()) { | |||
ViewModeSwitcher::VIEW_MODE_MINIMAL, ViewModeSwitcher::VIEW_MODE_COMMON => 'sm', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would split the lines here.
|
||
protected $tag = 'span'; | ||
|
||
public function __construct(string $state) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use constructor property promotion everywhere.
@@ -94,8 +97,42 @@ public function indexAction(): void | |||
$this->addControl($viewModeSwitcher); | |||
$this->addControl($searchBar); | |||
|
|||
$favorites = Favorite::on(Database::connection())->execute(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to call execute()
. Also for the other places in this file. Do you know why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It also loads every favorite for every resource type. This is not good. The implementation should be changed so that the favorites can be differentiated per resource type. This would allow favorites to be loaded as follows:
SELECT * FROM pod WHERE pod.uuid IN (SELECT resource_uuid FROM favorite WHERE kind = "pod") AND ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
execute()
is not necessary because ::on()
returns a Query
which implements IteratorAggregate
. The implemented method getIterator()
executes the query.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the sql statement, I think we could also do it as follows, so we don't have to change the schema and save the kind:
SELECT * FROM favorite WHERE favorite.reference_uuid IN (SELECT uuid FROM pod) AND ...
Would like to hear your opinion.
$favoriteResources = $modelClass::on(Database::connection()) | ||
->filter( | ||
Filter::all( | ||
$filter, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filter for username missing, right?
->execute(); | ||
} else { | ||
// Get empty ResultSet, otherwise all resources would be displayed as favorites | ||
$favoriteResources = $modelClass::on(Database::connection())->filter(Filter::equal('uuid', 0))->execute(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you add the favorites HTML if there are no favorites?
This PR introduces the ability to mark resources as favorites in the resource lists. A star icon appears when hovering over a list item, allowing users to toggle resources as favorites. Once a favorite is added, a new list with the favorites is displayed above the main resource list, with the star icon permanently visible for these items. Favorites are stored per user. Additionally to resource uuid and username the resource's kind is stored to optimize database queries.
Planned features:
Closes #107