This is an automated email from the ASF dual-hosted git repository. heneveld pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git
commit f31f7091bdf9a91533aa537fcbfc210ef45c7e0d Author: John Athanasiou <[email protected]> AuthorDate: Thu Sep 16 18:59:26 2021 +0300 WIP moved config entries row data generation back to config-sensor table, passing map with unsafe flags --- .../config-sensor-table.directive.js | 19 +++++++++++++++ .../config-sensor-table.template.html | 4 +++- .../main/inspect/summary/summary.controller.js | 28 ++++++++++++++-------- .../main/inspect/summary/summary.template.html | 6 ++++- 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/ui-modules/app-inspector/app/components/config-sensor-table/config-sensor-table.directive.js b/ui-modules/app-inspector/app/components/config-sensor-table/config-sensor-table.directive.js index 00ba0dd..76355bd 100644 --- a/ui-modules/app-inspector/app/components/config-sensor-table/config-sensor-table.directive.js +++ b/ui-modules/app-inspector/app/components/config-sensor-table/config-sensor-table.directive.js @@ -37,6 +37,7 @@ export function configSensorTableDirective(brSnackbar) { scope: { data: '=', info: '=', + configItemsUnsafeMap: '=', }, link, }; @@ -49,6 +50,23 @@ export function configSensorTableDirective(brSnackbar) { 'external provider should be used to store this value with a DSL expression supplied in the blueprint to ' + 'retrieve the value.'; + scope.$watchGroup(['data','configItemsUnsafeMap'], (changes)=> { + if (angular.isObject(scope.data)) { + console.log('scope',scope) + console.log('scope.configItemsUnsafeMap',scope.configItemsUnsafeMap) + scope.items = Object.entries(scope.data) + .map(([key, value]) => ({ + key, + value, + isUnsafe: (scope.configItemsUnsafeMap || {})[key], + })); + } + }); + + scope.$watch('configItemsUnsafeMap', () => { + console.log('scope.configItemsUnsafeMap 222',scope.configItemsUnsafeMap) + }); + scope.$watch('info', () => { if (angular.isArray(scope.info)) { scope.mapInfo = scope.info.reduce((pool, infoItem) => { @@ -57,6 +75,7 @@ export function configSensorTableDirective(brSnackbar) { }, {}); } }); + scope.onClipboardSuccess = (e)=> { angular.element(e.trigger).triggerHandler('copied'); e.clearSelection(); diff --git a/ui-modules/app-inspector/app/components/config-sensor-table/config-sensor-table.template.html b/ui-modules/app-inspector/app/components/config-sensor-table/config-sensor-table.template.html index c31bb1f..59bc391 100644 --- a/ui-modules/app-inspector/app/components/config-sensor-table/config-sensor-table.template.html +++ b/ui-modules/app-inspector/app/components/config-sensor-table/config-sensor-table.template.html @@ -16,6 +16,8 @@ specific language governing permissions and limitations under the License. --> +configItemsUnsafeMap inner +{{configItemsUnsafeMap}} <div class="form-group"> <input type="text" class="form-control" placeholder="Filter by name or value" ng-model="filterValue"> </div> @@ -30,7 +32,7 @@ </tr> </thead> <tbody> - <tr ng-repeat="item in data | orderBy:'key':sortReverse | filter:filterValue as filterResult track by item.key"> + <tr ng-repeat="item in items | orderBy:'key':sortReverse | filter:filterValue as filterResult track by item.key"> <td> <span>{{item.key}}</span> <i ng-if="mapInfo[item.key].description" class="fa fa-info-circle pull-right" uib-popover="{{mapInfo[item.key].description}}" popover-trigger="'mouseenter'" popover-title="Description" popover-animation="true"></i> diff --git a/ui-modules/app-inspector/app/views/main/inspect/summary/summary.controller.js b/ui-modules/app-inspector/app/views/main/inspect/summary/summary.controller.js index e2eecb3..4549a66 100644 --- a/ui-modules/app-inspector/app/views/main/inspect/summary/summary.controller.js +++ b/ui-modules/app-inspector/app/views/main/inspect/summary/summary.controller.js @@ -17,7 +17,7 @@ * under the License. */ import angular from "angular"; -import map from "lodash/map"; +import { map, mapValues } from "lodash"; import {HIDE_INTERSTITIAL_SPINNER_EVENT} from 'brooklyn-ui-utils/interstitial-spinner/interstitial-spinner'; import template from "./summary.template.html"; import { SENSITIVE_FIELD_REGEX } from 'brooklyn-ui-utils/sensitive-field/sensitive-field'; @@ -50,6 +50,7 @@ export function summaryController($scope, $state, $stateParams, $q, $http, $http }; // the eventual entries to share with the sensor table component vm.configItems = null; + vm.configItemsUnsafeMap = null; vm.configItemsInfo = null; let observers = []; @@ -100,15 +101,20 @@ export function summaryController($scope, $state, $stateParams, $q, $http, $http // TODO: ideally move this to a $watch block if (vm.config && vm.configResolved && vm.configInfo) { - vm.configItems = Object.entries(vm.showResolvedConfig ? vm.configResolved : vm.config) - .map(([key, value]) => ({ - key, - value, - // marking as unsafe if the field name looks sensitive - // and the unresolved value does *not* come from a secure external source - isUnsafe: SENSITIVE_FIELD_REGEX.test(key.trim()) && - !vm.config[key].toString().startsWith('$brooklyn:'), - })); + vm.configItems = vm.showResolvedConfig ? vm.configResolved : vm.config; + vm.configItemsUnsafeMap = mapValues(vm.configItems, (value, key) => + SENSITIVE_FIELD_REGEX.test(key.trim()) && !vm.config[key].toString().startsWith('$brooklyn:') + ); + + // vm.configItems = Object.entries(vm.showResolvedConfig ? vm.configResolved : vm.config) + // .map(([key, value]) => ({ + // key, + // value, + // // marking as unsafe if the field name looks sensitive + // // and the unresolved value does *not* come from a secure external source + // isUnsafe: SENSITIVE_FIELD_REGEX.test(key.trim()) && + // !vm.config[key].toString().startsWith('$brooklyn:'), + // })); } } @@ -133,6 +139,8 @@ export function summaryController($scope, $state, $stateParams, $q, $http, $http configInfoHandler(configInfoResult.value); // making sure that changes are propagated to table. + console.log('vm.configItems',vm.configItems) + console.log('vm.configItemsUnsafeMap',vm.configItemsUnsafeMap) $scope.$apply(); } }); diff --git a/ui-modules/app-inspector/app/views/main/inspect/summary/summary.template.html b/ui-modules/app-inspector/app/views/main/inspect/summary/summary.template.html index 02662fb..f4c3804 100644 --- a/ui-modules/app-inspector/app/views/main/inspect/summary/summary.template.html +++ b/ui-modules/app-inspector/app/views/main/inspect/summary/summary.template.html @@ -187,7 +187,11 @@ <div> <loading-state error="vm.error.configItems" ng-if="!vm.configItems"></loading-state> - <config-sensor-table data="vm.configItems" info="vm.configInfo" ng-if="vm.configItems"></config-sensor-table> + configItemsUnsafeMap outer {{vm.configItemsUnsafeMap}} + <config-sensor-table ng-if="vm.configItems" + data="vm.configItems" info="vm.configInfo" + configItemsUnsafeMap="vm.configItemsUnsafeMap" + ></config-sensor-table> </div> <div class="table-option-footer"> <button ng-click="vm.toggleConfigResolved()" ng-class="{ 'btn-outline': !vm.showResolvedConfig, 'btn-accent': vm.showResolvedConfig }">
