mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
made it possible to have frontend code in symlinked folders that can add routes
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -54,6 +54,7 @@ profile.cov
|
|||||||
/pkg/cmd/grafana-server/grafana-server
|
/pkg/cmd/grafana-server/grafana-server
|
||||||
/pkg/cmd/grafana-server/debug
|
/pkg/cmd/grafana-server/debug
|
||||||
/pkg/extensions
|
/pkg/extensions
|
||||||
|
/public/app/enterprise
|
||||||
debug.test
|
debug.test
|
||||||
/examples/*/dist
|
/examples/*/dist
|
||||||
/packaging/**/*.rpm
|
/packaging/**/*.rpm
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func (hs *HTTPServer) registerRoutes() {
|
func (hs *HTTPServer) registerRoutes() {
|
||||||
reqSignedIn := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true})
|
reqSignedIn := middleware.ReqSignedIn
|
||||||
reqGrafanaAdmin := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true, ReqGrafanaAdmin: true})
|
reqGrafanaAdmin := middleware.ReqGrafanaAdmin
|
||||||
reqEditorRole := middleware.RoleAuth(m.ROLE_EDITOR, m.ROLE_ADMIN)
|
reqEditorRole := middleware.ReqEditorRole
|
||||||
reqOrgAdmin := middleware.RoleAuth(m.ROLE_ADMIN)
|
reqOrgAdmin := middleware.ReqOrgAdmin
|
||||||
redirectFromLegacyDashboardURL := middleware.RedirectFromLegacyDashboardURL()
|
redirectFromLegacyDashboardURL := middleware.RedirectFromLegacyDashboardURL()
|
||||||
redirectFromLegacyDashboardSoloURL := middleware.RedirectFromLegacyDashboardSoloURL()
|
redirectFromLegacyDashboardSoloURL := middleware.RedirectFromLegacyDashboardSoloURL()
|
||||||
quota := middleware.Quota
|
quota := middleware.Quota
|
||||||
|
|||||||
@@ -14,6 +14,13 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/util"
|
"github.com/grafana/grafana/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
ReqGrafanaAdmin = Auth(&AuthOptions{ReqSignedIn: true, ReqGrafanaAdmin: true})
|
||||||
|
ReqSignedIn = Auth(&AuthOptions{ReqSignedIn: true})
|
||||||
|
ReqEditorRole = RoleAuth(m.ROLE_EDITOR, m.ROLE_ADMIN)
|
||||||
|
ReqOrgAdmin = RoleAuth(m.ROLE_ADMIN)
|
||||||
|
)
|
||||||
|
|
||||||
func GetContextHandler() macaron.Handler {
|
func GetContextHandler() macaron.Handler {
|
||||||
return func(c *macaron.Context) {
|
return func(c *macaron.Context) {
|
||||||
ctx := &m.ReqContext{
|
ctx := &m.ReqContext{
|
||||||
|
|||||||
@@ -29,6 +29,12 @@ _.move = (array, fromIndex, toIndex) => {
|
|||||||
import { coreModule, registerAngularDirectives } from './core/core';
|
import { coreModule, registerAngularDirectives } from './core/core';
|
||||||
import { setupAngularRoutes } from './routes/routes';
|
import { setupAngularRoutes } from './routes/routes';
|
||||||
|
|
||||||
|
// import enterprise frontend
|
||||||
|
const enterpriseIndex = (require as any).context('.', true, /enterprise\/index.ts/);
|
||||||
|
enterpriseIndex.keys().forEach(key => {
|
||||||
|
enterpriseIndex(key);
|
||||||
|
});
|
||||||
|
|
||||||
declare var System: any;
|
declare var System: any;
|
||||||
|
|
||||||
export class GrafanaApp {
|
export class GrafanaApp {
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
let components = (require as any).context('.', true, /\.tsx?/);
|
|
||||||
components.keys().forEach(key => {
|
|
||||||
console.log('extension component', components(key));
|
|
||||||
});
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
export class Tester {}
|
|
||||||
|
|
||||||
console.log('Tester');
|
|
||||||
@@ -4,7 +4,6 @@ import AdminListOrgsCtrl from './AdminListOrgsCtrl';
|
|||||||
import AdminEditOrgCtrl from './AdminEditOrgCtrl';
|
import AdminEditOrgCtrl from './AdminEditOrgCtrl';
|
||||||
import StyleGuideCtrl from './StyleGuideCtrl';
|
import StyleGuideCtrl from './StyleGuideCtrl';
|
||||||
|
|
||||||
import config from 'app/core/config';
|
|
||||||
import coreModule from 'app/core/core_module';
|
import coreModule from 'app/core/core_module';
|
||||||
|
|
||||||
class AdminSettingsCtrl {
|
class AdminSettingsCtrl {
|
||||||
@@ -36,21 +35,3 @@ coreModule.controller('AdminEditOrgCtrl', AdminEditOrgCtrl);
|
|||||||
coreModule.controller('AdminSettingsCtrl', AdminSettingsCtrl);
|
coreModule.controller('AdminSettingsCtrl', AdminSettingsCtrl);
|
||||||
coreModule.controller('AdminHomeCtrl', AdminHomeCtrl);
|
coreModule.controller('AdminHomeCtrl', AdminHomeCtrl);
|
||||||
coreModule.controller('StyleGuideCtrl', StyleGuideCtrl);
|
coreModule.controller('StyleGuideCtrl', StyleGuideCtrl);
|
||||||
|
|
||||||
if (config.buildInfo.isEnterprise) {
|
|
||||||
class AdminLicensingCtrl {
|
|
||||||
navModel: any;
|
|
||||||
|
|
||||||
/** @ngInject */
|
|
||||||
constructor($scope, backendSrv, navModelSrv) {
|
|
||||||
this.navModel = navModelSrv.getNav('cfg', 'admin', 'licensing', 1);
|
|
||||||
|
|
||||||
backendSrv.get('/api/licensing/token').then(token => {
|
|
||||||
token.maxUsers = token.max_users >= 0 ? token.max_users : 'Unlimited';
|
|
||||||
$scope.token = token;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
coreModule.controller('AdminLicensingCtrl', AdminLicensingCtrl);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
<page-header model="ctrl.navModel"></page-header>
|
|
||||||
|
|
||||||
<div class="page-container page-body">
|
|
||||||
<table class="filter-table form-inline">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" class="admin-settings-section">License Details</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>License ID</td>
|
|
||||||
<td>{{token.lid}} (<a href="{{token.iss}}/licenses/{{token.lid}}" target="_blank" rel="noopener noreferer">View Details</a>)</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Licensed URL</td>
|
|
||||||
<td><a href="{{token.sub}}" target="_blank" rel="noopener noreferer">{{token.sub}}</a></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Company</td>
|
|
||||||
<td>{{token.company}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Products</td>
|
|
||||||
<td>
|
|
||||||
<div ng-repeat="product in token.prod">{{product}}</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Max Users</td>
|
|
||||||
<td>{{token.maxUsers}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>License Issued</td>
|
|
||||||
<td>{{token.nbf*1000 | date:'medium'}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>License Expires</td>
|
|
||||||
<td>{{token.lexp*1000 | date:'medium'}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" class="admin-settings-section">Token Details</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Token ID</td>
|
|
||||||
<td>{{token.jti}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Token Issued</td>
|
|
||||||
<td>{{token.iat*1000 | date:'medium'}}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>Token Expires</td>
|
|
||||||
<td>{{token.exp*1000 | date:'medium'}}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
15
public/app/routes/registry.ts
Normal file
15
public/app/routes/registry.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
interface RegisterRoutesHandler {
|
||||||
|
($routeProvider): any;
|
||||||
|
}
|
||||||
|
|
||||||
|
const handlers: RegisterRoutesHandler[] = [];
|
||||||
|
|
||||||
|
export function applyRouteRegistrationHandlers($routeProvider) {
|
||||||
|
for (const handler of handlers) {
|
||||||
|
handler($routeProvider);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addRouteRegistrationHandler(fn: RegisterRoutesHandler) {
|
||||||
|
handlers.push(fn);
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import './dashboard_loaders';
|
import './dashboard_loaders';
|
||||||
import './ReactContainer';
|
import './ReactContainer';
|
||||||
import '../extensions';
|
import { applyRouteRegistrationHandlers } from './registry';
|
||||||
|
|
||||||
import ServerStats from 'app/features/admin/ServerStats';
|
import ServerStats from 'app/features/admin/ServerStats';
|
||||||
import AlertRuleList from 'app/features/alerting/AlertRuleList';
|
import AlertRuleList from 'app/features/alerting/AlertRuleList';
|
||||||
@@ -226,11 +226,6 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
|
|||||||
component: () => ServerStats,
|
component: () => ServerStats,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.when('/admin/licensing', {
|
|
||||||
templateUrl: 'public/app/features/admin/partials/licensing.html',
|
|
||||||
controller: 'AdminLicensingCtrl',
|
|
||||||
controllerAs: 'ctrl',
|
|
||||||
})
|
|
||||||
// LOGIN / SIGNUP
|
// LOGIN / SIGNUP
|
||||||
.when('/login', {
|
.when('/login', {
|
||||||
templateUrl: 'public/app/partials/login.html',
|
templateUrl: 'public/app/partials/login.html',
|
||||||
@@ -312,4 +307,6 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
|
|||||||
templateUrl: 'public/app/partials/error.html',
|
templateUrl: 'public/app/partials/error.html',
|
||||||
controller: 'ErrorCtrl',
|
controller: 'ErrorCtrl',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
applyRouteRegistrationHandlers($routeProvider);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user