@qrvey/utils 1.13.0-9 → 1.13.1
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.
- package/dist/cache-managers/cache-chart-manager.d.ts +5 -17
- package/dist/cache-managers/cache-chart-manager.js +25 -23
- package/dist/cache-managers/cache-manager.d.ts +25 -29
- package/dist/cache-managers/cache-manager.js +92 -32
- package/dist/cache-managers/cache-metric-manager.d.ts +6 -18
- package/dist/cache-managers/cache-metric-manager.js +26 -30
- package/dist/cache-managers/cache-model-manager.d.ts +5 -17
- package/dist/cache-managers/cache-model-manager.js +23 -25
- package/dist/cache-managers/cache-permissions-manager.d.ts +5 -18
- package/dist/cache-managers/cache-permissions-manager.js +22 -24
- package/dist/cache-managers/cache-theme-manager.d.ts +5 -18
- package/dist/cache-managers/cache-theme-manager.js +22 -24
- package/dist/cache-managers/clean-cache-managers.d.ts +1 -0
- package/dist/cache-managers/clean-cache-managers.js +26 -0
- package/dist/cache-managers/index.d.ts +7 -0
- package/dist/cache-managers/index.js +7 -0
- package/dist/cjs/cache-managers/cache-chart-manager.d.ts +5 -17
- package/dist/cjs/cache-managers/cache-chart-manager.js +25 -23
- package/dist/cjs/cache-managers/cache-manager.d.ts +25 -29
- package/dist/cjs/cache-managers/cache-manager.js +92 -32
- package/dist/cjs/cache-managers/cache-metric-manager.d.ts +6 -18
- package/dist/cjs/cache-managers/cache-metric-manager.js +26 -30
- package/dist/cjs/cache-managers/cache-model-manager.d.ts +5 -17
- package/dist/cjs/cache-managers/cache-model-manager.js +23 -25
- package/dist/cjs/cache-managers/cache-permissions-manager.d.ts +5 -18
- package/dist/cjs/cache-managers/cache-permissions-manager.js +22 -24
- package/dist/cjs/cache-managers/cache-theme-manager.d.ts +5 -18
- package/dist/cjs/cache-managers/cache-theme-manager.js +22 -24
- package/dist/cjs/cache-managers/clean-cache-managers.d.ts +1 -0
- package/dist/cjs/cache-managers/clean-cache-managers.js +30 -0
- package/dist/cjs/cache-managers/index.d.ts +7 -0
- package/dist/cjs/cache-managers/index.js +23 -0
- package/dist/cjs/columns/helpers/index.d.ts +1 -0
- package/dist/cjs/columns/helpers/index.js +1 -0
- package/dist/cjs/columns/helpers/isCompoundColumn.d.ts +7 -0
- package/dist/cjs/columns/helpers/isCompoundColumn.js +15 -0
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/qrvey/interfaces/IBDataset.d.ts +2 -0
- package/dist/cjs/qrvey/interfaces/IDataset.d.ts +3 -1
- package/dist/cjs/services/adapters/BDatasetsToUIDatasets.adapter.js +1 -0
- package/dist/cjs/services/api/metrics.api.js +1 -1
- package/dist/cjs/services/helpers/Request.js +5 -1
- package/dist/columns/helpers/index.d.ts +1 -0
- package/dist/columns/helpers/index.js +1 -0
- package/dist/columns/helpers/isCompoundColumn.d.ts +7 -0
- package/dist/columns/helpers/isCompoundColumn.js +11 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/qrvey/interfaces/IBDataset.d.ts +2 -0
- package/dist/qrvey/interfaces/IDataset.d.ts +3 -1
- package/dist/services/adapters/BDatasetsToUIDatasets.adapter.js +1 -0
- package/dist/services/api/metrics.api.js +1 -1
- package/dist/services/helpers/Request.js +5 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QrveyCacheManager, QvCacheStoreProperties } from "./cache-manager";
|
|
2
2
|
export interface IGetChartConfig {
|
|
3
3
|
qv_token?: string;
|
|
4
4
|
api_key?: string;
|
|
@@ -14,21 +14,9 @@ export interface IGetChartConfig {
|
|
|
14
14
|
"temporal-tokens"?: boolean;
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
error: any;
|
|
21
|
-
}
|
|
22
|
-
export declare class ChartCacheManager extends QrveyCacheManager<IChartStoreState, IGetChartConfig> {
|
|
23
|
-
static getInstance(): ChartCacheManager;
|
|
24
|
-
protected getConfigPropertyName(): keyof IGetChartConfig;
|
|
25
|
-
protected getStorePropertyName(): keyof IChartStoreState;
|
|
17
|
+
export declare class ChartCacheManager extends QrveyCacheManager<QvCacheStoreProperties, IGetChartConfig> {
|
|
18
|
+
static getInstance(): any;
|
|
19
|
+
protected getConfigEntityId(): keyof IGetChartConfig;
|
|
26
20
|
protected buildStoreId({ chart_id }: IGetChartConfig): string;
|
|
27
|
-
protected
|
|
28
|
-
state: IChartStoreState;
|
|
29
|
-
onChange: OnChangeType;
|
|
30
|
-
set: (property: keyof IChartStoreState, value: unknown) => void;
|
|
31
|
-
};
|
|
32
|
-
protected fetchDataAndUpdateStore(state: IChartStoreState, config: IGetChartConfig): void;
|
|
21
|
+
protected fetchDataAndUpdateStore(state: QvCacheStoreProperties, config: IGetChartConfig): Promise<void>;
|
|
33
22
|
}
|
|
34
|
-
export {};
|
|
@@ -1,38 +1,40 @@
|
|
|
1
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
2
10
|
import { QrveyCacheManager } from "./cache-manager";
|
|
3
11
|
import ChartsApi from "../services/api/Charts.api";
|
|
4
12
|
export class ChartCacheManager extends QrveyCacheManager {
|
|
5
13
|
static getInstance() {
|
|
6
|
-
if (!window.
|
|
7
|
-
window.
|
|
14
|
+
if (!window.qvChartCacheManager) {
|
|
15
|
+
window.qvChartCacheManager = new ChartCacheManager();
|
|
8
16
|
}
|
|
9
|
-
return window.
|
|
17
|
+
return window.qvChartCacheManager;
|
|
10
18
|
}
|
|
11
|
-
|
|
19
|
+
getConfigEntityId() {
|
|
12
20
|
return "chart_id";
|
|
13
21
|
}
|
|
14
|
-
getStorePropertyName() {
|
|
15
|
-
return "chart";
|
|
16
|
-
}
|
|
17
22
|
buildStoreId({ chart_id }) {
|
|
18
23
|
return `${chart_id}`;
|
|
19
24
|
}
|
|
20
|
-
createStore(_initialState) {
|
|
21
|
-
return createStore(Object.assign({ chart: null, loading: true, error: null }, _initialState));
|
|
22
|
-
}
|
|
23
25
|
fetchDataAndUpdateStore(state, config) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const chartConfig = Object.assign(Object.assign({}, config), { translated: true });
|
|
28
|
+
const api = new ChartsApi(chartConfig);
|
|
29
|
+
return api
|
|
30
|
+
.getChart(chartConfig)
|
|
31
|
+
.then((chart) => {
|
|
32
|
+
state.entity = chart;
|
|
33
|
+
state.error = null;
|
|
34
|
+
})
|
|
35
|
+
.catch((e) => {
|
|
36
|
+
state.error = e;
|
|
37
|
+
});
|
|
36
38
|
});
|
|
37
39
|
}
|
|
38
40
|
}
|
|
@@ -1,36 +1,32 @@
|
|
|
1
1
|
export type OnChangeType = (property: string | number | symbol, callback: (entity: unknown) => void) => () => void;
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
export interface QvCacheStoreProperties {
|
|
3
|
+
entity: unknown;
|
|
4
|
+
error: boolean;
|
|
5
|
+
}
|
|
6
|
+
interface QrveyCacheStore<T> {
|
|
7
|
+
state: T;
|
|
8
|
+
onChange: OnChangeType;
|
|
9
|
+
set: (property: keyof T, value: unknown) => void;
|
|
10
|
+
dispose: () => void;
|
|
11
|
+
}
|
|
12
|
+
export declare abstract class QrveyCacheManager<TStoreState extends QvCacheStoreProperties, TConfig> {
|
|
13
|
+
protected stores: Map<string, QrveyCacheStore<TStoreState> | Promise<QrveyCacheStore<TStoreState>>>;
|
|
14
|
+
operationLocks: Map<any, any>;
|
|
15
|
+
protected abstract getConfigEntityId(): keyof TConfig;
|
|
10
16
|
protected abstract buildStoreId(config: TConfig): string;
|
|
11
|
-
protected abstract fetchDataAndUpdateStore(state: TStoreState, config: TConfig): void
|
|
12
|
-
protected
|
|
13
|
-
|
|
14
|
-
onChange: OnChangeType;
|
|
15
|
-
set: (property: keyof TStoreState, value: unknown) => void;
|
|
16
|
-
};
|
|
17
|
-
protected getStoreFromPromise(config: TConfig, id: string): Promise<{
|
|
18
|
-
state: TStoreState;
|
|
19
|
-
onChange: OnChangeType;
|
|
20
|
-
set: (property: keyof TStoreState, value: unknown) => void;
|
|
21
|
-
}>;
|
|
17
|
+
protected abstract fetchDataAndUpdateStore(state: TStoreState, config: TConfig): Promise<void>;
|
|
18
|
+
protected createStore(_initialState?: Partial<TStoreState>): Promise<QrveyCacheStore<TStoreState>>;
|
|
19
|
+
getStoreFromPromise(config: TConfig, id: string): Promise<QrveyCacheStore<TStoreState>>;
|
|
22
20
|
private getCreatedStore;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
set: (property: keyof TStoreState, value: unknown) => void;
|
|
27
|
-
};
|
|
28
|
-
getMultipleStores(config: TConfig, ids: string[]): Promise<{
|
|
29
|
-
state: TStoreState;
|
|
30
|
-
onChange: OnChangeType;
|
|
31
|
-
}[]>;
|
|
21
|
+
private initializeStore;
|
|
22
|
+
getStore(config: TConfig): Promise<QrveyCacheStore<TStoreState>>;
|
|
23
|
+
getMultipleStores(config: TConfig, ids: string[]): Promise<QrveyCacheStore<TStoreState>[]>;
|
|
32
24
|
setStoresFromData(stores: {
|
|
33
25
|
storeId: string;
|
|
34
26
|
state: Partial<TStoreState>;
|
|
35
|
-
}[]): void
|
|
27
|
+
}[]): Promise<void[]>;
|
|
28
|
+
private deleteStoreRegister;
|
|
29
|
+
cleanStore(storeId: string): Promise<void>;
|
|
30
|
+
cleanAllStores(): Promise<void>;
|
|
36
31
|
}
|
|
32
|
+
export {};
|
|
@@ -1,54 +1,114 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { createStore } from "@stencil/store";
|
|
1
11
|
export class QrveyCacheManager {
|
|
2
12
|
constructor() {
|
|
3
13
|
this.stores = new Map();
|
|
14
|
+
this.operationLocks = new Map();
|
|
15
|
+
}
|
|
16
|
+
createStore(_initialState) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
const initialState = Object.assign({ entity: null, error: null }, _initialState);
|
|
19
|
+
return createStore(initialState);
|
|
20
|
+
});
|
|
4
21
|
}
|
|
5
22
|
getStoreFromPromise(config, id) {
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
const unsubscribe = store.onChange(storeProperty, (entity) => {
|
|
16
|
-
if (entity !== null) {
|
|
17
|
-
unsubscribe();
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
(() => __awaiter(this, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
const configEntityId = this.getConfigEntityId();
|
|
28
|
+
const extendedConfig = Object.assign(Object.assign({}, config), { [configEntityId]: id });
|
|
29
|
+
const store = yield this.getStore(extendedConfig);
|
|
18
30
|
resolve(store);
|
|
19
31
|
}
|
|
20
|
-
|
|
21
|
-
|
|
32
|
+
catch (error) {
|
|
33
|
+
reject(error);
|
|
34
|
+
}
|
|
35
|
+
}))();
|
|
36
|
+
});
|
|
22
37
|
});
|
|
23
38
|
}
|
|
24
39
|
getCreatedStore(storeId) {
|
|
25
|
-
return this
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return this.stores.get(storeId);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
initializeStore(config, storeId) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const newStore = yield this.createStore();
|
|
47
|
+
yield this.fetchDataAndUpdateStore(newStore.state, config);
|
|
48
|
+
this.stores.set(storeId, newStore);
|
|
49
|
+
return newStore;
|
|
50
|
+
});
|
|
26
51
|
}
|
|
27
52
|
getStore(config) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
const storeId = this.buildStoreId(config);
|
|
55
|
+
while (this.operationLocks.has(storeId)) {
|
|
56
|
+
yield this.operationLocks.get(storeId);
|
|
57
|
+
}
|
|
58
|
+
let store = this.stores.get(storeId);
|
|
59
|
+
if (!store) {
|
|
60
|
+
let resolveLock;
|
|
61
|
+
const lockPromise = new Promise((resolve) => (resolveLock = resolve));
|
|
62
|
+
this.operationLocks.set(storeId, lockPromise);
|
|
63
|
+
try {
|
|
64
|
+
store = yield this.initializeStore(config, storeId);
|
|
65
|
+
this.stores.set(storeId, store);
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
resolveLock();
|
|
69
|
+
this.operationLocks.delete(storeId);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
31
72
|
return store;
|
|
32
|
-
}
|
|
33
|
-
const { state, onChange, set } = store !== null && store !== void 0 ? store : this.createStore();
|
|
34
|
-
this.stores.set(storeId, { state, onChange, set });
|
|
35
|
-
this.fetchDataAndUpdateStore(state, config);
|
|
36
|
-
return { state, onChange, set };
|
|
73
|
+
});
|
|
37
74
|
}
|
|
38
75
|
getMultipleStores(config, ids) {
|
|
39
|
-
const promises = ids.map((id) => this.getStoreFromPromise(config, id));
|
|
76
|
+
const promises = ids.map((id) => __awaiter(this, void 0, void 0, function* () { return yield this.getStoreFromPromise(config, id); }));
|
|
40
77
|
return Promise.all(promises);
|
|
41
78
|
}
|
|
42
79
|
setStoresFromData(stores) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
80
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
81
|
+
return Promise.all(stores.map((store) => __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
let createdStore = yield this.getCreatedStore(store.storeId);
|
|
83
|
+
if (!createdStore) {
|
|
84
|
+
createdStore = yield this.createStore();
|
|
85
|
+
this.stores.set(store.storeId, createdStore);
|
|
86
|
+
}
|
|
87
|
+
Object.entries(store.state).forEach(([key, value]) => {
|
|
88
|
+
createdStore.set(key, value);
|
|
89
|
+
});
|
|
90
|
+
})));
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
deleteStoreRegister(storeId) {
|
|
94
|
+
this.stores.delete(storeId);
|
|
95
|
+
}
|
|
96
|
+
cleanStore(storeId) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const existingStore = yield this.getCreatedStore(storeId);
|
|
99
|
+
if (existingStore) {
|
|
100
|
+
const store = existingStore instanceof Promise ? yield existingStore : existingStore;
|
|
101
|
+
store.dispose();
|
|
102
|
+
this.deleteStoreRegister(storeId);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
cleanAllStores() {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
const storeIds = Array.from(this.stores.keys());
|
|
109
|
+
for (const storeId of storeIds) {
|
|
110
|
+
yield this.cleanStore(storeId);
|
|
48
111
|
}
|
|
49
|
-
Object.entries(store.state).forEach(([key, value]) => {
|
|
50
|
-
createdStore.set(key, value);
|
|
51
|
-
});
|
|
52
112
|
});
|
|
53
113
|
}
|
|
54
114
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QrveyCacheManager, QvCacheStoreProperties } from "./cache-manager";
|
|
2
2
|
export interface IGetMetricConfig {
|
|
3
3
|
qv_token?: string;
|
|
4
4
|
api_key?: string;
|
|
@@ -15,21 +15,9 @@ export interface IGetMetricConfig {
|
|
|
15
15
|
"temporal-tokens"?: boolean;
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export declare class MetricCacheManager extends QrveyCacheManager<QvCacheStoreProperties, IGetMetricConfig> {
|
|
19
|
+
static getInstance(): any;
|
|
20
|
+
protected getConfigEntityId(): keyof IGetMetricConfig;
|
|
21
|
+
protected buildStoreId({ metric_id }: IGetMetricConfig): string;
|
|
22
|
+
protected fetchDataAndUpdateStore(state: QvCacheStoreProperties, config: IGetMetricConfig): Promise<void>;
|
|
22
23
|
}
|
|
23
|
-
export declare class MetricCacheManager extends QrveyCacheManager<IMetricStoreState, IGetMetricConfig> {
|
|
24
|
-
static getInstance(): MetricCacheManager;
|
|
25
|
-
protected getConfigPropertyName(): keyof IGetMetricConfig;
|
|
26
|
-
protected getStorePropertyName(): keyof IMetricStoreState;
|
|
27
|
-
protected buildStoreId({ metric_id, translated }: IGetMetricConfig): string;
|
|
28
|
-
protected createStore(): {
|
|
29
|
-
state: IMetricStoreState;
|
|
30
|
-
onChange: OnChangeType;
|
|
31
|
-
set: (property: keyof IMetricStoreState, value: unknown) => void;
|
|
32
|
-
};
|
|
33
|
-
protected fetchDataAndUpdateStore(state: IMetricStoreState, config: IGetMetricConfig): void;
|
|
34
|
-
}
|
|
35
|
-
export {};
|
|
@@ -1,43 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
2
10
|
import { QrveyCacheManager } from "./cache-manager";
|
|
3
|
-
import { isEmpty } from "../general/mix/isEmpty";
|
|
4
11
|
import MetricPanelApi from "../services/api/metrics.api";
|
|
5
12
|
export class MetricCacheManager extends QrveyCacheManager {
|
|
6
13
|
static getInstance() {
|
|
7
|
-
if (!window.
|
|
8
|
-
window.
|
|
14
|
+
if (!window.qvMetricCacheManager) {
|
|
15
|
+
window.qvMetricCacheManager = new MetricCacheManager();
|
|
9
16
|
}
|
|
10
|
-
return window.
|
|
17
|
+
return window.qvMetricCacheManager;
|
|
11
18
|
}
|
|
12
|
-
|
|
19
|
+
getConfigEntityId() {
|
|
13
20
|
return "metric_id";
|
|
14
21
|
}
|
|
15
|
-
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
buildStoreId({ metric_id, translated }) {
|
|
19
|
-
const translate = isEmpty(translated) ? true : translated;
|
|
20
|
-
return `${metric_id}-${translate ? "translated" : ""}`;
|
|
21
|
-
}
|
|
22
|
-
createStore() {
|
|
23
|
-
return createStore({
|
|
24
|
-
metric: null,
|
|
25
|
-
loading: true,
|
|
26
|
-
error: null,
|
|
27
|
-
});
|
|
22
|
+
buildStoreId({ metric_id }) {
|
|
23
|
+
return `${metric_id}`;
|
|
28
24
|
}
|
|
29
25
|
fetchDataAndUpdateStore(state, config) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const api = new MetricPanelApi();
|
|
28
|
+
return api
|
|
29
|
+
.getMetricConfig(config)
|
|
30
|
+
.then((metric) => {
|
|
31
|
+
state.entity = metric;
|
|
32
|
+
state.error = null;
|
|
33
|
+
})
|
|
34
|
+
.catch((e) => {
|
|
35
|
+
state.error = e;
|
|
36
|
+
});
|
|
41
37
|
});
|
|
42
38
|
}
|
|
43
39
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IModel } from "../qrvey";
|
|
1
|
+
import { QrveyCacheManager, QvCacheStoreProperties } from "./cache-manager";
|
|
3
2
|
interface IGetModelConfig {
|
|
4
3
|
qv_token?: string;
|
|
5
4
|
api_key?: string;
|
|
@@ -10,21 +9,10 @@ interface IGetModelConfig {
|
|
|
10
9
|
qrvey_id: string;
|
|
11
10
|
i18n?: any;
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
error: any;
|
|
17
|
-
}
|
|
18
|
-
export declare class ModelCacheManager extends QrveyCacheManager<IModelStoreState, IGetModelConfig> {
|
|
19
|
-
static getInstance(): ModelCacheManager;
|
|
20
|
-
protected getConfigPropertyName(): keyof IGetModelConfig;
|
|
21
|
-
protected getStorePropertyName(): keyof IModelStoreState;
|
|
12
|
+
export declare class ModelCacheManager extends QrveyCacheManager<QvCacheStoreProperties, IGetModelConfig> {
|
|
13
|
+
static getInstance(): any;
|
|
14
|
+
protected getConfigEntityId(): keyof IGetModelConfig;
|
|
22
15
|
protected buildStoreId({ qrvey_id }: IGetModelConfig): string;
|
|
23
|
-
protected
|
|
24
|
-
state: IModelStoreState;
|
|
25
|
-
onChange: OnChangeType;
|
|
26
|
-
set: (property: keyof IModelStoreState, value: unknown) => void;
|
|
27
|
-
};
|
|
28
|
-
protected fetchDataAndUpdateStore(state: IModelStoreState, config: IGetModelConfig): void;
|
|
16
|
+
protected fetchDataAndUpdateStore(state: QvCacheStoreProperties, config: IGetModelConfig): Promise<void>;
|
|
29
17
|
}
|
|
30
18
|
export {};
|
|
@@ -1,40 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
2
10
|
import { QrveyCacheManager } from "./cache-manager";
|
|
3
11
|
import { getModel } from "../services/api/getModel.api";
|
|
4
12
|
export class ModelCacheManager extends QrveyCacheManager {
|
|
5
13
|
static getInstance() {
|
|
6
|
-
if (!window.
|
|
7
|
-
window.
|
|
14
|
+
if (!window.qvModelCacheManager) {
|
|
15
|
+
window.qvModelCacheManager = new ModelCacheManager();
|
|
8
16
|
}
|
|
9
|
-
return window.
|
|
17
|
+
return window.qvModelCacheManager;
|
|
10
18
|
}
|
|
11
|
-
|
|
19
|
+
getConfigEntityId() {
|
|
12
20
|
return "qrvey_id";
|
|
13
21
|
}
|
|
14
|
-
getStorePropertyName() {
|
|
15
|
-
return "model";
|
|
16
|
-
}
|
|
17
22
|
buildStoreId({ qrvey_id }) {
|
|
18
23
|
return `${qrvey_id}`;
|
|
19
24
|
}
|
|
20
|
-
createStore() {
|
|
21
|
-
return createStore({
|
|
22
|
-
model: null,
|
|
23
|
-
loading: true,
|
|
24
|
-
error: null,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
25
|
fetchDataAndUpdateStore(state, config) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
const includeInfo = ["bucketsInfo", "formulaInfo", "colorByValueInfo"];
|
|
28
|
+
return getModel(config, { includeInfo })
|
|
29
|
+
.then((model) => {
|
|
30
|
+
state.entity = model;
|
|
31
|
+
state.error = null;
|
|
32
|
+
})
|
|
33
|
+
.catch((e) => {
|
|
34
|
+
state.error = e;
|
|
35
|
+
});
|
|
38
36
|
});
|
|
39
37
|
}
|
|
40
38
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { OnChangeType, QrveyCacheManager } from "./cache-manager";
|
|
1
|
+
import { QrveyCacheManager, QvCacheStoreProperties } from "./cache-manager";
|
|
3
2
|
export interface IGetPermissionsConfig {
|
|
4
3
|
qv_token?: string;
|
|
5
4
|
api_key?: string;
|
|
@@ -7,21 +6,9 @@ export interface IGetPermissionsConfig {
|
|
|
7
6
|
user_id?: string;
|
|
8
7
|
domain?: string;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
error: any;
|
|
14
|
-
}
|
|
15
|
-
export declare class PermissionsCacheManager extends QrveyCacheManager<IPermissionsStoreState, IGetPermissionsConfig> {
|
|
16
|
-
static getInstance(): PermissionsCacheManager;
|
|
17
|
-
protected getConfigPropertyName(): keyof IGetPermissionsConfig;
|
|
18
|
-
protected getStorePropertyName(): keyof IPermissionsStoreState;
|
|
9
|
+
export declare class PermissionsCacheManager extends QrveyCacheManager<QvCacheStoreProperties, IGetPermissionsConfig> {
|
|
10
|
+
static getInstance(): any;
|
|
11
|
+
protected getConfigEntityId(): keyof IGetPermissionsConfig;
|
|
19
12
|
protected buildStoreId({ user_id }: IGetPermissionsConfig): string;
|
|
20
|
-
protected
|
|
21
|
-
state: IPermissionsStoreState;
|
|
22
|
-
onChange: OnChangeType;
|
|
23
|
-
set: (property: keyof IPermissionsStoreState, value: unknown) => void;
|
|
24
|
-
};
|
|
25
|
-
protected fetchDataAndUpdateStore(state: IPermissionsStoreState, config: IGetPermissionsConfig): void;
|
|
13
|
+
protected fetchDataAndUpdateStore(state: QvCacheStoreProperties, config: IGetPermissionsConfig): Promise<void>;
|
|
26
14
|
}
|
|
27
|
-
export {};
|
|
@@ -1,39 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
2
10
|
import { QrveyCacheManager } from "./cache-manager";
|
|
3
11
|
import { getAdminPermissions } from "../services/api/adminPermissions.api";
|
|
4
12
|
export class PermissionsCacheManager extends QrveyCacheManager {
|
|
5
13
|
static getInstance() {
|
|
6
|
-
if (!window.
|
|
7
|
-
window.
|
|
14
|
+
if (!window.qvPermissionsCacheManager) {
|
|
15
|
+
window.qvPermissionsCacheManager = new PermissionsCacheManager();
|
|
8
16
|
}
|
|
9
|
-
return window.
|
|
17
|
+
return window.qvPermissionsCacheManager;
|
|
10
18
|
}
|
|
11
|
-
|
|
19
|
+
getConfigEntityId() {
|
|
12
20
|
return "user_id";
|
|
13
21
|
}
|
|
14
|
-
getStorePropertyName() {
|
|
15
|
-
return "permissions";
|
|
16
|
-
}
|
|
17
22
|
buildStoreId({ user_id }) {
|
|
18
23
|
return `${user_id}`;
|
|
19
24
|
}
|
|
20
|
-
createStore() {
|
|
21
|
-
return createStore({
|
|
22
|
-
permissions: null,
|
|
23
|
-
loading: true,
|
|
24
|
-
error: null,
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
25
|
fetchDataAndUpdateStore(state, config) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
return getAdminPermissions(config)
|
|
28
|
+
.then((permissions) => {
|
|
29
|
+
state.entity = permissions;
|
|
30
|
+
state.error = null;
|
|
31
|
+
})
|
|
32
|
+
.catch((e) => {
|
|
33
|
+
state.error = e;
|
|
34
|
+
});
|
|
37
35
|
});
|
|
38
36
|
}
|
|
39
37
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AnTheme } from "../interfaces/themes/an-theme";
|
|
1
|
+
import { QrveyCacheManager, QvCacheStoreProperties } from "./cache-manager";
|
|
3
2
|
export interface IGetThemeConfig {
|
|
4
3
|
qv_token?: string;
|
|
5
4
|
api_key?: string;
|
|
@@ -8,21 +7,9 @@ export interface IGetThemeConfig {
|
|
|
8
7
|
domain?: string;
|
|
9
8
|
theme_id?: string;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
error: any;
|
|
15
|
-
}
|
|
16
|
-
export declare class ThemeCacheManager extends QrveyCacheManager<IThemeStoreState, IGetThemeConfig> {
|
|
17
|
-
static getInstance(): ThemeCacheManager;
|
|
18
|
-
protected getConfigPropertyName(): keyof IGetThemeConfig;
|
|
19
|
-
protected getStorePropertyName(): keyof IThemeStoreState;
|
|
10
|
+
export declare class ThemeCacheManager extends QrveyCacheManager<QvCacheStoreProperties, IGetThemeConfig> {
|
|
11
|
+
static getInstance(): any;
|
|
12
|
+
protected getConfigEntityId(): keyof IGetThemeConfig;
|
|
20
13
|
protected buildStoreId({ theme_id, app_id }: IGetThemeConfig): string;
|
|
21
|
-
protected
|
|
22
|
-
state: IThemeStoreState;
|
|
23
|
-
onChange: OnChangeType;
|
|
24
|
-
set: (property: keyof IThemeStoreState, value: unknown) => void;
|
|
25
|
-
};
|
|
26
|
-
protected fetchDataAndUpdateStore(state: IThemeStoreState, config: IGetThemeConfig): void;
|
|
14
|
+
protected fetchDataAndUpdateStore(state: QvCacheStoreProperties, config: IGetThemeConfig): Promise<void>;
|
|
27
15
|
}
|
|
28
|
-
export {};
|