forked from Normation/rudder
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
322 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 40 additions & 27 deletions
67
webapp/sources/rudder/rudder-web/src/main/elm/secret/sources/DataTypes.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,63 @@ | ||
module DataTypes exposing(..) | ||
|
||
import Http exposing (Error) | ||
import Toasty | ||
import Toasty.Defaults | ||
|
||
type alias Secret = | ||
{ name : String | ||
{ info : SecretInfo | ||
, value : String | ||
} | ||
|
||
type alias SecretInfo = | ||
{ name : String | ||
, description : String | ||
} | ||
|
||
|
||
type alias Model = | ||
{ contextPath : String | ||
, secrets : List Secret | ||
, focusOn : Maybe Secret | ||
, newSecretInput : Maybe Secret | ||
, isOpenCreateModal : Bool | ||
, isOpenEditModal : Bool | ||
, stateInputs : List StateInput | ||
{ contextPath : String | ||
, secrets : List SecretInfo | ||
, focusOn : Maybe SecretInfo | ||
, newSecretInput : Maybe Secret | ||
, openModalMode : Mode | ||
, stateInputs : List StateInput | ||
, openedDescription : List String | ||
, sortOn : (Sorting, Column) | ||
, filteredSecrets : Maybe (List SecretInfo) | ||
} | ||
|
||
type WriteAction | ||
type Mode | ||
= Edit | ||
| Add | ||
| Delete | ||
| Read | ||
|
||
type StateInput | ||
= InvalidName | ||
| InvalidValue | ||
| InvalidDescription | ||
= EmptyInputName | ||
| EmptyInputValue | ||
| EmptyInputDescription | ||
|
||
type Sorting | ||
= ASC | ||
| DESC | ||
| NONE | ||
|
||
type Column | ||
= Name | ||
| Description | ||
|
||
type Msg | ||
= GetAllSecrets (Result Error (List Secret)) | ||
| GetSecret (Result Error Secret) | ||
| AddSecret (Result Error Secret) | ||
| DeleteSecret (Result Error String) | ||
| UpdateSecret (Result Error Secret) | ||
= GetAllSecrets (Result Error (List SecretInfo)) | ||
| GetSecret (Result Error (List SecretInfo)) | ||
| AddSecret (Result Error (List SecretInfo)) | ||
| DeleteSecret (Result Error (List SecretInfo)) | ||
| UpdateSecret (Result Error (List SecretInfo)) | ||
| CallApi (Model -> Cmd Msg) | ||
| OpenCreateModal | ||
| OpenEditModal Secret | ||
| OpenModal Mode (Maybe SecretInfo) | ||
| CloseModal | ||
| InputName String | ||
| InputValue String | ||
| InputDescription String | ||
| SubmitSecret WriteAction | ||
| OpenDescription Secret | ||
-- | ||
-- -- NOTIFICATIONS | ||
--| ToastyMsg (Toasty.Msg Toasty.Defaults.Toast) | ||
--| Notification (Toasty.Msg Toasty.Defaults.Toast) | ||
| SubmitSecret Mode | ||
| OpenDescription SecretInfo | ||
| ChangeSorting Column | ||
| FilterSecrets String |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 9 additions & 17 deletions
26
webapp/sources/rudder/rudder-web/src/main/elm/secret/sources/JsonDecoder.elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
module JsonDecoder exposing (..) | ||
|
||
import DataTypes exposing (Secret) | ||
import DataTypes exposing (Secret, SecretInfo) | ||
import Json.Decode as D exposing (Decoder) | ||
import Json.Decode.Pipeline exposing (required) | ||
import Json.Decode.Pipeline exposing (hardcoded, optional, required) | ||
|
||
decodeGetAllSecrets : Decoder (List Secret) | ||
decodeGetAllSecrets = | ||
D.at [ "data" ] ( D.at [ "secrets" ] (D.list <| decodeSecret) ) | ||
decodeSecretsApi : Decoder (List SecretInfo) | ||
decodeSecretsApi = | ||
D.at [ "data" ] ( D.at [ "secrets" ] (D.list <| decodeSecretInfo) ) | ||
|
||
decodeOneSecret : Decoder Secret | ||
decodeOneSecret = | ||
D.at [ "data" ] ( D.at [ "secret" ] decodeSecret) | ||
|
||
decodeDeleteSecret : Decoder String | ||
decodeDeleteSecret = | ||
D.at [ "data" ] ( D.at [ "secretName" ] D.string ) | ||
|
||
decodeSecret : Decoder Secret | ||
decodeSecret = | ||
D.succeed Secret | ||
decodeSecretInfo : Decoder SecretInfo | ||
decodeSecretInfo = | ||
D.succeed SecretInfo | ||
|> required "name" D.string | ||
|> required "value" D.string | ||
|> required "description" D.string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.