Skip to content

Commit

Permalink
config changes according to domain
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhikachhawa24 committed Jun 17, 2024
1 parent 2b65b00 commit 0442d80
Show file tree
Hide file tree
Showing 25 changed files with 497 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<ion-footer>
<div class="footer_menu">
<ion-label class="sb-menu-item" role="button" menuClose>{{"Version: " | translate}} {{appVersion}}</ion-label>
<ion-label role="button" menuClose><span>{{ configVariables.siteName }}</span></ion-label>
<ion-label role="button" menuClose><span>{{ configVariables?.siteName }}</span></ion-label>
</div>
</ion-footer>
</ion-menu>
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ApplicationHeaderComponent implements OnInit {
defaultFilter!: any;
appVersion: string = ''
appName: string = ""
configVariables = ConfigVariables;
configVariables : any;

constructor(private utilService: UtilService,
private telemetryGeneratorService: TelemetryGeneratorService,
Expand All @@ -33,6 +33,14 @@ export class ApplicationHeaderComponent implements OnInit {
this.appVersion = `v${val.version}.${val.build}`
this.appName = val.name
})

ConfigVariables.then(config => {
console.log('Configuration:', config);
this.configVariables = config;
// Use the config data as needed
}).catch(error => {
console.error('Failed to load configuration:', error);
});
}

