Skip to content

Conversation

@thibaut1304
Copy link
Contributor

Description

πŸ“Œ Issue :

There was no native support to display the current version and display active connection for SFTPGo from Homer.

βœ… Solution

This PR introduces a new service type SFTPGo:
    Shows the current version in the subtitle
    Shows the number of active SFTP connections
    Maintains Homer’s design philosophy: minimalist, clear, and non-intrusive

Updated customservices.md documentation with configuration instructions

πŸ”₯ Motivation

Allows you to see at a glance if there are active connections and the version of our instance

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I've read & comply with the contributing guidelines
  • I have tested my code for new features & regressions on both mobile & desktop devices, using the latest version of major browsers.
  • I have made corresponding changes to the documentation (README.md).
  • I've checked my modifications for any breaking changes, especially in the config.yml file

@thibaut1304
Copy link
Contributor Author

  1. Go to the admin portal:
    http://localhost:8888/web/admin/login
  2. In the Advanced Settings, enable:
    Allow REST API access
    Capture d'Γ©cran 2025-06-21 215246
  3. Get a bearer token and generate an API key:
export ADMIN_ACCESS_TOKEN=$(curl -s http://localhost:8888/api/v2/token -u "admin:password" | jq -r .access_token)

export ADMIN_API_KEY=$(curl -s -X POST http://localhost:8888/api/v2/apikeys \
  -H "Authorization: Bearer $ADMIN_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "admin-key", "scope": 1, "description": "API key for Homer", "admin": "admin", "expires_at": 0}' \
  | jq -r .key)

Capture d'Γ©cran 2025-06-21 215359
Capture d'Γ©cran 2025-06-21 215432

4.Then test the API:

curl -H "X-SFTPGO-API-KEY: $ADMIN_API_KEY" http://localhost:8888/api/v2/connections

curl -H "X-SFTPGO-API-KEY: $ADMIN_API_KEY" http://localhost:8888/api/v2/version

πŸ“˜ Full API documentation is available at:

http://<your-sftpgo-host>:<port>/openapi/swagger-ui

@thibaut1304
Copy link
Contributor Author

⚠️ Just a quick note: I forgot to adapt the mobile version in this PR.
I plan to add a new commit shortly to fix that. Thanks for your patience!

Copy link
Owner

@bastienwirtz bastienwirtz left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution @thibaut1304 !
I didn't know about SFTPGo, looks like a cool project.
A few minor thing and we should be good to go πŸ‘

}
try {
const response = await this.fetch("/api/v2/version", { headers });
this.versionstring = response.version || "inconnue";
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
this.versionstring = response.version || "inconnue";
this.versionstring = response.version || "unknown";

Copy link
Contributor Author

@thibaut1304 thibaut1304 Jul 2, 2025

Choose a reason for hiding this comment

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

Yes, sorry, I will be careful in the future on the new PR to put everything in English.
Fix in this commit 440160f

const response = await this.fetch("/api/v2/version", { headers });
this.versionstring = response.version || "inconnue";

const connResponse = await this.fetch("/api/v2/connections", { headers });
Copy link
Owner

Choose a reason for hiding this comment

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

could make both requests run in parallel? Using promise for exemple. This way the card would load faster, doing both request at the same time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion!
Switched to Promise.all so /version and /connections are fetched in parallel; card now renders in one RTT.
fix here : 2d7b8e3

this.versionstring = response.version || "inconnue";

const connResponse = await this.fetch("/api/v2/connections", { headers });
this.activeConnections = Array.isArray(connResponse) ? connResponse.length : null;
Copy link
Owner

Choose a reason for hiding this comment

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

If the request is successful but connResponse is not an array, does it means there is 0 connections ? If that's the case, I would suggest to change for connResponse.length : 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The /api/v2/connections route always returns an array even if there are 0 connections! I simplified it in this commit 2d7b8e3

@bastienwirtz
Copy link
Owner

Also, could you add some sample API output here : https://github.com/bastienwirtz/homer/tree/main/dummy-data#dummy-data so I can test it and add it to the demo page ? Thanks !

@thibaut1304
Copy link
Contributor Author

thibaut1304 commented Jul 2, 2025

Also, could you add some sample API output here : https://github.com/bastienwirtz/homer/tree/main/dummy-data#dummy-data so I can test it and add it to the demo page ? Thanks !

I can't get the mock server to work. I figured out from the demo page that I needed to set an endpoint: "/dummy-data/sftpgo," but even then, I can't get it to work.
Yet, I can find the information I want in the network tab!

I added the information anyway, but I couldn't test it. I'd like to know the procedure. Thank you.
278ce56

@thibaut1304 thibaut1304 requested a review from bastienwirtz July 2, 2025 13:32
Copy link
Contributor Author

@thibaut1304 thibaut1304 left a comment

Choose a reason for hiding this comment

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

This issue ('e' is defined but never used) has been fixed in commit 7db55c6.

Copy link
Owner

@bastienwirtz bastienwirtz left a comment

Choose a reason for hiding this comment

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

Thx for your patience πŸ™

One last question and we should be good to go !

Comment on lines +11 to +12
<span v-if="activeConnections !== null && !this.showUpdateAvailable">
– Active connections: {{ activeConnections }}
Copy link
Owner

Choose a reason for hiding this comment

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

The idea here is to not show the line on small screen right? why showUpdateAvailable is named like that ? It's not related to updates ? or I'm missing something ?
You may be able to reduce the message (for example, just {{ activeConnections }} connections or {{ activeConnections }} clients) to make it fit on most screen and avoid the need to have a matchMedia check.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants