1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-08 23:35:31 +02:00

fix(app): use deps injection in router correctly (#4049)

* fix(app): use deps injection in router correctly

* feat(app): guard against using wrong endpoint type

* feat(sidebar): supply endpoint id

* feat(templates): move custom templates to docker
This commit is contained in:
Chaim Lev-Ari 2020-07-21 00:06:37 +03:00 committed by GitHub
parent 66a3104805
commit 4b97cf738e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 135 additions and 101 deletions

View file

@ -81,8 +81,7 @@ angular.module('portainer.app', []).config([
parent: 'root',
abstract: true,
resolve: {
/* @ngInject */
endpoint($async, $state, $transition$, EndpointService, Notifications) {
endpoint: /* @ngInject */ function endpoint($async, $state, $transition$, EndpointService, Notifications) {
return $async(async () => {
try {
const endpointId = +$transition$.params().endpointId;

View file

@ -13,9 +13,13 @@
<a ui-sref="portainer.home" ui-sref-active="active">Home <span class="menu-icon fa fa-home fa-fw"></span></a>
</li>
<li class="sidebar-title endpoint-name" ng-if="applicationState.endpoint.name"> <span class="fa fa-plug space-right"></span>{{ applicationState.endpoint.name }} </li>
<kubernetes-sidebar-content ng-if="applicationState.endpoint.mode && applicationState.endpoint.mode.provider === 'KUBERNETES'" admin-access="isAdmin">
<kubernetes-sidebar-content
ng-if="applicationState.endpoint.mode && applicationState.endpoint.mode.provider === 'KUBERNETES'"
admin-access="isAdmin"
endpoint-id="endpointId"
>
</kubernetes-sidebar-content>
<azure-sidebar-content ng-if="applicationState.endpoint.mode && applicationState.endpoint.mode.provider === 'AZURE'"> </azure-sidebar-content>
<azure-sidebar-content ng-if="applicationState.endpoint.mode && applicationState.endpoint.mode.provider === 'AZURE'" endpoint-id="endpointId"> </azure-sidebar-content>
<docker-sidebar-content
ng-if="applicationState.endpoint.mode && applicationState.endpoint.mode.provider !== 'AZURE' && applicationState.endpoint.mode.provider !== 'KUBERNETES'"
current-route-name="$state.current.name"
@ -25,6 +29,7 @@
standalone-management="applicationState.endpoint.mode.provider === 'DOCKER_STANDALONE'"
admin-access="isAdmin"
offline-mode="endpointState.OfflineMode"
endpoint-id="endpointId"
></docker-sidebar-content>
<li class="sidebar-title" authorization="IntegrationStoridgeAdmin" ng-if="applicationState.endpoint.mode && applicationState.endpoint.extensions.length > 0">
<span>Integrations</span>

View file

@ -1,11 +1,13 @@
angular.module('portainer.app').controller('SidebarController', [
'$q',
'$scope',
'$transitions',
'StateManager',
'Notifications',
'Authentication',
'UserService',
function ($q, $scope, StateManager, Notifications, Authentication, UserService) {
'EndpointProvider',
function ($q, $scope, $transitions, StateManager, Notifications, Authentication, UserService, EndpointProvider) {
function checkPermissions(memberships) {
var isLeader = false;
angular.forEach(memberships, function (membership) {
@ -23,6 +25,7 @@ angular.module('portainer.app').controller('SidebarController', [
let userDetails = Authentication.getUserDetails();
let isAdmin = Authentication.isAdmin();
$scope.isAdmin = isAdmin;
$scope.endpointId = EndpointProvider.endpointID();
$q.when(!isAdmin ? UserService.userMemberships(userDetails.ID) : [])
.then(function success(data) {
@ -31,6 +34,10 @@ angular.module('portainer.app').controller('SidebarController', [
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve user memberships');
});
$transitions.onEnter({}, () => {
$scope.endpointId = EndpointProvider.endpointID();
});
}
initView();