<commit_before>/// <reference path="../../../typings/tsd.d.ts" />

export class ServerService {
    config: Array<any>;
    rest: restangular.IService;
    restFull: restangular.IService;
    static $inject: Array<string> = ['Restangular'];
    constructor(rest: restangular.ICollection) {
        this.rest = rest.withConfig((RestangularConfigurer) => {
            RestangularConfigurer.setBaseUrl('/api/v1/');
        });
        this.restFull = rest.withConfig((RestangularConfigurer) => {
            RestangularConfigurer.setBaseUrl('/api/v1/');
            RestangularConfigurer.setFullResponse(true);
        });
    }

    // **getEvents**
    // **@returns** a promise with all events.
    getEvents() {
        return this.rest.all('events').getList().then(function(events) {
            return events;
        });
    }

    // **getList**
    // **@returns** a promise with all servers.
    getList() {
        return this.rest.all('nodes').getList().then(function(servers) {
            return _.sortBy(servers, "hostname");
        });
    }

    // **getListByCluster**
    // **@returns** a promise with all nodes part of the cluster.
    getListByCluster(clusterId) {
        return this.rest.one('clusters', clusterId).all('nodes').getList().then(function(nodes) {
            return nodes;
        });
    }

    // **getFreeHosts**
    // **@returns** a promise with all servers which are free.
    getFreeHosts() {
        return this.rest.all('nodes').getList({ state: 'free' }).then(function(servers) {
            return servers;
        });
    }

    // **getDiscoveredHosts**
    // **@returns** a promise with all unmanaged nodes.
    getDiscoveredHosts() {
        return this.rest.all('unmanaged_nodes').getList().then(function(nodes: Array<any>) {
            var unmanagedNodes: Array<any> = [];
            _.each(nodes, (node) => {
                 unmanagedNodes.push({ hostname: node.name, saltfingerprint: node.saltfingerprint });
            });
            return unmanagedNodes;
        });
    }<commit_msg>host lists are sorted alphabetically.<commit_after>/// <reference path="../../../typings/tsd.d.ts" />

export class ServerService {
    config: Array<any>;
    rest: restangular.IService;
    restFull: restangular.IService;
    static $inject: Array<string> = ['Restangular'];
    constructor(rest: restangular.ICollection) {
        this.rest = rest.withConfig((RestangularConfigurer) => {
            RestangularConfigurer.setBaseUrl('/api/v1/');
        });
        this.restFull = rest.withConfig((RestangularConfigurer) => {
            RestangularConfigurer.setBaseUrl('/api/v1/');
            RestangularConfigurer.setFullResponse(true);
        });
    }

    // **getEvents**
    // **@returns** a promise with all events.
    getEvents() {
        return this.rest.all('events').getList().then(function(events) {
            return events;
        });
    }

    // **getList**
    // **@returns** a promise with all servers.
    getList() {
        return this.rest.all('nodes').getList().then(function(servers) {
            return _.sortBy(servers, "hostname");
        });
    }

    // **getListByCluster**
    // **@returns** a promise with all nodes part of the cluster.
    getListByCluster(clusterId) {
        return this.rest.one('clusters', clusterId).all('nodes').getList().then(function(nodes) {
            return _.sortBy(nodes, "hostname");
        });
    }

    // **getFreeHosts**
    // **@returns** a promise with all servers which are free.
    getFreeHosts() {
        return this.rest.all('nodes').getList({ state: 'free' }).then(function(servers) {
            return  _.sortBy(servers, "hostname");
        });
    }

    // **getDiscoveredHosts**
    // **@returns** a promise with all unmanaged nodes.
    getDiscoveredHosts() {
        return this.rest.all('unmanaged_nodes').getList().then(function(nodes: Array<any>) {
            var unmanagedNodes: Array<any> = [];
            _.each(nodes, (node) => {
                 unmanagedNodes.push({ hostname: node.name, saltfingerprint: node.saltfingerprint });
            });
            return _.sortBy(unmanagedNodes, "hostname");
        });
    }
{'fraction_non_alphanumeric': 0.1601814275483409, 'fraction_numerical': 0.0009548818333731201, 'mean_word_length': 2.3927125506072873, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, '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': '639727', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1199, 'n_words': 225}