/*jshint -W100*/
/**
 * Each section of the site has its own module. It probably also has
 * submodules, though this boilerplate is too simple to demonstrate it. Within
 * `src/app/home`, however, could exist several additional folders representing
 * additional modules that would then be listed as dependencies of this one.
 * For example, a `note` section could have the submodules `note.create`,
 * `note.delete`, `note.edit`, etc.
 *
 * Regardless, so long as dependencies are managed correctly, the build process
 * will automatically take take of the rest.
 *
 * The dependencies block here is also where component dependencies should be
 * specified, as shown below.
 */
angular.module( 'ngBoilerplate.admin', [
  'ui.router',
  'plusOne',
  'ngBoilerplate.account',
  'ngBoilerplate.users',
  'ngBoilerplate.home',
  'ngBoilerplate.admin_mail_list',
  'ngBoilerplate.admin_modify_db',
  'ngBoilerplate.admin_suggestions',
  'ngBoilerplate.admin_users'
])

/**
 * Each section or module of the site can also have its own routes. AngularJS
 * will handle ensuring they are all available at run-time, but splitting it
 * this way makes each module more "self-contained".
 */
.config(function config( $stateProvider ) {
  $stateProvider.state( 'admin', {
    url: '/admin',
    views: {
       "header": {
        controller: 'AdminCtrl',
        templateUrl: 'header/header.tpl.html'
      },
      "admin_header": {
        controller: 'AdminCtrl',
        templateUrl: 'admin_header/admin_header.tpl.html'
      },
      "main": {
        controller: 'AdminCtrl',
        templateUrl: 'admin/admin.tpl.html'
      },
      "footer": {
        controller: 'AdminCtrl',
        templateUrl: 'footer/footer.tpl.html'
      }
    },
    data:{ pageTitle: 'Administración' }
  });
})

/**
 * And of course we define a controller for our route.
 */
.controller( 'AdminCtrl', function AdminController( $scope, sessionService, $state) {
    console.log("AdminCtrl");
    $scope.isLoggedIn = sessionService.isLoggedIn;
    $scope.logout = function() {
        sessionService.logout();
        $state.go("home");
    };
    $scope.isAdmin = sessionService.isAdmin;
    $scope.isUser = sessionService.isUser;
    $scope.isTempUser = sessionService.isTempUser;
});

