Skip to content

Commit

Permalink
feat(interactive-tour): add config + handling error no configtourFile (
Browse files Browse the repository at this point in the history
…#746)

Co-authored-by: Josée Martel <[email protected]>
  • Loading branch information
josee666 and Josée Martel authored Oct 14, 2020
1 parent 78f781a commit eff4335
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
3 changes: 2 additions & 1 deletion demo/src/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export const environment: Environment = {
prefix: './locale/'
},
interactiveTour: {
tourInMobile: true
tourInMobile: true,
activateInteractiveTour: true
},
importExport: {
url: '/apis/ogre',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ export class InteractiveTourLoader {

constructor(private http: HttpClient, private configService: ConfigService) {
this.jsonURL = this.getPathToConfigFile();
this.allToursOptions = this.getJSON().subscribe((data) => {
this.allToursOptions = data;
});
}

public loadConfigTour() {
this.getJSON()
.subscribe(
(data) => {
this.allToursOptions = data;
},
(err) => {
throw new Error('Problem with Interactive tour configuration file: interactiveTour.json not find. Check if the file and is path is set correctly.');
}
);
}

public getPathToConfigFile(): string {
return (
this.configService.getConfig('interactiveTour.pathToConfigFile') ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,20 @@ export class InteractiveTourService {
private languageService: LanguageService,
private interactiveTourLoader: InteractiveTourLoader,
private shepherdService: ShepherdService
) {}
) {
if (this.isAppHaveTour()) {
this.interactiveTourLoader.loadConfigTour();
}
}

public isAppHaveTour() {
const haveTour = this.configService.getConfig('interactiveTour.activateInteractiveTour')
if (haveTour === undefined) {
return true;
} else {
return haveTour;
}
}

public isToolHaveTourConfig(toolName: string): boolean {
const checkTourActiveOptions = this.interactiveTourLoader.getTourOptionData(
Expand Down

0 comments on commit eff4335

Please sign in to comment.