Remove angular code related to API Keys and point the route to the React component #13411

This commit is contained in:
Johannes Schill 2018-09-27 11:34:28 +02:00
parent c7fb6916b9
commit 362010c438
5 changed files with 0 additions and 135 deletions

View File

@ -6,6 +6,5 @@ import './change_password_ctrl';
import './new_org_ctrl';
import './user_invite_ctrl';
import './create_team_ctrl';
import './org_api_keys_ctrl';
import './org_details_ctrl';
import './prefs_control';

View File

@ -1,44 +0,0 @@
import angular from 'angular';
export class OrgApiKeysCtrl {
/** @ngInject */
constructor($scope, $http, backendSrv, navModelSrv) {
$scope.navModel = navModelSrv.getNav('cfg', 'apikeys', 0);
$scope.roleTypes = ['Viewer', 'Editor', 'Admin'];
$scope.token = { role: 'Viewer' };
$scope.init = () => {
$scope.getTokens();
};
$scope.getTokens = () => {
backendSrv.get('/api/auth/keys').then(tokens => {
$scope.tokens = tokens;
});
};
$scope.removeToken = id => {
backendSrv.delete('/api/auth/keys/' + id).then($scope.getTokens);
};
$scope.addToken = () => {
backendSrv.post('/api/auth/keys', $scope.token).then(result => {
const modalScope = $scope.$new(true);
modalScope.key = result.key;
modalScope.rootPath = window.location.origin + $scope.$root.appSubUrl;
$scope.appEvent('show-modal', {
src: 'public/app/features/org/partials/apikeyModal.html',
scope: modalScope,
});
$scope.getTokens();
});
};
$scope.init();
}
}
angular.module('grafana.controllers').controller('OrgApiKeysCtrl', OrgApiKeysCtrl);

View File

@ -1,37 +0,0 @@
<div class="modal-body">
<div class="modal-header">
<h2 class="modal-header-title">
<i class="fa fa-key"></i>
<span class="p-l-1">API Key Created</span>
</h2>
<a class="modal-header-close" ng-click="dismiss();">
<i class="fa fa-remove"></i>
</a>
</div>
<div class="modal-content">
<div class="gf-form-group">
<div class="gf-form">
<span class="gf-form-label">Key</span>
<span class="gf-form-label">{{key}}</span>
</div>
</div>
<div class="grafana-info-box" style="border: 0;">
You will only be able to view this key here once! It is not stored in this form. So be sure to copy it now.
<br>
<br>
You can authenticate request using the Authorization HTTP header, example:
<br>
<br>
<pre class="small">
curl -H "Authorization: Bearer {{key}}" {{rootPath}}/api/dashboards/home
</pre>
</div>
</div>
</div>

View File

@ -1,49 +0,0 @@
<page-header model="navModel"></page-header>
<div class="page-container page-body">
<h3 class="page-heading">Add new</h3>
<form name="addTokenForm" class="gf-form-group">
<div class="gf-form-inline">
<div class="gf-form max-width-21">
<span class="gf-form-label">Key name</span>
<input type="text" class="gf-form-input" ng-model='token.name' placeholder="Name"></input>
</div>
<div class="gf-form">
<span class="gf-form-label">Role</span>
<span class="gf-form-select-wrapper">
<select class="gf-form-input gf-size-auto" ng-model="token.role" ng-options="r for r in roleTypes"></select>
</span>
</div>
<div class="gf-form">
<button class="btn gf-form-btn btn-success" ng-click="addToken()">Add</button>
</div>
</div>
</form>
<h3 class="page-heading">Existing Keys</h3>
<table class="filter-table">
<thead>
<tr>
<th>Name</th>
<th>Role</th>
<th style="width: 34px;"></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="t in tokens">
<td>{{t.name}}</td>
<td>{{t.role}}</td>
<td>
<a ng-click="removeToken(t.id)" class="btn btn-danger btn-mini">
<i class="fa fa-remove"></i>
</a>
</td>
</tr>
</tbody>
</table>
</div>

View File

@ -139,10 +139,6 @@ export function setupAngularRoutes($routeProvider, $locationProvider) {
controllerAs: 'ctrl',
})
.when('/org/apikeys', {
templateUrl: 'public/app/features/org/partials/orgApiKeys.html',
controller: 'OrgApiKeysCtrl',
})
.when('/org/apikeys2', {
template: '<react-container />',
resolve: {
roles: () => ['Editor', 'Admin'],