<commit_before>module Updater exposing (..)

import Html exposing (..)
import Html.Attributes exposing (..)
import Helpers exposing (Helpers)


-- MODEL


type alias Progress =
    { total : Float
    , transferred : Float
    }


type State
    = Checking
    | Downloading (Maybe Progress)


type alias Model =
    { version : String
    , state : State
    }


init : String -> Model
init version =
    { version = version
    , state = Checking
    }



-- UPDATE


type Msg
    = UpdateDownloading (Maybe Progress)


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case
        msg
    of
        UpdateDownloading progress ->
            ( { model | state = Downloading progress }, Cmd.none )



-- VIEW


humanReadableDiskValue : Helpers -> Float -> String
humanReadableDiskValue helpers v =
    (toString (round (v / 1000000)) ++ " M" ++ (helpers.t "Account b"))


progressbar : Float -> Html Msg
progressbar ratio =
    let
        cappedRatio =
            (Basics.min 1 ratio)

        percent =
            (toString (cappedRatio * 100)) ++ "%"
    in
        div [ class "progress" ]
            [ div
                [ class "progress-inner"
                , style [ ( "width", percent ) ]
                ]
                []
            ]


view : Helpers -> Model -> Html Msg
view helpers model =
    section [ class "updater" ]
        (case model.state of
            Checking ->
                [ p [] [ text (helpers.t "Updater Checking for Update") ] ]

            Downloading (Just progress) ->
                [ h1 [] [ text (helpers.t "Updater Downloading") ]
                , div [ class "spacer" ]
                    [ (progressbar (progress.transferred / progress.total))
                    , div [ class "progress-indicator" ]
                        [ text
                            ((humanReadableDiskValue helpers progress.transferred)
                                ++ " / "
                                ++ (humanReadableDiskValue helpers progress.total)
                            )
                        ]
                    ]
                , p []
                    [ text (helpers.t "Updater Please wait") ]
                ]

            Downloading Nothing ->
                [ h1 []
                    [ text (helpers.t "Updater Downloading") ]
                , div [ class "spacer" ]
                    [ div [ class "progress indeterminate" ]
                        [ div
                            [ class "progress-inner" ]
                            []
                        ]
                    ]
                , p []
                    [ text (helpers.t "Updater Please wait") ]

                --, p [] []
                ]
        )<commit_msg>gui: No more update check screen<commit_after>module Updater exposing (..)

import Html exposing (..)
import Html.Attributes exposing (..)
import Helpers exposing (Helpers)


-- MODEL


type alias Progress =
    { total : Float
    , transferred : Float
    }


type alias Model =
    { version : String
    , progress : Maybe Progress
    }


init : String -> Model
init version =
    { version = version
    , progress = Nothing
    }



-- UPDATE


type Msg
    = UpdateDownloading (Maybe Progress)


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        UpdateDownloading progress ->
            ( { model | progress = progress }, Cmd.none )



-- VIEW


humanReadableDiskValue : Helpers -> Float -> String
humanReadableDiskValue helpers v =
    (toString (round (v / 1000000)) ++ " M" ++ (helpers.t "Account b"))


progressbar : Float -> Html Msg
progressbar ratio =
    let
        cappedRatio =
            (Basics.min 1 ratio)

        percent =
            (toString (cappedRatio * 100)) ++ "%"
    in
        div [ class "progress" ]
            [ div
                [ class "progress-inner"
                , style [ ( "width", percent ) ]
                ]
                []
            ]


view : Helpers -> Model -> Html Msg
view helpers model =
    section [ class "updater" ]
        (case model.progress of
            Just progress ->
                [ h1 [] [ text (helpers.t "Updater Downloading") ]
                , div [ class "spacer" ]
                    [ (progressbar (progress.transferred / progress.total))
                    , div [ class "progress-indicator" ]
                        [ text
                            ((humanReadableDiskValue helpers progress.transferred)
                                ++ " / "
                                ++ (humanReadableDiskValue helpers progress.total)
                            )
                        ]
                    ]
                , p []
                    [ text (helpers.t "Updater Please wait") ]
                ]

            Nothing ->
                [ h1 []
                    [ text (helpers.t "Updater Downloading") ]
                , div [ class "spacer" ]
                    [ div [ class "progress indeterminate" ]
                        [ div
                            [ class "progress-inner" ]
                            []
                        ]
                    ]
                , p []
                    [ text (helpers.t "Updater Please wait") ]
                ]
        )
{'fraction_non_alphanumeric': 0.09863687996970845, 'fraction_numerical': 0.004922377887163953, 'mean_word_length': 1.1493083807973963, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5142497', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1318, 'n_words': 358}