From 0a1055dc105a43f1a11cc6dc1a81b67e3cb0b308 Mon Sep 17 00:00:00 2001 From: Hongbin Lu Date: Sat, 16 Jun 2018 03:16:07 +0000 Subject: [PATCH] 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 --- .../images/actions/delete.service.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/zun_ui/static/dashboard/container/images/actions/delete.service.js b/zun_ui/static/dashboard/container/images/actions/delete.service.js index 1782030..a324d9d 100644 --- a/zun_ui/static/dashboard/container/images/actions/delete.service.js +++ b/zun_ui/static/dashboard/container/images/actions/delete.service.js @@ -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() {