diff --git a/ipynbsrv/api/serializer.py b/ipynbsrv/api/serializer.py index 2e61a12..ced546a 100644 --- a/ipynbsrv/api/serializer.py +++ b/ipynbsrv/api/serializer.py @@ -138,6 +138,16 @@ class Meta: model = Server +class PortMappingSerializer(serializers.ModelSerializer): + """ + + """ + is_protected_mapping = serializers.BooleanField(read_only=True) + + class Meta: + model = PortMapping + + class ContainerSerializer(serializers.ModelSerializer): """ Todo: write doc. @@ -145,12 +155,17 @@ class ContainerSerializer(serializers.ModelSerializer): Server is set through the server selection algorithm set in the conf module. """ backend_name = serializers.CharField(read_only=True, source='get_backend_name') + backend_base_url = serializers.CharField(read_only=True, source='get_backend_base_url') friendly_name = serializers.CharField(read_only=True, source='get_friendly_name') is_clone = serializers.BooleanField(read_only=True) is_image_based = serializers.BooleanField(read_only=True) is_running = serializers.BooleanField(read_only=True) is_suspended = serializers.BooleanField(read_only=True) has_clones = serializers.BooleanField(read_only=True) + port_mappings = PortMappingSerializer( + many=True, + read_only=True + ) owner = serializers.HiddenField( default=CurrentBackendUserDefault() diff --git a/ipynbsrv/core/models.py b/ipynbsrv/core/models.py index 60d5d52..6dea440 100644 --- a/ipynbsrv/core/models.py +++ b/ipynbsrv/core/models.py @@ -1173,6 +1173,12 @@ def get_available_server_port(cls, server): # ServerSelectionAlgorithm must guarantee enough ports are free! return port + def is_protected_mapping(self): + """ + Return `True` if this mapping is for the protected container port. + """ + return self.internal_port == self.container.image.protected_port + def __str__(self): """ :inherit. diff --git a/ipynbsrv/web/templates/web/snippets/container_grid.html b/ipynbsrv/web/templates/web/snippets/container_grid.html index e106094..a49ec22 100644 --- a/ipynbsrv/web/templates/web/snippets/container_grid.html +++ b/ipynbsrv/web/templates/web/snippets/container_grid.html @@ -2,8 +2,14 @@
{{ port_mapping.internal }} | -{{ port_mapping.external }} | -
{{ port_mapping.internal_port }} | +{{ ct.server.external_ip }}:{{ port_mapping.external_port }} | +