blob: 3cb769e3a0b64ea1920568dfb599371f049df0b1 [file] [log] [blame]
Matteo Scandoloa8cbc9c2016-06-16 17:03:24 -07001'use strict';
2
3angular.module('xos.hpc', [
4 'ngResource',
5 'ngCookies',
6 'ui.router',
7 'xos.helpers'
8])
9.config(($stateProvider) => {
10 $stateProvider
11 .state('hpc-list', {
12 url: '/',
13 template: '<hpcs-list></hpcs-list>'
14 });
15})
16.config(function($httpProvider){
17 $httpProvider.interceptors.push('NoHyperlinks');
18})
19.service('Hpc', function($q, $http){
20 this.query = (params) => {
21 const d = $q.defer();
22
23 $http.get('/xoslib/hpcview', {params: params})
24 .then((res) => {
25 d.resolve(res.data);
26 })
27 .catch(d.reject);
28
29 return {$promise: d.promise};
30 };
31})
32.directive('hpcsList', function(){
33 return {
34 restrict: 'E',
35 scope: {},
36 bindToController: true,
37 controllerAs: 'vm',
38 templateUrl: 'templates/hpc-list.tpl.html',
39 controller: function(Hpc){
40
41 this.routerConfig = {
42 filter: 'field',
43 order: true,
44 columns: [
45 {
46 label: 'Name',
47 prop: 'name'
48 },
49 {
50 label: 'Ip Address',
51 prop: 'ip'
52 },
53 {
54 label: 'Record Checker',
55 prop: 'watcher.DNS.msg'
56 },
57 {
58 label: 'Name Servers',
59 prop: 'nameservers',
60 type: 'arrray'
61 },
62 {
63 label: 'Dns Demux Config Age',
64 prop: 'dnsdemux_config_age'
65 },
66 {
67 label: 'Dns Redir Config Age',
68 prop: 'dnsredir_config_age'
69 }
70 ]
71 };
72
73 this.cacheConfig = {
74 filter: 'field',
75 order: true,
76 columns: [
77 {
78 label: 'Name',
79 prop: 'name'
80 },
81 {
82 label: 'Prober',
83 prop: 'watcher.HPC-hb.msg'
84 },
85 {
86 label: 'Fetcher',
87 prop: 'watcher.HPC-fetch.msg'
88 },
89 {
90 label: 'Config Age',
91 prop: 'config_age'
92 }
93 ]
94 };
95
96 // retrieving user list
97 Hpc.query().$promise
98 .then((hpcs) => {
99 this.routers = hpcs[0].dnsdemux;
100 this.caches = hpcs[0].hpc;
101 })
102 .catch((e) => {
103 throw new Error(e);
104 });
105 }
106 };
107});