From fac51d92c5f5d90d1fd23569bdefb54aaa30135a Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Thu, 11 Feb 2016 00:06:04 -0800 Subject: [PATCH 1/7] Added DS deletion confirmation modal --- public/app/core/routes/routes.ts | 1 + public/app/features/datasources/list_ctrl.js | 36 ------------- public/app/features/datasources/list_ctrl.ts | 53 +++++++++++++++++++ .../features/datasources/partials/list.html | 8 +-- 4 files changed, 58 insertions(+), 40 deletions(-) delete mode 100644 public/app/features/datasources/list_ctrl.js create mode 100644 public/app/features/datasources/list_ctrl.ts diff --git a/public/app/core/routes/routes.ts b/public/app/core/routes/routes.ts index 8963228210b..82da84fbc56 100644 --- a/public/app/core/routes/routes.ts +++ b/public/app/core/routes/routes.ts @@ -45,6 +45,7 @@ function setupAngularRoutes($routeProvider, $locationProvider) { .when('/datasources', { templateUrl: 'public/app/features/datasources/partials/list.html', controller : 'DataSourcesCtrl', + controllerAs: 'ctrl', resolve: loadOrgBundle, }) .when('/datasources/edit/:id', { diff --git a/public/app/features/datasources/list_ctrl.js b/public/app/features/datasources/list_ctrl.js deleted file mode 100644 index da77df252e1..00000000000 --- a/public/app/features/datasources/list_ctrl.js +++ /dev/null @@ -1,36 +0,0 @@ -define([ - 'angular', - 'lodash', -], -function (angular) { - 'use strict'; - - var module = angular.module('grafana.controllers'); - - module.controller('DataSourcesCtrl', function($scope, $http, backendSrv, datasourceSrv) { - - $scope.init = function() { - $scope.datasources = []; - $scope.getDatasources(); - }; - - $scope.getDatasources = function() { - backendSrv.get('/api/datasources').then(function(results) { - $scope.datasources = results; - }); - }; - - $scope.remove = function(ds) { - backendSrv.delete('/api/datasources/' + ds.id).then(function() { - $scope.getDatasources(); - - backendSrv.get('/api/frontend/settings').then(function(settings) { - datasourceSrv.init(settings.datasources); - }); - }); - }; - - $scope.init(); - - }); -}); diff --git a/public/app/features/datasources/list_ctrl.ts b/public/app/features/datasources/list_ctrl.ts new file mode 100644 index 00000000000..20d480bb96a --- /dev/null +++ b/public/app/features/datasources/list_ctrl.ts @@ -0,0 +1,53 @@ +/// + +import angular from 'angular'; +import _ from 'lodash'; +import coreModule from '../../core/core_module'; + +export class DataSourcesCtrl { + datasources: any; + + /** @ngInject */ + constructor(private $scope, private $location, private $http, private backendSrv, private datasourceSrv) { + backendSrv.get('/api/datasources') + .then((result) => { + this.datasources = result; + }); + } + + removeDataSourceConfirmed(ds) { + ///_.remove(this.playlistsd, { id: playlist.id }); + + this.backendSrv.delete('/api/datasources/' + ds.id) + .then(() => { + this.$scope.appEvent('alert-success', ['Datasource deleted', '']); + }, () => { + this.$scope.appEvent('alert-error', ['Unable to delete datasource', '']); + }).then(() => { + this.backendSrv.get('/api/datasources') + .then((result) => { + this.datasources = result; + }); + this.backendSrv.get('/api/frontend/settings') + .then((settings) => { + this.datasourceSrv.init(settings.datasources); + }); + }); + } + + removeDataSource(ds) { + + this.$scope.appEvent('confirm-modal', { + title: 'Confirm delete datasource', + text: 'Are you sure you want to delete datasource ' + ds.name + '?', + yesText: "Delete", + icon: "fa-warning", + onConfirm: () => { + this.removeDataSourceConfirmed(ds); + } + }); + } + +} + +coreModule.controller('DataSourcesCtrl', DataSourcesCtrl); diff --git a/public/app/features/datasources/partials/list.html b/public/app/features/datasources/partials/list.html index ec660ef79d4..bdd6fe363a0 100644 --- a/public/app/features/datasources/partials/list.html +++ b/public/app/features/datasources/partials/list.html @@ -12,11 +12,11 @@

Data sources


-
+
No data sources defined
- +
@@ -27,7 +27,7 @@ - + From c051ff3eacc97d7de01321eb98fa04c25d2584b0 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Thu, 11 Feb 2016 07:01:45 -0800 Subject: [PATCH 2/7] Removed unused commented code --- public/app/features/datasources/list_ctrl.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/public/app/features/datasources/list_ctrl.ts b/public/app/features/datasources/list_ctrl.ts index 20d480bb96a..b1f93f1a158 100644 --- a/public/app/features/datasources/list_ctrl.ts +++ b/public/app/features/datasources/list_ctrl.ts @@ -16,7 +16,6 @@ export class DataSourcesCtrl { } removeDataSourceConfirmed(ds) { - ///_.remove(this.playlistsd, { id: playlist.id }); this.backendSrv.delete('/api/datasources/' + ds.id) .then(() => { From 81ad4695339bda5bd2319896132694b958f0f421 Mon Sep 17 00:00:00 2001 From: Mitsuhiro Tanda Date: Fri, 12 Feb 2016 00:26:48 +0900 Subject: [PATCH 3/7] (cloudwatch) custom metrics namespace support --- pkg/api/cloudwatch/metrics.go | 5 +++++ .../datasource/cloudwatch/partials/config.html | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/pkg/api/cloudwatch/metrics.go b/pkg/api/cloudwatch/metrics.go index 7a98386347c..b4321791926 100644 --- a/pkg/api/cloudwatch/metrics.go +++ b/pkg/api/cloudwatch/metrics.go @@ -126,6 +126,11 @@ func handleGetNamespaces(req *cwRequest, c *middleware.Context) { for key := range metricsMap { keys = append(keys, key) } + if customMetricsNamespaces, ok := req.DataSource.JsonData["customMetricsNamespaces"].(string); ok { + for _, key := range strings.Split(customMetricsNamespaces, ",") { + keys = append(keys, key) + } + } sort.Sort(sort.StringSlice(keys)) result := []interface{}{} diff --git a/public/app/plugins/datasource/cloudwatch/partials/config.html b/public/app/plugins/datasource/cloudwatch/partials/config.html index 92a963da7c6..69ec729a160 100644 --- a/public/app/plugins/datasource/cloudwatch/partials/config.html +++ b/public/app/plugins/datasource/cloudwatch/partials/config.html @@ -29,5 +29,16 @@
+
+
    +
  • + Custom Metrics namespaceNamespaces of Custom Metrics +
  • +
  • + +
  • +
+
+
From 814ca99e3d7f84f2ef152cdc48675c17f82914f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 12 Feb 2016 09:52:45 +0100 Subject: [PATCH 4/7] fix(google tag manager): fixed link to google tag manager, fixes #4005 --- public/views/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/views/index.html b/public/views/index.html index 7c492c01480..e24d4ec6e7d 100644 --- a/public/views/index.html +++ b/public/views/index.html @@ -81,7 +81,7 @@ }]; - + From f797b19825bdb99570e6b2a98d48ff439bf8731a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 12 Feb 2016 09:58:00 +0100 Subject: [PATCH 5/7] fix(build): changed from postinstall script to regular grunt task for the copying of npm dependencies into public dir, fixes #4003 --- package.json | 3 +-- tasks/build_task.js | 1 + tasks/default_task.js | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4b67aeefacb..2331bf0fe20 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,7 @@ }, "scripts": { "test": "grunt test", - "coveralls": "grunt karma:coveralls && rm -rf ./coverage", - "postinstall": "./node_modules/.bin/grunt copy:node_modules" + "coveralls": "grunt karma:coveralls && rm -rf ./coverage" }, "license": "Apache-2.0", "dependencies": { diff --git a/tasks/build_task.js b/tasks/build_task.js index d844b661722..3ace8514164 100644 --- a/tasks/build_task.js +++ b/tasks/build_task.js @@ -8,6 +8,7 @@ module.exports = function(grunt) { 'jscs', 'tslint', 'clean:release', + 'copy:node_modules', 'copy:public_to_gen', 'typescript:build', 'karma:test', diff --git a/tasks/default_task.js b/tasks/default_task.js index 7877fc2a34b..033acb3921e 100644 --- a/tasks/default_task.js +++ b/tasks/default_task.js @@ -8,6 +8,7 @@ module.exports = function(grunt) { 'jshint', 'tslint', 'clean:gen', + 'copy:node_modules', 'copy:public_to_gen', 'phantomjs', 'css', From 53f5cb6553d9d2e1b01e7eda74d12714e4eaa41e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 12 Feb 2016 10:01:45 +0100 Subject: [PATCH 6/7] fix(api): org name taken error now returns HTTP status code 409, closes --- pkg/api/org.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/api/org.go b/pkg/api/org.go index 0316116b6d3..61af62311c6 100644 --- a/pkg/api/org.go +++ b/pkg/api/org.go @@ -84,7 +84,7 @@ func CreateOrg(c *middleware.Context, cmd m.CreateOrgCommand) Response { cmd.UserId = c.UserId if err := bus.Dispatch(&cmd); err != nil { if err == m.ErrOrgNameTaken { - return ApiError(400, "Organization name taken", err) + return ApiError(409, "Organization name taken", err) } return ApiError(500, "Failed to create organization", err) } From b5dc1727d2cf668211ee89c85b22ca32803df375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 12 Feb 2016 10:10:07 +0100 Subject: [PATCH 7/7] fix(postgres): If password or user is empty use empty quotes for connection string, #3985 --- pkg/services/sqlstore/sqlstore.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/services/sqlstore/sqlstore.go b/pkg/services/sqlstore/sqlstore.go index 3ab4bf1c00b..e3db2d7f537 100644 --- a/pkg/services/sqlstore/sqlstore.go +++ b/pkg/services/sqlstore/sqlstore.go @@ -149,8 +149,13 @@ func getEngine() (*xorm.Engine, error) { if len(fields) > 1 && len(strings.TrimSpace(fields[1])) > 0 { port = fields[1] } - cnnstr = fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s", - DbCfg.User, DbCfg.Pwd, host, port, DbCfg.Name, DbCfg.SslMode) + if DbCfg.Pwd == "" { + DbCfg.Pwd = "''" + } + if DbCfg.User == "" { + DbCfg.User = "''" + } + cnnstr = fmt.Sprintf("user=%s password=%s host=%s port=%s dbname=%s sslmode=%s", DbCfg.User, DbCfg.Pwd, host, port, DbCfg.Name, DbCfg.SslMode) case "sqlite3": if !filepath.IsAbs(DbCfg.Path) { DbCfg.Path = filepath.Join(setting.DataPath, DbCfg.Path)
Name
  {{ds.name}} @@ -48,7 +48,7 @@ - +