{"size": 3948, "ext": "js", "max_stars_repo_path": "webroot/monitor/networking/ui/js/networking.main.js", "max_stars_repo_name": "Mirantis/contrail-web-controller", "max_stars_repo_stars_event_min_datetime": "2018-01-16T01:43:27.000Z", "max_stars_repo_stars_event_max_datetime": "2018-01-16T01:43:27.000Z", "max_issues_repo_path": "webroot/monitor/networking/ui/js/networking.main.js", "max_issues_repo_name": "Mirantis/contrail-web-controller", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "webroot/monitor/networking/ui/js/networking.main.js", "max_forks_repo_name": "Mirantis/contrail-web-controller", "max_forks_repo_forks_event_min_datetime": "2018-01-16T01:43:46.000Z", "max_forks_repo_forks_event_max_datetime": "2018-01-16T01:43:49.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 39.8787878788, "max_line_length": 95, "alphanum_fraction": 0.507852077}
/*
 * Copyright (c) 2014 Juniper Networks, Inc. All rights reserved.
 */

var mnPageLoader = new MonitorNetworkingLoader();

function MonitorNetworkingLoader() {
    this.load = function (paramObject) {
        var self = this, currMenuObj = globalObj.currMenuObj,
            hashParams = paramObject['hashParams'],
            pathMNView = ctWebDir + '/monitor/networking/ui/js/views/MonitorNetworkingView.js',
            renderFn = paramObject['function'],
            loadingStartedDefObj = paramObject['loadingStartedDefObj'];

        require([pathMNView], function (MonitorNetworkingView) {
            self.mnView = new MonitorNetworkingView();
            self.renderView(renderFn, hashParams);
            if(contrail.checkIfExist(loadingStartedDefObj)) {
                loadingStartedDefObj.resolve();
            }
        });
    };
    this.renderView = function (renderFn, hashParams, view) {
        $(contentContainer).empty();
        switch (renderFn) {
            case 'renderProjects':
                if (hashParams.type == "project") {
                    if (hashParams.view == "details") {
                        this.mnView.renderProject({hashParams: hashParams});
                    } else {
                        this.mnView.renderProjectList({hashParams: hashParams});
                    }
                } else if (hashParams.type == "flow"){
                    if (hashParams.view == "list") {
                        this.mnView.renderFlowList({hashParams: hashParams});
                    } else if (hashParams.view == "details") {
                        this.mnView.renderFlow({hashParams: hashParams});
                    }
                }
                break;

            case 'renderNetworks':
                if (hashParams.type == "network") {
                    if (hashParams.view == "details") {
                        this.mnView.renderNetwork({hashParams: hashParams});
                    } else {
                        if(view != undefined) {
                            view.renderNetworkList({hashParams: hashParams});
                        } else {
                            this.mnView.renderNetworkList({hashParams: hashParams});
                        }
                    }
                } else if (hashParams.type == "flow"){
                    if (hashParams.view == "list") {
                        this.mnView.renderFlowList({hashParams: hashParams});
                    } else if (hashParams.view == "details") {
                        this.mnView.renderFlow({hashParams: hashParams});
                    }
                }
                break;

            case 'renderInstances':
                if (hashParams.view == "details") {
                    this.mnView.renderInstance({hashParams: hashParams});
                } else {
                    this.mnView.renderInstanceList({hashParams: hashParams});
                }
                break;

            case 'renderFlows':
                if (hashParams.view == "list") {
                    this.mnView.renderFlowList({hashParams: hashParams});
                } else if (hashParams.view == "details") {
                    this.mnView.renderFlow({hashParams: hashParams});
                }
                break;
        }
    },

    this.updateViewByHash = function (currPageQueryStr) {
        var renderFn;

        //TODO: The renderFunction should be passed from ContentHandler
        if(currPageQueryStr.type == "network"){
            renderFn = "renderNetworks";
        } else if (currPageQueryStr.type == "project"){
            renderFn = "renderProjects"
        } else if (currPageQueryStr.type == "instance"){
            renderFn = "renderInstances"
        } else if (currPageQueryStr.type == "flow"){
            renderFn = "renderFlows"
        }

        this.load({hashParams: currPageQueryStr, 'function': renderFn});
    };

    this.destroy = function () {};
};
