Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix loader animation on factory loading page #13415

Merged
merged 4 commits into from
May 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion dashboard/src/app/demo-components/demo-components.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import {ICheEditModeOverlayConfig} from '../../components/widget/edit-mode-overlay/che-edit-mode-overlay.directive';
import {CheNotification} from '../../components/notification/che-notification.factory';

enum Tab {Font, Panel, Selecter, Icons, Dropdown_button, Buttons, Input, List, Label_container, Stack_selector, Popover, Edit_mode_overlay}
enum Tab {Font, Panel, Selecter, Icons, Dropdown_button, Buttons, Input, List, Label_container, Stack_selector, Popover, Edit_mode_overlay, Loader}

/**
* This class is handling the controller for the demo of components
Expand Down Expand Up @@ -57,6 +57,8 @@ export class DemoComponentsController {

overlayConfig: ICheEditModeOverlayConfig;

loader: any;

/**
* Default constructor that is using resource
*/
Expand Down Expand Up @@ -152,6 +154,8 @@ export class DemoComponentsController {
disabled: false
}
};

this.createLoader();
}

/**
Expand Down Expand Up @@ -182,4 +186,26 @@ export class DemoComponentsController {
this.numberIsChanged++;
}

createLoader(): void {
this.loader = {};
const allSteps = [
{text: 'Loading factory', inProgressText: '', logs: '', hasError: false},
{text: 'Looking for devfile', inProgressText: '', logs: '', hasError: false},
{text: 'Initializing workspace', inProgressText: 'Provision workspace and associating it with the existing user', logs: '', hasError: false},
{text: 'Starting workspace runtime', inProgressText: 'Retrieving the stack\'s image and launching it', logs: '', hasError: false},
{text: 'Starting workspace agent', inProgressText: 'Agents provide RESTful services like intellisense and SSH', logs: '', hasError: false},
{text: 'Open IDE', inProgressText: '', logs: '', hasError: false}
]
this.loader.getLoadingSteps = () => allSteps;
let currentProgressStep = 0;
this.loader.getCurrentProgressStep = () => currentProgressStep;
this.loader.nextStep = () => {
currentProgressStep++;
currentProgressStep = currentProgressStep % (allSteps.length);
}
this.loader.pause = () => {
this.loader.paused = !this.loader.paused;
};
}

}
24 changes: 24 additions & 0 deletions dashboard/src/app/demo-components/demo-components.html
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,30 @@ <h6>This is h6

</md-tab>

<md-tab label="Crane" md-on-select="demoComponentsController.onSelectTab(demoComponentsController.tab.Loader)">

<div>
Current step: {{demoComponentsController.loader.getCurrentProgressStep()}}
</div>
<div>
<input type="button" value="Next Step" ng-click="demoComponentsController.loader.nextStep()">
</div>
<div>
<label for="loader-pause">Pause</label><input id="loader-pause" type="checkbox"
ng-click="demoComponentsController.loader.pause()" value="{{demoComponentsController.loader.paused}}">
</div>

<md-content flex>
<div class="{{demoComponentsController.loader.paused ? 'animation-pause' : ''}}">
<che-loader-crane che-all-steps="demoComponentsController.loader.getLoadingSteps()"
che-exclude-steps="[demoComponentsController.loader.getLoadingSteps().length-1]"
che-step="{{demoComponentsController.loader.getCurrentProgressStep()}}" che-switch-on-iteration="true">
</che-loader-crane>
</div>
</md-content>

</md-tab>

</md-tabs>

</md-content>
4 changes: 4 additions & 0 deletions dashboard/src/app/demo-components/demo-components.styl
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@

label
min-width 100px

.animation-pause
.che-loader-animation
animation-play-state: paused
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
'use strict';
import {CheAPI} from '../../../components/api/che-api.factory';
import {LoadFactoryService} from './load-factory.service';
import {LoadFactoryService, FactoryLoadingStep} from './load-factory.service';
import {CheNotification} from '../../../components/notification/che-notification.factory';
import {RouteHistory} from '../../../components/routing/route-history.service';
import {CheJsonRpcApi} from '../../../components/api/json-rpc/che-json-rpc-api.factory';
Expand Down Expand Up @@ -127,7 +127,7 @@ export class LoadFactoryController {
} else {
this.loadFactoryService.goToNextStep();
this.$timeout(() => {
this.processFactorySource();
this.processFactorySource();
}, 1500);
}
}, (error: any) => {
Expand Down Expand Up @@ -623,7 +623,7 @@ export class LoadFactoryController {
*
* @returns {any}
*/
getLoadingSteps(): any {
getLoadingSteps(): FactoryLoadingStep[] {
return this.loadFactoryService.getFactoryLoadingSteps();
}

Expand Down
16 changes: 11 additions & 5 deletions dashboard/src/app/factories/load-factory/load-factory.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@
*/
'use strict';

export interface FactoryLoadingStep {
text: string;
logs: string;
hasError: boolean;
inProgressText?: string;
}

/**
* This class is handling the service for the factory loading.
* @author Ann Shumilova
*/
export class LoadFactoryService {
private loadFactoryInProgress: boolean;
private currentProgressStep: number;
private loadingSteps: Array<any>;
private loadingSteps: Array<FactoryLoadingStep>;

/**
* Default constructor that is using resource
Expand All @@ -27,7 +34,6 @@ export class LoadFactoryService {
this.loadFactoryInProgress = false;
this.currentProgressStep = 0;


this.loadingSteps = [
{text: 'Loading factory', inProgressText: '', logs: '', hasError: false},
{text: 'Looking for devfile', inProgressText: '', logs: '', hasError: false},
Expand Down Expand Up @@ -56,9 +62,9 @@ export class LoadFactoryService {
/**
* Returns the information of the factory's loading steps.
*
* @returns {Array<any>} loading steps of the factory
* @returns {Array<FactoryLoadingStep>} loading steps of the factory
*/
getFactoryLoadingSteps(): Array<any> {
getFactoryLoadingSteps(): Array<FactoryLoadingStep> {
return this.loadingSteps;
}

Expand Down Expand Up @@ -91,7 +97,7 @@ export class LoadFactoryService {
* Reset the loading progress.
*/
resetLoadProgress(): void {
this.loadingSteps.forEach((step: any) => {
this.loadingSteps.forEach((step: FactoryLoadingStep) => {
step.logs = '';
step.hasError = false;
});
Expand Down
Loading