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

Add "Fiber Connected Hub" and Map Display Override Options #794

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Generated by Django 4.2.17 on 2024-12-24 21:57

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("meshapi", "0003_alter_historicalinstall_request_date_and_more"),
]

operations = [
migrations.AlterField(
model_name="historicalnode",
name="type",
field=models.CharField(
choices=[
("Standard", "Standard"),
("Hub", "Hub"),
("Fiber Connected Hub", "Fiber Hub"),
("Supernode", "Supernode"),
("POP", "Pop"),
("AP", "Ap"),
("Remote", "Remote"),
],
default="Standard",
help_text="The type of node this is, controls the icon used on the network map",
),
),
migrations.AlterField(
model_name="node",
name="type",
field=models.CharField(
choices=[
("Standard", "Standard"),
("Hub", "Hub"),
("Fiber Connected Hub", "Fiber Hub"),
("Supernode", "Supernode"),
("POP", "Pop"),
("AP", "Ap"),
("Remote", "Remote"),
],
default="Standard",
help_text="The type of node this is, controls the icon used on the network map",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Generated by Django 4.2.17 on 2024-12-24 21:57

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("meshapi", "0004_alter_historicalnode_type_alter_node_type"),
]

operations = [
migrations.AddField(
model_name="historicallink",
name="map_display_override",
field=models.CharField(
blank=True,
choices=[
("Hidden", "Hidden"),
("Planned", "Planned"),
("Yellow", "Yellow"),
("Light Blue", "Light Blue"),
("Dark Blue", "Dark Blue"),
("Purple", "Purple"),
],
default=None,
help_text="Optional configuration to force specific map display for this link, regardless of the actual type/status. This should not be used for most links",
null=True,
),
),
migrations.AddField(
model_name="link",
name="map_display_override",
field=models.CharField(
blank=True,
choices=[
("Hidden", "Hidden"),
("Planned", "Planned"),
("Yellow", "Yellow"),
("Light Blue", "Light Blue"),
("Dark Blue", "Dark Blue"),
("Purple", "Purple"),
],
default=None,
help_text="Optional configuration to force specific map display for this link, regardless of the actual type/status. This should not be used for most links",
null=True,
),
),
]
17 changes: 17 additions & 0 deletions src/meshapi/models/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ class LinkType(models.TextChoices):
FIBER = "Fiber"
ETHERNET = "Ethernet"

class MapDisplayOverride(models.TextChoices):
HIDDEN = "Hidden"
PLANNED = "Planned"
YELLOW = "Yellow"
LIGHT_BLUE = "Light Blue"
DARK_BLUE = "Dark Blue"
PURPLE = "Purple"

class Meta:
ordering = ["id"]

Expand Down Expand Up @@ -52,6 +60,15 @@ class Meta:
help_text="The technology used for this link 5Ghz, 60Ghz, fiber, etc.",
)

map_display_override = models.CharField(
choices=MapDisplayOverride.choices,
default=None,
blank=True,
null=True,
help_text="Optional configuration to force specific map display for this link, regardless of "
"the actual type/status. This should not be used for most links",
)

install_date = models.DateField(default=None, blank=True, null=True, help_text="The date this link was created")
abandon_date = models.DateField(
default=None,
Expand Down
1 change: 1 addition & 0 deletions src/meshapi/models/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class NodeStatus(models.TextChoices):
class NodeType(models.TextChoices):
STANDARD = "Standard"
HUB = "Hub"
FIBER_HUB = "Fiber Connected Hub"
SUPERNODE = "Supernode"
POP = "POP"
AP = "AP"
Expand Down
21 changes: 18 additions & 3 deletions src/meshapi/serializers/map.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from collections import OrderedDict
from typing import List, Optional, Tuple
from typing import Dict, List, Optional, Tuple
from urllib.parse import urlparse

from rest_framework import serializers
Expand Down Expand Up @@ -80,13 +80,17 @@ def get_synthetic_notes(self, install: Install) -> Optional[str]:
return None

# Start the notes with the map display type
synthetic_notes = []
synthetic_notes: List[str] = []

# In the case of multiple dots per node, we only want to
# make the one that actually corresponds to the NN the big dot (the "fake" install)
# for the real install numbers that don't match the network number, leave them as red dots
if install.node.type != Node.NodeType.STANDARD and self._is_node_dot(install):
synthetic_notes.append(install.node.type)
if install.node.type == Node.NodeType.FIBER_HUB:
# Draw fiber-connected hubs with the big blue "supernode" dot
synthetic_notes.append(Node.NodeType.SUPERNODE)
else:
synthetic_notes.append(install.node.type)

# Supplement with "Omni" if this node has an omni attached
for device in install.node.devices.all():
Expand Down Expand Up @@ -149,6 +153,17 @@ class Meta:
installDate = JavascriptDateField(source="install_date")

def convert_status_to_spreadsheet_status(self, link: Link) -> str:
if link.map_display_override:
map_override_to_spreadsheet_status: Dict[str, str] = {
Link.MapDisplayOverride.HIDDEN: "dead",
Link.MapDisplayOverride.PLANNED: "planned",
Link.MapDisplayOverride.YELLOW: "fiber",
Link.MapDisplayOverride.LIGHT_BLUE: "60GHz",
Link.MapDisplayOverride.DARK_BLUE: "active",
Link.MapDisplayOverride.PURPLE: "vpn",
}
return map_override_to_spreadsheet_status[link.map_display_override]

if link.status == Link.LinkStatus.PLANNED:
return str(link.status).lower()

Expand Down
Loading
Loading