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

View File

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

View File

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

View File

@@ -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.apps = {};
@@ -27,6 +26,7 @@ function (angular, config) {
};
$scope.init();
}
}
});
});
angular.module('grafana.controllers').controller('AppListCtrl', AppListCtrl);

View File

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

View File

@@ -14,26 +14,21 @@
<table class="grafana-options-table" ng-if="apps">
<tr>
<td><strong>Type</strong></td>
<td><strong>Name</strong></td>
<td></td>
<td></td>
</tr>
<tr ng-repeat="(type, p) in apps">
<td style="width:1%">
<td style="width:99%">
<i class="fa fa-cubes"></i> &nbsp;
{{p.type}}
</td>
<td style="width: 1%">
<a href="org/apps/edit/{{p.type}}" class="btn btn-inverse btn-mini">
<i class="fa fa-edit"></i>
Edit
Configure
</a>
</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>
</table>