Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pve-manager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
pve-manager
Commits
1c753859
Commit
1c753859
authored
Sep 14, 2012
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve task viewer
parent
a7ff6dfe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
2 deletions
+95
-2
Tasks.pm
PVE/API2/Tasks.pm
+11
-0
TaskViewer.js
www/manager/window/TaskViewer.js
+84
-2
No files found.
PVE/API2/Tasks.pm
View file @
1c753859
...
@@ -279,6 +279,9 @@ __PACKAGE__->register_method({
...
@@ -279,6 +279,9 @@ __PACKAGE__->register_method({
return
$lines
;
return
$lines
;
}});
}});
my
$exit_status_cache
=
{};
__PACKAGE__
->
register_method
({
__PACKAGE__
->
register_method
({
name
=>
'
read_task_status
',
name
=>
'
read_task_status
',
path
=>
'
{upid}/status
',
path
=>
'
{upid}/status
',
...
@@ -331,5 +334,13 @@ __PACKAGE__->register_method({
...
@@ -331,5 +334,13 @@ __PACKAGE__->register_method({
$task
->
{
upid
}
=
$param
->
{
upid
};
# include upid
$task
->
{
upid
}
=
$param
->
{
upid
};
# include upid
if
(
$task
->
{
status
}
eq
'
stopped
')
{
if
(
!
defined
(
$exit_status_cache
->
{
$task
->
{
upid
}}))
{
$exit_status_cache
->
{
$task
->
{
upid
}}
=
PVE::Tools::
upid_read_status
(
$task
->
{
upid
});
}
$task
->
{
exitstatus
}
=
$exit_status_cache
->
{
$task
->
{
upid
}};
}
return
$task
;
return
$task
;
}});
}});
www/manager/window/TaskViewer.js
View file @
1c753859
Ext
.
define
(
'
PVE.window.TaskProgress
'
,
{
extend
:
'
Ext.window.Window
'
,
alias
:
'
widget.pveTaskProgress
'
,
initComponent
:
function
()
{
var
me
=
this
;
if
(
!
me
.
upid
)
{
throw
"
no task specified
"
;
}
var
task
=
PVE
.
Utils
.
parse_task_upid
(
me
.
upid
);
var
statstore
=
Ext
.
create
(
'
PVE.data.ObjectStore
'
,
{
url
:
"
/api2/json/nodes/
"
+
task
.
node
+
"
/tasks/
"
+
me
.
upid
+
"
/status
"
,
interval
:
1000
,
rows
:
{
status
:
{
defaultValue
:
'
unknown
'
},
exitstatus
:
{
defaultValue
:
'
unknown
'
}
}
});
me
.
on
(
'
destroy
'
,
statstore
.
stopUpdate
);
var
getObjectValue
=
function
(
key
,
defaultValue
)
{
var
rec
=
statstore
.
getById
(
key
);
if
(
rec
)
{
return
rec
.
data
.
value
;
}
return
defaultValue
;
};
var
pbar
=
Ext
.
create
(
'
Ext.ProgressBar
'
,
{
text
:
'
running...
'
});
me
.
mon
(
statstore
,
'
load
'
,
function
()
{
var
status
=
getObjectValue
(
'
status
'
);
if
(
status
===
'
stopped
'
)
{
var
exitstatus
=
getObjectValue
(
'
exitstatus
'
);
if
(
exitstatus
==
'
OK
'
)
{
pbar
.
reset
();
pbar
.
updateText
(
"
Done!
"
);
Ext
.
Function
.
defer
(
me
.
close
,
1000
,
me
);
}
else
{
me
.
close
();
Ext
.
Msg
.
alert
(
'
Task failed
'
,
exitstatus
);
}
}
});
var
descr
=
PVE
.
Utils
.
format_task_description
(
task
.
type
,
task
.
id
);
Ext
.
applyIf
(
me
,
{
title
:
"
Task:
"
+
descr
,
width
:
300
,
layout
:
'
auto
'
,
modal
:
true
,
bodyPadding
:
5
,
items
:
pbar
});
me
.
callParent
();
statstore
.
startUpdate
();
pbar
.
wait
();
}
});
// fixme: how can we avoid those lint errors?
// fixme: how can we avoid those lint errors?
/*jslint confusion: true */
/*jslint confusion: true */
...
@@ -14,10 +82,24 @@ Ext.define('PVE.window.TaskViewer', {
...
@@ -14,10 +82,24 @@ Ext.define('PVE.window.TaskViewer', {
var
task
=
PVE
.
Utils
.
parse_task_upid
(
me
.
upid
);
var
task
=
PVE
.
Utils
.
parse_task_upid
(
me
.
upid
);
var
statgrid
;
var
rows
=
{
var
rows
=
{
status
:
{
status
:
{
header
:
gettext
(
'
Status
'
),
header
:
gettext
(
'
Status
'
),
defaultValue
:
'
unknown
'
defaultValue
:
'
unknown
'
,
renderer
:
function
(
value
)
{
if
(
value
!=
'
stopped
'
)
{
return
value
;
}
var
es
=
statgrid
.
getObjectValue
(
'
exitstatus
'
);
if
(
es
)
{
return
value
+
'
:
'
+
es
;
}
}
},
exitstatus
:
{
visible
:
false
},
},
type
:
{
type
:
{
header
:
'
Task type
'
,
header
:
'
Task type
'
,
...
@@ -76,7 +158,7 @@ Ext.define('PVE.window.TaskViewer', {
...
@@ -76,7 +158,7 @@ Ext.define('PVE.window.TaskViewer', {
handler
:
stop_task
handler
:
stop_task
});
});
var
statgrid
=
Ext
.
create
(
'
PVE.grid.ObjectGrid
'
,
{
statgrid
=
Ext
.
create
(
'
PVE.grid.ObjectGrid
'
,
{
title
:
gettext
(
'
Status
'
),
title
:
gettext
(
'
Status
'
),
layout
:
'
fit
'
,
layout
:
'
fit
'
,
tbar
:
[
stop_btn1
],
tbar
:
[
stop_btn1
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment