Skip to content
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

implement dashboard api for recommended files #543

Merged
merged 2 commits into from
Sep 22, 2022
Merged

Conversation

icewind1991
Copy link
Member

@icewind1991 icewind1991 commented Aug 23, 2022

@tobiasKaminsky
Copy link
Member

Bug: iconUrl must always be set, as clients cannot know via API which type it is, they cannot fall back to their placeholder.
This means that also for a folder / empty text file correctly tinted placeholder must be returned.

@AndyScherzinger AndyScherzinger changed the title implement dashboard api implement dashboard api for recommended files Sep 7, 2022
@PVince81
Copy link
Member

linter is also not happy here


return array_map(function(IRecommendation $recommendation) {
$url = $this->urlGenerator->linkToRouteAbsolute('files.viewcontroller.showFile', ['fileid' => $recommendation->getNode()->getId()]);
$icon = $this->urlGenerator->linkToRouteAbsolute('core.Preview.getPreviewByFileId', [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tobiasKaminsky do you mean we should pre-check if a preview exists, and if yes, return the preview URL and if not return the mime type icon URL instead ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, clients always need a real icon, may it be svg or png.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least in Qt/QML, this is not required as you can easily detect if the image loaded and add a fallback (e.g. mimetype icon). See e.g. https://invent.kde.org/frameworks/kirigami/-/blob/master/src/controls/Avatar.qml#L235

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But we do not have any info about the mimetype.
And sending mimetype along side, and then have clients deteminate it and show correct placeholder is way more work than directly sending the correct image.
(widgets on Android / iOS are limited in opposite to our full apps, so we cannot do too much calculation/work there)

@PVince81
Copy link
Member

@tobiasKaminsky do you happen to have a curl call handy to call this API ? (so that someone else can take over and continue without needing the full setup)

@tobiasKaminsky
Copy link
Member

CURL:

curl --request GET \
  --url 'https://server.com/ocs/v2.php/apps/dashboard/api/v1/widget-items?format=json&limit=14&widgets%5B%5D=recommendations' \
  --header 'Authorization: Basic 123123' \
  --header 'OCS-APIRequest: true' \
  --header 'format: json'

icewind1991 and others added 2 commits September 21, 2022 15:39
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
@ArtificialOwl
Copy link
Member

It seems the IRecommendation already have a value regarding the availability of a preview

@PVince81 Need to clarify if this is enough

Example of result of the ocs request:

{
  "ocs": {
    "meta": {
      "status": "ok",
      "statuscode": 200,
      "message": "OK"
    },
    "data": {
      "recommendations": [
        {
          "subtitle": "",
          "title": "Talk",
          "link": "http://nc25.local/index.php/f/411",
          "iconUrl": "http://nc25.local/index.php/apps/theming/img/core/filetypes/folder.svg?v=0",
          "sinceId": "1663763213"
        },
        {
          "subtitle": "",
          "title": "Library.jpg",
          "link": "http://nc25.local/index.php/f/406",
          "iconUrl": "http://nc25.local/index.php/core/preview?x=256&y=256&fileId=406&c=e6abee908319368e8bbdf39ea20f770e",
          "sinceId": "1663763212"
        },
[...]

Copy link
Member

@PVince81 PVince81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 awesome

@PVince81
Copy link
Member

@tobiasKaminsky can you review if this solution is now suitable for clients ? thanks

@tobiasKaminsky
Copy link
Member

This works @ArtificialOwl 👏

@PVince81 PVince81 merged commit 8b4f188 into master Sep 22, 2022
@PVince81 PVince81 deleted the dashboard-api branch September 22, 2022 10:30
@PVince81
Copy link
Member

/backport to stable25

@ChristophWurst
Copy link
Member

There was no backport @PVince81

@ChristophWurst
Copy link
Member

/backport to stable25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants