Skip to content

Commit 03f527e

Browse files
committed
Shorten allocation ID in table
1 parent 1868005 commit 03f527e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

webui/src/Models/Resources/Allocation.elm

+11
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ type alias Allocation =
2020
}
2121

2222

23+
{-| Get the short ID of an allocation.
24+
25+
Nomad uses UUIDs as allocation IDs and allows to refer to allocations with a
26+
short ID, ie, the first component of the UUID ("up to the first dash").
27+
28+
-}
29+
shortAllocationId : AllocationId -> AllocationId
30+
shortAllocationId id =
31+
String.split "-" id |> List.head |> Maybe.withDefault id
32+
33+
2334
{-| Decode an allocation from JSON.
2435
-}
2536
decoder : Decode.Decoder Allocation

webui/src/Views/InstanceView.elm

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Models.Resources.Role exposing (Role(..))
66
import Models.Resources.Task exposing (Task)
77
import Models.Resources.TaskState exposing (TaskState(..))
88
import Models.Resources.ClientStatus exposing (ClientStatus(ClientComplete))
9-
import Models.Resources.Allocation as Allocation exposing (Allocation)
9+
import Models.Resources.Allocation as Allocation exposing (Allocation, shortAllocationId)
1010
import Updates.Messages exposing (UpdateBodyViewMsg(..))
1111
import Utils.HtmlUtils exposing (icon, iconButtonText, iconButton)
1212
import Views.ParameterFormView as ParameterFormView
@@ -405,7 +405,7 @@ instanceAllocationRow index ( taskName, allocation ) =
405405
in
406406
tr []
407407
[ th [ scope <| toString (index + 1) ] [ text taskName ]
408-
, td [] [ code [] [ text allocation.id ] ]
408+
, td [] [ code [] [ text (shortAllocationId allocation.id) ] ]
409409
, td [] [ span [ class ("label " ++ labelKind) ] [ text description ] ]
410410
]
411411

0 commit comments

Comments
 (0)