Viewing File: /usr/local/cpanel/base/frontend/jupiter/site-monitor/index.js

/*
# site-monitor/index.js                            Copyright 2021 cPanel, L.L.C.
#                                                           All rights reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
*/
/* global require, define, PAGE */

/** @namespace cpanel.siteMonitor */

define(
    [
        "angular",
        "cjt/core",
        "app/views/ROUTES",
        "cjt/modules",
        "ngRoute",
        "ngAnimate",
        "cjt/services/alertService",
        "app/services/sites",
        "app/services/sitesCache",
        "cjt/directives/loadingPanel",
        "cjt/decorators/alertAPIReporter",
        "cjt/directives/alertList",
        "angular-chosen",

        // Bundle in the views for now
        "app/views/listSiteMonitors",
    ],
    function(angular, CJT, ROUTES) {

        "use strict";

        return function() {

            // First create the application
            angular.module("cpanel.siteMonitor", [
                "ngRoute",
                "ngAnimate",
                "cjt2.cpanel",
                "cpanel.siteMonitor.sitesService",
                "cpanel.siteMonitor.sitesCacheService",
                "cjt2.directives.loadingPanel",
                "cjt2.services.alert",
                "localytics.directives",

                // View Modules
                "cpanel.siteMonitor.listSiteMonitors",
            ]);

            var requires = [
                "cjt/bootstrap",
                "cjt/directives/breadcrumbs",
                "cjt/views/applicationController",
            ];

            ROUTES.forEach(function(route) {
                requires.push("app/views/" + route.controller);
            });

            // Then load the application dependencies
            var app = require(requires, function(BOOTSTRAP) {

                var app = angular.module("cpanel.siteMonitor");

                app.value("PAGE", PAGE);

                app.value("ITEM_LISTER_CONSTANTS", {
                    ITEM_CLICKED_EVENT: "ClickEmitted",
                    ITEM_SELECT_EVENT: "SelectEmitted",
                    MONITOR_CHANGE_EVENT: "MonitorChangeEmitted"
                });

                app.config([
                    "$routeProvider",
                    "$animateProvider",
                    function($routeProvider, $animateProvider) {

                        $animateProvider.classNameFilter(/^((?!no-animate).)*$/);

                        ROUTES.forEach(function(ROUTE) {
                            var route = {
                                controller: ROUTE.controller,
                                templateUrl: ROUTE.templateUrl,
                                breadcrumb: ROUTE.breadcrumb,
                                resolve: ROUTE.resolve,
                            };
                            $routeProvider.when(ROUTE.path, route);
                        });

                        $routeProvider.otherwise({
                            "redirectTo": "/"
                        });

                    }
                ]);

                app.controller(
                    "main",
                    [
                        "$scope", "$rootScope", "$location", "alertService",
                        function($scope, $rootScope, $location, $alertService) {

                            $rootScope.$on("$routeChangeStart", function() {
                                $scope.loading = true;
                                $alertService.clear("danger");
                            });

                            $rootScope.$on("$routeChangeSuccess", function(event, current) {
                                $scope.loading = false;
                            });

                            $rootScope.$on("$routeChangeError", function() {
                                $scope.loading = false;
                            });
                        }
                    ]
                );

                BOOTSTRAP("#content", "cpanel.siteMonitor");

            });

            /*
            // The following lines are a workaround for CPANEL-3887. Having a dummy mt call
            // ensures that the minified version of this file is not deleted during a build.
            require(["cjt/util/locale"], function(LOCALE) {
                LOCALE.maketext("Enabled");
            });
            */

            return app;
        };
    }
);
Back to Directory File Manager