@@ -22,21 +22,28 @@ export class DatasetService {
2222
2323 constructor ( ) {
2424 // Refresh dataset count only when the organization ID changes
25- this . _userService . currentOrganizationId$ . pipe (
26- tap ( ( orgId ) => {
27- this . orgId = orgId
28- this . list ( this . orgId )
29- this . countDatasets ( this . orgId )
30- } ) ,
31- ) . subscribe ( )
25+ this . _userService . currentOrganizationId$
26+ . pipe (
27+ tap ( ( orgId ) => {
28+ this . orgId = orgId
29+ this . list ( this . orgId )
30+ this . countDatasets ( this . orgId )
31+ } ) ,
32+ )
33+ . subscribe ( )
3234 }
3335
3436 list ( organizationId : number ) {
3537 const url = `/api/v3/datasets/?organization_id=${ organizationId } `
36- this . _httpClient . get < ListDatasetsResponse > ( url ) . pipe (
37- map ( ( { datasets } ) => datasets ) ,
38- tap ( ( datasets ) => { this . _datasets . next ( datasets ) } ) ,
39- ) . subscribe ( )
38+ this . _httpClient
39+ . get < ListDatasetsResponse > ( url )
40+ . pipe (
41+ map ( ( { datasets } ) => datasets ) ,
42+ tap ( ( datasets ) => {
43+ this . _datasets . next ( datasets )
44+ } ) ,
45+ )
46+ . subscribe ( )
4047 }
4148
4249 get ( orgId : number , datasetId : number ) : Observable < Dataset > {
@@ -52,7 +59,9 @@ export class DatasetService {
5259 create ( orgId : number , name : string ) : Observable < Dataset > {
5360 const url = `/api/v3/datasets/?organization_id=${ orgId } `
5461 return this . _httpClient . post < Dataset > ( url , { name } ) . pipe (
55- tap ( ( response ) => { console . log ( 'temp' , response ) } ) ,
62+ tap ( ( response ) => {
63+ console . log ( 'temp' , response )
64+ } ) ,
5665 tap ( ( ) => {
5766 this . countDatasets ( orgId )
5867 this . list ( orgId )
@@ -67,7 +76,9 @@ export class DatasetService {
6776 update ( orgId : number , datasetId : number , name : string ) : Observable < Dataset > {
6877 const url = `/api/v3/datasets/${ datasetId } /?organization_id=${ orgId } `
6978 return this . _httpClient . put < Dataset > ( url , { dataset : name } ) . pipe (
70- tap ( ( response ) => { console . log ( 'temp' , response ) } ) ,
79+ tap ( ( response ) => {
80+ console . log ( 'temp' , response )
81+ } ) ,
7182 tap ( ( ) => {
7283 this . countDatasets ( orgId )
7384 this . list ( orgId )
@@ -94,19 +105,26 @@ export class DatasetService {
94105 }
95106
96107 countDatasets ( orgId : number ) {
97- this . _httpClient . get < CountDatasetsResponse > ( `/api/v3/datasets/count/?organization_id=${ orgId } ` ) . pipe (
98- map ( ( { datasets_count } ) => datasets_count ) ,
99- tap ( ( datasetsCount ) => { this . _datasetCount . next ( datasetsCount ) } ) ,
100- catchError ( ( error : HttpErrorResponse ) => {
101- return this . _errorService . handleError ( error , 'Error fetching dataset count' )
102- } ) ,
103- ) . subscribe ( )
108+ this . _httpClient
109+ . get < CountDatasetsResponse > ( `/api/v3/datasets/count/?organization_id=${ orgId } ` )
110+ . pipe (
111+ map ( ( { datasets_count } ) => datasets_count ) ,
112+ tap ( ( datasetsCount ) => {
113+ this . _datasetCount . next ( datasetsCount )
114+ } ) ,
115+ catchError ( ( error : HttpErrorResponse ) => {
116+ return this . _errorService . handleError ( error , 'Error fetching dataset count' )
117+ } ) ,
118+ )
119+ . subscribe ( )
104120 }
105121
106122 deleteFile ( orgId : number , fileId : number ) {
107123 const url = `/api/v3/import_files/${ fileId } /?organization_id=${ orgId } `
108124 return this . _httpClient . delete ( url ) . pipe (
109- tap ( ( ) => { this . _snackBar . success ( 'File deleted successfully' ) } ) ,
125+ tap ( ( ) => {
126+ this . _snackBar . success ( 'File deleted successfully' )
127+ } ) ,
110128 catchError ( ( error : HttpErrorResponse ) => {
111129 return this . _errorService . handleError ( error , 'Error deleting file' )
112130 } ) ,
0 commit comments