@noatgnu/cupcake-core 1.2.12 → 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');
|
|
@@ -1277,14 +1289,23 @@ class SiteConfigService extends BaseApiService {
|
|
|
1277
1289
|
}
|
|
1278
1290
|
});
|
|
1279
1291
|
}
|
|
1292
|
+
refreshConfig() {
|
|
1293
|
+
this.loadConfig();
|
|
1294
|
+
}
|
|
1280
1295
|
fetchConfigFromBackend() {
|
|
1281
1296
|
return this.get(`${this.apiUrl}/site-config/public/`);
|
|
1282
1297
|
}
|
|
1283
1298
|
getCurrentConfig() {
|
|
1284
|
-
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
|
+
}));
|
|
1285
1303
|
}
|
|
1286
1304
|
updateConfig(config) {
|
|
1287
|
-
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
|
+
}));
|
|
1288
1309
|
}
|
|
1289
1310
|
getSiteName() {
|
|
1290
1311
|
return this.configSubject.value.siteName;
|
|
@@ -2081,10 +2102,32 @@ class LoginComponent {
|
|
|
2081
2102
|
});
|
|
2082
2103
|
this.authService.isAuthenticated$.subscribe(isAuthenticated => {
|
|
2083
2104
|
if (isAuthenticated) {
|
|
2084
|
-
this.
|
|
2105
|
+
this.navigateToReturnUrl();
|
|
2085
2106
|
}
|
|
2086
2107
|
});
|
|
2087
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
|
+
}
|
|
2088
2131
|
/**
|
|
2089
2132
|
* Clean return URL to prevent accumulating login URLs
|
|
2090
2133
|
*/
|
|
@@ -2152,7 +2195,7 @@ class LoginComponent {
|
|
|
2152
2195
|
next: (response) => {
|
|
2153
2196
|
this.success.set('Login successful!');
|
|
2154
2197
|
setTimeout(() => {
|
|
2155
|
-
this.
|
|
2198
|
+
this.navigateToReturnUrl();
|
|
2156
2199
|
}, 1000);
|
|
2157
2200
|
},
|
|
2158
2201
|
error: (error) => {
|
|
@@ -2196,7 +2239,7 @@ class LoginComponent {
|
|
|
2196
2239
|
next: (response) => {
|
|
2197
2240
|
this.success.set(`Welcome, ${response.user.firstName || response.user.username}!`);
|
|
2198
2241
|
setTimeout(() => {
|
|
2199
|
-
this.
|
|
2242
|
+
this.navigateToReturnUrl();
|
|
2200
2243
|
}, 1000);
|
|
2201
2244
|
},
|
|
2202
2245
|
error: (error) => {
|