<commit_before>angular.module('containersNetwork', ['ngVis'])
.controller('ContainersNetworkController', ['$scope', '$location', 'Container', 'Messages', 'VisDataSet', function($scope, $location, Container, Messages, VisDataSet) {

    function ContainerNode(data) {
        this.Id = data.Id;
        // names have the following format: /Name
        this.Name = data.Name.substring(1);
        this.Image = data.Config.Image;
	this.Running = data.State.Running;
        var dataLinks = data.HostConfig.Links;
        if (dataLinks != null) {
            this.Links = {};
            for (var i = 0; i < dataLinks.length; i++) {
                // links have the following format: /TargetContainerName:/SourceContainerName/LinkAlias
                var link = dataLinks[i].split(":");
                var target = link[0].substring(1);
                var alias = link[1].substring(link[1].lastIndexOf("/") + 1);
                // only keep shortest alias
                if (this.Links[target] == null || alias.length < this.Links[target].length) {
                    this.Links[target] = alias;
                }
            }
        }
        var dataVolumes = data.HostConfig.VolumesFrom;
        //converting array into properties for simpler and faster access
        if (dataVolumes != null) {
            this.VolumesFrom = {};
            for (var j = 0; j < dataVolumes.length; j++) {
                this.VolumesFrom[dataVolumes[j]] = true;
            }
        }
    }

    function ContainersNetworkData() {
        this.nodes = new VisDataSet();
        this.edges = new VisDataSet();

        this.addContainerNode = function(container) {
            this.nodes.add({
                id: container.Id,
                label: container.Name,
                title: "<ul style=\"list-style-type:none; padding: 0px; margin: 0px\">" +
                    "<li><strong>ID:</strong> " + container.Id + "</li>" +
                    "<li><strong>Image:</strong> " + container.Image + "</li>" +
                    "</ul>",
		color: (container.Running ? null : "gray")
	    });
        };

        this.addLinkEdgeIfExists = function(from, to) {
            if (from.Links != null && from.Links[to.Name] != null) {
                this.edges.add({
                    from: from.Id,
                    to: to.Id,
                    label: from.Links[to.Name] });
            }
        };

        this.addVolumeEdgeIfExists = function(from, to) {
          if (from.VolumesFrom != null && (from.VolumesFrom[to.Id] != null || from.VolumesFrom[to.Name] != null)) {
                this.edges.add({
                    from: from.Id,
                    to: to.Id,
                    color: { color: '#A0A0A0', highlight: '#A0A0A0', hover: '#848484'}});
            }
        };

        this.removeContainersNodes = function(containersIds) {
            this.nodes.remove(containersIds);<commit_msg>Have to provide a color<commit_after>angular.module('containersNetwork', ['ngVis'])
.controller('ContainersNetworkController', ['$scope', '$location', 'Container', 'Messages', 'VisDataSet', function($scope, $location, Container, Messages, VisDataSet) {

    function ContainerNode(data) {
        this.Id = data.Id;
        // names have the following format: /Name
        this.Name = data.Name.substring(1);
        this.Image = data.Config.Image;
	this.Running = data.State.Running;
        var dataLinks = data.HostConfig.Links;
        if (dataLinks != null) {
            this.Links = {};
            for (var i = 0; i < dataLinks.length; i++) {
                // links have the following format: /TargetContainerName:/SourceContainerName/LinkAlias
                var link = dataLinks[i].split(":");
                var target = link[0].substring(1);
                var alias = link[1].substring(link[1].lastIndexOf("/") + 1);
                // only keep shortest alias
                if (this.Links[target] == null || alias.length < this.Links[target].length) {
                    this.Links[target] = alias;
                }
            }
        }
        var dataVolumes = data.HostConfig.VolumesFrom;
        //converting array into properties for simpler and faster access
        if (dataVolumes != null) {
            this.VolumesFrom = {};
            for (var j = 0; j < dataVolumes.length; j++) {
                this.VolumesFrom[dataVolumes[j]] = true;
            }
        }
    }

    function ContainersNetworkData() {
        this.nodes = new VisDataSet();
        this.edges = new VisDataSet();

        this.addContainerNode = function(container) {
            this.nodes.add({
                id: container.Id,
                label: container.Name,
                title: "<ul style=\"list-style-type:none; padding: 0px; margin: 0px\">" +
                    "<li><strong>ID:</strong> " + container.Id + "</li>" +
                    "<li><strong>Image:</strong> " + container.Image + "</li>" +
                    "</ul>",
		color: (container.Running ? "cyan" : "gray")
	    });
        };

        this.addLinkEdgeIfExists = function(from, to) {
            if (from.Links != null && from.Links[to.Name] != null) {
                this.edges.add({
                    from: from.Id,
                    to: to.Id,
                    label: from.Links[to.Name] });
            }
        };

        this.addVolumeEdgeIfExists = function(from, to) {
          if (from.VolumesFrom != null && (from.VolumesFrom[to.Id] != null || from.VolumesFrom[to.Name] != null)) {
                this.edges.add({
                    from: from.Id,
                    to: to.Id,
                    color: { color: '#A0A0A0', highlight: '#A0A0A0', hover: '#848484'}});
            }
        };

        this.removeContainersNodes = function(containersIds) {
            this.nodes.remove(containersIds);
{'fraction_non_alphanumeric': 0.1429061000685401, 'fraction_numerical': 0.0075394105551747775, 'mean_word_length': 1.7212121212121212, 'pattern_counts': {'":': 2, '<': 29, '<?xml version=': 0, '>': 23, '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': '4822875', 'n_tokens_mistral': 1670, 'n_tokens_neox': 1597, 'n_words': 339}