@noatgnu/cupcake-core 1.2.13 → 1.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,9 +2,9 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { inject, InjectionToken, Injectable, signal, computed, Component, effect, ChangeDetectorRef, NgModule } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common/http';
|
|
4
4
|
import { HttpClient, HttpParams, provideHttpClient, withInterceptors, HttpClientModule } from '@angular/common/http';
|
|
5
|
-
import { BehaviorSubject, catchError, throwError, switchMap, filter, take, map, tap, Subject, timer, EMPTY, debounceTime, distinctUntilChanged } from 'rxjs';
|
|
5
|
+
import { BehaviorSubject, catchError, throwError, switchMap, filter, take, map, tap, Subject, interval, timer, EMPTY, debounceTime, distinctUntilChanged } from 'rxjs';
|
|
6
6
|
import { Router, ActivatedRoute, RouterModule } from '@angular/router';
|
|
7
|
-
import { map as map$1,
|
|
7
|
+
import { map as map$1, tap as tap$1, takeUntil, switchMap as switchMap$1 } from 'rxjs/operators';
|
|
8
8
|
import * as i1$1 from '@angular/forms';
|
|
9
9
|
import { FormBuilder, Validators, ReactiveFormsModule, FormsModule, NonNullableFormBuilder } from '@angular/forms';
|
|
10
10
|
import * as i2 from '@angular/common';
|
|
@@ -1255,6 +1255,18 @@ class SiteConfigService extends BaseApiService {
|
|
|
1255
1255
|
constructor() {
|
|
1256
1256
|
super();
|
|
1257
1257
|
this.loadConfig();
|
|
1258
|
+
this.startPeriodicRefresh();
|
|
1259
|
+
}
|
|
1260
|
+
startPeriodicRefresh() {
|
|
1261
|
+
interval(60000).subscribe(() => {
|
|
1262
|
+
this.fetchConfigFromBackend().subscribe({
|
|
1263
|
+
next: (config) => {
|
|
1264
|
+
this.configSubject.next({ ...this.defaultConfig, ...config });
|
|
1265
|
+
localStorage.setItem('site_config', JSON.stringify(config));
|
|
1266
|
+
},
|
|
1267
|
+
error: () => { }
|
|
1268
|
+
});
|
|
1269
|
+
});
|
|
1258
1270
|
}
|
|
1259
1271
|
loadConfig() {
|
|
1260
1272
|
const savedConfig = localStorage.getItem('site_config');
|
|
@@ -1284,10 +1296,16 @@ class SiteConfigService extends BaseApiService {
|
|
|
1284
1296
|
return this.get(`${this.apiUrl}/site-config/public/`);
|
|
1285
1297
|
}
|
|
1286
1298
|
getCurrentConfig() {
|
|
1287
|
-
return this.get(`${this.apiUrl}/site-config/current/`)
|
|
1299
|
+
return this.get(`${this.apiUrl}/site-config/current/`).pipe(tap$1(config => {
|
|
1300
|
+
this.configSubject.next({ ...this.defaultConfig, ...config });
|
|
1301
|
+
localStorage.setItem('site_config', JSON.stringify(config));
|
|
1302
|
+
}));
|
|
1288
1303
|
}
|
|
1289
1304
|
updateConfig(config) {
|
|
1290
|
-
return this.put(`${this.apiUrl}/site-config/update_config/`, config)
|
|
1305
|
+
return this.put(`${this.apiUrl}/site-config/update_config/`, config).pipe(tap$1(updatedConfig => {
|
|
1306
|
+
this.configSubject.next({ ...this.defaultConfig, ...updatedConfig });
|
|
1307
|
+
localStorage.setItem('site_config', JSON.stringify(updatedConfig));
|
|
1308
|
+
}));
|
|
1291
1309
|
}
|
|
1292
1310
|
getSiteName() {
|
|
1293
1311
|
return this.configSubject.value.siteName;
|
|
@@ -2084,10 +2102,32 @@ class LoginComponent {
|
|
|
2084
2102
|
});
|
|
2085
2103
|
this.authService.isAuthenticated$.subscribe(isAuthenticated => {
|
|
2086
2104
|
if (isAuthenticated) {
|
|
2087
|
-
this.
|
|
2105
|
+
this.navigateToReturnUrl();
|
|
2088
2106
|
}
|
|
2089
2107
|
});
|
|
2090
2108
|
}
|
|
2109
|
+
/**
|
|
2110
|
+
* Navigate to return URL, properly handling query parameters
|
|
2111
|
+
*/
|
|
2112
|
+
navigateToReturnUrl() {
|
|
2113
|
+
const url = this.returnUrl;
|
|
2114
|
+
if (!url || url === '/') {
|
|
2115
|
+
this.router.navigate(['/']);
|
|
2116
|
+
return;
|
|
2117
|
+
}
|
|
2118
|
+
const [path, queryString] = url.split('?');
|
|
2119
|
+
if (queryString) {
|
|
2120
|
+
const queryParams = {};
|
|
2121
|
+
const params = new URLSearchParams(queryString);
|
|
2122
|
+
params.forEach((value, key) => {
|
|
2123
|
+
queryParams[key] = value;
|
|
2124
|
+
});
|
|
2125
|
+
this.router.navigate([path], { queryParams });
|
|
2126
|
+
}
|
|
2127
|
+
else {
|
|
2128
|
+
this.router.navigate([path]);
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2091
2131
|
/**
|
|
2092
2132
|
* Clean return URL to prevent accumulating login URLs
|
|
2093
2133
|
*/
|
|
@@ -2155,7 +2195,7 @@ class LoginComponent {
|
|
|
2155
2195
|
next: (response) => {
|
|
2156
2196
|
this.success.set('Login successful!');
|
|
2157
2197
|
setTimeout(() => {
|
|
2158
|
-
this.
|
|
2198
|
+
this.navigateToReturnUrl();
|
|
2159
2199
|
}, 1000);
|
|
2160
2200
|
},
|
|
2161
2201
|
error: (error) => {
|
|
@@ -2199,7 +2239,7 @@ class LoginComponent {
|
|
|
2199
2239
|
next: (response) => {
|
|
2200
2240
|
this.success.set(`Welcome, ${response.user.firstName || response.user.username}!`);
|
|
2201
2241
|
setTimeout(() => {
|
|
2202
|
-
this.
|
|
2242
|
+
this.navigateToReturnUrl();
|
|
2203
2243
|
}, 1000);
|
|
2204
2244
|
},
|
|
2205
2245
|
error: (error) => {
|