{"size": 864, "ext": "js", "max_stars_repo_path": "src/view/agent-overview.js", "max_stars_repo_name": "robisrob/teamcity-radiator", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/view/agent-overview.js", "max_issues_repo_name": "robisrob/teamcity-radiator", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/view/agent-overview.js", "max_forks_repo_name": "robisrob/teamcity-radiator", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 27.8709677419, "max_line_length": 86, "alphanum_fraction": 0.5706018519}
import { AgentService } from '../domain/services/agent-service';
import { inject } from 'aurelia-framework';

@inject(AgentService)
export class AgentOverview {
    constructor(service) {
        this.service = service;
    }

    getConnectedCssClass(agent) {
        if (agent.connected == true) {
            return 'alert-success';
        }
        if (agent.connected === false) {
            return 'alert-danger';
        }
        throw new Error('The connected property "' + agent.connected + '" is invalid')
    }

    activate(params) {
        this.url = params.baseUrl;
        setAgents.bind(this)(params);
        setInterval(setAgents.bind(this), 30000, params);

        function setAgents(params) {
            this.service
                .getAgents(params.baseUrl)
                .then(agents => { this.agents = agents; });
        }
    }
} 