async ngOnInit() {
Expand Down
123 changes: 26 additions & 97 deletions src/app/config.ts
Original file line number Diff line number Diff line change
@@ -1,97 +1,26 @@
export const ConfigVariables = {
"tenantLogo": "assets/school/GEMS.svg",
"siteName": "Garhwal English Medium",
"siteByLine": "Listen, Learn & Grow !!!",
"splashImage": "assets/school/GEMS.jpeg",
"headerFilters": [{
"defaultFilter": {
"id": "All",
"label": "All",
"query": "",
"filters": "All"
},
"additionalFilters": [
{
"id": "Stories",
"label": "Stories",
"query": "Stories",
"filters": "Stories"
},
{
"id": "Activities",
"label": "Activities",
"query": "Activities",
"filters": "Activities"
},
{
"id": "Songs",
"label": "Songs",
"query": "Songs",
"filters": "Songs"
},
{
"id": "Audio Books",
"label": "Audio Books",
"query": "Audio Books",
"filters": "Audio Books"
},
{
"id": "Handbooks",
"label": "Handbooks",
"query": "Handbooks",
"filters": "Handbooks"
},
]
}],
"languages": [
{
"id": "en",
"label": "English",
"default": false
},
{
"id": "hi",
"label": "हिंदी",
"default": true
}
],
// "apiEndPoint": "/dsep/search",
// "bookmark": "BookMark",
// "rating": "Rating",
// "share": "Share",
// "pagination": "10",
// "orderBy": "",
// "filterBy": "default",
"footerText": "Developed with ❤️ by Tekdi Technologies ",
"headerColor": "brown",
"headerFontSize": "16",
"footerColor": "brown",
"footerFontSize": "16",
// "positionByLine": "false",
// "positionLogo": "false",
// "positionSiteName": "false",
// "labelTitle": "शीर्षक",
// "labelAuthor": "लेखक",
// "labelDesc": "Desc",
// "labelRating": "Rating",
// "displayOrder": {
// "title": "3",
// "author": "1",
// "description": "2",
// "publisher": "4"
// },
// "filters": {
// "minAge": "",
// "language": "",
// "contentType": ""
// },
// "searchFilters":{
// "age":["1","2","3","4","5","6","7","8","9","10"],
// "language":["English","Hindi","Gujarati","Tamil","Kannada"],
// "type":["Video","Audio","Read","Others"]
// },
// "contentSource":{
// "source":["onest","SB"]
// },
// "logo": "photo-1492144534655-ae79c964c9d71699539070789.avif"
}
// config.ts
const urlObj = new URL(document.baseURI);
const hostname = urlObj.hostname; // e.g., "subdomain.example.com"
const domainParts = hostname.split('.');
console.log(domainParts);
const jsonFilename = domainParts[0] + '.json';
const jsonUrl = `../assets/appConfig/${jsonFilename}`;
// const jsonUrl = `../assets/appConfig/localhost.json`;

console.log(`Fetching configuration from: ${jsonUrl}`);

export const ConfigVariables = fetch(jsonUrl)
.then(response => {
console.log({ response });
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
console.log('Fetched data:', data);
return data; // Return the fetched data so that it can be used by other parts of the application
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error);
});
12 changes: 11 additions & 1 deletion src/app/pages/home/home.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class HomePage implements OnInit, OnTabViewWillEnter, OnDestroy {
networkChangeSub: Subscription | null = null;
selectedLang: any = "";
appName: string = "";
configVariables = ConfigVariables;
configVariables : any;
responseList: Array<any> = [];
constructor(
private headerService: AppHeaderService,
Expand All @@ -70,6 +70,15 @@ export class HomePage implements OnInit, OnTabViewWillEnter, OnDestroy {
private lcoalNotifService: LocalNotificationService,
private appUpdateService: AppUpdateService,
private confirmService: ConfirmService) {

ConfigVariables.then(config => {
console.log('Configuration:', config);
this.configVariables = config;
// Use the config data as needed
}).catch(error => {
console.error('Failed to load configuration:', error);
});

App.getInfo().then(info => {this.appName = info.name});
this.configContents = [];
this.contentList = [];
Expand Down Expand Up @@ -116,6 +125,7 @@ export class HomePage implements OnInit, OnTabViewWillEnter, OnDestroy {
}

async ngOnInit(): Promise<void> {

this.headerService.headerEventEmitted$.subscribe(async (val) => {
if(val == 'language') {
let lang = await this.storage.getData('lang');
Expand Down
6 changes: 3 additions & 3 deletions src/app/pages/splash/splash.page.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<ion-content [fullscreen]="true" class="splash-screen">
<div class="splash-screen_box">
<img [src]=(configVariables.splashImage) alt="Pitara box" class="pitara-box">
<img [src]=(configVariables?.splashImage) alt="Pitara box" class="pitara-box">
</div>
<div class="footer-img">
<h3>{{configVariables.siteName}}</h3>
<h3>{{configVariables?.siteName}}</h3>
</div>
</ion-content>
</ion-content>
10 changes: 9 additions & 1 deletion src/app/pages/splash/splash.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ConfigVariables } from "../../config";
styleUrls: ['splash.page.scss'],
})
export class SplashPage implements OnInit {
configVariables = ConfigVariables;
configVariables : any;
constructor(private appinitialise: AppInitializeService,
private storage: StorageService,
private router: Router,
Expand All @@ -33,6 +33,14 @@ export class SplashPage implements OnInit {
}

async ngOnInit() {
ConfigVariables.then(config => {
console.log('Configuration:', config);
this.configVariables = config;
// Use the config data as needed
}).catch(error => {
console.error('Failed to load configuration:', error);
});

this.headerService.showStatusBar(true);
this.headerService.hideHeader();
ApiModule.getInstance().init(await this.utilService.getDeviceId())
Expand Down
4 changes: 2 additions & 2 deletions src/app/tabs/tabs.page.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<ion-content>
<ion-tabs #tabRef (ionTabsDidChange)="ionTabsDidChange($event)">
<ion-tab-button tab="home" href="/tabs/home" class="home-screen" style="--background: {{configVariables.footerColor}}">
<ion-tab-button tab="home" href="/tabs/home" class="home-screen" style="--background: {{configVariables?.footerColor}}">
<ion-icon aria-hidden="true" src="assets/icon/home.svg"></ion-icon>
</ion-tab-button>

<ion-tab-bar slot="bottom" class="tabbar" style="--background: {{configVariables.footerColor}}">
<ion-tab-bar slot="bottom" class="tabbar" style="--background: {{configVariables?.footerColor}}">

<ion-tab-button tab="story" href="">
<ion-icon aria-hidden="true" src="assets/icon/book.svg"></ion-icon>
Expand Down
9 changes: 8 additions & 1 deletion src/app/tabs/tabs.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,20 @@ import { ConfigVariables } from "../config";
export class TabsPage implements OnTabViewWillEnter{
subscription: any;
optModalOpen = false;
configVariables = ConfigVariables;
configVariables: any;
@ViewChild('tabRef', { static: false }) tabRef!: IonTabs;
constructor(private platform: Platform,
private router: Router,
private tabService: TabsService,
private telemetry: TelemetryGeneratorService,
private modalCtrl: ModalController) {
ConfigVariables.then(config => {
console.log('Configuration:', config);
this.configVariables = config;
// Use the config data as needed
}).catch(error => {
console.error('Failed to load configuration:', error);
});
}

tabViewWillEnter(): void {
Expand Down
63 changes: 63 additions & 0 deletions src/assets/appConfig/garhwal-school.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{
"tenantLogo": "assets/school/GEMS.svg",
"siteName": "Garhwal English Medium",
"siteByLine": "Listen, Learn & Grow !!!",
"splashImage": "assets/school/GEMS.jpeg",
"headerFilters": [{
"defaultFilter": {
"id": "All",
"label": "All",
"query": "",
"filters": "All"
},
"additionalFilters": [
{
"id": "Stories",
"label": "Stories",
"query": "Stories",
"filters": "Stories"
},
{
"id": "Activities",
"label": "Activities",
"query": "Activities",
"filters": "Activities"
},
{
"id": "Songs",
"label": "Songs",
"query": "Songs",
"filters": "Songs"
},
{
"id": "Audio Books",
"label": "Audio Books",
"query": "Audio Books",
"filters": "Audio Books"
},
{
"id": "Handbooks",
"label": "Handbooks",
"query": "Handbooks",
"filters": "Handbooks"
}
]
}],
"languages": [
{
"id": "en",
"label": "English",
"default": false
},
{
"id": "hi",
"label": "हिंदी",
"default": true
}
],
"footerText": "Developed with ❤️ by Tekdi Technologies ",
"headerColor": "brown",
"headerFontSize": "16",
"footerColor": "brown",
"footerFontSize": "16"
}
Loading

0 comments on commit 0442d80

Please sign in to comment.