Browse Source

feat(apps): rewrote appsCtrl to app_list_ctrl and to typescript

Torkel Ödegaard 10 years ago
parent
commit
d0dead0a08

+ 3 - 3
public/app/core/routes/all.js

@@ -132,12 +132,12 @@ define([
         controller : 'ResetPasswordCtrl',
         controller : 'ResetPasswordCtrl',
       })
       })
       .when('/org/apps', {
       .when('/org/apps', {
-        templateUrl: 'app/features/org/partials/apps.html',
-        controller: 'AppsCtrl',
+        templateUrl: 'app/features/org/partials/app_list.html',
+        controller: 'AppListCtrl',
         resolve: loadOrgBundle,
         resolve: loadOrgBundle,
       })
       })
       .when('/org/apps/edit/:type', {
       .when('/org/apps/edit/:type', {
-        templateUrl: 'app/features/org/partials/appEdit.html',
+        templateUrl: 'app/features/org/partials/app_edit.html',
         controller: 'AppEditCtrl',
         controller: 'AppEditCtrl',
         resolve: loadOrgBundle,
         resolve: loadOrgBundle,
       })
       })

+ 2 - 2
public/app/features/org/all.js

@@ -6,8 +6,8 @@ define([
   './userInviteCtrl',
   './userInviteCtrl',
   './orgApiKeysCtrl',
   './orgApiKeysCtrl',
   './orgDetailsCtrl',
   './orgDetailsCtrl',
-  './appsCtrl',
-  './appEditCtrl',
+  './app_list_ctrl',
+  './app_edit_ctrl',
   './app_srv',
   './app_srv',
   './app_directive',
   './app_directive',
 ], function () {});
 ], function () {});

+ 10 - 10
public/app/features/org/appsCtrl.js → public/app/features/org/app_list_ctrl.ts

@@ -1,13 +1,12 @@
-define([
-  'angular',
-  'app/core/config',
-],
-function (angular, config) {
-  'use strict';
+///<reference path="../../headers/common.d.ts" />
 
 
-  var module = angular.module('grafana.controllers');
+import config = require('app/core/config');
+import angular from 'angular';
 
 
-  module.controller('AppsCtrl', function($scope, $location, appSrv) {
+export class AppListCtrl {
+
+  /** @ngInject */
+  constructor($scope: any, appSrv: any, $location: any) {
 
 
     $scope.init = function() {
     $scope.init = function() {
       $scope.apps = {};
       $scope.apps = {};
@@ -27,6 +26,7 @@ function (angular, config) {
     };
     };
 
 
     $scope.init();
     $scope.init();
+  }
+}
 
 
-  });
-});
+angular.module('grafana.controllers').controller('AppListCtrl', AppListCtrl);

+ 3 - 3
public/app/features/org/app_srv.ts

@@ -30,10 +30,10 @@ export class AppSrv {
     }
     }
 
 
     return this.backendSrv.get('api/org/apps').then(results => {
     return this.backendSrv.get('api/org/apps').then(results => {
-      this.apps = results.reduce((prev, current) => {
+      return results.reduce((prev, current) => {
         prev[current.type] = current;
         prev[current.type] = current;
-      }, {});
-      return this.apps;
+        return prev;
+      }, this.apps);
     });
     });
   }
   }
 
 

+ 4 - 9
public/app/features/org/partials/app_list.html

@@ -14,28 +14,23 @@
 
 
 		<table class="grafana-options-table" ng-if="apps">
 		<table class="grafana-options-table" ng-if="apps">
 			<tr>
 			<tr>
-				<td><strong>Type</strong></td>
+				<td><strong>Name</strong></td>
 				<td></td>
 				<td></td>
 				<td></td>
 				<td></td>
 			</tr>
 			</tr>
 			<tr ng-repeat="(type, p) in apps">
 			<tr ng-repeat="(type, p) in apps">
-				<td style="width:1%">
+				<td style="width:99%">
 					<i class="fa fa-cubes"></i> &nbsp;
 					<i class="fa fa-cubes"></i> &nbsp;
 					{{p.type}}
 					{{p.type}}
 				</td>
 				</td>
 				<td style="width: 1%">
 				<td style="width: 1%">
 					<a href="org/apps/edit/{{p.type}}" class="btn btn-inverse btn-mini">
 					<a href="org/apps/edit/{{p.type}}" class="btn btn-inverse btn-mini">
 						<i class="fa fa-edit"></i>
 						<i class="fa fa-edit"></i>
-						Edit
+						Configure
 					</a>
 					</a>
 				</td>
 				</td>
-				<td style="width: 1%">
-					Enabled&nbsp;
-					<input  id="p.enabled" type="checkbox" ng-model="p.enabled" ng-checked="p.enabled" ng-change="update(p)">
-					<label for="p.enabled"></label>
-				</td>
 			</tr>
 			</tr>
 		</table>
 		</table>
 
 
 	</div>
 	</div>
-</div>
+</div>