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

feat(manager): move and update metrics cards in the server view #2241

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

daniellacosse
Copy link
Contributor

@daniellacosse daniellacosse commented Oct 14, 2024

Screenshot 2024-10-16 at 2 03 59 PM

TODOs:

  • access key tab
  • localize strings
  • add api call to server (not finalized)

@@ -161,6 +161,28 @@ export class ShadowboxServer implements server.Server {
return usageMap;
}

async getTunnelTimeByLocation(): Promise<server.TunnelTimeSecondsByLocation> {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be implemented once we finalize the endpoint in this PR: Jigsaw-Code/outline-server#1581

@daniellacosse daniellacosse requested a review from sbruens October 16, 2024 18:07
@daniellacosse daniellacosse changed the title feat(manager): move and update metrics cards in the server view feat(manager): [MISSING ENDPOINT] move and update metrics cards in the server view Oct 16, 2024
@daniellacosse daniellacosse marked this pull request as ready for review October 16, 2024 18:08
@daniellacosse daniellacosse requested review from fortuna and a team as code owners October 16, 2024 18:08
@daniellacosse daniellacosse changed the title feat(manager): [MISSING ENDPOINT] move and update metrics cards in the server view feat(manager): [MISSING ENDPOINT - DO NOT MERGE] move and update metrics cards in the server view Oct 16, 2024
Copy link
Collaborator

@fortuna fortuna left a comment

Choose a reason for hiding this comment

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

This is very helpful to see how the API is used. I believe we will benefit a lot from merging the stats flows into one.

server_manager/index.html Outdated Show resolved Hide resolved
server_manager/messages/master_messages.json Show resolved Hide resolved
server_manager/messages/master_messages.json Show resolved Hide resolved
server_manager/model/server.ts Outdated Show resolved Hide resolved
server_manager/www/app.ts Outdated Show resolved Hide resolved
server_manager/www/app.ts Outdated Show resolved Hide resolved
@daniellacosse daniellacosse force-pushed the daniellacosse/tunneltime/move_metrics branch from 55108a4 to ee8c388 Compare November 12, 2024 16:09
@github-actions github-actions bot added size/L and removed size/M labels Nov 12, 2024
Copy link
Contributor Author

@daniellacosse daniellacosse left a comment

Choose a reason for hiding this comment

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

Updated with the new endpoint JSON: will merge methods next

server_manager/messages/master_messages.json Show resolved Hide resolved
server_manager/messages/master_messages.json Show resolved Hide resolved
server_manager/www/app.ts Outdated Show resolved Hide resolved
Copy link
Collaborator

@fortuna fortuna left a comment

Choose a reason for hiding this comment

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

As discussed offline, Per-ASN breakdown was a significant gap during the Iran crisis. It's a confirmed need and and we put a lot of effort to implement it. It's more of a question of how, not whether we want to surface that.

I would like to see that surfaced somehow in this PR, to inform the UX design. We've discussed a simple table, which seems to work well.

@daniellacosse
Copy link
Contributor Author

As discussed offline, Per-ASN breakdown was a significant gap during the Iran crisis. It's a confirmed need and and we put a lot of effort to implement it. It's more of a question of how, not whether we want to surface that.

I would like to see that surfaced somehow in this PR, to inform the UX design. We've discussed a simple table, which seems to work well.

Sure thing, working on it!

@daniellacosse
Copy link
Contributor Author

As discussed offline, Per-ASN breakdown was a significant gap during the Iran crisis. It's a confirmed need and and we put a lot of effort to implement it. It's more of a question of how, not whether we want to surface that.

I would like to see that surfaced somehow in this PR, to inform the UX design. We've discussed a simple table, which seems to work well.

Here's an initial PR for a data table component: #2273

@daniellacosse daniellacosse changed the title feat(manager): [MISSING ENDPOINT - DO NOT MERGE] move and update metrics cards in the server view feat(manager): move and update metrics cards in the server view Nov 21, 2024
@daniellacosse daniellacosse requested a review from fortuna December 4, 2024 19:04
server_manager/index.html Outdated Show resolved Hide resolved
server_manager/model/server.ts Outdated Show resolved Hide resolved
@@ -168,6 +168,34 @@ export class FakeServer implements server.Server {
getDataUsage() {
return Promise.resolve(new Map<server.AccessKeyId, number>());
}
getServerMetrics() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps throw an error instead. The tests should define what to return instead.

Copy link
Contributor Author

@daniellacosse daniellacosse Dec 10, 2024

Choose a reason for hiding this comment

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

Just to be clear - by extending this mock and overriding the method? Or via injection?

Copy link
Contributor

Choose a reason for hiding this comment

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

On that note, I'd like to see some tests for the 2 scenarios (supported and unsupported), probably in app.spec.ts?

server_manager/www/app.ts Outdated Show resolved Hide resolved
);

return result;
} catch (e) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't fall back on every error. We should pick an API based on the server capability.
An improvement would be to fallback only on 404 errors, but that still means two requests for every update call in the non experimental case. It should be one.

We need a mechanism that will allow for a single request on the non experimental case.

One approach would be using streaming requests or websockets, then the 404 would be ok, because it's only once for all updates.
Perhaps we query in the constructor?
Or it comes in the server config?

@sbruens for thoughts

Copy link
Contributor Author

@daniellacosse daniellacosse Dec 10, 2024

Choose a reason for hiding this comment

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

I feel like testing for "experimental features" in the constructor would be the simplest? If an experimental endpoint 404s in the constructor test, set a flag for that endpoint to false. Then we don't have to change the server while minimizing the number of requests in the manager.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry missed this thread until now. Constructor test works for now. 👍

server_manager/messages/master_messages.json Show resolved Hide resolved
server_manager/messages/master_messages.json Show resolved Hide resolved
server_manager/index.html Outdated Show resolved Hide resolved
{
icon: 'timer',
name: this.localize('server-metrics-user-hours'),
units: this.localize('server-metrics-user-hours-unit'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not really how we should be formatting units. Use the standard libraries instead: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#unit_2

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think we need a follow up PR that fixes this and breaks out the units that are baked into the messages (e.g. / last 30 days) as mentioned above. It just needs to be rethought, as I assumed relying on the localizer was enough. I'll make a ticket for it, fair?


let totalUserHours = 0;
for (const {tunnelTime} of serverMetrics.server) {
// convert to hours
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Kind of a pointless comment tbh given the naming of the variables. If it is unclear, prefer to make 60*60 self-documenting, then you won't need the comment. Something like:

const HOUR_IN_SECS = 60 * 60;

...

totalUserHours += tunnelTime.seconds / HOUR_IN_SECS;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ha, I think this comment was provided by Gemini. I'll make it self-documenting.

);

return result;
} catch (e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry missed this thread until now. Constructor test works for now. 👍

@@ -168,6 +168,34 @@ export class FakeServer implements server.Server {
getDataUsage() {
return Promise.resolve(new Map<server.AccessKeyId, number>());
}
getServerMetrics() {
Copy link
Contributor

Choose a reason for hiding this comment

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

On that note, I'd like to see some tests for the 2 scenarios (supported and unsupported), probably in app.spec.ts?

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

Successfully merging this pull request may close these issues.

3 participants