function link()

in ui-modules/app-inspector/app/components/config-sensor-table/config-sensor-table.directive.js [47:102]


    function link(scope) {
        scope.items = [];
        scope.mapInfo = {};
        scope.WARNING_TEXT = 'This value is identified as potentially sensitive based and so is masked here. ' +
            'The value should be supplied as a DSL expression not as plain text. ' +
            'Note that the unmasked value still might not reveal the actual value, ' +
            'if sensitive values are blocked by the API or if DSL resolution is skipped.';

        scope.$watchGroup(['data'], (changes)=> {
            if (angular.isObject(scope.data)) {
                const dataPlusReconfigurable = Object.assign({}, scope.data);
                if (scope.info) {
                    scope.info.forEach(info => {
                        if (info.reconfigurable && !dataPlusReconfigurable.hasOwnProperty(info.name)) {
                            dataPlusReconfigurable[info.name] = undefined;
                        }
                    });
                }
                scope.items = Object.entries(dataPlusReconfigurable)
                    .map(([key, value]) => ({
                        key,
                        value,
                        isPlaintextSensitiveValue: scope.checkPlaintextSensitiveKeyValue && scope.checkPlaintextSensitiveKeyValue(key, value),
                    }));
            }
        });

        scope.$watch('info', () => {
            if (angular.isArray(scope.info)) {
                scope.mapInfo = scope.info.reduce((pool, infoItem) => {
                    pool[infoItem.name] = infoItem;
                    return pool;
                }, {});
            }
        });

        scope.onClipboardSuccess = (e)=> {
            angular.element(e.trigger).triggerHandler('copied');
            e.clearSelection();
        };
        scope.onClipboardError = (e)=> {
            let message = '';
            let actionKey = e.action === 'cut' ? 'X' : 'C';
            if(/iPhone|iPad/i.test(navigator.userAgent)) {
                message = 'No support :(';
            }
            else if(/Mac/i.test(navigator.userAgent)) {
                message = 'Press ⌘-' + actionKey + ' to ' + e.action;
            }
            else {
                message = 'Press Ctrl-' + actionKey + ' to ' + e.action;
            }
            brSnackbar.create(message);
        };
        scope.isNullish = (x) => x===null || typeof x === 'undefined';
    }