Commit abef94b0 by Torkel Ödegaard

made it possible to have frontend code in symlinked folders that can add routes

parent 5b46c088
......@@ -54,6 +54,7 @@ profile.cov
/pkg/cmd/grafana-server/grafana-server
/pkg/cmd/grafana-server/debug
/pkg/extensions
/public/app/enterprise
debug.test
/examples/*/dist
/packaging/**/*.rpm
......
......@@ -10,10 +10,10 @@ import (
)
func (hs *HTTPServer) registerRoutes() {
reqSignedIn := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true})
reqGrafanaAdmin := middleware.Auth(&middleware.AuthOptions{ReqSignedIn: true, ReqGrafanaAdmin: true})
reqEditorRole := middleware.RoleAuth(m.ROLE_EDITOR, m.ROLE_ADMIN)
reqOrgAdmin := middleware.RoleAuth(m.ROLE_ADMIN)
reqSignedIn := middleware.ReqSignedIn
reqGrafanaAdmin := middleware.ReqGrafanaAdmin
reqEditorRole := middleware.ReqEditorRole
reqOrgAdmin := middleware.ReqOrgAdmin
redirectFromLegacyDashboardURL := middleware.RedirectFromLegacyDashboardURL()
redirectFromLegacyDashboardSoloURL := middleware.RedirectFromLegacyDashboardSoloURL()
quota := middleware.Quota
......
......@@ -14,6 +14,13 @@ import (
"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 {
return func(c *macaron.Context) {
ctx := &m.ReqContext{
......
......@@ -29,6 +29,12 @@ _.move = (array, fromIndex, toIndex) => {
import { coreModule, registerAngularDirectives } from './core/core';
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;
export class GrafanaApp {
......
let components = (require as any).context('.', true, /\.tsx?/);
components.keys().forEach(key => {
console.log('extension component', components(key));
});
export class Tester {}
console.log('Tester');
......@@ -4,7 +4,6 @@ import AdminListOrgsCtrl from './AdminListOrgsCtrl';
import AdminEditOrgCtrl from './AdminEditOrgCtrl';
import StyleGuideCtrl from './StyleGuideCtrl';
import config from 'app/core/config';
import coreModule from 'app/core/core_module';
class AdminSettingsCtrl {
......@@ -36,21 +35,3 @@ coreModule.controller('AdminEditOrgCtrl', AdminEditOrgCtrl);
coreModule.controller('AdminSettingsCtrl', AdminSettingsCtrl);
coreModule.controller('AdminHomeCtrl', AdminHomeCtrl);
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);
}
<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>
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);
}
import './dashboard_loaders';
import './ReactContainer';
import '../extensions';
import { applyRouteRegistrationHandlers } from './registry';
import ServerStats from 'app/features/admin/ServerStats';
import AlertRuleList from 'app/features/alerting/AlertRuleList';
......@@ -226,11 +226,6 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
component: () => ServerStats,
},
})
.when('/admin/licensing', {
templateUrl: 'public/app/features/admin/partials/licensing.html',
controller: 'AdminLicensingCtrl',
controllerAs: 'ctrl',
})
// LOGIN / SIGNUP
.when('/login', {
templateUrl: 'public/app/partials/login.html',
......@@ -312,4 +307,6 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
templateUrl: 'public/app/partials/error.html',
controller: 'ErrorCtrl',
});
applyRouteRegistrationHandlers($routeProvider);
}
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