'use strict'; (function() { var lemur = angular .module('lemur', [ 'ui.router', 'ngTable', 'ngAnimate', 'chart.js', 'restangular', 'angular-loading-bar', 'ui.bootstrap', 'toaster', 'uiSwitch', 'mgo-angular-wizard', 'satellizer', 'ngLetterAvatar', 'angular-clipboard', 'ngFileSaver', 'ngSanitize', 'ui.select' ]); function fetchData() { var initInjector = angular.injector(['ng']); var $http = initInjector.get('$http'); return $http.get('http://localhost:8000/api/1/auth/providers').then(function(response) { lemur.constant('providers', response.data); }, function(errorResponse) { console.log('Could not fetch SSO providers' + errorResponse); }); } function bootstrapApplication() { angular.element(document).ready(function() { angular.bootstrap(document, ['lemur']); }); } fetchData().then(bootstrapApplication); lemur.config(function ($stateProvider, $urlRouterProvider, $authProvider, providers) { $urlRouterProvider.otherwise('/welcome'); $stateProvider .state('welcome', { url: '/welcome', templateUrl: 'angular/welcome/welcome.html' }); _.each(providers, function(provider) { if ($authProvider.hasOwnProperty(provider.name)) { $authProvider[provider.name](provider); } else { $authProvider.oauth2(provider); } }); }); lemur.directive('compareTo', function() { return { require: 'ngModel', scope: { otherModelValue: '=compareTo' }, link: function(scope, element, attributes, ngModel) { ngModel.$validators.compareTo = function(modelValue) { return modelValue === scope.otherModelValue; }; scope.$watch('otherModelValue', function() { ngModel.$validate(); }); } }; }); lemur.service('MomentService', function () { this.diffMoment = function (start, end) { if (end !== 'None') { return moment(end, 'YYYY-MM-DD HH:mm Z').diff(moment(start, 'YYYY-MM-DD HH:mm Z'), 'minutes') + ' minutes'; } return 'Unknown'; }; this.createMoment = function (date) { if (date !== 'None') { return moment(date, 'YYYY-MM-DD HH:mm Z').fromNow(); } return 'Unknown'; }; }); lemur.controller('datePickerController', function ($scope, $timeout){ $scope.open = function() { $timeout(function() { $scope.opened = true; }); }; }); lemur.service('DefaultService', function (LemurRestangular) { var DefaultService = this; DefaultService.get = function () { return LemurRestangular.all('defaults').customGET().then(function (defaults) { return defaults; }); }; }); lemur.service('DnsService', function (LemurRestangular) { var DnsService = this; DnsService.get = function () { return LemurRestangular.all('dns_service').customGET().then(function (dns_service) { return dns_service; }); }; }); lemur.directive('lemurBadRequest', [function () { return { template: '