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

This commit is contained in:
Torkel Ödegaard
2015-12-22 12:13:55 +01:00
parent ad94f99d57
commit d0dead0a08
5 changed files with 22 additions and 27 deletions
+3 -3
View File
@@ -132,12 +132,12 @@ define([
controller : 'ResetPasswordCtrl', controller : 'ResetPasswordCtrl',
}) })
.when('/org/apps', { .when('/org/apps', {
templateUrl: 'app/features/org/partials/apps.html', templateUrl: 'app/features/org/partials/app_list.html',
controller: 'AppsCtrl', 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
View File
@@ -6,8 +6,8 @@ define([
'./userInviteCtrl', './userInviteCtrl',
'./orgApiKeysCtrl', './orgApiKeysCtrl',
'./orgDetailsCtrl', './orgDetailsCtrl',
'./appsCtrl', './app_list_ctrl',
'./appEditCtrl', './app_edit_ctrl',
'./app_srv', './app_srv',
'./app_directive', './app_directive',
], function () {}); ], function () {});
@@ -1,13 +1,12 @@
define([ ///<reference path="../../headers/common.d.ts" />
'angular',
'app/core/config',
],
function (angular, config) {
'use strict';
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
View File
@@ -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 prev;
return this.apps; }, this.apps);
}); });
} }
@@ -14,26 +14,21 @@
<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>