feat(apps): WIP progress app views

This commit is contained in:
Torkel Ödegaard
2015-12-22 13:42:48 +01:00
parent 7a87c900ee
commit b8cb5e0367
6 changed files with 49 additions and 78 deletions

View File

@@ -2,36 +2,26 @@
import config = require('app/core/config');
import angular from 'angular';
import * as _ from 'lodash';
export class AppEditCtrl {
appModel: any;
/** @ngInject */
constructor(private $scope: any, private appSrv: any, private $routeParams: any) {
constructor(private appSrv: any, private $routeParams: any) {}
$scope.init = function() {
$scope.current = {};
$scope.getApps();
};
$scope.getApps = function() {
appSrv.get($routeParams.type).then(function(result) {
$scope.current = _.clone(result);
});
};
$scope.update = function() {
$scope._update();
};
$scope._update = function() {
appSrv.update($scope.current).then(function() {
window.location.href = config.appSubUrl + "org/apps";
});
};
$scope.init();
init() {
this.appModel = {};
this.appSrv.get(this.$routeParams.type).then(result => {
this.appModel = _.clone(result);
});
}
update() {
this.appSrv.update(this.appModel).then(function() {
window.location.href = config.appSubUrl + "org/apps";
});
}
}
angular.module('grafana.controllers').controller('AppEditCtrl', AppEditCtrl);

View File

@@ -4,28 +4,15 @@ import config = require('app/core/config');
import angular from 'angular';
export class AppListCtrl {
apps: any[];
/** @ngInject */
constructor($scope: any, appSrv: any, $location: any) {
constructor(private appSrv: any) {}
$scope.init = function() {
$scope.apps = {};
$scope.getApps();
};
$scope.getApps = function() {
appSrv.getAll().then(function(result) {
$scope.apps = result;
});
};
$scope.update = function(app) {
appSrv.update(app).then(function() {
window.location.href = config.appSubUrl + $location.path();
});
};
$scope.init();
init() {
this.appSrv.getAll().then(result => {
this.apps = result;
});
}
}

View File

@@ -23,7 +23,6 @@ export class AppSrv {
});
}
getAll() {
if (!_.isEmpty(this.apps)) {
return this.$q.when(this.apps);

View File

@@ -5,10 +5,9 @@
</ul>
</topnav>
<div class="page-container">
<div class="page">
<h2>Edit App</h2>
<div class="page-container" style="background: transparent; border: 0;">
<div class="page-wide" ng-init="ctrl.init()">
<h2>{{ctrl.appModel.type}}</h2>
<form name="editForm">
<div class="tight-form">
@@ -34,14 +33,9 @@
</ul>
<div class="clearfix"></div>
</div>
<br>
<app-config-loader></app-config-loader>
<div class="pull-right" style="margin-top: 35px">
<button type="submit" class="btn btn-success" ng-click="update()">Save</button>
<a class="btn btn-inverse" href="org/apps">Cancel</a>
</div>
<br>
</form>
</div>
</div>
</div>

View File

@@ -4,33 +4,32 @@
</ul>
</topnav>
<div class="page-container">
<div class="page">
<h2>Apps</h2>
<div class="page-container" style="background: transparent; border: 0;">
<div class="page-wide" ng-init="ctrl.init()">
<h2>Apps</h2>
<div ng-if="!apps">
<div ng-if="!ctrl.apps">
<em>No apps defined</em>
</div>
<table class="grafana-options-table" ng-if="apps">
<tr>
<td><strong>Name</strong></td>
<td></td>
<td></td>
</tr>
<tr ng-repeat="(type, p) in apps">
<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>
Configure
</a>
</td>
</tr>
</table>
<ul class="filter-list">
<li ng-repeat="app in ctrl.apps">
<ul class="filter-list-card">
<li>
<div class="filter-list-card-controls">
<div class="filter-list-card-config">
<a href="org/apps/edit/{{app.type}}">
<i class="fa fa-cog"></i>
</a>
</div>
</div>
<span class="filter-list-card-title">Litmus{{app.type}}</span>
<span class="filter-list-card-status">
<span class="filter-list-card-state">Dashboards: 1</span>
</span>
</li>
</ul>
</li>
</ul>
</div>
</div>