mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
refactoring: enterprise build/hooks refactorings (#12478)
This commit is contained in:
@@ -13,6 +13,7 @@ type IndexViewData struct {
|
|||||||
Theme string
|
Theme string
|
||||||
NewGrafanaVersionExists bool
|
NewGrafanaVersionExists bool
|
||||||
NewGrafanaVersion string
|
NewGrafanaVersion string
|
||||||
|
AppName string
|
||||||
}
|
}
|
||||||
|
|
||||||
type PluginCss struct {
|
type PluginCss struct {
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ func getFrontendSettingsMap(c *m.ReqContext) (map[string]interface{}, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
jsonObj := map[string]interface{}{
|
jsonObj := map[string]interface{}{
|
||||||
"enterprise": setting.Enterprise,
|
|
||||||
"defaultDatasource": defaultDatasource,
|
"defaultDatasource": defaultDatasource,
|
||||||
"datasources": datasources,
|
"datasources": datasources,
|
||||||
"panels": panels,
|
"panels": panels,
|
||||||
@@ -154,6 +153,7 @@ func getFrontendSettingsMap(c *m.ReqContext) (map[string]interface{}, error) {
|
|||||||
"latestVersion": plugins.GrafanaLatestVersion,
|
"latestVersion": plugins.GrafanaLatestVersion,
|
||||||
"hasUpdate": plugins.GrafanaHasUpdate,
|
"hasUpdate": plugins.GrafanaHasUpdate,
|
||||||
"env": setting.Env,
|
"env": setting.Env,
|
||||||
|
"isEnterprise": setting.IsEnterprise,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ func setIndexViewData(c *m.ReqContext) (*dtos.IndexViewData, error) {
|
|||||||
BuildCommit: setting.BuildCommit,
|
BuildCommit: setting.BuildCommit,
|
||||||
NewGrafanaVersion: plugins.GrafanaLatestVersion,
|
NewGrafanaVersion: plugins.GrafanaLatestVersion,
|
||||||
NewGrafanaVersionExists: plugins.GrafanaHasUpdate,
|
NewGrafanaVersionExists: plugins.GrafanaHasUpdate,
|
||||||
|
AppName: setting.ApplicationName,
|
||||||
}
|
}
|
||||||
|
|
||||||
if setting.DisableGravatar {
|
if setting.DisableGravatar {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/metrics"
|
"github.com/grafana/grafana/pkg/metrics"
|
||||||
"github.com/grafana/grafana/pkg/setting"
|
"github.com/grafana/grafana/pkg/setting"
|
||||||
|
|
||||||
_ "github.com/grafana/grafana/pkg/extensions"
|
extensions "github.com/grafana/grafana/pkg/extensions"
|
||||||
_ "github.com/grafana/grafana/pkg/services/alerting/conditions"
|
_ "github.com/grafana/grafana/pkg/services/alerting/conditions"
|
||||||
_ "github.com/grafana/grafana/pkg/services/alerting/notifiers"
|
_ "github.com/grafana/grafana/pkg/services/alerting/notifiers"
|
||||||
_ "github.com/grafana/grafana/pkg/tsdb/cloudwatch"
|
_ "github.com/grafana/grafana/pkg/tsdb/cloudwatch"
|
||||||
@@ -35,7 +35,6 @@ import (
|
|||||||
var version = "5.0.0"
|
var version = "5.0.0"
|
||||||
var commit = "NA"
|
var commit = "NA"
|
||||||
var buildstamp string
|
var buildstamp string
|
||||||
var enterprise string
|
|
||||||
|
|
||||||
var configFile = flag.String("config", "", "path to config file")
|
var configFile = flag.String("config", "", "path to config file")
|
||||||
var homePath = flag.String("homepath", "", "path to grafana install/home path, defaults to working directory")
|
var homePath = flag.String("homepath", "", "path to grafana install/home path, defaults to working directory")
|
||||||
@@ -78,7 +77,7 @@ func main() {
|
|||||||
setting.BuildVersion = version
|
setting.BuildVersion = version
|
||||||
setting.BuildCommit = commit
|
setting.BuildCommit = commit
|
||||||
setting.BuildStamp = buildstampInt64
|
setting.BuildStamp = buildstampInt64
|
||||||
setting.Enterprise, _ = strconv.ParseBool(enterprise)
|
setting.IsEnterprise = extensions.IsEnterprise
|
||||||
|
|
||||||
metrics.M_Grafana_Version.WithLabelValues(version).Set(1)
|
metrics.M_Grafana_Version.WithLabelValues(version).Set(1)
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
package extensions
|
package extensions
|
||||||
|
|
||||||
import _ "github.com/pkg/errors"
|
var IsEnterprise bool = false
|
||||||
|
|||||||
@@ -334,6 +334,14 @@ func updateTotalStats() {
|
|||||||
|
|
||||||
var usageStatsURL = "https://stats.grafana.org/grafana-usage-report"
|
var usageStatsURL = "https://stats.grafana.org/grafana-usage-report"
|
||||||
|
|
||||||
|
func getEdition() string {
|
||||||
|
if setting.IsEnterprise {
|
||||||
|
return "enterprise"
|
||||||
|
} else {
|
||||||
|
return "oss"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func sendUsageStats() {
|
func sendUsageStats() {
|
||||||
if !setting.ReportingEnabled {
|
if !setting.ReportingEnabled {
|
||||||
return
|
return
|
||||||
@@ -349,6 +357,7 @@ func sendUsageStats() {
|
|||||||
"metrics": metrics,
|
"metrics": metrics,
|
||||||
"os": runtime.GOOS,
|
"os": runtime.GOOS,
|
||||||
"arch": runtime.GOARCH,
|
"arch": runtime.GOARCH,
|
||||||
|
"edition": getEdition(),
|
||||||
}
|
}
|
||||||
|
|
||||||
statsQuery := models.GetSystemStatsQuery{}
|
statsQuery := models.GetSystemStatsQuery{}
|
||||||
|
|||||||
@@ -18,9 +18,10 @@ import (
|
|||||||
|
|
||||||
"github.com/go-macaron/session"
|
"github.com/go-macaron/session"
|
||||||
|
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/grafana/grafana/pkg/log"
|
"github.com/grafana/grafana/pkg/log"
|
||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Scheme string
|
type Scheme string
|
||||||
@@ -49,7 +50,7 @@ var (
|
|||||||
BuildVersion string
|
BuildVersion string
|
||||||
BuildCommit string
|
BuildCommit string
|
||||||
BuildStamp int64
|
BuildStamp int64
|
||||||
Enterprise bool
|
IsEnterprise bool
|
||||||
ApplicationName string
|
ApplicationName string
|
||||||
|
|
||||||
// Paths
|
// Paths
|
||||||
@@ -517,7 +518,7 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
|
|||||||
Raw = cfg.Raw
|
Raw = cfg.Raw
|
||||||
|
|
||||||
ApplicationName = "Grafana"
|
ApplicationName = "Grafana"
|
||||||
if Enterprise {
|
if IsEnterprise {
|
||||||
ApplicationName += " Enterprise"
|
ApplicationName += " Enterprise"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,18 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
|
|
||||||
class Settings {
|
export interface BuildInfo {
|
||||||
|
version: string;
|
||||||
|
commit: string;
|
||||||
|
isEnterprise: boolean;
|
||||||
|
env: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Settings {
|
||||||
datasources: any;
|
datasources: any;
|
||||||
panels: any;
|
panels: any;
|
||||||
appSubUrl: string;
|
appSubUrl: string;
|
||||||
window_title_prefix: string;
|
window_title_prefix: string;
|
||||||
buildInfo: any;
|
buildInfo: BuildInfo;
|
||||||
new_panel_title: string;
|
new_panel_title: string;
|
||||||
bootData: any;
|
bootData: any;
|
||||||
externalUserMngLinkUrl: string;
|
externalUserMngLinkUrl: string;
|
||||||
@@ -22,7 +29,6 @@ class Settings {
|
|||||||
disableUserSignUp: boolean;
|
disableUserSignUp: boolean;
|
||||||
loginHint: any;
|
loginHint: any;
|
||||||
loginError: any;
|
loginError: any;
|
||||||
enterprise: boolean;
|
|
||||||
|
|
||||||
constructor(options) {
|
constructor(options) {
|
||||||
var defaults = {
|
var defaults = {
|
||||||
@@ -33,7 +39,14 @@ class Settings {
|
|||||||
playlist_timespan: '1m',
|
playlist_timespan: '1m',
|
||||||
unsaved_changes_warning: true,
|
unsaved_changes_warning: true,
|
||||||
appSubUrl: '',
|
appSubUrl: '',
|
||||||
|
buildInfo: {
|
||||||
|
version: 'v1.0',
|
||||||
|
commit: '1',
|
||||||
|
env: 'production',
|
||||||
|
isEnterprise: false,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
_.extend(this, defaults, options);
|
_.extend(this, defaults, options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,14 +34,10 @@ export class ContextSrv {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.sidemenu = store.getBool('grafana.sidemenu', true);
|
this.sidemenu = store.getBool('grafana.sidemenu', true);
|
||||||
|
|
||||||
if (!config.buildInfo) {
|
|
||||||
config.buildInfo = {};
|
|
||||||
}
|
|
||||||
if (!config.bootData) {
|
if (!config.bootData) {
|
||||||
config.bootData = { user: {}, settings: {} };
|
config.bootData = { user: {}, settings: {} };
|
||||||
}
|
}
|
||||||
|
|
||||||
this.version = config.buildInfo.version;
|
|
||||||
this.user = new User();
|
this.user = new User();
|
||||||
this.isSignedIn = this.user.isSignedIn;
|
this.isSignedIn = this.user.isSignedIn;
|
||||||
this.isGrafanaAdmin = this.user.isGrafanaAdmin;
|
this.isGrafanaAdmin = this.user.isGrafanaAdmin;
|
||||||
|
|||||||
@@ -86,9 +86,7 @@ describe('given dashboard with repeated panels', () => {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
config.buildInfo = {
|
config.buildInfo.version = '3.0.2';
|
||||||
version: '3.0.2',
|
|
||||||
};
|
|
||||||
|
|
||||||
//Stubs test function calls
|
//Stubs test function calls
|
||||||
var datasourceSrvStub = { get: jest.fn(arg => getStub(arg)) };
|
var datasourceSrvStub = { get: jest.fn(arg => getStub(arg)) };
|
||||||
|
|||||||
@@ -67,39 +67,39 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="gf-form-group" ng-if="ctrl.enterprise">
|
<div class="gf-form-group" ng-if="ctrl.isMappingsEnabled">
|
||||||
|
|
||||||
<h3 class="page-heading">Team Group Mapping</h3>
|
<h3 class="page-heading">Mappings to external groups</h3>
|
||||||
<form name="ctrl.addGroupForm" class="gf-form-group">
|
<form name="ctrl.addGroupForm" class="gf-form-group">
|
||||||
<div class="gf-form">
|
<div class="gf-form">
|
||||||
<span class="gf-form-label width-10">Add group</span>
|
<span class="gf-form-label width-10">Add group</span>
|
||||||
<input class="gf-form-input max-width-22" type="text" ng-model="ctrl.newGroupId">
|
<input class="gf-form-input max-width-22" type="text" ng-model="ctrl.newGroupId">
|
||||||
</div>
|
</div>
|
||||||
<div class="gf-form-button-row">
|
<div class="gf-form-button-row">
|
||||||
<button type="submit" class="btn btn-success" ng-click="ctrl.addGroup()">Add</button>
|
<button type="submit" class="btn btn-success" ng-click="ctrl.addGroup()">Add</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<table class="filter-table" ng-show="ctrl.teamGroups.length > 0">
|
<table class="filter-table" ng-show="ctrl.teamGroups.length > 0">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Group</th>
|
<th>Group</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tr ng-repeat="group in ctrl.teamGroups">
|
<tr ng-repeat="group in ctrl.teamGroups">
|
||||||
<td>{{group.groupId}}</td>
|
<td>{{group.groupId}}</td>
|
||||||
<td style="width: 1%">
|
<td style="width: 1%">
|
||||||
<a ng-click="ctrl.removeGroup(group)" class="btn btn-danger btn-mini">
|
<a ng-click="ctrl.removeGroup(group)" class="btn btn-danger btn-mini">
|
||||||
<i class="fa fa-remove"></i>
|
<i class="fa fa-remove"></i>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div>
|
<div>
|
||||||
<em class="muted" ng-hide="ctrl.teamGroups.length > 0">
|
<em class="muted" ng-hide="ctrl.teamGroups.length > 0">
|
||||||
This team has no associated groups yet.
|
This team has no associated groups yet.
|
||||||
</em>
|
</em>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export default class TeamDetailsCtrl {
|
|||||||
navModel: any;
|
navModel: any;
|
||||||
teamGroups: TeamGroup[] = [];
|
teamGroups: TeamGroup[] = [];
|
||||||
newGroupId: string;
|
newGroupId: string;
|
||||||
enterprise: boolean;
|
isMappingsEnabled: boolean;
|
||||||
|
|
||||||
/** @ngInject **/
|
/** @ngInject **/
|
||||||
constructor(private $scope, private backendSrv, private $routeParams, navModelSrv) {
|
constructor(private $scope, private backendSrv, private $routeParams, navModelSrv) {
|
||||||
@@ -15,7 +15,7 @@ export default class TeamDetailsCtrl {
|
|||||||
this.userPicked = this.userPicked.bind(this);
|
this.userPicked = this.userPicked.bind(this);
|
||||||
this.get = this.get.bind(this);
|
this.get = this.get.bind(this);
|
||||||
this.newGroupId = '';
|
this.newGroupId = '';
|
||||||
this.enterprise = config.enterprise;
|
this.isMappingsEnabled = config.buildInfo.isEnterprise;
|
||||||
this.get();
|
this.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ export default class TeamDetailsCtrl {
|
|||||||
this.teamMembers = result;
|
this.teamMembers = result;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (config.enterprise) {
|
if (this.isMappingsEnabled) {
|
||||||
this.backendSrv.get(`/api/teams/${this.$routeParams.id}/groups`).then(result => {
|
this.backendSrv.get(`/api/teams/${this.$routeParams.id}/groups`).then(result => {
|
||||||
this.teamGroups = result;
|
this.teamGroups = result;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="https://grafana.com" target="_blank">Grafana</a>
|
<a href="https://grafana.com" target="_blank">[[.AppName]]</a>
|
||||||
<span>v[[.BuildVersion]] (commit: [[.BuildCommit]])</span>
|
<span>v[[.BuildVersion]] (commit: [[.BuildCommit]])</span>
|
||||||
</li>
|
</li>
|
||||||
[[if .NewGrafanaVersionExists]]
|
[[if .NewGrafanaVersionExists]]
|
||||||
|
|||||||
Reference in New Issue
Block a user