mirror of
https://github.com/portainer/portainer.git
synced 2025-08-06 22:35:23 +02:00
feat(jobs): add the ability to run a job on a target endpoint #2374
* feat(jobs): adding the ability to run scripts on endpoints fix(job): click on containerId in JobsDatatable redirects to container's logs refactor(job): remove the jobs datatable settings + texts changes on JobCreation view fix(jobs): jobs payloads are now following API rules and case feat(jobs): adding the capability to run scripts on hosts * feat(jobs): adding the ability to purge jobs containers * refactor(job): apply review changes * feat(job-creation): store image name in local storage * feat(host): disable job exec link in non-agent Swarm setup * feat(host): only display execute job in agent setups or standalone * feat(job): job execution overhaul * docs(swagger): update EndpointJob documentation
This commit is contained in:
parent
6ab510e5cb
commit
354fda31f1
37 changed files with 739 additions and 100 deletions
|
@ -1,21 +1,17 @@
|
|||
angular
|
||||
.module('portainer.docker')
|
||||
.controller('HostBrowserViewController', [
|
||||
'SystemService', 'HttpRequestHelper',
|
||||
function HostBrowserViewController(SystemService, HttpRequestHelper) {
|
||||
var ctrl = this;
|
||||
angular.module('portainer.docker').controller('HostBrowserViewController', [
|
||||
'SystemService', 'Notifications',
|
||||
function HostBrowserViewController(SystemService, Notifications) {
|
||||
var ctrl = this;
|
||||
ctrl.$onInit = $onInit;
|
||||
|
||||
ctrl.$onInit = $onInit;
|
||||
|
||||
function $onInit() {
|
||||
loadInfo();
|
||||
}
|
||||
|
||||
function loadInfo() {
|
||||
SystemService.info().then(function onInfoLoaded(host) {
|
||||
HttpRequestHelper.setPortainerAgentTargetHeader(host.Name);
|
||||
ctrl.host = host;
|
||||
});
|
||||
}
|
||||
function $onInit() {
|
||||
SystemService.info()
|
||||
.then(function onInfoLoaded(host) {
|
||||
ctrl.host = host;
|
||||
})
|
||||
.catch(function onError(err) {
|
||||
Notifications.error('Unable to retrieve host information', err);
|
||||
});
|
||||
}
|
||||
]);
|
||||
}
|
||||
]);
|
||||
|
|
17
app/docker/views/host/host-job/host-job-controller.js
Normal file
17
app/docker/views/host/host-job/host-job-controller.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
angular.module('portainer.docker').controller('HostJobController', [
|
||||
'SystemService', 'Notifications',
|
||||
function HostJobController(SystemService, Notifications) {
|
||||
var ctrl = this;
|
||||
ctrl.$onInit = $onInit;
|
||||
|
||||
function $onInit() {
|
||||
SystemService.info()
|
||||
.then(function onInfoLoaded(host) {
|
||||
ctrl.host = host;
|
||||
})
|
||||
.catch(function onError(err) {
|
||||
Notifications.error('Unable to retrieve host information', err);
|
||||
});
|
||||
}
|
||||
}
|
||||
]);
|
16
app/docker/views/host/host-job/host-job.html
Normal file
16
app/docker/views/host/host-job/host-job.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
<rd-header>
|
||||
<rd-header-title title-text="Host job execution"></rd-header-title>
|
||||
<rd-header-content>
|
||||
Host > <a ui-sref="docker.host">{{ $ctrl.host.Name }}</a> > execute job
|
||||
</rd-header-content>
|
||||
</rd-header>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<rd-widget>
|
||||
<rd-widget-body>
|
||||
<execute-job-form></execute-job-form>
|
||||
</rd-widget-body>
|
||||
</rd-widget>
|
||||
</div>
|
||||
</div>
|
4
app/docker/views/host/host-job/host-job.js
Normal file
4
app/docker/views/host/host-job/host-job.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
angular.module('portainer.docker').component('hostJobView', {
|
||||
templateUrl: 'app/docker/views/host/host-job/host-job.html',
|
||||
controller: 'HostJobController'
|
||||
});
|
|
@ -1,13 +1,15 @@
|
|||
angular.module('portainer.docker').controller('HostViewController', [
|
||||
'$q', 'SystemService', 'Notifications', 'StateManager', 'AgentService',
|
||||
function HostViewController($q, SystemService, Notifications, StateManager, AgentService) {
|
||||
'$q', 'SystemService', 'Notifications', 'StateManager', 'AgentService', 'ContainerService', 'Authentication',
|
||||
function HostViewController($q, SystemService, Notifications, StateManager, AgentService, ContainerService, Authentication) {
|
||||
var ctrl = this;
|
||||
|
||||
this.$onInit = initView;
|
||||
|
||||
ctrl.state = {
|
||||
isAgent: false
|
||||
isAgent: false,
|
||||
isAdmin : false
|
||||
};
|
||||
|
||||
|
||||
this.engineDetails = {};
|
||||
this.hostDetails = {};
|
||||
this.devices = null;
|
||||
|
@ -16,31 +18,34 @@ angular.module('portainer.docker').controller('HostViewController', [
|
|||
function initView() {
|
||||
var applicationState = StateManager.getState();
|
||||
ctrl.state.isAgent = applicationState.endpoint.mode.agentProxy;
|
||||
ctrl.state.isAdmin = Authentication.getUserDetails().role === 1;
|
||||
var agentApiVersion = applicationState.endpoint.agentApiVersion;
|
||||
ctrl.state.agentApiVersion = agentApiVersion;
|
||||
|
||||
$q.all({
|
||||
version: SystemService.version(),
|
||||
info: SystemService.info()
|
||||
info: SystemService.info(),
|
||||
jobs: ctrl.state.isAdmin ? ContainerService.containers(true, { label: ['io.portainer.job.endpoint'] }) : []
|
||||
})
|
||||
.then(function success(data) {
|
||||
ctrl.engineDetails = buildEngineDetails(data);
|
||||
ctrl.hostDetails = buildHostDetails(data.info);
|
||||
.then(function success(data) {
|
||||
ctrl.engineDetails = buildEngineDetails(data);
|
||||
ctrl.hostDetails = buildHostDetails(data.info);
|
||||
ctrl.jobs = data.jobs;
|
||||
|
||||
if (ctrl.state.isAgent && agentApiVersion > 1) {
|
||||
return AgentService.hostInfo(data.info.Hostname).then(function onHostInfoLoad(agentHostInfo) {
|
||||
ctrl.devices = agentHostInfo.PCIDevices;
|
||||
ctrl.disks = agentHostInfo.PhysicalDisks;
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error(
|
||||
'Failure',
|
||||
err,
|
||||
'Unable to retrieve engine details'
|
||||
);
|
||||
});
|
||||
if (ctrl.state.isAgent && agentApiVersion > 1) {
|
||||
return AgentService.hostInfo(data.info.Hostname).then(function onHostInfoLoad(agentHostInfo) {
|
||||
ctrl.devices = agentHostInfo.PCIDevices;
|
||||
ctrl.disks = agentHostInfo.PhysicalDisks;
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(function error(err) {
|
||||
Notifications.error(
|
||||
'Failure',
|
||||
err,
|
||||
'Unable to retrieve engine details'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function buildEngineDetails(data) {
|
||||
|
|
|
@ -5,7 +5,9 @@
|
|||
agent-api-version="$ctrl.state.agentApiVersion"
|
||||
disks="$ctrl.disks"
|
||||
devices="$ctrl.devices"
|
||||
|
||||
refresh-url="docker.host"
|
||||
browse-url="docker.host.browser"
|
||||
></host-overview>
|
||||
is-job-enabled="$ctrl.state.isAdmin"
|
||||
job-url="docker.host.job"
|
||||
jobs="$ctrl.jobs"
|
||||
></host-overview>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue