Commit e7a202fe by Torkel Ödegaard

Merge branch 'master' into style-changes-bulletfactory

parents 3c6fadb6 b5dc1727
......@@ -60,8 +60,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": {
......
......@@ -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{}{}
......
......@@ -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)
}
......
......@@ -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)
......
......@@ -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', {
......
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();
});
});
///<reference path="../../headers/common.d.ts" />
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) {
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);
......@@ -20,11 +20,11 @@
</div>
<br>
<div ng-if="datasources.length === 0">
<div ng-if="ctrl.datasources.length === 0">
<em>No data sources defined</em>
</div>
<table class="filter-table" ng-if="datasources.length > 0">
<table class="filter-table" ng-if="ctrl.datasources.length > 0">
<thead>
<tr>
<th><strong>Name</strong></th>
......@@ -35,7 +35,7 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="ds in datasources">
<tr ng-repeat="ds in ctrl.datasources">
<td>
<a href="datasources/edit/{{ds.id}}">
<i class="fa fa-database"></i> &nbsp; {{ds.name}}
......@@ -56,7 +56,7 @@
</a>
</td>
<td class="text-right">
<a ng-click="remove(ds)" class="btn btn-danger btn-mini">
<a ng-click="ctrl.removeDataSource(ds)" class="btn btn-danger btn-mini">
<i class="fa fa-remove"></i>
</a>
</td>
......
......@@ -29,5 +29,16 @@
</ul>
<div class="clearfix"></div>
</div>
<div class="tight-form">
<ul class="tight-form-list">
<li class="tight-form-item" style="width: 200px">
Custom Metrics namespace<tip>Namespaces of Custom Metrics</tip>
</li>
<li>
<input type="text" class="tight-form-input input-large last" ng-model='ctrl.current.jsonData.customMetricsNamespaces' placeholder="Namespace1,Namespace2"></input>
</li>
</ul>
<div class="clearfix"></div>
</div>
</div>
</div>
......@@ -81,7 +81,7 @@
}];
</script>
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-K2MJ65" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<noscript><iframe src="//www.googletagmanager.com/ns.html?id=[[.GoogleTagManagerId]]" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','[[.GoogleTagManagerId]]');</script>
......
......@@ -8,6 +8,7 @@ module.exports = function(grunt) {
'jscs',
'tslint',
'clean:release',
'copy:node_modules',
'copy:public_to_gen',
'typescript:build',
'karma:test',
......
......@@ -8,6 +8,7 @@ module.exports = function(grunt) {
'jshint',
'tslint',
'clean:gen',
'copy:node_modules',
'copy:public_to_gen',
'phantomjs',
'css',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment