import uiModules from 'ui/modules';
import uiRoutes from 'ui/routes';

import 'ui/autoload/styles';
import './less/main.less';
import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
import overviewTemplate from './templates/index.html';
import detailTemplate from './templates/detail.html';
import healthTemplate from './templates/health.html';
import dataTemplate from './templates/data.html';

require('jquery');
require('bootstrap');

uiRoutes.enable();
uiRoutes
.when('/', {
  template: overviewTemplate,
  controller: 'elasticsearchStatusController',
  controllerAs: 'ctrl'
})
.when('/index/:name', {
  template: detailTemplate,
  controller: 'elasticsearchDetailController',
  controllerAs: 'ctrl'
})
.when('/health', {
  template: healthTemplate,
  controller: 'elasticsearchHealthController',
  controllerAs: 'ctrl'
})
.when('/data', {
  template: dataTemplate,
  controller: 'elasticsearchDataController',
  controllerAs: 'ctrl'
});

uiModules
.get('app/malice')
.controller('elasticsearchStatusController', function ($http) {
  $http.get('../api/malice/indices').then((response) => {
    this.indices = response.data;
  });
})
.controller('elasticsearchDetailController', function ($routeParams, $http) {
  this.index = $routeParams.name;

  $http.get(`../api/malice/index/${this.index}`).then((response) => {
    this.status = response.data;
  });
})
.controller('elasticsearchHealthController', function ($http) {
  $http.get('../api/malice/health').then((response) => {
    this.health = response.data;
  });
})
.controller('elasticsearchDataController', function ($http) {
  $http.get('../api/malice/data').then((response) => {
    this.data = response.data;
  });
});

@@ -1,458 +1,244 @@
-import uiModules from 'ui/modules';%0Aimport uiRoutes from 'ui/routes';%0A%0Aimport 'ui/autoload/styles';%0Aimport './less/main.less';%0Aimport '../node_modules/bootstrap/dist/css/bootstrap.min.css';%0Aimport overviewTemplate from './templates/index.html';%0Aimport detailTemplate from './templates/detail.html';%0Aimport healthTemplate from './templates/health.html';%0Aimport dataTemplate from './templates/data.html';%0A%0Arequire('jquery');%0Arequire('bootstrap');%0A%0AuiR
+var app = require('ui/modules').get('apps/malice', %5B%5D);%0A%0Aimport 'ui/autoload/styles';%0A%0Arequire('jquery');%0Arequire('bootstrap');%0A%0Aimport '../node_modules/bootstrap/dist/css/bootstrap.min.css';%0Aimport './less/main.less';%0A%0Arequire('ui/r
 outes
+')
 .ena
@@ -248,17 +248,31 @@
 ();%0A
-uiRoutes%0A
+require('ui/routes')%0A  
 .whe
@@ -278,24 +278,26 @@
 en('/', %7B%0A  
+ 
+ 
 template: ov
@@ -298,26 +298,45 @@
 te: 
-overviewTemplate,%0A
+require('./templates/index.html'),%0A  
   co
@@ -346,29 +346,22 @@
 oller: '
-elasticsearch
+malice
 StatusCo
@@ -363,32 +363,34 @@
 tusController',%0A
+  
   controllerAs: 
@@ -388,35 +388,39 @@
 ollerAs: 'ctrl'%0A
+  
 %7D)%0A
+  
 .when('/index/:n
@@ -423,24 +423,26 @@
 x/:name', %7B%0A
+  
   template: 
@@ -445,24 +445,46 @@
 te: 
-detailTemplate,%0A
+require('./templates/detail.html'),%0A  
   co
@@ -494,29 +494,22 @@
 oller: '
-elasticsearch
+malice
 DetailCo
@@ -511,32 +511,34 @@
 ailController',%0A
+  
   controllerAs: 
@@ -536,35 +536,39 @@
 ollerAs: 'ctrl'%0A
+  
 %7D)%0A
+  
 .when('/health',
@@ -566,24 +566,26 @@
 /health', %7B%0A
+  
   template: 
@@ -588,24 +588,46 @@
 te: 
-healthTemplate
+require('./templates/health.html')
 ,%0A
+  
   co
@@ -637,29 +637,22 @@
 oller: '
-elasticsearch
+malice
 HealthCo
@@ -656,32 +656,34 @@
 hController',%0A  
+ 
+ 
 controllerAs: 'c
@@ -687,19 +687,23 @@
  'ctrl'%0A
+  
 %7D)%0A
+  
 .when('/
@@ -711,16 +711,18 @@
 ata', %7B%0A
+  
   templa
@@ -729,22 +729,44 @@
 te: 
-dataTemplate,%0A
+require('./templates/data.html'),%0A  
   co
@@ -776,29 +776,22 @@
 oller: '
-elasticsearch
+malice
 DataCont
@@ -799,16 +799,18 @@
 oller',%0A
+  
   contro
@@ -828,68 +828,37 @@
 rl'%0A
+  
 %7D);%0A%0A
-uiModules%0A.get('app/malice')%0A.controller('elasticsearch
+app.controller('malice
 Stat
@@ -1005,29 +1005,22 @@
 roller('
-elasticsearch
+malice
 DetailCo
@@ -1223,29 +1223,22 @@
 roller('
-elasticsearch
+malice
 HealthCo
@@ -1383,21 +1383,14 @@
 er('
-elasticsearch
+malice
 Data

clean up app.js code