All Downloads are FREE. Search and download functionalities are using the official Maven repository.

asysmon-res.js.ctrl-envvar.js Maven / Gradle / Ivy

There is a newer version: 1.0-pre28
Show newest version

angular.module('ASysMonApp').controller('CtrlEnvVar', function($scope, $log, Rest, escapeHtml) {
    $('.btn').tooltip({
        container: 'body',
        html: true
    });

    var rootLevel = 0;
    var nodesByFqn = {};

    function initFromResponse(data) {
        reorder(data.envTree);
        $scope.envTree = data.envTree;
        nodesByFqn = {};
        initTreeNodes($scope.envTree, 0, '');

        $('#theTree').html(htmlForAllTrees());
        $('.data-row.with-children')
            .click(function() {
                var fqn = $(this).children('.fqn-holder').text();
                var childrenDiv = $(this).next();
                var nodeIconDiv = $(this).children('.node-icon');
                var isExpanded = nodeIconDiv.hasClass('node-icon-expanded');

                childrenDiv.slideToggle(50, function() {
                    if(isExpanded) {
                        nodeIconDiv.addClass('node-icon-collapsed').removeClass('node-icon-expanded');
                    }
                    else {
                        nodeIconDiv.removeClass('node-icon-collapsed').addClass('node-icon-expanded');
                    }
                });
            });
        expandFirstNode();
    }
    function expandFirstNode() {
        var dataRow = $('.data-row-0').first();
        var childrenDiv = dataRow.next();
        var nodeIconDiv = dataRow.children('.node-icon');

        childrenDiv.show();
        nodeIconDiv.addClass('node-icon-expanded').removeClass('node-icon-collapsed');
    }

    function reorder(rootNodes) {
        for(var i=0; i';
        });

        return result;
    }

    function htmlForTreeNode(curNode) {
        var withChildrenClass = (curNode.children && curNode.children.length) ? ' with-children' : '';

        var result =
            '
' + '
' + curNode.fqn + '
' + '
 
' + '
' + escapeHtml(curNode.value) + '
' + '
' + escapeHtml(curNode.name) + '
' + '
'; if(curNode.children && curNode.children.length) { result += ''; } return result; } function nodeIconClass(node) { if(! node.fqn) { //TODO remove this heuristic node = nodesByFqn[node]; } if(node.children && node.children.length) { return 'node-icon-collapsed'; // return expansionModel[node.fqn] ? 'node-icon-expanded' : 'node-icon-collapsed'; } return 'node-icon-empty'; } });




© 2015 - 2024 Weber Informatics LLC | Privacy Policy