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

refactor(environments): remove endpoints cache [DTD-100] (#6408)

This commit is contained in:
Chaim Lev-Ari 2022-11-02 13:29:26 +02:00 committed by GitHub
parent 9ef2e27aae
commit 37d4a80769
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
51 changed files with 155 additions and 353 deletions

View file

@ -14,7 +14,7 @@ angular.module('portainer.docker', ['portainer.app', reactModule]).config([
parent: 'endpoint',
url: '/docker',
abstract: true,
onEnter: /* @ngInject */ function onEnter(endpoint, $async, $state, EndpointService, EndpointProvider, Notifications, StateManager, SystemService) {
onEnter: /* @ngInject */ function onEnter(endpoint, $async, $state, EndpointService, Notifications, StateManager, SystemService) {
return $async(async () => {
if (![1, 2, 4].includes(endpoint.Type)) {
$state.go('portainer.home');
@ -32,10 +32,6 @@ angular.module('portainer.docker', ['portainer.app', reactModule]).config([
throw new Error('Environment is unreachable.');
}
EndpointProvider.setEndpointID(endpoint.Id);
EndpointProvider.setEndpointPublicURL(endpoint.PublicURL);
EndpointProvider.setOfflineModeFromStatus(endpoint.Status);
await StateManager.updateEndpointState(endpoint);
} catch (e) {
Notifications.error('Failed loading environment', e);

View file

@ -1,4 +1,7 @@
angular.module('portainer.docker').component('dashboardClusterAgentInfo', {
templateUrl: './dashboardClusterAgentInfo.html',
controller: 'DashboardClusterAgentInfoController',
bindings: {
endpointId: '<',
},
});

View file

@ -5,7 +5,7 @@ angular.module('portainer.docker').controller('DashboardClusterAgentInfoControll
var ctrl = this;
this.$onInit = function () {
AgentService.agents()
AgentService.agents(ctrl.endpointId)
.then(function success(data) {
ctrl.agentCount = data.length;
})

View file

@ -1,19 +0,0 @@
angular.module('portainer.docker').factory('SystemEndpoint', [
'$resource',
'API_ENDPOINT_ENDPOINTS',
function SystemEndpointFactory($resource, API_ENDPOINT_ENDPOINTS) {
'use strict';
return $resource(
API_ENDPOINT_ENDPOINTS + '/:endpointId/docker/:action/:subAction',
{
name: '@name',
},
{
ping: {
method: 'GET',
params: { action: '_ping', endpointId: '@endpointId' },
},
}
);
},
]);

View file

@ -0,0 +1,10 @@
import axios, { parseAxiosError } from '@/portainer/services/axios';
import { EnvironmentId } from '@/react/portainer/environments/types';
export async function ping(environmentId: EnvironmentId) {
try {
await axios.get(`/endpoints/${environmentId}/docker/_ping`);
} catch (error) {
throw parseAxiosError(error as Error);
}
}

View file

@ -1,10 +1,10 @@
import { EventViewModel } from '../models/event';
import { ping } from './ping';
angular.module('portainer.docker').factory('SystemService', [
'$q',
'System',
'SystemEndpoint',
function SystemServiceFactory($q, System, SystemEndpoint) {
function SystemServiceFactory($q, System) {
'use strict';
var service = {};
@ -26,7 +26,7 @@ angular.module('portainer.docker').factory('SystemService', [
};
service.ping = function (endpointId) {
return SystemEndpoint.ping({ endpointId: endpointId }).$promise;
return ping(endpointId);
};
service.version = function () {

View file

@ -144,7 +144,7 @@
<div ng-if="applicationState.endpoint.mode.agentProxy && applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'">
<div class="col-sm-12 form-section-title"> Deployment </div>
<!-- node-selection -->
<node-selector model="formValues.NodeName"> </node-selector>
<node-selector model="formValues.NodeName" endpoint-id="endpoint.Id"> </node-selector>
<!-- !node-selection -->
</div>
<!-- access-control -->

View file

@ -2,7 +2,7 @@
<div class="row" ng-if="applicationState.endpoint.mode.agentProxy && applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'">
<div class="col-sm-12">
<dashboard-cluster-agent-info></dashboard-cluster-agent-info>
<dashboard-cluster-agent-info endpoint-id="endpoint.Id"></dashboard-cluster-agent-info>
</div>
</div>
<information-panel-offline ng-if="offlineMode"></information-panel-offline>

View file

@ -1,7 +1,9 @@
angular.module('portainer.docker').controller('BuildImageController', BuildImageController);
/* @ngInject */
function BuildImageController($scope, $async, $window, ModalService, BuildService, Notifications, HttpRequestHelper) {
function BuildImageController($scope, $async, $window, ModalService, BuildService, Notifications, HttpRequestHelper, endpoint) {
$scope.endpoint = endpoint;
$scope.state = {
BuildType: 'editor',
actionInProgress: false,

View file

@ -220,7 +220,7 @@
<div ng-if="applicationState.endpoint.mode.agentProxy && applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'">
<div class="col-sm-12 form-section-title"> Deployment </div>
<!-- node-selection -->
<node-selector model="formValues.NodeName"> </node-selector>
<node-selector model="formValues.NodeName" endpoint-id="endpoint.Id"> </node-selector>
<!-- !node-selection -->
</div>
<!-- actions -->

View file

@ -20,7 +20,7 @@
<div ng-if="applicationState.endpoint.mode.agentProxy && applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'">
<div class="col-sm-12 form-section-title"> Deployment </div>
<!-- node-selection -->
<node-selector model="formValues.NodeName"> </node-selector>
<node-selector model="formValues.NodeName" endpoint-id="endpoint.Id"> </node-selector>
<!-- !node-selection -->
</div>
<div class="form-group">

View file

@ -23,7 +23,7 @@
<div ng-if="applicationState.endpoint.mode.agentProxy && applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE'">
<div class="col-sm-12 form-section-title"> Deployment </div>
<!-- node-selection -->
<node-selector model="formValues.NodeName"> </node-selector>
<node-selector model="formValues.NodeName" endpoint-id="endpoint.Id"> </node-selector>
<!-- !node-selection -->
</div>
<div class="row" authorization="DockerImageCreate">

View file

@ -14,7 +14,10 @@ angular.module('portainer.docker').controller('CreateNetworkController', [
'ResourceControlService',
'FormValidator',
'HttpRequestHelper',
function ($q, $scope, $state, PluginService, Notifications, NetworkService, LabelHelper, Authentication, ResourceControlService, FormValidator, HttpRequestHelper) {
'endpoint',
function ($q, $scope, $state, PluginService, Notifications, NetworkService, LabelHelper, Authentication, ResourceControlService, FormValidator, HttpRequestHelper, endpoint) {
$scope.endpoint = endpoint;
$scope.formValues = {
DriverOptions: [],
IPV4: {

View file

@ -216,7 +216,7 @@
>
<div class="col-sm-12 form-section-title"> Deployment </div>
<!-- node-selection -->
<node-selector model="formValues.NodeName"> </node-selector>
<node-selector model="formValues.NodeName" endpoint-id="endpoint.Id"> </node-selector>
<!-- !node-selection -->
</div>
<!-- access-control -->

View file

@ -66,7 +66,7 @@ angular.module('portainer.docker').controller('NetworksController', [
};
if ($scope.applicationState.endpoint.mode.agentProxy && $scope.applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE') {
req.agents = AgentService.agents();
req.agents = AgentService.agents(endpoint.Id);
}
$q.all(req)

View file

@ -42,7 +42,7 @@ angular.module('portainer.docker').controller('NodeDetailsViewController', [
return;
}
AgentService.hostInfo(node.Hostname).then(function onHostInfoLoad(agentHostInfo) {
AgentService.hostInfo(ctrl.endpoint.Id, node.Hostname).then(function onHostInfoLoad(agentHostInfo) {
ctrl.devices = agentHostInfo.PCIDevices;
ctrl.disks = agentHostInfo.PhysicalDisks;
});

View file

@ -13,7 +13,10 @@ angular.module('portainer.docker').controller('CreateVolumeController', [
'Notifications',
'FormValidator',
'HttpRequestHelper',
function ($q, $scope, $state, VolumeService, PluginService, ResourceControlService, Authentication, Notifications, FormValidator, HttpRequestHelper) {
'endpoint',
function ($q, $scope, $state, VolumeService, PluginService, ResourceControlService, Authentication, Notifications, FormValidator, HttpRequestHelper, endpoint) {
$scope.endpoint = endpoint;
$scope.formValues = {
Driver: 'local',
DriverOptions: [],

View file

@ -72,7 +72,7 @@
<div ng-if="applicationState.endpoint.mode.agentProxy && applicationState.endpoint.mode.provider === 'DOCKER_SWARM_MODE' && formValues.Driver === 'local'">
<div class="col-sm-12 form-section-title"> Deployment </div>
<!-- node-selection -->
<node-selector model="formValues.NodeName"> </node-selector>
<node-selector model="formValues.NodeName" endpoint-id="endpoint.Id"> </node-selector>
<!-- !node-selection -->
</div>
<!-- access-control -->