mirror of
https://github.com/portainer/portainer.git
synced 2025-08-08 15:25:22 +02:00
feat(system): path to upgrade standalone to BE [EE-4071] (#8095)
This commit is contained in:
parent
756ac034ec
commit
5cbf52377d
73 changed files with 1374 additions and 421 deletions
|
@ -1,8 +1,7 @@
|
|||
import { useQuery } from 'react-query';
|
||||
|
||||
import { error as notifyError } from '@/portainer/services/notifications';
|
||||
|
||||
import { getNodesCount } from '../services/api/status.service';
|
||||
import { useNodesCount } from '@/react/portainer/system/useNodesCount';
|
||||
|
||||
import { getLicenseInfo } from './license.service';
|
||||
import { LicenseInfo, LicenseType } from './types';
|
||||
|
@ -21,22 +20,8 @@ export function useLicenseInfo() {
|
|||
return { isLoading, info };
|
||||
}
|
||||
|
||||
function useNodesCounts() {
|
||||
const { isLoading, data } = useQuery(
|
||||
['status', 'nodes'],
|
||||
() => getNodesCount(),
|
||||
{
|
||||
onError(error) {
|
||||
notifyError('Failure', error as Error, 'Failed to get nodes count');
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return { nodesCount: data || 0, isLoading };
|
||||
}
|
||||
|
||||
export function useIntegratedLicenseInfo() {
|
||||
const { isLoading: isLoadingNodes, nodesCount } = useNodesCounts();
|
||||
const { isLoading: isLoadingNodes, data: nodesCount = 0 } = useNodesCount();
|
||||
|
||||
const { isLoading: isLoadingLicense, info } = useLicenseInfo();
|
||||
if (
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
angular.module('portainer.app').factory('Status', [
|
||||
'$resource',
|
||||
'API_ENDPOINT_STATUS',
|
||||
function StatusFactory($resource, API_ENDPOINT_STATUS) {
|
||||
'use strict';
|
||||
return $resource(
|
||||
API_ENDPOINT_STATUS + '/:action',
|
||||
{},
|
||||
{
|
||||
get: { method: 'GET' },
|
||||
version: { method: 'GET', params: { action: 'version' } },
|
||||
}
|
||||
);
|
||||
},
|
||||
]);
|
|
@ -1,80 +0,0 @@
|
|||
import { useQuery } from 'react-query';
|
||||
|
||||
import axios, { parseAxiosError } from '../axios';
|
||||
|
||||
export interface NodesCountResponse {
|
||||
nodes: number;
|
||||
}
|
||||
|
||||
export async function getNodesCount() {
|
||||
try {
|
||||
const { data } = await axios.get<NodesCountResponse>(buildUrl('nodes'));
|
||||
return data.nodes;
|
||||
} catch (error) {
|
||||
throw parseAxiosError(error as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export interface StatusResponse {
|
||||
Edition: string;
|
||||
Version: string;
|
||||
InstanceID: string;
|
||||
}
|
||||
|
||||
export async function getStatus() {
|
||||
try {
|
||||
const { data } = await axios.get<StatusResponse>(buildUrl());
|
||||
|
||||
data.Edition = 'Community Edition';
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
throw parseAxiosError(error as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export function useStatus<T = StatusResponse>(
|
||||
select?: (status: StatusResponse) => T
|
||||
) {
|
||||
return useQuery(['status'], () => getStatus(), { select });
|
||||
}
|
||||
|
||||
export interface VersionResponse {
|
||||
// Whether portainer has an update available
|
||||
UpdateAvailable: boolean;
|
||||
// The latest version available
|
||||
LatestVersion: string;
|
||||
ServerVersion: string;
|
||||
DatabaseVersion: string;
|
||||
Build: {
|
||||
BuildNumber: string;
|
||||
ImageTag: string;
|
||||
NodejsVersion: string;
|
||||
YarnVersion: string;
|
||||
WebpackVersion: string;
|
||||
GoVersion: string;
|
||||
};
|
||||
}
|
||||
|
||||
export async function getVersionStatus() {
|
||||
try {
|
||||
const { data } = await axios.get<VersionResponse>(buildUrl('version'));
|
||||
return data;
|
||||
} catch (error) {
|
||||
throw parseAxiosError(error as Error);
|
||||
}
|
||||
}
|
||||
|
||||
export function useVersionStatus() {
|
||||
return useQuery(['version'], () => getVersionStatus());
|
||||
}
|
||||
|
||||
function buildUrl(action?: string) {
|
||||
let url = '/status';
|
||||
|
||||
if (action) {
|
||||
url += `/${action}`;
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
|
@ -1,42 +1,27 @@
|
|||
import { StatusVersionViewModel, StatusViewModel } from '../../models/status';
|
||||
import { getSystemStatus } from '@/react/portainer/system/useSystemStatus';
|
||||
import { StatusViewModel } from '../../models/status';
|
||||
|
||||
angular.module('portainer.app').factory('StatusService', [
|
||||
'$q',
|
||||
'Status',
|
||||
function StatusServiceFactory($q, Status) {
|
||||
'use strict';
|
||||
var service = {};
|
||||
angular.module('portainer.app').factory('StatusService', StatusServiceFactory);
|
||||
|
||||
service.status = function () {
|
||||
var deferred = $q.defer();
|
||||
/* @ngInject */
|
||||
function StatusServiceFactory($q) {
|
||||
'use strict';
|
||||
var service = {};
|
||||
|
||||
Status.get()
|
||||
.$promise.then(function success(data) {
|
||||
var status = new StatusViewModel(data);
|
||||
deferred.resolve(status);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: 'Unable to retrieve application status', err: err });
|
||||
});
|
||||
service.status = function () {
|
||||
var deferred = $q.defer();
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
getSystemStatus()
|
||||
.then(function success(data) {
|
||||
var status = new StatusViewModel(data);
|
||||
deferred.resolve(status);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: 'Unable to retrieve application status', err: err });
|
||||
});
|
||||
|
||||
service.version = function () {
|
||||
var deferred = $q.defer();
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
Status.version()
|
||||
.$promise.then(function success(data) {
|
||||
var status = new StatusVersionViewModel(data);
|
||||
deferred.resolve(status);
|
||||
})
|
||||
.catch(function error(err) {
|
||||
deferred.reject({ msg: 'Unable to retrieve application version info', err: err });
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
return service;
|
||||
},
|
||||
]);
|
||||
return service;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue