Retrieve hosts under initAction

In before, the UI tried to call Zun API to retrieve the list of
hosts at the top level. However, if the user is not login, the Zun
API call will return 401 which causes error on loading the page.

Change-Id: I4af881d38a721a1e70610440e0fba416eab85f41
This commit is contained in:
Hongbin Lu 2018-06-16 03:16:07 +00:00
parent a667cd4bf0
commit 0a1055dc10

View File

@ -77,16 +77,6 @@
// model
var model;
// get hosts for zun
zun.getHosts().then(onGetZunHosts);
function onGetZunHosts(response) {
var hs = [];
response.data.items.forEach(function (host) {
hs.push({value: host.id, name: host.hostname});
});
push.apply(hosts, hs);
}
var message = {
success: gettext('Container %s was successfully restarted.')
};
@ -104,6 +94,15 @@
// include this function in your service
// if you plan to emit events to the parent controller
function initAction() {
// get hosts for zun
zun.getHosts().then(onGetZunHosts);
function onGetZunHosts(response) {
var hs = [];
response.data.items.forEach(function (host) {
hs.push({value: host.id, name: host.hostname});
});
push.apply(hosts, hs);
}
}
function allowed() {