inviton-powerduck 0.0.173 → 0.0.175

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.
@@ -4,6 +4,7 @@ import type { IPowerduckSystemResources } from './powerduck-system-resources';
4
4
  import jquery from 'jquery';
5
5
  import moment from 'moment';
6
6
  import select2 from 'select2';
7
+ import StorageProvider from '../common/local-storage-shim';
7
8
  import { isNullOrEmpty } from '../common/utils/is-null-or-empty';
8
9
  import { LanguageUtils } from '../common/utils/language-utils';
9
10
  import TemporalUtils from '../common/utils/temporal-utils';
@@ -29,9 +30,9 @@ export default class PowerduckInitializer {
29
30
 
30
31
  globalState.addEventListener('vite:preloadError', (event) => {
31
32
  const key = `${PowerduckState.getAppPrefix()}errLastReload`;
32
- const lastTry = Number(localStorage.getItem(key) || '0');
33
+ const lastTry = Number(StorageProvider.getString(key) || '0');
33
34
  if (TemporalUtils.dateNowMs() - lastTry > 3000) {
34
- localStorage.setItem(key, TemporalUtils.dateNowMs().toString());
35
+ StorageProvider.setString(key, TemporalUtils.dateNowMs().toString());
35
36
 
36
37
  if (globalState.__routerNextTo != null && !isNullOrEmpty(globalState.__routerNextTo.path)) {
37
38
  location.href = globalState.__routerNextTo.path;
@@ -2,6 +2,7 @@ import type { IDynamicComponentContainer } from '../components/app/dynamic-compo
2
2
  import type { IPowerduckSystemResources } from './powerduck-system-resources';
3
3
  import { Language } from '../common/enums/language';
4
4
  import { ModalSectionMode } from '../common/enums/modal';
5
+ import StorageProvider from '../common/local-storage-shim';
5
6
  import { isNullOrEmpty } from '../common/utils/is-null-or-empty';
6
7
  import { documentWrap, globalState } from './global-state';
7
8
 
@@ -100,8 +101,8 @@ export default class PowerduckState {
100
101
 
101
102
  static getModalSectionMode(): ModalSectionMode {
102
103
  if ((PowerduckState as any)._modalSectionMode == null) {
103
- if (localStorage.getItem(`${PowerduckState._prefix}modalSectionMode`) != null) {
104
- (PowerduckState as any)._modalSectionMode = Number(localStorage.getItem(`${PowerduckState._prefix}modalSectionMode`));
104
+ if (StorageProvider.getString(`${PowerduckState._prefix}modalSectionMode`) != null) {
105
+ (PowerduckState as any)._modalSectionMode = Number(StorageProvider.getString(`${PowerduckState._prefix}modalSectionMode`));
105
106
  } else {
106
107
  PowerduckState.setModalSectionMode(ModalSectionMode.navPills);
107
108
  }
@@ -111,7 +112,7 @@ export default class PowerduckState {
111
112
  }
112
113
 
113
114
  static setModalSectionMode(mode: ModalSectionMode): void {
114
- localStorage.setItem(`${PowerduckState._prefix}modalSectionMode`, mode.toString());
115
+ StorageProvider.setString(`${PowerduckState._prefix}modalSectionMode`, mode.toString());
115
116
  (PowerduckState as any)._modalSectionMode = mode;
116
117
  }
117
118
 
@@ -194,14 +194,23 @@ export interface AjaxLogProvider {
194
194
  log: (level: 'debug' | 'info' | 'warning' | 'error', message: string, data: any) => any;
195
195
  }
196
196
 
197
+ export interface AjaxMiddlewareArgs {
198
+ response: any;
199
+ httpCode: number;
200
+ }
201
+
202
+ export type AjaxMiddleware = (args: AjaxMiddlewareArgs) => Promise<void>;
203
+
197
204
  export class AppHttpProvider {
198
205
  static getRetryCount = 0;
199
206
  static postRetryCount = 0;
200
207
  static appLanguage: string = null;
201
208
  static logProvider: AjaxLogProvider = null;
209
+ static arraySerializeForGet: (val: any[]) => string;
202
210
  static defaultRequestProvider: AppHttpRequestProvider = 'xhr';
203
211
  static xhrRequestProvider: AjaxRequestProvider = new AjaxProviderXhr();
204
212
  static cordovaRequestProvider: AjaxRequestProvider = null;
213
+ static middlewares: AjaxMiddleware[] = [];
205
214
  static getRequestTimeoutMessage(): string {
206
215
  return PowerduckState.getResourceValue('requestTimeout');
207
216
  }
@@ -302,10 +311,14 @@ export class AppHttpProvider {
302
311
  for (const key in data) {
303
312
  const value = data[key];
304
313
  if (value != null) {
305
- if (value.constructor === Array) {
314
+ if (Array.isArray(value)) {
306
315
  const encodedKey = encodeURIComponent(key);
307
- for (let i = 0; i < value.length; i++) {
308
- query.push(`${encodedKey}=${value[i]}`);
316
+ if (AppHttpProvider.arraySerializeForGet != null) {
317
+ query.push(`${encodedKey}=${AppHttpProvider.arraySerializeForGet(value)}`);
318
+ } else {
319
+ for (let i = 0; i < value.length; i++) {
320
+ query.push(`${encodedKey}=${value[i]}`);
321
+ }
309
322
  }
310
323
  } else {
311
324
  query.push(`${encodeURIComponent(key)}=${encodeURIComponent(data[key])}`);
@@ -402,7 +415,7 @@ export class AppHttpProvider {
402
415
  timeout: args.timeout,
403
416
  url,
404
417
  })
405
- .then((resp) => {
418
+ .then(async (resp) => {
406
419
  if (blockUiEnabled) {
407
420
  try {
408
421
  this.unblockUi(args);
@@ -415,6 +428,20 @@ export class AppHttpProvider {
415
428
  AppHttpProvider.postProcessJsObject(jsonData, args.jsonAdapter);
416
429
  }
417
430
 
431
+ if (AppHttpProvider.middlewares?.length > 0) {
432
+ for (const middleware of this.middlewares) {
433
+ try {
434
+ await middleware({
435
+ httpCode: resp.httpCode,
436
+ response: jsonData ?? resp.responseText,
437
+ });
438
+ } catch (e) {
439
+ reject(e);
440
+ return;
441
+ }
442
+ }
443
+ }
444
+
418
445
  if (resp.httpCode < 300 && resp.httpCode > 0) {
419
446
  if (resp.httpCode == 204) {
420
447
  AppHttpProvider.log('info', `Request success to ${url}, took ${stop - start}ms`);
@@ -745,7 +772,7 @@ export class AppHttpProvider {
745
772
  public static apiGet<T>(
746
773
  apiMethodName: string,
747
774
  data: object | string,
748
- timeout: number = null,
775
+ timeout: number = null,
749
776
  ): Promise<T> {
750
777
  return this.getJSON(
751
778
  this.getApiUrl(
@@ -770,7 +797,7 @@ export class AppHttpProvider {
770
797
  public static privateApiGet<T>(
771
798
  apiMethodName: string,
772
799
  data: object | string,
773
- timeout: number = null,
800
+ timeout: number = null,
774
801
  ): Promise<T> {
775
802
  return this.getJSON(
776
803
  this.getApiUrl(
@@ -9,6 +9,7 @@ import { globalState } from '../app/global-state';
9
9
  import PowerduckState from '../app/powerduck-state';
10
10
  import NotificationProvider from './../components/ui/notification';
11
11
  import { TryCallApiResult } from './enums/api';
12
+ import StorageProvider from './local-storage-shim';
12
13
  import ScrollUtils from './scroll-utils';
13
14
  import { isNullOrEmpty } from './utils/is-null-or-empty';
14
15
  import { PortalUtils } from './utils/utils';
@@ -193,12 +194,12 @@ export abstract class PowerduckViewModelBase extends Vue {
193
194
  * Validates current viewModel state based on given valdiation ruleset
194
195
  */
195
196
  async validate(showErrorMessage?: boolean, silent?: boolean): Promise<boolean> {
196
- if (localStorage.getItem('disableValidation') == '1') {
197
+ if (StorageProvider.getString('disableValidation') == '1') {
197
198
  return true;
198
199
  }
199
200
 
200
201
  if (this.v$ == null) {
201
- throw 'Validation rules not specified, has to be specified in @Component declaration!';
202
+ throw new Error('Validation rules not specified, has to be specified in @Component declaration!');
202
203
  }
203
204
 
204
205
  const isInvalid = !(await this.v$.$validate());
@@ -13,6 +13,7 @@ import { DialogResult, DialogUtils } from '../../common/dialog-utils';
13
13
  import { DialogIcons } from '../../common/enums/dialog-icons';
14
14
  import { sortBy } from '../../common/extensions/array-extensions';
15
15
  import { capitalize, latinize } from '../../common/extensions/string-extensions';
16
+ import StorageProvider from '../../common/local-storage-shim';
16
17
  import { QueryStringUtils } from '../../common/query-string-utils';
17
18
  import CheckboxUtils from '../../common/utils/checkbox-utils';
18
19
  import DropdownUtils from '../../common/utils/dropdown-utils';
@@ -213,7 +214,7 @@ class StorageHelper {
213
214
  }
214
215
 
215
216
  static getStoredState(id: string): StoredState {
216
- const retVal = localStorage.getItem(StorageHelper.getStorageKey(id));
217
+ const retVal = StorageProvider.getString(StorageHelper.getStorageKey(id));
217
218
  if (retVal != null) {
218
219
  try {
219
220
  return JSON.parse(retVal);
@@ -224,7 +225,7 @@ class StorageHelper {
224
225
  }
225
226
 
226
227
  static saveStoredState(id: string, state: StoredState): void {
227
- localStorage.setItem(StorageHelper.getStorageKey(id), JSON.stringify(state));
228
+ StorageProvider.setString(StorageHelper.getStorageKey(id), JSON.stringify(state));
228
229
  }
229
230
 
230
231
  static storeSortOrder(id: string, sortOrder: string[]) {
@@ -9,6 +9,7 @@ import DateUtils from '../../../../common/utils/date-utils';
9
9
  import TemporalUtils from '../../../../common/utils/temporal-utils';
10
10
  import DaterangePickerConfig from './daterangepicker-config';
11
11
  import './daterangepicker.css';
12
+ import '../../../../app/css/input-effects.css';
12
13
  import { utcEpochMilliseconds } from '../../../../common/extensions/temporal-extensions';
13
14
  import { globalState } from '../../../../app/global-state';
14
15
 
@@ -2086,23 +2087,31 @@ import { globalState } from '../../../../app/global-state';
2086
2087
  return;
2087
2088
  }
2088
2089
 
2090
+ let afterAnimFired = false
2089
2091
  const afterAnim = function () {
2092
+ if (afterAnimFired) {
2093
+ return;
2094
+ }
2095
+
2096
+ afterAnimFired = true;
2097
+ box.hide();
2090
2098
  $(self).data('date-picker-opened', false);
2091
2099
  $(self).trigger('datepicker-closed', {
2092
2100
  relatedTarget: box,
2093
2101
  });
2102
+ box.removeClass('pd-dropdown-open-animation pd-dropdown-open-animation-above pd-dropdown-close-animation pd-dropdown-close-animation-above');
2094
2103
  };
2095
2104
  if (opt.customCloseAnimation) {
2096
2105
  opt.customCloseAnimation.call(box.get(0), afterAnim);
2097
2106
  } else {
2098
2107
  box.removeClass('pd-dropdown-open-animation pd-dropdown-open-animation-above pd-dropdown-close-animation pd-dropdown-close-animation-above');
2099
2108
  box[0].offsetWidth; // reflow
2100
- box.addClass('pd-dropdown-close-animation');
2101
2109
 
2102
- box.one('animationend', function () {
2103
- box.hide();
2104
- afterAnim();
2105
- box.removeClass('pd-dropdown-open-animation pd-dropdown-open-animation-above pd-dropdown-close-animation pd-dropdown-close-animation-above');
2110
+ box.addClass('pd-dropdown-close-animation');
2111
+ const timeout = setTimeout(afterAnim, 450)
2112
+ box.one('animationend', () => {
2113
+ clearTimeout(timeout)
2114
+ afterAnim()
2106
2115
  });
2107
2116
  }
2108
2117
 
@@ -183,7 +183,9 @@ export class OpenStreetMapComponent extends TsxComponent<OpenStreetMapArgs> impl
183
183
  @Watch('geoJSON')
184
184
  onGeoJsonChanged () {
185
185
  if (this.geoJSONClustering) {
186
- this.initCluster();
186
+ this.waitForLeaflet().then(() => {
187
+ this.initCluster()
188
+ })
187
189
  }
188
190
  }
189
191
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
3
  "type": "module",
4
- "version": "0.0.173",
4
+ "version": "0.0.175",
5
5
  "files": [
6
6
  "app/",
7
7
  "common/",