|
168 | 168 | $dashboardItem.appendTo($dashboard); |
169 | 169 |
|
170 | 170 | $dashboardItem.click(function() { |
171 | | - $('#browser .container').cloudBrowser('addPanel', { |
172 | | - title: tier.name + ' - ' + dashboardItem.name, |
173 | | - maximizeIfSelected: true, |
174 | | - complete: function($panel) { |
175 | | - var section = cloudStack.vpc.sections[id]; |
176 | | - var $section = $('<div>'); |
177 | | - |
178 | | - if ($.isFunction(section)) { |
179 | | - section = cloudStack.vpc.sections[id](); |
180 | | - } |
| 171 | + var section = cloudStack.vpc.sections[id]; |
| 172 | + var $section = $('<div>'); |
| 173 | + var $loading = $('<div>').addClass('loading-overlay'); |
| 174 | + |
| 175 | + if ($.isFunction(section)) { |
| 176 | + section = cloudStack.vpc.sections[id](); |
| 177 | + } |
181 | 178 |
|
182 | | - if (section.listView) { |
183 | | - $section.listView($.extend(true, {}, section, { |
184 | | - onActionComplete: function() { |
185 | | - $dashboardItem.closest('.vpc-network-chart').trigger('reload'); |
186 | | - }, |
187 | | - context: context |
188 | | - })); |
189 | | - } |
| 179 | + var before = section.before; |
| 180 | + var load = function() { |
| 181 | + $('#browser .container').cloudBrowser('addPanel', { |
| 182 | + title: tier.name + ' - ' + dashboardItem.name, |
| 183 | + maximizeIfSelected: true, |
| 184 | + complete: function($panel) { |
| 185 | + if (section.listView) { |
| 186 | + $section.listView($.extend(true, {}, section, { |
| 187 | + onActionComplete: function() { |
| 188 | + $dashboardItem.closest('.vpc-network-chart').trigger('reload'); |
| 189 | + }, |
| 190 | + context: context |
| 191 | + })); |
| 192 | + } |
190 | 193 |
|
191 | | - $section.appendTo($panel); |
| 194 | + $section.appendTo($panel); |
| 195 | + } |
| 196 | + }); |
| 197 | + }; |
| 198 | + |
| 199 | + before.check({ |
| 200 | + context: context, |
| 201 | + response: { |
| 202 | + success: function(result) { |
| 203 | + // true means content exists |
| 204 | + if (result) { |
| 205 | + load(); |
| 206 | + } else { |
| 207 | + cloudStack.dialog.confirm({ |
| 208 | + message: before.messages.confirm, |
| 209 | + action: function() { |
| 210 | + $loading.appendTo($dashboardItem.closest('.vpc-network-chart')); |
| 211 | + before.action({ |
| 212 | + context: context, |
| 213 | + response: { |
| 214 | + success: function() { |
| 215 | + $loading.remove(); |
| 216 | + $dashboardItem.closest('.vpc-network-chart').trigger('reload'); |
| 217 | + load(); |
| 218 | + } |
| 219 | + } |
| 220 | + }); |
| 221 | + } |
| 222 | + }) |
| 223 | + } |
| 224 | + } |
192 | 225 | } |
193 | 226 | }); |
194 | 227 | }); |
|
0 commit comments