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.
   }
   ```

##########
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.node.status; // explicit reference to the controller 
instance.
   }
   ```

##########
File path: 
ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js
##########
@@ -230,7 +230,7 @@ function BlueprintService($log, $q, $sce, paletteApi, 
iconGenerator, dslService,
     }
 
     function lookup(entity, id, any = false) {
-        if (entity._id === id) {
+        if ((entity._id === id) || (entity.id === id)) {

Review comment:
       Do we still need this? I thought we agreed to not engage public ID of 
the Entity (which is optional, can be null, and not unique) into lookup.

##########
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:
       Applies to all functions defined below.

##########
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:
       Controller instance could be named asa `vm`, the same as `controllerAs: 
'vm',`, instead of `mgmtController`.
   See examples in blueprint-composer, e.g. spec-editor.

##########
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:
       Controller instance could be named as `vm`, the same as `controllerAs: 
'vm',`, instead of `mgmtController`.
   See examples in blueprint-composer, e.g. spec-editor.




-- 
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