algairim commented on a change in pull request #228:
URL: https://github.com/apache/brooklyn-ui/pull/228#discussion_r655132274



##########
File path: ui-modules/home/app/views/about/about.controller.js
##########
@@ -67,4 +72,139 @@ export function aboutStateController($scope, brBrandInfo, 
version, states) {
         buildCommitId: BUILD_COMMIT_ID,
         brooklynVersion: BROOKLYN_VERSION,
     };
+
+    this.container = $element[0];
+    this.now = Date.now();
+    this.expectedNodeCounter = Object.keys(this.states.nodes).length;
+    this.template = 'haStatusTemplate';
+
+    let modalInstance = null;
+
+    this.openDialog = function (states, nodeId, serverApi, container) {
+        if (!modalInstance) {
+            modalInstance = $uibModal.open({
+                template: nodeManagementTemplate,
+                controller: ['$scope', '$uibModalInstance', 'node', 
'serverApi', nodeManagementController],
+                controllerAs: 'vm',
+                backdrop: 'static',
+                windowClass: 'quick-launch-modal',
+                size: 'md',
+                resolve: {
+                    node: function () {
+                        return states.nodes[nodeId];
+                    },
+                    serverApi: function () {
+                        return serverApi;
+                    }
+                }
+            });
+            modalInstance.result.then(
+                (promiseList) => {
+                    this.template = 'spinnerTemplate';
+                    Promise.allSettled(promiseList).then((values) => {
+                        let event = new CustomEvent('update-states', {});
+                        container.dispatchEvent(event);
+                    });
+                    modalInstance = null;
+                },
+                () => {
+                    this.template = 'spinnerTemplate';
+                    let event = new CustomEvent('update-states', {});
+                    container.dispatchEvent(event);
+                    modalInstance = null;
+                }
+            );
+        }
+
+    };
+
+    function nodeManagementController($scope, $uibModalInstance, node, 
serverApi) {
+
+        this.node = node;

Review comment:
       I suggest to create reference variable for `this` to reference the 
instance of the controller.
   ```
   let mgmtController = this;
   mgmtController.node = node;
   // etc.
   ```
   
   So that it is clear what instance does `this` reference to:
   ```
   mgmtController.setHaStatus = function () {
       let result = serverApi.setHaStatus(this.newStatus);
       this.node.status = this.newStatus; // this is likely to be a reference 
to function() instance, not the controller.
       // or ?
       mgmtController.setHaStatus.node.status; // explicit reference to the 
controller instance.
   }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to