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

New helper nodeName to allow centralized formatting of hostnames #6

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

mruettgers
Copy link

This PR adds a new helper "nodeName" to allow a centralized handling of extra long or empty hostnames.
Long node names will be trimmed to avoid layout issues, empty node names will be replaced with the node id in square brackets.

…xtra-long node names.

Handle empty hostnames

Removed some debug output
else if (d && d.nodeinfo && d.nodeinfo.node_id)
name = '[' + d.nodeinfo.node_id + ']'
if (trim && name.length > 48)
name = name.substring(0,48) + "..."
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be the Unicode character "…" instead of three single "."?

@jplitza
Copy link
Member

jplitza commented Oct 7, 2015

I support the idea, both content-wise (shortening node names) and implementation-wise (introducing a single helper function that does the job). However, my knowledge of the codebase is too scarce to decide whether the implementation is done properly.

@tcatm
Copy link

tcatm commented Oct 7, 2015

I wouldn't call it "trim". That usually implies cutting excess whitespace from strings. "shorten" might be better suited.

I'd also create two functions, e.g. shortenNodename and prettyNodename and chain them when a shorter name is required (e.g shortenNodename(prettyNodename(d))).

@tcatm
Copy link

tcatm commented Oct 7, 2015

Actually, call it truncate as we don't actually do any magic to retain a meaningful hostname. Also, use "…" instead of "...".

@tcatm
Copy link

tcatm commented Oct 7, 2015

Also make sure, that truncateNodename("𝟘𝟙𝟚𝟛𝟜𝟝𝟞𝟟𝟠𝟡", 3) + "foo" actually returns "𝟘𝟙𝟚foo" and not just "𝟘𝟙" with some garbage at the end.

@tcatm
Copy link

tcatm commented Oct 7, 2015

On the other hand, why don't we use CSS?

Set this on a table cell:

text-overflow: ellipse;
overflow: hidden;
white-space: nowrap;
max-width: 0;

@mruettgers
Copy link
Author

I like the CSS based solution for truncating.
But this does not solve issues caused by missing hostnames wherever they are expected to be available as string objects.
So we need both, the CSS based solution and a central function for formatting the node name.
I'll have a look on this later.

MPW1412 pushed a commit to FreiFunkMuenster/meshviewer that referenced this pull request Jan 8, 2016
added OS switch for the coords …

(new) fix for plumpudding/meshviewer/ffnord#6

restore backwards compatibility

resolve builderror

fixed typo
jplitza added a commit that referenced this pull request Jan 8, 2016
This implements part of #6 with CSS to shorten extremely long node names
with ellipsis.
rubo77 pushed a commit to rubo77/meshviewer that referenced this pull request Apr 20, 2019
This implements part of ffnord#6 with CSS to shorten extremely long node names
with ellipsis.
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.

3 participants