From b8cb5e03677c055231f35a4b9dce5c048e152194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 22 Dec 2015 13:42:48 +0100 Subject: [PATCH] feat(apps): WIP progress app views --- public/app/core/routes/all.js | 2 + public/app/features/org/app_edit_ctrl.ts | 36 +++++--------- public/app/features/org/app_list_ctrl.ts | 25 +++------- public/app/features/org/app_srv.ts | 1 - .../app/features/org/partials/app_edit.html | 16 ++----- .../app/features/org/partials/app_list.html | 47 +++++++++---------- 6 files changed, 49 insertions(+), 78 deletions(-) diff --git a/public/app/core/routes/all.js b/public/app/core/routes/all.js index 2f2a0b6fbde..82b9c409f9d 100644 --- a/public/app/core/routes/all.js +++ b/public/app/core/routes/all.js @@ -134,11 +134,13 @@ define([ .when('/org/apps', { templateUrl: 'app/features/org/partials/app_list.html', controller: 'AppListCtrl', + controllerAs: 'ctrl', resolve: loadOrgBundle, }) .when('/org/apps/edit/:type', { templateUrl: 'app/features/org/partials/app_edit.html', controller: 'AppEditCtrl', + controllerAs: 'ctrl', resolve: loadOrgBundle, }) .when('/global-alerts', { diff --git a/public/app/features/org/app_edit_ctrl.ts b/public/app/features/org/app_edit_ctrl.ts index e04be09fc35..ad7db2970e2 100644 --- a/public/app/features/org/app_edit_ctrl.ts +++ b/public/app/features/org/app_edit_ctrl.ts @@ -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); diff --git a/public/app/features/org/app_list_ctrl.ts b/public/app/features/org/app_list_ctrl.ts index 92c1b65ea60..7d89a3baffe 100644 --- a/public/app/features/org/app_list_ctrl.ts +++ b/public/app/features/org/app_list_ctrl.ts @@ -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; + }); } } diff --git a/public/app/features/org/app_srv.ts b/public/app/features/org/app_srv.ts index 2862ca689ea..6d712301b90 100644 --- a/public/app/features/org/app_srv.ts +++ b/public/app/features/org/app_srv.ts @@ -23,7 +23,6 @@ export class AppSrv { }); } - getAll() { if (!_.isEmpty(this.apps)) { return this.$q.when(this.apps); diff --git a/public/app/features/org/partials/app_edit.html b/public/app/features/org/partials/app_edit.html index 02236355c92..cdd878e47b5 100644 --- a/public/app/features/org/partials/app_edit.html +++ b/public/app/features/org/partials/app_edit.html @@ -5,10 +5,9 @@ -
-
-

Edit App

- +
+
+

{{ctrl.appModel.type}}

@@ -34,14 +33,9 @@
-
+ -
- - Cancel -
-
-
\ No newline at end of file +
diff --git a/public/app/features/org/partials/app_list.html b/public/app/features/org/partials/app_list.html index 94044c00cf7..79afd4a03fe 100644 --- a/public/app/features/org/partials/app_list.html +++ b/public/app/features/org/partials/app_list.html @@ -4,33 +4,32 @@ -
-
-

Apps

+
+
+

Apps

-
+
No apps defined
- - - - - - - - - - -
Name
-   - {{p.type}} - - - - Configure - -
- +
    +
  • +
      +
    • +
      +
      + + + +
      +
      + Litmus{{app.type}} + + Dashboards: 1 + +
    • +
    +
  • +