Fix: show connect data source link only to admins

This commit is contained in:
Arik Fraimovich 2018-03-08 09:43:30 +02:00
parent 051f12c712
commit 797b5582ac
3 changed files with 15 additions and 9 deletions

View File

@ -10,14 +10,18 @@
<h4>Let's get started</h4>
<ol>
<li ng-class="{done: $ctrl.dataSourceStepCompleted}">
<a href="data_sources">Connect</a> a Data Source</li>
<span ng-if="!$ctrl.isAdmin">Ask an account admin to connect a data source.</span>
<span ng-if="$ctrl.isAdmin">
<a href="data_sources">Connect</a> a Data Source
</span>
</li>
<li ng-class="{done: $ctrl.queryStepCompleted}">
<a href="queries/new">Create</a> your first Query</li>
<li ng-if="$ctrl.showAlertStep" ng-class="{done: $ctrl.alertStepCompleted}">
<a href="alerts/new">Create</a> your first Alert</li>
<li ng-if="$ctrl.showDashboardStep" ng-class="{done: $ctrl.dashboardStepCompleted}">
<a ng-click="$ctrl.newDashboard()">Create</a> your first Dashboard</li>
<li ng-if="$ctrl.showInviteStep" ng-class="{done: $ctrl.inviteStepCompleted}">
<li ng-if="$ctrl.showInviteStep" ng-class="{done: $ctrl.inviteStepCompleted}">
<a href="users/new">Invite</a> your team members</li>
</ol>
<p>Need more support?

View File

@ -14,8 +14,9 @@ const EmptyStateComponent = {
showInviteStep: '<',
onboardingMode: '<',
},
controller($http, $uibModal) {
controller($http, $uibModal, currentUser) {
this.loading = true;
this.isAdmin = currentUser.isAdmin;
$http.get('api/organization/status').then((response) => {
this.loading = false;

View File

@ -1,10 +1,11 @@
import json
from flask import request
from flask_login import login_required
from flask_login import current_user, login_required
from redash import models
from redash.handlers import routes
from redash.handlers.base import json_response, org_scoped_rule
from redash.authentication import current_org
from redash.permissions import require_admin
@ -12,10 +13,10 @@ from redash.permissions import require_admin
@login_required
def organization_status(org_slug=None):
counters = {
'users': models.User.query.count(),
'alerts': models.Alert.query.count(),
'data_sources': models.DataSource.query.count(),
'queries': models.Query.query.filter(models.Query.is_archived==False).count(),
'dashboards': models.Dashboard.query.filter(models.Dashboard.is_archived==False).count(),
'users': models.User.all(current_org).count(),
'alerts': models.Alert.all(group_ids=current_user.group_ids).count(),
'data_sources': models.DataSource.all(current_org, group_ids=current_user.group_ids).count(),
'queries': models.Query.all_queries(current_user.group_ids, current_user.id, drafts=True).count(),
'dashboards': models.Dashboard.all(current_org, current_user.group_ids, current_user.id).count(),
}
return json_response(dict(object_counters=counters))