Skip to content

Commit 1a1d7bc

Browse files
authored
Show loading spinner on first page view (#870)
Fixes #827
1 parent 8ab77bb commit 1a1d7bc

File tree

7 files changed

+37
-16
lines changed

7 files changed

+37
-16
lines changed

src/app/frontend/chrome/chrome.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
<md-toolbar class="kd-toolbar">
1818
<div class="md-toolbar-tools kd-toolbar-tools">
19-
<a ng-href="{{ctrl.getLogoHref()}}" tabindex="-1">
19+
<a ng-href="{{$ctrl.getLogoHref()}}" tabindex="-1">
2020
<md-icon md-svg-icon="assets/images/kubernetes-logo.svg" class="kd-toolbar-logo"></md-icon>
2121
</a>
2222
<h2>
@@ -27,10 +27,10 @@ <h2>
2727
</div>
2828
</md-toolbar>
2929

30-
<kd-actionbar ng-if="ctrl.isActionbarVisible()"></kd-actionbar>
30+
<kd-actionbar ng-if="$ctrl.isActionbarVisible()"></kd-actionbar>
3131

3232
<md-content flex="auto" class="kd-app-content">
33-
<div ng-switch="ctrl.showLoadingSpinner" flex="auto" >
33+
<div ng-switch="$ctrl.showLoadingSpinner" flex="auto" >
3434
<div ng-switch-when="true" class="kd-center-fixed">
3535
<md-progress-circular md-mode="indeterminate" md-diameter="96">
3636
</md-progress-circular>

src/app/frontend/chrome/chrome_controller.js renamed to src/app/frontend/chrome/chrome_component.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import {actionbarViewName} from './chrome_state';
2121
*
2222
* @final
2323
*/
24-
export default class ChromeController {
24+
export class ChromeController {
2525
/**
2626
* @param {!ui.router.$state} $state
2727
* @param {!angular.Scope} $scope
@@ -37,9 +37,13 @@ export default class ChromeController {
3737
/** @private {!ui.router.$state} */
3838
this.state_ = $state;
3939

40-
this.registerStateChangeListeners($scope);
40+
/** @private {!angular.Scope} */
41+
this.scope_ = $scope;
4142
}
4243

44+
/** @export */
45+
$onInit() { this.registerStateChangeListeners(this.scope_); }
46+
4347
/**
4448
* @return {string}
4549
* @export
@@ -70,3 +74,11 @@ export default class ChromeController {
7074
*/
7175
hideSpinner_() { this.showLoadingSpinner = false; }
7276
}
77+
78+
/**
79+
* @type {!angular.Component}
80+
*/
81+
export const chromeComponent = {
82+
controller: ChromeController,
83+
templateUrl: 'chrome/chrome.html',
84+
};

src/app/frontend/chrome/chrome_module.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
import stateConfig from './chrome_stateconfig';
16+
import {chromeComponent} from './chrome_component';
1617
import componentsModule from 'common/components/components_module';
1718
import namespaceModule from 'common/namespace/namespace_module';
1819

@@ -28,4 +29,5 @@ export default angular
2829
componentsModule.name,
2930
namespaceModule.name,
3031
])
31-
.config(stateConfig);
32+
.config(stateConfig)
33+
.component('kdChrome', chromeComponent);

src/app/frontend/chrome/chrome_stateconfig.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import ChromeController from './chrome_controller';
16-
import {stateName, namespaceParam} from './chrome_state';
15+
import {actionbarViewName, namespaceParam, stateName, toolbarViewName} from './chrome_state';
1716

1817
/**
1918
* Namespace is an abstract state with no path, but with one parameter ?namespace= that
@@ -28,9 +27,17 @@ export default function stateConfig($stateProvider) {
2827
$stateProvider.state(stateName, {
2928
url: `?${namespaceParam}`,
3029
abstract: true,
31-
templateUrl: 'chrome/chrome.html',
32-
controller: ChromeController,
33-
controllerAs: 'ctrl',
30+
views: {
31+
'': {
32+
template: '<div ui-view></div>',
33+
},
34+
[toolbarViewName]: {
35+
template: `<div ui-view="${toolbarViewName}"></div>`,
36+
},
37+
[actionbarViewName]: {
38+
template: `<div ui-view="${actionbarViewName}"></div>`,
39+
},
40+
},
3441
});
3542
$stateProvider.decorator('parent', requireParentState);
3643
}

src/app/frontend/deploymentdetail/deploymentinfo_component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default class DeploymentInfoController {
2727
/**
2828
* Definition object for the component that displays replica set info.
2929
*
30-
* @return {!angular.Directive}
30+
* @type {!angular.Component}
3131
*/
3232
export const deploymentInfoComponent = {
3333
controller: DeploymentInfoController,

src/app/frontend/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
experience.</p>
4545
<![endif]-->
4646

47-
<div ui-view layout="column" layout-fill> <!-- Application content is inserted here. --> </div>
47+
<kd-chrome layout="column" layout-fill> <!-- Application content is inserted here. --> </kd-chrome>
4848
<!-- build:js static/vendor.js -->
4949
<!-- bower:js -->
5050
<!-- Bower JS dependencies are populated here (dev build) and compiled

src/test/frontend/chrome/chrome_controller_test.js renamed to src/test/frontend/chrome/chrome_component_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import ChromeController from 'chrome/chrome_controller';
1615
import chromeModule from 'chrome/chrome_module';
1716
import {actionbarViewName} from 'chrome/chrome_state';
1817

@@ -26,8 +25,9 @@ describe('Chrome controller', () => {
2625

2726
beforeEach(() => {
2827
angular.mock.module(chromeModule.name);
29-
angular.mock.inject(($controller, $rootScope, $state) => {
30-
ctrl = $controller(ChromeController, {$scope: $rootScope});
28+
angular.mock.inject(($componentController, $rootScope, $state) => {
29+
ctrl = $componentController('kdChrome', {$scope: $rootScope});
30+
ctrl.$onInit();
3131
scope = $rootScope;
3232
state = $state;
3333
});

0 commit comments

Comments
 (0)