dashboard

This commit is contained in:
string 2025-10-25 14:43:42 +05:30
parent f60657ca64
commit 6c01e71d04
12 changed files with 163 additions and 79 deletions

View File

@ -23,6 +23,20 @@ export interface DashboardContentModel {
component?: any;
name: string;
type?:string;
// Common properties
table?: string;
connection?: string;
baseFilters?: any[];
// Common filter properties
commonFilterEnabled?: boolean;
// Drilldown properties
drilldownEnabled?: boolean;
drilldownApiUrl?: string;
drilldownXAxis?: string;
drilldownYAxis?: string;
drilldownParameter?: string;
drilldownFilters?: any[];
drilldownLayers?: any[];
}
export interface DashboardModel {
@ -67,6 +81,10 @@ export class value1{
export const WidgetsMock: WidgetModel[] = [
{
name: 'Common Filter',
identifier: 'common_filter'
},
{
name: 'Radar Chart',
identifier: 'radar_chart'
@ -111,4 +129,4 @@ export const WidgetsMock: WidgetModel[] = [
name: 'To Do',
identifier: 'to_do_chart'
}
]
]

View File

@ -97,6 +97,7 @@ export class LoginPageComponent implements OnInit {
.subscribe(
resp => {
console.log('API Response received:', resp);
// Always reset loading state when response is received
this.isLoading = false;
// Handle different response formats
@ -106,7 +107,7 @@ export class LoginPageComponent implements OnInit {
return;
}
// Handle different response formats
if (resp.success === 'false') {
if (resp.success === 'false' || resp.success === false) {
this.isError = true;
this.errMsg = resp.message || 'Login failed';
return;
@ -123,6 +124,7 @@ export class LoginPageComponent implements OnInit {
},
(errResponse: HttpErrorResponse) => {
console.log('API Error received:', errResponse);
// Always reset loading state when error occurs
this.isLoading = false;
this.isError = true;
@ -167,4 +169,4 @@ export class LoginPageComponent implements OnInit {
this.showPassword = !this.showPassword;
}
}
}

View File

@ -1,20 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>gaurav</title>
</head>
<body>
<h1>this is h1</h1>
<h2>this is h1</h2>
<h3>this is h1</h3>
<h4>this is h1</h4>
<p>Lorem ipsum, dolor sit amet consectetur adipisicing elit. Ipsa fuga, asperiores mollitia iste vitae repellendus adipisci atque eum corrupti ad placeat unde voluptatum quia perferendis neque expedita, sequi iure quo. Ut error adipisci ex cum sint, suscipit, voluptatem repellat nemo dolorum unde dolores quasi aut. A earum quo mollitia voluptatibus!</p>
</body>
</html>

View File

@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Component, OnInit, OnDestroy, Input } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { Subscription } from 'rxjs';
import { Filter, FilterService, FilterType } from './filter.service';
@ -9,6 +9,12 @@ import { Filter, FilterService, FilterType } from './filter.service';
styleUrls: ['./common-filter.component.scss']
})
export class CommonFilterComponent implements OnInit, OnDestroy {
@Input() baseFilters: any[] = [];
@Input() drilldownFilters: any[] = [];
@Input() drilldownLayers: any[] = [];
@Input() fieldName: string;
@Input() connection: number;
filters: Filter[] = [];
filterForm: FormGroup;
presets: string[] = [];
@ -102,7 +108,15 @@ export class CommonFilterComponent implements OnInit, OnDestroy {
// Handle filter value changes
onFilterChange(filterId: string, value: any): void {
console.log('=== COMMON FILTER DEBUG INFO ===');
console.log('Filter value changed for ID:', filterId);
console.log('New value:', value);
const filterDef = this.filters.find(f => f.id === filterId);
console.log('Filter definition:', filterDef);
this.filterService.updateFilterValue(filterId, value);
console.log('=== END COMMON FILTER DEBUG ===');
}
// Handle multiselect changes

View File

@ -62,11 +62,19 @@ export class FilterService {
// Update filter value
updateFilterValue(filterId: string, value: any): void {
console.log('=== FILTER SERVICE DEBUG INFO ===');
console.log('Updating filter value for ID:', filterId);
console.log('New value:', value);
const currentState = this.filterStateSubject.value;
this.filterStateSubject.next({
const newState = {
...currentState,
[filterId]: value
});
};
console.log('New filter state:', newState);
this.filterStateSubject.next(newState);
console.log('=== END FILTER SERVICE DEBUG ===');
}
// Get current filter values

View File

@ -798,6 +798,15 @@ export class EditnewdashComponent implements OnInit {
drilldownLayers: item['drilldownLayers'] || []
};
// For CommonFilterComponent, also pass baseFilters, drilldownFilters, drilldownLayers, fieldName, and connection
if (item.component && item.component.name === 'CommonFilterComponent') {
chartInputs['baseFilters'] = item['baseFilters'] || [];
chartInputs['drilldownFilters'] = item['drilldownFilters'] || [];
chartInputs['drilldownLayers'] = item['drilldownLayers'] || [];
chartInputs['fieldName'] = item['name'] || '';
chartInputs['connection'] = item['connection'] || undefined;
}
// Remove undefined properties to avoid passing unnecessary data
Object.keys(chartInputs).forEach(key => {
if (chartInputs[key] === undefined) {

View File

@ -122,10 +122,15 @@ export class BarChartComponent implements OnInit, OnChanges, OnDestroy {
// If we have the necessary data, fetch chart data from the service
if (this.table && this.xAxis && this.yAxis) {
console.log('Fetching bar chart data for:', { table: this.table, xAxis: this.xAxis, yAxis: this.yAxis, connection: this.connection });
console.log('=== BAR CHART DEBUG INFO ===');
console.log('Table:', this.table);
console.log('X-Axis:', this.xAxis);
console.log('Y-Axis:', this.yAxis);
console.log('Connection:', this.connection);
// Convert yAxis to string if it's an array
const yAxisString = Array.isArray(this.yAxis) ? this.yAxis.join(',') : this.yAxis;
console.log('Y-Axis String:', yAxisString);
// Get the parameter value from the drilldown stack for base level (should be empty)
let parameterValue = '';
@ -147,10 +152,14 @@ export class BarChartComponent implements OnInit, OnChanges, OnDestroy {
filterParams = JSON.stringify(filterObj);
}
}
console.log('Base filters:', this.baseFilters);
console.log('Base filter params:', filterParams);
// Add common filters to filter parameters
const commonFilters = this.filterService.getFilterValues();
const filterDefinitions = this.filterService.getFilters();
console.log('Common filters from service:', commonFilters);
console.log('Filter definitions:', filterDefinitions);
if (Object.keys(commonFilters).length > 0) {
// Merge common filters with base filters
@ -169,17 +178,25 @@ export class BarChartComponent implements OnInit, OnChanges, OnDestroy {
// Add common filters using the field name as the key, not the filter id
Object.keys(commonFilters).forEach(filterId => {
const filterValue = commonFilters[filterId];
console.log(`Processing filter ID: ${filterId}, Value:`, filterValue);
// Find the filter definition to get the field name
const filterDef = this.filterService.getFilters().find(f => f.id === filterId);
console.log(`Filter definition for ${filterId}:`, filterDef);
if (filterDef && filterDef.field) {
const fieldName = filterDef.field;
console.log(`Mapping filter ID ${filterId} to field name: ${fieldName}`);
if (filterValue !== undefined && filterValue !== null && filterValue !== '') {
mergedFilterObj[fieldName] = filterValue;
console.log(`Added to merged filters: ${fieldName} =`, filterValue);
}
} else {
// Fallback to using filterId as field name if no field is defined
console.log(`No field name found for filter ID ${filterId}, using ID as field name`);
if (filterValue !== undefined && filterValue !== null && filterValue !== '') {
mergedFilterObj[filterId] = filterValue;
console.log(`Added to merged filters: ${filterId} =`, filterValue);
}
}
});
@ -189,11 +206,12 @@ export class BarChartComponent implements OnInit, OnChanges, OnDestroy {
}
}
console.log('Final filter parameters:', filterParams);
console.log('Final merged filter object:', filterParams);
// Fetch data from the dashboard service with parameter field and value
// For base level, we pass empty parameter and value, but now also pass filters
const subscription = this.dashboardService.getChartData(this.table, 'bar', this.xAxis, yAxisString, this.connection, '', '', filterParams).subscribe(
(data: any) => {
console.log('=== BAR CHART DATA RESPONSE ===');
console.log('Received bar chart data:', data);
if (data === null) {
console.warn('Bar chart API returned null data. Check if the API endpoint is working correctly.');
@ -214,6 +232,7 @@ export class BarChartComponent implements OnInit, OnChanges, OnDestroy {
// Trigger change detection
// this.barChartData = [...this.barChartData];
console.log('Updated bar chart with data:', { labels: this.barChartLabels, data: this.barChartData });
console.log('=== CHART UPDATED SUCCESSFULLY ===');
} else if (data && data.labels && data.datasets) {
// Backend has already filtered the data, just display it
this.noDataAvailable = data.labels.length === 0;
@ -222,6 +241,7 @@ export class BarChartComponent implements OnInit, OnChanges, OnDestroy {
// Trigger change detection
// this.barChartData = [...this.barChartData];
console.log('Updated bar chart with legacy data format:', { labels: this.barChartLabels, data: this.barChartData });
console.log('=== CHART UPDATED SUCCESSFULLY (LEGACY) ===');
} else {
console.warn('Bar chart received data does not have expected structure', data);
this.noDataAvailable = true;
@ -232,6 +252,7 @@ export class BarChartComponent implements OnInit, OnChanges, OnDestroy {
this.isFetchingData = false;
},
(error) => {
console.error('=== BAR CHART ERROR ===');
console.error('Error fetching bar chart data:', error);
this.noDataAvailable = true;
this.barChartLabels = [];

View File

@ -1,7 +1,7 @@
import { Injectable } from '@angular/core';
import { Router } from '@angular/router';
import { Observable, BehaviorSubject } from 'rxjs';
import { Observable, BehaviorSubject, Subject } from 'rxjs';
import { UserInfoService, LoginInfoInStorage} from '../user-info.service';
import { ApiRequestService } from './api-request.service';
import { HttpClient } from '@angular/common/http';
@ -43,63 +43,70 @@ export class LoginService {
*/
let loginDataSubject:BehaviorSubject<any> = new BehaviorSubject<any>([]); // Will use this BehaviorSubject to emit data that we want after ajax login attempt
// let loginDataSubject:BehaviorSubject<any> = new BehaviorSubject<any>([]); // Will use this BehaviorSubject to emit data that we want after ajax login attempt
let loginDataSubject: Subject<any> = new Subject<any>();
let loginInfoReturn:LoginInfoInStorage; // Object that we want to send back to Login Page
this.apiRequest.loginAuthentication('token/session', bodyData)
.subscribe(jsonResp => {
console.log('login response in service : ', jsonResp);
if (jsonResp.operationMessage=='Login Failed') {
this.toastr.warning('Not Login Getting Error check your Username and password');
}
if (jsonResp !== undefined && jsonResp !== null && jsonResp.operationStatus === "SUCCESS"){
//Create a success object that we want to send back to login page
////"displayName": jsonResp.item.fullname,
//"username" : jsonResp.item.username,
loginInfoReturn = {
"success" : true,
"message" : jsonResp.operationMessage,
"landingPage": this.landingPage,
"user" : {
"userId" : jsonResp.item.userId,
"email" : jsonResp.item.email,
"displayName": jsonResp.item.firstName,
"username" : jsonResp.item.username,
"roles" : jsonResp.item.roles,
"token" : jsonResp.item.token,
},
};
console.log(loginInfoReturn.user);
if(jsonResp !== undefined && jsonResp !== null && jsonResp.operationStatus === "SUCCESS"){
this.toastr.success(`Welcome To home Page!! your Role is ${jsonResp.item.roles}`);
.subscribe({
next: (jsonResp) => {
console.log('login response in service : ', jsonResp);
if (jsonResp.operationMessage=='Login Failed') {
this.toastr.warning('Not Login Getting Error check your Username and password');
}
// store username and jwt token in session storage to keep user logged in between page refreshes
this.userInfoService.storeUserInfo(JSON.stringify(loginInfoReturn.user));
}
else {
//Create a faliure object that we want to send back to login page
if (jsonResp !== undefined && jsonResp !== null && jsonResp.operationStatus === "SUCCESS"){
//Create a success object that we want to send back to login page
////"displayName": jsonResp.item.fullname,
//"username" : jsonResp.item.username,
loginInfoReturn = {
"success" : true,
"message" : jsonResp.operationMessage,
"landingPage": this.landingPage,
"user" : {
"userId" : jsonResp.item.userId,
"email" : jsonResp.item.email,
"displayName": jsonResp.item.firstName,
"username" : jsonResp.item.username,
"roles" : jsonResp.item.roles,
"token" : jsonResp.item.token,
},
};
console.log(loginInfoReturn.user);
if(jsonResp !== undefined && jsonResp !== null && jsonResp.operationStatus === "SUCCESS"){
this.toastr.success(`Welcome To home Page!! your Role is ${jsonResp.item.roles}`);
}
// store username and jwt token in session storage to keep user logged in between page refreshes
this.userInfoService.storeUserInfo(JSON.stringify(loginInfoReturn.user));
}
else {
//Create a failure object that we want to send back to login page
loginInfoReturn = {
"success":false,
"message":jsonResp.operationMessage,
"landingPage":"/login"
};
}
loginDataSubject.next(loginInfoReturn);
loginDataSubject.complete(); // Complete the subject
},
error: (err) => {
console.log('login error ', err);
loginInfoReturn = {
"success":false,
"message":jsonResp.operationMessage,
"landingPage":"/login"
"success": false,
"message": err.url + " >>> " + err.statusText + "[" + err.status +"]",
"landingPage": "/login"
};
if (err) {
this.toastr.error('Getting Server Error');
}
loginDataSubject.next(loginInfoReturn); // Send the error response
loginDataSubject.complete(); // Complete the subject
}
loginDataSubject.next(loginInfoReturn);
},
err => {
console.log('login error ', err);
loginInfoReturn = {
"success": false,
"message": err.url + " >>> " + err.statusText + "[" + err.status +"]",
"landingPage": "/login"
};
if (err) {
this.toastr.error('Getting Server Error');
}
});
return loginDataSubject;
return loginDataSubject;
}
logout(navigatetoLogout=true): void {

View File

@ -281,7 +281,7 @@ export class Dashboard3Service {
return this.apiRequest.get(`Dashboard/Dashboard`);
}
public getChartData(tableName: string, jobType: string, xAxis?: any, yAxes?: any, sureId?: number, parameter?: string, parameterValue?: string): Observable<any> {
public getChartData(tableName: string, jobType: string, xAxis?: any, yAxes?: any, sureId?: number, parameter?: string, parameterValue?: string, filters?: string): Observable<any> {
let url = `${baseUrl}/chart/getdashjson/${jobType}?tableName=${tableName}&xAxis=${xAxis}&yAxes=${yAxes}`;
if (sureId) {
url += `&sureId=${sureId}`;
@ -292,8 +292,27 @@ export class Dashboard3Service {
if (parameterValue) {
url += `&parameterValue=${encodeURIComponent(parameterValue)}`;
}
console.log('=== DASHBOARD SERVICE DEBUG INFO ===');
console.log('Base URL:', url);
console.log('Filters parameter:', filters);
// Parse filters JSON and add as a single "filters" parameter
if (filters) {
try {
const filterObj = JSON.parse(filters);
console.log('Parsed filter object:', filterObj);
// Add all filters as a single "filters" parameter with JSON object
url += `&filters=${encodeURIComponent(JSON.stringify(filterObj))}`;
console.log('Added filters parameter:', JSON.stringify(filterObj));
} catch (e) {
console.warn('Failed to parse filter parameters:', e);
}
}
console.log('Final constructed URL:', url);
console.log('=== END DASHBOARD SERVICE DEBUG ===');
return this._http.get(url);
}

View File

@ -372,5 +372,9 @@
"select_Field2": "select_Field2",
"Password_Field": "Password_Field",
"age": "age",
"Button_Field": "Button_Field"
"Button_Field": "Button_Field",
"API_REGISTERY": "API Registry",
"API_REGISTERY_DESCRIPTION": "API Registry Description",
"TOKEN_REGISTERY": "Token Registry",
"TOKEN_REGISTERY_DESCRIPTION": "Token Registry Description"
}

View File

@ -105,6 +105,8 @@
"REPORT_DESCRIPTION": "रिपोर्ट विवरण",
"API_REGISTERY": "एपीआई रजिस्ट्री",
"API_REGISTERY_DESCRIPTION": "एपीआई रजिस्ट्री विवरण",
"TOKEN_REGISTERY": "टोकन रजिस्ट्री",
"TOKEN_REGISTERY_DESCRIPTION": "टोकन रजिस्ट्री विवरण",
"ACTIVE": "सक्रिय",
"FOLDER_NAME": "फ़ोल्डर नाम",
"ACTION": "क्रिया",