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
5487cccf
Commit
5487cccf
authored
Jan 23, 2015
by
Dietmar Maurer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HardwareView: correctly enable/disable buttons
parent
e284f961
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
67 deletions
+47
-67
HardwareView.js
www/manager/qemu/HardwareView.js
+39
-60
Options.js
www/manager/qemu/Options.js
+8
-7
No files found.
www/manager/qemu/HardwareView.js
View file @
5487cccf
...
...
@@ -277,16 +277,6 @@ Ext.define('PVE.qemu.HardwareView', {
text
:
gettext
(
'
Edit
'
),
selModel
:
sm
,
disabled
:
true
,
enableFn
:
function
(
rec
)
{
if
(
!
rec
)
{
return
false
;
}
if
(
rec
.
data
[
'
delete
'
]){
return
false
;
}
var
rowdef
=
rows
[
rec
.
data
.
key
];
return
!!
rowdef
.
editor
;
},
handler
:
run_editor
});
...
...
@@ -294,16 +284,6 @@ Ext.define('PVE.qemu.HardwareView', {
text
:
gettext
(
'
Resize disk
'
),
selModel
:
sm
,
disabled
:
true
,
enableFn
:
function
(
rec
)
{
if
(
!
rec
||
rec
.
data
.
key
.
match
(
/^unused
\d
+/
)
||
rec
.
data
[
'
delete
'
])
{
return
false
;
}
if
(
Ext
.
isDefined
(
rec
.
data
.
pending
)
&&
(
rec
.
data
.
pending
!==
''
))
{
return
false
;
}
var
rowdef
=
rows
[
rec
.
data
.
key
];
return
rowdef
.
tdCls
==
'
pve-itype-icon-storage
'
&&
!
rec
.
data
.
value
.
match
(
/media=cdrom/
);
},
handler
:
run_resize
});
...
...
@@ -311,16 +291,6 @@ Ext.define('PVE.qemu.HardwareView', {
text
:
gettext
(
'
Move disk
'
),
selModel
:
sm
,
disabled
:
true
,
enableFn
:
function
(
rec
)
{
if
(
!
rec
||
rec
.
data
.
key
.
match
(
/^unused
\d
+/
))
{
return
false
;
}
if
(
rec
.
data
[
'
pending
'
]
||
rec
.
data
[
'
delete
'
]){
return
false
;
}
var
rowdef
=
rows
[
rec
.
data
.
key
];
return
rowdef
.
tdCls
==
'
pve-itype-icon-storage
'
&&
!
rec
.
data
.
value
.
match
(
/media=cdrom/
);
},
handler
:
run_move
});
...
...
@@ -328,13 +298,6 @@ Ext.define('PVE.qemu.HardwareView', {
text
:
gettext
(
'
Disk Throttle
'
),
selModel
:
sm
,
disabled
:
true
,
enableFn
:
function
(
rec
)
{
if
(
!
rec
||
rec
.
data
.
key
.
match
(
/^unused
\d
+/
))
{
return
false
;
}
var
rowdef
=
rows
[
rec
.
data
.
key
];
return
rowdef
.
tdCls
==
'
pve-itype-icon-storage
'
&&
!
rec
.
data
.
value
.
match
(
/media=cdrom/
);
},
handler
:
run_diskthrottle
});
...
...
@@ -352,17 +315,6 @@ Ext.define('PVE.qemu.HardwareView', {
return
msg
;
},
enableFn
:
function
(
rec
)
{
if
(
!
rec
)
{
return
false
;
}
if
(
rec
.
data
[
'
delete
'
])
{
return
false
;
}
var
rowdef
=
rows
[
rec
.
data
.
key
];
return
rowdef
.
never_delete
!==
true
;
},
handler
:
function
(
b
,
e
,
rec
)
{
PVE
.
Utils
.
API2Request
({
url
:
'
/api2/extjs/
'
+
baseurl
,
...
...
@@ -385,17 +337,6 @@ Ext.define('PVE.qemu.HardwareView', {
text
:
gettext
(
'
Revert
'
),
selModel
:
sm
,
disabled
:
true
,
enableFn
:
function
(
rec
)
{
if
(
!
rec
)
{
return
false
;
}
if
(
rec
.
data
[
'
delete
'
])
{
return
true
;
}
return
me
.
hasPendingChanges
(
rec
.
data
.
key
);
},
handler
:
function
(
b
,
e
,
rec
)
{
var
rowdef
=
me
.
rows
[
rec
.
data
.
key
]
||
{};
var
keys
=
rowdef
.
multiKey
||
[
rec
.
data
.
key
];
...
...
@@ -417,6 +358,40 @@ Ext.define('PVE.qemu.HardwareView', {
}
});
var
set_button_status
=
function
()
{
var
sm
=
me
.
getSelectionModel
();
var
rec
=
sm
.
getSelection
()[
0
];
if
(
!
rec
)
{
remove_btn
.
disable
();
edit_btn
.
disable
();
resize_btn
.
disable
();
move_btn
.
disable
();
diskthrottle_btn
.
disable
();
revert_btn
.
disable
();
return
;
}
var
key
=
rec
.
data
.
key
;
var
value
=
rec
.
data
.
value
;
var
rowdef
=
rows
[
key
];
var
pending
=
rec
.
data
[
'
delete
'
]
||
me
.
hasPendingChanges
(
key
);
var
isDisk
=
!
key
.
match
(
/^unused
\d
+/
)
&&
(
rowdef
.
tdCls
==
'
pve-itype-icon-storage
'
&&
!
value
.
match
(
/media=cdrom/
));
remove_btn
.
setDisabled
(
rec
.
data
[
'
delete
'
]
||
(
rowdef
.
never_delete
===
true
));
edit_btn
.
setDisabled
(
rec
.
data
[
'
delete
'
]
||
!
rowdef
.
editor
);
resize_btn
.
setDisabled
(
pending
||
!
isDisk
);
move_btn
.
setDisabled
(
pending
||
!
isDisk
);
diskthrottle_btn
.
setDisabled
(
pending
||
!
isDisk
);
revert_btn
.
setDisabled
(
!
pending
);
};
Ext
.
applyIf
(
me
,
{
url
:
'
/api2/json/
'
+
'
nodes/
'
+
nodename
+
'
/qemu/
'
+
vmid
+
'
/pending
'
,
interval
:
5000
,
...
...
@@ -479,7 +454,8 @@ Ext.define('PVE.qemu.HardwareView', {
rows
:
rows
,
sorterFn
:
sorterFn
,
listeners
:
{
itemdblclick
:
run_editor
itemdblclick
:
run_editor
,
selectionchange
:
set_button_status
}
});
...
...
@@ -489,5 +465,8 @@ Ext.define('PVE.qemu.HardwareView', {
me
.
on
(
'
hide
'
,
me
.
rstore
.
stopUpdate
);
me
.
on
(
'
destroy
'
,
me
.
rstore
.
stopUpdate
);
me
.
rstore
.
on
(
'
datachanged
'
,
function
()
{
set_button_status
();
});
}
});
www/manager/qemu/Options.js
View file @
5487cccf
...
...
@@ -338,15 +338,12 @@ Ext.define('PVE.qemu.Options', {
return
;
}
if
((
Ext
.
isDefined
(
rec
.
data
.
pending
)
&&
(
rec
.
data
.
pending
!==
''
))
||
rec
.
data
[
'
delete
'
])
{
revert_btn
.
setDisabled
(
false
);
}
else
{
revert_btn
.
setDisabled
(
true
);
}
var
key
=
rec
.
data
.
key
;
var
pending
=
rec
.
data
[
'
delete
'
]
||
me
.
hasPendingChanges
(
key
);
var
rowdef
=
rows
[
key
];
var
rowdef
=
rows
[
rec
.
data
.
key
];
edit_btn
.
setDisabled
(
!
rowdef
.
editor
);
revert_btn
.
setDisabled
(
!
pending
);
};
Ext
.
applyIf
(
me
,
{
...
...
@@ -366,6 +363,10 @@ Ext.define('PVE.qemu.Options', {
me
.
on
(
'
show
'
,
me
.
rstore
.
startUpdate
);
me
.
on
(
'
hide
'
,
me
.
rstore
.
stopUpdate
);
me
.
on
(
'
destroy
'
,
me
.
rstore
.
stopUpdate
);
me
.
rstore
.
on
(
'
datachanged
'
,
function
()
{
set_button_status
();
});
}
});
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