Commit 09a9899a by sawit

set localStorage companyId

parent e63279f3
......@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
import { Observable, of } from 'rxjs';
import { DatasetModel } from '../models/widgets.model';
import { HttpClient } from '@angular/common/http';
import { TokenService } from '../../../shared/services/token.service';
@Injectable({
providedIn: 'root'
......@@ -22,14 +23,16 @@ export class DatasetService {
// ];
constructor(private http: HttpClient) { }
constructor(private http: HttpClient, private tokenService: TokenService) { }
getDatasets(): Observable<DatasetModel[]> {
return this.http.get<DatasetModel[]>('https://portal.myhr.co.th/api/template-file/menuitem/mini/lists?companyid=DEMO');
const companyId = this.tokenService.getSelectCompany().companyId || "MYSKILX_UAT";
return this.http.get<DatasetModel[]>(`https://portal.myhr.co.th/api/template-file/menuitem/mini/lists?companyid=${companyId}`);
}
getDatasetByTemplate(templateId : string , fileName : string): Observable<any> {
// return this.http.get<DatasetModel>(`https://portal.myhr.co.th/api/template-file/dataset/${id}`);
return this.http.get<any>(`https://portal.myhr.co.th/api/template-file/dataset/${templateId}/${fileName}?companyid=DEMO`)
const companyId = this.tokenService.getSelectCompany().companyId || "MYSKILX_UAT";
return this.http.get<any>(`https://portal.myhr.co.th/api/template-file/dataset/${templateId}/${fileName}?companyid=${companyId}`)
}
}
......@@ -23,7 +23,7 @@ export class MMenuitemsWidgetService {
* @returns An Observable of MenuItemsWidget[] that are linked to the given datasetId.
*/
getWidgetsForDataset(datasetId: string): Observable<MenuItemsWidget[]> {
const companyId = this.tokenService.getSelectCompany().companyId || "DEMO"; // Get companyId from TokenService
const companyId = this.tokenService.getSelectCompany().companyId || "MYSKILX_UAT"; // Get companyId from TokenService
// Assuming the backend /search endpoint supports filtering by datasetId and companyId
return this.http.get<any[]>(`${this.baseUrl}/lists/search`, { params: { companyId : companyId , itemId : datasetId } }).pipe(
map(items => items.map(item => new MenuItemsWidget(item))),
......
......@@ -270,7 +270,7 @@ export class DatasetWidgetLinkerComponent implements OnInit {
dialogRef.afterClosed().subscribe(resultConfig => {
if (resultConfig) {
const newLinkedWidget: MenuItemsWidget = {
companyId: 'DEMO', itemId: this.selectedDatasetId!, widget: widget,
companyId: 'MYSKILX_UAT', itemId: this.selectedDatasetId!, widget: widget,
config: JSON.stringify(resultConfig), data: '', perspective: ''
};
this.mMenuitemsWidgetService.saveLinkedWidget(newLinkedWidget).subscribe(() => {
......
......@@ -4,23 +4,28 @@ import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs';
import { environment } from '../../../environments/environment';
import { AlertModel } from '../models/alert.model';
import { TokenService } from '../../shared/services/token.service';
@Injectable({
providedIn: 'root'
})
export class CustomCubeService {
constructor(private http: HttpClient,
private translateService: TranslateService
private translateService: TranslateService,
private tokenService: TokenService
) { }
getExcelColumn(body: {
templateId: string,
fileName: string,
}) {
return this.http.post(environment.url + "customcube/get-excel-column?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47", body)
const companyId = this.tokenService.getSelectCompany()?.companyId;
return this.http.post(environment.url + `customcube/get-excel-column?companyid=${companyId}`, body)
}
getExcelData(body: any) {
return this.http.post(environment.url + "customcube/get-excel-data?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47", body)
const companyId = this.tokenService.getSelectCompany()?.companyId;
return this.http.post(environment.url + `customcube/get-excel-data?companyid=${companyId}`, body)
}
saveExcelPerspective(body: {
templateId: string,
......@@ -28,12 +33,14 @@ export class CustomCubeService {
dataGridStr: string,
pivotStr: string,
}): Observable<AlertModel> {
return this.http.post<AlertModel>(environment.url + "customcube/save-excel-perspective?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47", body)
const companyId = this.tokenService.getSelectCompany()?.companyId;
return this.http.post<AlertModel>(environment.url + `customcube/save-excel-perspective?companyid=${companyId}`, body)
}
getExcelPerspective(body: {
templateId: string,
fileName: string,
}) {
return this.http.post(environment.url + "customcube/get-excel-perspective?companyid=eb2f4f30-edaf-11ee-a69a-c7680edc0e47", body)
const companyId = this.tokenService.getSelectCompany()?.companyId;
return this.http.post(environment.url + `customcube/get-excel-perspective?companyid=${companyId}`, body)
}
}
\ No newline at end of file
......@@ -31,6 +31,87 @@ export class TokenService {
"myjob": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJBdXRoIiwidWlkIjoiOGFhNDUzMzAtMzE0Yy0xMWU3LWJhZjMtMmQ3ZDA5ODc3NzQ0Iiwicm9sZXMiOlsiYWRtaW4iXSwiaXNzIjoiQ29tcHV0ZXIgU2NpZW5jZSBDb3Jwb3JhdGlvbiBMaW1pdGVkIiwidXNlcm5hbWUiOiJhZG1pbiJ9.Um39_CTM01n1g4XpFyuAa3VPxOozNPnJ0mu7kxU6KUs",
"myskill-x": "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJBdXRoIiwidWlkIjoiOGFhNDUzMzAtMzE0Yy0xMWU3LWJhZjMtMmQ3ZDA5ODc3NzQ0Iiwicm9sZXMiOlsiYWRtaW4iXSwiaXNzIjoiQ29tcHV0ZXIgU2NpZW5jZSBDb3Jwb3JhdGlvbiBMaW1pdGVkIiwidXNlcm5hbWUiOiJhZG1pbiJ9.Um39_CTM01n1g4XpFyuAa3VPxOozNPnJ0mu7kxU6KUs",
}
dbApp: any = {
"myhr-plus": {
"companyId": "DEMO",
"companyName": "DEMO",
"serverName": "192.168.30.150",
"databaseName": "DEMOCUS",
"portNumber": "5432",
"userName": "myhradmin",
"password": "systemadmin",
"status": "online",
"dbType": "PGSQL"
},
"myhr-lite": {
"companyId": "",
"companyName": "",
"serverName": "",
"databaseName": "",
"portNumber": "",
"userName": "",
"password": "",
"status": "",
"dbType": ""
},
"zeeme": {
"companyId": "",
"companyName": "",
"serverName": "",
"databaseName": "",
"portNumber": "",
"userName": "",
"password": "",
"status": "",
"dbType": ""
},
"myface": {
"companyId": "",
"companyName": "",
"serverName": "",
"databaseName": "",
"portNumber": "",
"userName": "",
"password": "",
"status": "",
"dbType": ""
},
"mylearn": {
"companyId": "",
"companyName": "",
"serverName": "",
"databaseName": "",
"portNumber": "",
"userName": "",
"password": "",
"status": "",
"dbType": ""
},
"myjob": {
"companyId": "DEMO",
"companyName": "DEMO",
"databaseName": "DEMOCUS",
"dbType": "PGSQL",
"password": "systemadmin",
"portNumber": "5432",
"serverName": "192.168.30.150",
"status": "online",
"userName": "myhradmin"
},
"myskill-x": {
"companyId": "MYSKILX_UAT",
"companyName": "MYSKILX_UAT",
"databaseName": "MYSKILL_X_UAT",
"dbType": "PGSQL",
"password": "systemadmin",
"portNumber": "5432",
"serverName": "10.204.50.30",
"status": "online",
"userName": "myhradmin"
},
}
constructor(private router: Router) { }
signOut(): void {
......@@ -123,6 +204,10 @@ export class TokenService {
// window.localStorage.setItem(APP_TOKEN_KEY, tokenkey);
window.sessionStorage.removeItem(APP_TOKEN_KEY);
window.sessionStorage.setItem(APP_TOKEN_KEY, tokenkey);
let db = this.dbApp[module]
window.localStorage.removeItem(COMPANY);
window.localStorage.setItem(COMPANY, JSON.stringify(new CompanyModel(db)));
}
public getAppToken(): string | null {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment