-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Deployment group detail page): Support for auto update at custom…
… interval feat(Deployment group page): Set default view to table view and use new table component
- Loading branch information
Showing
21 changed files
with
446 additions
and
86 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
code/portfolio/src/sixsq/nuvla/ui/components/duration_picker_scenes.cljs
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
(ns sixsq.nuvla.ui.components.duration-picker-scenes | ||
(:require [reagent.core :as r] | ||
[sixsq.nuvla.ui.portfolio-utils :refer [defscene]] | ||
[sixsq.nuvla.ui.common-components.plugins.duration-picker :refer [DurationPickerController]] | ||
[sixsq.nuvla.ui.utils.semantic-ui :as ui])) | ||
|
||
(defn BoolParam | ||
[!value? test-id label] | ||
[:div {:style {:margin-bottom "5px"}} | ||
[ui/Checkbox {:data-testid test-id | ||
:label label | ||
:style {:position :relative | ||
:vertical-align :middle} | ||
:checked @!value? | ||
:on-click #(swap! !value? not)}]]) | ||
|
||
(defscene basic-picker | ||
(r/with-let [!seconds (r/atom 0) | ||
!show-days? (r/atom true) | ||
!show-hours? (r/atom true) | ||
!show-minutes? (r/atom true) | ||
!show-seconds? (r/atom true)] | ||
[:div {:style {:width 400}} | ||
[BoolParam !show-days? "checkbox-show-days" "Show days ?"] | ||
[BoolParam !show-hours? "checkbox-show-hours" "Show hours ?"] | ||
[BoolParam !show-minutes? "checkbox-show-minutes" "Show minutes ?"] | ||
[BoolParam !show-seconds? "checkbox-show-seconds" "Show seconds ?"] | ||
[:div {:style {:margin 10}} | ||
[DurationPickerController {:!value !seconds | ||
:!show-days? !show-days? | ||
:!show-hours? !show-hours? | ||
:!show-minutes? !show-minutes? | ||
:!show-seconds? !show-seconds?}]] | ||
[:div {:data-testid "total-seconds"} "Duration in seconds: " @!seconds]])) | ||
|
||
(defscene custom-options | ||
(r/with-let [!seconds (r/atom 0) | ||
!days-options (r/atom [0 5 10]) | ||
!hours-options (r/atom [0 5 10 15 20]) | ||
!minutes-options (r/atom [0 10 20 30 40 50]) | ||
!seconds-options (r/atom [0 30])] | ||
[:div {:style {:width 400}} | ||
[:div {:style {:margin 10}} | ||
[DurationPickerController {:!value !seconds | ||
:!days-options !days-options | ||
:!hours-options !hours-options | ||
:!minutes-options !minutes-options | ||
:!seconds-options !seconds-options}]] | ||
[:div {:data-testid "total-seconds"} "Duration in seconds: " @!seconds]])) |
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
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
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
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
119 changes: 119 additions & 0 deletions
119
code/src/cljs/sixsq/nuvla/ui/common_components/plugins/duration_picker.cljs
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 |
---|---|---|
@@ -0,0 +1,119 @@ | ||
(ns sixsq.nuvla.ui.common-components.plugins.duration-picker | ||
(:require [clojure.string :as str] | ||
[reagent.core :as r] | ||
[sixsq.nuvla.ui.utils.semantic-ui :as ui] | ||
[sixsq.nuvla.ui.utils.ui-callback :as ui-callback])) | ||
|
||
(defn decompose-duration | ||
[total-seconds] | ||
(let [days (quot total-seconds 86400) | ||
hours (quot (rem total-seconds 86400) 3600) | ||
minutes (quot (rem total-seconds 3600) 60) | ||
seconds (rem total-seconds 60)] | ||
{:days days | ||
:hours hours | ||
:minutes minutes | ||
:seconds seconds})) | ||
|
||
(defn ->seconds | ||
[{:keys [days hours minutes seconds] :as value}] | ||
(apply + (remove nil? | ||
[(some-> days (* 3600 24)) | ||
(some-> hours (* 3600)) | ||
(some-> minutes (* 60)) | ||
seconds]))) | ||
|
||
(defn DurationPicker | ||
[{:keys [::!value ::set-value-fn ::tr-fn | ||
::!show-days? ::!show-hours? ::!show-minutes? ::!show-seconds? | ||
::!days-options ::!hours-options ::!minutes-options ::!seconds-options] :as _control}] | ||
(let [opts-fn (fn [vals] (map (fn [i] {:key i :value i :content i :text i}) vals)) | ||
{:keys [days hours minutes seconds] :as value} (decompose-duration @!value) | ||
set-value #(set-value-fn (->seconds %))] | ||
[:div {:style {:display :flex | ||
:align-items :center | ||
:gap 5}} | ||
(when @!show-days? | ||
[:<> | ||
[:label (tr-fn [:days])] | ||
[ui/Dropdown {:class :duration-days | ||
:value days | ||
:options (opts-fn @!days-options) | ||
:selection true | ||
:style {:min-width "70px"} | ||
:on-change (ui-callback/value #(set-value (assoc value :days %)))}]]) | ||
(when @!show-hours? | ||
[:<> | ||
[:label (tr-fn [:hours])] | ||
[ui/Dropdown {:class :duration-hours | ||
:value hours | ||
:options (opts-fn @!hours-options) | ||
:selection true | ||
:style {:min-width "70px"} | ||
:on-change (ui-callback/value #(set-value (assoc value :hours %)))}]]) | ||
(when @!show-minutes? | ||
[:<> | ||
[:label (tr-fn [:minutes])] | ||
[ui/Dropdown {:class :duration-minutes | ||
:value minutes | ||
:options (opts-fn @!minutes-options) | ||
:selection true | ||
:style {:min-width "70px"} | ||
:on-change (ui-callback/value #(set-value (assoc value :minutes %)))}]]) | ||
(when @!show-seconds? | ||
[:<> | ||
[:label (tr-fn [:seconds])] | ||
[ui/Dropdown {:class :duration-seconds | ||
:value seconds | ||
:options (opts-fn @!seconds-options) | ||
:selection true | ||
:style {:min-width "70px"} | ||
:on-change (ui-callback/value #(set-value (assoc value :seconds %)))}]])])) | ||
|
||
(defn DurationPickerController | ||
[{:keys [;; current value in seconds | ||
!value | ||
set-value-fn | ||
|
||
;; Optional (all enabled by default) | ||
;; whether to show days, hours, minutes and seconds | ||
!show-days? | ||
!show-hours? | ||
!show-minutes? | ||
!show-seconds? | ||
|
||
;; Optional | ||
;; Dropdown options to show | ||
!days-options | ||
!hours-options | ||
!minutes-options | ||
!seconds-options | ||
|
||
;; Optional | ||
;; Translations | ||
tr-fn | ||
]}] | ||
(r/with-let [!value (or !value (r/atom 0)) | ||
set-value-fn (or set-value-fn #(reset! !value %)) | ||
!show-days? (or !show-days? (r/atom true)) | ||
!show-hours? (or !show-hours? (r/atom true)) | ||
!show-minutes? (or !show-minutes? (r/atom true)) | ||
!show-seconds? (or !show-seconds? (r/atom true)) | ||
!days-options (or !days-options (r/atom (range 0 31))) | ||
!hours-options (or !hours-options (r/atom (range 0 24))) | ||
!minutes-options (or !minutes-options (r/atom (range 0 60))) | ||
!seconds-options (or !seconds-options (r/atom (range 0 60))) | ||
tr-fn (or tr-fn (comp str/capitalize name first))] | ||
[DurationPicker {::!value !value | ||
::set-value-fn set-value-fn | ||
::!show-days? !show-days? | ||
::!show-hours? !show-hours? | ||
::!show-minutes? !show-minutes? | ||
::!show-seconds? !show-seconds? | ||
::!days-options !days-options | ||
::!hours-options !hours-options | ||
::!minutes-options !minutes-options | ||
::!seconds-options !seconds-options | ||
::tr-fn tr-fn}])) | ||
|
||
|
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
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.