<?php

class Groups extends Cf_Controller
{
    public function __construct()
    {
        parent::__construct();
        setCurrentApplication('groups_app');
    }

    public function index()
    {
        $requiredcss = [['../../../themes/default/css/angularjs-ui/angular-ui.css']];

        $this->carabiner->css($requiredcss);

        $requiredAngularjs = [['dist/angular-base.bundle.js']];

        $requiredjs = [
            ['common_directives/hostsInclude/services/paginationService.js'],
            ['common_directives/editableField.js'],
            //inventory directive (for filter)
            ['advancedreports/dca.js'],
            ['advancedreports/services/notificationService.js'],
            ['advancedreports/services/reportService.js'],
            ['dashboard/helpers/inventory/BaseInventoryWidgetClass.js'],
            ['dashboard/helpers/inventory/PieInventoryWidgetClass.js'],
            ['common_directives/tableDirective.js'],
            ['common_directives/objectsFilter.js'],
            ['common_directives/high-chart.js'],
            ['common_directives/inventory/services/inventoryDataService.js'],
            ['common_directives/inventory/services/inventoryFilterService.js'],
            ['common_directives/inventory/inventory_dca.js'],
            ['common_directives/inventory/services/inventoryService.js'],
            ['common_directives/inventory/helpers/inventoryHelper.js'],
            ['common_directives/inventory/directives/inventoryFilterDirectiveCtrl.js'],
            ['common_directives/inventory/directives/inventoryFilter_directive.js'],
            ['common_directives/objectsFilter.js'],
            // hosts include exclude selector
            ['dashboard/helpers/commonHelper.js'],
            ['common/helper.js'],
            ['common/filters.js'],
            ['common_directives/hostsInclude/services/paginationService.js'],
            ['common_directives/hostsInclude/services/includeExcludeService.js'],
            ['common_directives/hostsInclude/services/autocompleteService.js'],
            ['common_directives/hostsInclude/services/naviTreeService.js'],
            ['common_directives/hostsInclude/directives/include_exclude_directive.js'],
            ['common_directives/hostsInclude/directives/includeExcludeSelectionDirective.js'],
            ['common_directives/hostsInclude/directives/includeExcludeByHostkeyDirective.js'],
            ['common_directives/hostsInclude/services/paginationService.js'],
            ['common_directives/environment/services/naviTreeService.js'],
            // groups APP
            ['groups/app.js'],
            ['groups/controllers/groupsListController.js'],
            ['groups/controllers/baseGroupController.js'],
            ['groups/controllers/personalGroupController.js'],
            ['groups/controllers/sharedGroupController.js'],
            ['groups/services/personalGroupsService.js'],
            ['groups/services/sharedGroupsService.js'],
        ];

        $highchartsjs = [['dist/highcharts.bundle.js']];

        $this->carabiner->js($requiredAngularjs, $requiredAngularjs, $combine = true, $minify = false);
        $this->carabiner->js($requiredjs, $requiredjs, $combine = true, $minify = true);
        $this->carabiner->js($highchartsjs, $highchartsjs, true, false, 'footer');

        $data = ['title' => 'Mission Portal - Groups'];

        $this->load->model('ProfileModel');
        $this->ProfileModel->setAdditionalData(
            $this->session->userdata('username'),
            ProfileModel::GROUPS_APP_OPENED_KEY,
            true,
        );

        $this->template->load('template', 'groups_app/index', $data);
    }

    public function partials($dir, $partial)
    {
        $view = addslashes($dir) . '/' . addslashes($partial) . '.php';
        $this->load->view($view);
    }
}
