Browse code
feat(stack): add the ability to refresh the stack information
Ed Langley authored on 23/12/2019 21:00:06
Showing 3 changed files
Showing 3 changed files
... | ... |
@@ -1,7 +1,8 @@ |
1 | 1 |
(defpackage :mfa-tool.aws-dispatcher |
2 | 2 |
(:use :cl) |
3 | 3 |
(:export #:aws-dispatcher #:update-stacks #:select-stack #:stacks #:stack |
4 |
- #:put-stack)) |
|
4 |
+ #:put-stack |
|
5 |
+ #:refresh-stack)) |
|
5 | 6 |
(in-package :mfa-tool.aws-dispatcher) |
6 | 7 |
|
7 | 8 |
(defclass aws-dispatcher () |
... | ... |
@@ -22,6 +23,12 @@ |
22 | 23 |
(defprint-slots daydreamer.aws-result:stack |
23 | 24 |
(daydreamer.aws-result::%stack-name)) |
24 | 25 |
|
26 |
+(defclass refresh-stack () |
|
27 |
+ ((%stack :reader stack :initarg :stack))) |
|
28 |
+(defprint-slots refresh-stack (%stack)) |
|
29 |
+(defun refresh-stack (stack) |
|
30 |
+ (fw.lu:new 'refresh-stack stack)) |
|
31 |
+ |
|
25 | 32 |
(defclass put-stack () |
26 | 33 |
((%stack :reader stack :initarg :stack))) |
27 | 34 |
(defun put-stack (stack) |
... | ... |
@@ -55,6 +62,16 @@ |
55 | 62 |
(defmethod mfa-tool.store:dispatch :after ((store aws-dispatcher) (action update-region)) |
56 | 63 |
(mfa-tool.store:dispatch store :|Get Stacks|)) |
57 | 64 |
|
65 |
+(defmethod mfa-tool.store:dispatch :after ((store aws-dispatcher) (action refresh-stack)) |
|
66 |
+ (let ((new-value (daydreamer.aws-result:extract-stack |
|
67 |
+ (car |
|
68 |
+ (daydreamer.aws-result:extract-list |
|
69 |
+ (cdar |
|
70 |
+ (aws/cloudformation:describe-stacks |
|
71 |
+ :stack-name (daydreamer.aws-result:stack-name |
|
72 |
+ (stack action))))))))) |
|
73 |
+ (mfa-tool.store:dispatch store (put-stack new-value)))) |
|
74 |
+ |
|
58 | 75 |
(defmethod mfa-tool.store:dispatch :after ((store aws-dispatcher) (action (eql :|Get Stacks|))) |
59 | 76 |
(bt:make-thread |
60 | 77 |
(lambda () |
... | ... |
@@ -24,10 +24,32 @@ |
24 | 24 |
(column "ParameterValue")) |
25 | 25 |
output)) |
26 | 26 |
|
27 |
+(defmethod mfa-tool.store:dispatch :after ((store stack-store) |
|
28 |
+ (action (eql :refresh))) |
|
29 |
+ (mfa-tool.store:dispatch store |
|
30 |
+ (mfa-tool.aws-dispatcher:refresh-stack |
|
31 |
+ (mfa-tool.stack-store:selected-stack |
|
32 |
+ store)))) |
|
33 |
+ |
|
34 |
+(defmethod mfa-tool.store:dispatch :after ((store stack-store) |
|
35 |
+ (action mfa-tool.aws-dispatcher:put-stack)) |
|
36 |
+ (let* ((stack (mfa-tool.aws-dispatcher:stack action)) |
|
37 |
+ (old-stack (find (daydreamer.aws-result:stack-name stack) |
|
38 |
+ (available-stacks store) |
|
39 |
+ :key 'daydreamer.aws-result:stack-name |
|
40 |
+ :test 'equal)) |
|
41 |
+ (new-stacks (substitute stack old-stack (available-stacks store)))) |
|
42 |
+ (mfa-tool.store:dispatch store (mfa-tool.aws-dispatcher:select-stack stack)) |
|
43 |
+ (mfa-tool.store:dispatch store (mfa-tool.aws-dispatcher:update-stacks new-stacks)))) |
|
44 |
+ |
|
27 | 45 |
(defmethod mfa-tool.store:dispatch :after ((store stack-store) |
28 | 46 |
(action mfa-tool.aws-dispatcher:update-stacks)) |
29 |
- (alexandria:when-let ((stack (car (mfa-tool.aws-dispatcher:stacks action)))) |
|
30 |
- (mfa-tool.store:dispatch store (mfa-tool.aws-dispatcher:select-stack stack)))) |
|
47 |
+ (when (not (selected-stack store)) |
|
48 |
+ (alexandria:when-let ((stack (car (mfa-tool.aws-dispatcher:stacks action)))) |
|
49 |
+ (mfa-tool.store:dispatch store (mfa-tool.aws-dispatcher:select-stack stack))))) |
|
50 |
+ |
|
51 |
+(defmethod mfa-tool.store:execute ((store stack-store) (action (eql :refresh))) |
|
52 |
+ ) |
|
31 | 53 |
|
32 | 54 |
(defmethod mfa-tool.store:execute ((store stack-store) (action mfa-tool.aws-dispatcher:update-stacks)) |
33 | 55 |
(setf (available-stacks store) (sort (mfa-tool.aws-dispatcher:stacks action) |
... | ... |
@@ -41,3 +63,6 @@ |
41 | 63 |
(parameters store) (mapcar 'parameter-columns (daydreamer.aws-result:parameters stack)) |
42 | 64 |
|
43 | 65 |
(outputs store) (mapcar 'output-columns (daydreamer.aws-result:outputs stack))))) |
66 |
+ |
|
67 |
+(defmethod mfa-tool.store:execute ((store stack-store) (action mfa-tool.aws-dispatcher:put-stack)) |
|
68 |
+ ) |
... | ... |
@@ -54,6 +54,11 @@ |
54 | 54 |
:selection-callback (dispatch-with-action-creator 'mfa-tool.aws-dispatcher:select-stack) |
55 | 55 |
:callback-type :interface-data) |
56 | 56 |
|
57 |
+ (refresh-status capi:push-button |
|
58 |
+ :text "Refresh" |
|
59 |
+ :callback-type :interface |
|
60 |
+ :callback (lambda (store) |
|
61 |
+ (mfa-tool.store:dispatch store :refresh))) |
|
57 | 62 |
(status-display capi:display-pane |
58 | 63 |
:background :transparent |
59 | 64 |
:reader status-display |
... | ... |
@@ -100,8 +105,14 @@ |
100 | 105 |
'(region-chooser |
101 | 106 |
stack-chooser) |
102 | 107 |
:visible-max-width '(character 35)) |
108 |
+ (status-layout capi:row-layout |
|
109 |
+ '(status-display |
|
110 |
+ nil |
|
111 |
+ #+(or)open-web-console |
|
112 |
+ refresh-status) |
|
113 |
+ :adjust :center) |
|
103 | 114 |
(attribute-layout capi:column-layout |
104 |
- '(status-display |
|
115 |
+ '(status-layout |
|
105 | 116 |
parameters-display |
106 | 117 |
outputs-display)) |
107 | 118 |
(main-layout capi:row-layout |
... | ... |
@@ -115,8 +126,9 @@ |
115 | 126 |
(defmethod mfa-tool.store:execute :after ((interface stack-interface) (_ mfa-tool.aws-dispatcher:update-stacks)) |
116 | 127 |
(with-pp (interface) |
117 | 128 |
(with-accessors ((stack-chooser stack-chooser)) interface |
118 |
- (setf (capi:collection-items stack-chooser) |
|
119 |
- (mfa-tool.stack-store:available-stacks interface))))) |
|
129 |
+ (setf (capi:collection-items stack-chooser) (mfa-tool.stack-store:available-stacks interface) |
|
130 |
+ (capi:choice-selected-item |
|
131 |
+ (stack-chooser interface)) (mfa-tool.stack-store:selected-stack interface))))) |
|
120 | 132 |
|
121 | 133 |
(defun max-widths (cols) |
122 | 134 |
(loop for (col1 col2) in cols |
... | ... |
@@ -135,6 +147,9 @@ |
135 | 147 |
(capi:modify-multi-column-list-panel-columns |
136 | 148 |
parameters-display :columns (apply 'get-output-columns "Parameter" (max-widths parameters))) |
137 | 149 |
|
150 |
+ (when (not (eq (capi:choice-selected-item (stack-chooser interface)) |
|
151 |
+ (mfa-tool.aws-dispatcher:stack _))) |
|
152 |
+ (setf (capi:choice-selected-item (stack-chooser interface)) (mfa-tool.stack-store:selected-stack interface))) |
|
138 | 153 |
(setf (capi:display-pane-text status-display) |
139 | 154 |
(format nil "~a: ~/mfa-tool.stack:format-stack-status/" |
140 | 155 |
(daydreamer.aws-result:stack-name selected-stack) |