<commit_before>module Fabric {

  export var jmxDomain = 'org.fusesource.fabric';

  export var templatePath = 'app/fabric/html/';

  export var currentContainerId = '';


  angular.module('fabric', ['bootstrap', 'ui.bootstrap', 'ui.bootstrap.dialog', 'ngResource', 'ngGrid', 'hawtio-forms', 'hawtioCore', 'ngDragDrop', 'wiki']).config(($routeProvider) => {
    $routeProvider.
            when('/createFabric', {templateUrl: templatePath + 'createFabric.html'}).
            when('/fabric/containers/createContainer', {templateUrl: templatePath + 'createContainer.html' , reloadOnSearch: false }).
            when('/fabric/map', {templateUrl: templatePath + 'map.html'}).
            when('/fabric/clusters/*page', {templateUrl: templatePath + 'clusters.html'}).
            when('/fabric/containers', {templateUrl: templatePath + 'containers.html'}).
            when('/fabric/container/:containerId', {templateUrl: templatePath + 'container.html'}).
            when('/fabric/activeProfiles', {templateUrl: templatePath + 'activeProfiles.html'}).
            //when('/fabric/profile/:versionId/:profileId', {templateUrl: templatePath + 'profile.html'}).
            when('/wiki/profile/:versionId/:profileId/editFeatures', {templateUrl: templatePath + 'editFeatures.html'}).
            when('/fabric/profile/:versionId/:profileId/:fname', {templateUrl: templatePath + 'pid.html'}).
            when('/fabric/view', { templateUrl: templatePath + 'fabricView.html', reloadOnSearch: false }).
            when('/fabric/patching', { templateUrl: templatePath + 'patching.html' }).
            when('/fabric/mq/brokers', { templateUrl: templatePath + 'brokers.html' }).
            when('/fabric/mq/brokerNetwork', { templateUrl: templatePath + 'brokerNetwork.html' }).
            when('/fabric/mq/createBroker', { templateUrl: templatePath + 'createBroker.html' }).
            when('/fabric/test', { templateUrl: templatePath + 'test.html' });
  }).

    directive('fabricVersionSelector', function() {
      return new Fabric.VersionSelector();
    }).
    directive('fabricProfileSelector', function() {
      return new Fabric.ProfileSelector();
    }).
    directive('fabricContainerList', () => {
      return new Fabric.ContainerList();
    }).
    directive('fabricProfileDetails', () => {
      return new Fabric.ProfileDetails();
    }).
    directive('fabricActiveProfileList', () => {
      return new Fabric.ActiveProfileList();
    }).
    directive('fabricProfileLink', (workspace, jolokia, localStorage) => {
        return {
            restrict: 'A',
            link: ($scope, $element, $attrs) => {
            var profileId = $attrs['fabricProfileLink'];

            if (profileId && !profileId.isBlank()) {
              var container = Fabric.getCurrentContainer(jolokia, ['versionId']);
              var versionId = container['versionId'];
              if (versionId && !versionId.isBlank()) {
                var url = '#' + Fabric.profileLink(workspace, jolokia, localStorage, versionId, profileId);
                if (angular.isDefined($attrs['file'])) {
                  url = url + "/" + $attrs['file'];
                }

                $element.attr('href', url);
              }
            }
          }
        }
    }).
    directive('fabricContainers', (workspace, jolokia, localStorage) => {
        return {
            restrict: 'A',
            link: ($scope, $element, $attrs) => {
            var model = $attrs['fabricContainers'];
            var profileId = $attrs['profile'];
            var version = $scope.versionId || $scope.version || "1.0";
            if (model && !model.isBlank() && profileId && !profileId.isBlank()) {
              var containerIds = Fabric.getContainerIdsForProfile(jolokia, version, profileId);
              log.info("Searching for containers for profile: " + profileId + " version " + version + ". Found: " + containerIds);
              $scope[model] = containerIds;
            }
          }
        }
    }).
    directive('fabricContainerConnect', ($location, jolokia, workspace) => {
        return {
            restrict: 'A',
            link: ($scope, $element, $attrs) => {
            var containerId = $attrs['fabricContainerConnect'];
            var view = $attrs['view'];
            if (containerId && !containerId.isBlank()) {
              //var fields = ["parentId", "profileIds", "versionId", "provisionResult", "jolokiaUrl", "root", 'jmxDomains'];
              var fields = ["jolokiaUrl"];
              Fabric.initScope($scope, $location, jolokia, workspace);

              $scope["connect"] = () => {
                log.info("Fired connect() function!!!");

                var container = Fabric.getContainerFields(jolokia, containerId, fields);
                log.info("Connecting to container id " + containerId + " details + " + JSON.stringify(container));
                container["id"]  = containerId;
                $scope.doConnect(container, view);
              };
              $element.attr('ng-click', "connect()");
            }
          }
        }
    }).<commit_msg>#721 fixed up the containers and containerConnect directives so they actually work<commit_after>module Fabric {

  export var jmxDomain = 'org.fusesource.fabric';

  export var templatePath = 'app/fabric/html/';

  export var currentContainerId = '';


  angular.module('fabric', ['bootstrap', 'ui.bootstrap', 'ui.bootstrap.dialog', 'ngResource', 'ngGrid', 'hawtio-forms', 'hawtioCore', 'ngDragDrop', 'wiki']).config(($routeProvider) => {
    $routeProvider.
            when('/createFabric', {templateUrl: templatePath + 'createFabric.html'}).
            when('/fabric/containers/createContainer', {templateUrl: templatePath + 'createContainer.html' , reloadOnSearch: false }).
            when('/fabric/map', {templateUrl: templatePath + 'map.html'}).
            when('/fabric/clusters/*page', {templateUrl: templatePath + 'clusters.html'}).
            when('/fabric/containers', {templateUrl: templatePath + 'containers.html'}).
            when('/fabric/container/:containerId', {templateUrl: templatePath + 'container.html'}).
            when('/fabric/activeProfiles', {templateUrl: templatePath + 'activeProfiles.html'}).
            //when('/fabric/profile/:versionId/:profileId', {templateUrl: templatePath + 'profile.html'}).
            when('/wiki/profile/:versionId/:profileId/editFeatures', {templateUrl: templatePath + 'editFeatures.html'}).
            when('/fabric/profile/:versionId/:profileId/:fname', {templateUrl: templatePath + 'pid.html'}).
            when('/fabric/view', { templateUrl: templatePath + 'fabricView.html', reloadOnSearch: false }).
            when('/fabric/patching', { templateUrl: templatePath + 'patching.html' }).
            when('/fabric/mq/brokers', { templateUrl: templatePath + 'brokers.html' }).
            when('/fabric/mq/brokerNetwork', { templateUrl: templatePath + 'brokerNetwork.html' }).
            when('/fabric/mq/createBroker', { templateUrl: templatePath + 'createBroker.html' }).
            when('/fabric/test', { templateUrl: templatePath + 'test.html' });
  }).

    directive('fabricVersionSelector', function() {
      return new Fabric.VersionSelector();
    }).
    directive('fabricProfileSelector', function() {
      return new Fabric.ProfileSelector();
    }).
    directive('fabricContainerList', () => {
      return new Fabric.ContainerList();
    }).
    directive('fabricProfileDetails', () => {
      return new Fabric.ProfileDetails();
    }).
    directive('fabricActiveProfileList', () => {
      return new Fabric.ActiveProfileList();
    }).
    directive('fabricProfileLink', (workspace, jolokia, localStorage) => {
        return {
            restrict: 'A',
            link: ($scope, $element, $attrs) => {
            var profileId = $attrs['fabricProfileLink'];

            if (profileId && !profileId.isBlank()) {
              var container = Fabric.getCurrentContainer(jolokia, ['versionId']);
              var versionId = container['versionId'];
              if (versionId && !versionId.isBlank()) {
                var url = '#' + Fabric.profileLink(workspace, jolokia, localStorage, versionId, profileId);
                if (angular.isDefined($attrs['file'])) {
                  url = url + "/" + $attrs['file'];
                }

                $element.attr('href', url);
              }
            }
          }
        }
    }).
    directive('fabricContainers', ($location, jolokia, workspace, $compile) => {
        return {
            restrict: 'A',
            link: ($scope, $element, $attrs) => {
            var model = $attrs['fabricContainers'];
            var profileId = $attrs['profile'];
            var version = $scope.versionId || $scope.version || "1.0";
            if (model && !model.isBlank() && profileId && !profileId.isBlank()) {
              // lets expose the $scope.connect object!

              Fabric.initScope($scope, $location, jolokia, workspace);
              var containerIds = Fabric.getContainerIdsForProfile(jolokia, version, profileId);
              log.info("Searching for containers for profile: " + profileId + " version " + version + ". Found: " + containerIds);
              $scope[model] = containerIds;

              $scope["onCancel"] = () => {
                console.log("In our new cancel thingy!");
              };

              // now lets add the connect dialog
              var dialog = $("<div ng-include=\"'app/fabric/html/connectToContainerDialog.html'\"></div>");
              var answer = $compile(dialog)($scope);
              $element.append(answer);
            }
          }
        }
    }).
    directive('fabricContainerConnect', ($location, jolokia) => {
        return {
            restrict: 'A',
            link: ($scope, $element, $attrs) => {
            var containerId = $attrs['fabricContainerConnect'];
            var view = $attrs['view'];
            if (containerId && !containerId.isBlank()) {
              //var fields = ["parentId", "profileIds", "versionId", "provisionResult", "jolokiaUrl", "root", 'jmxDomains'];
              var fields = ["jolokiaUrl"];
              //Fabric.initScope($scope, $location, jolokia, workspace);

              var connectFn = () => {
                var container = Fabric.getContainerFields(jolokia, containerId, fields);
                log.info("Connecting to container id " + containerId + " details + " + JSON.stringify(container));
                container["id"]  = containerId;
                $scope.doConnect(container, view);
                Core.$apply($scope);
              };
              $element.on("click", connectFn);
            }
          }
        }
    }).
{'fraction_non_alphanumeric': 0.15725205070842654, 'fraction_numerical': 0.0006524981357196123, 'mean_word_length': 2.412531806615776, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5448075', 'n_tokens_mistral': 2955, 'n_tokens_neox': 2844, 'n_words': 553}