@qrvey/utils 1.13.0-6.performance.1 → 1.13.0-7.performance.0

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.
@@ -0,0 +1,27 @@
1
+ import { OnChangeType, QrveyCacheManager } from "./cache-manager";
2
+ import { AnTheme } from "../interfaces/themes/an-theme";
3
+ export interface IGetThemeConfig {
4
+ qv_token?: string;
5
+ api_key?: string;
6
+ app_id?: string;
7
+ user_id?: string;
8
+ domain?: string;
9
+ theme_id?: string;
10
+ }
11
+ interface IThemeStoreState {
12
+ theme: AnTheme;
13
+ loading: boolean;
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;
20
+ protected buildStoreId({ theme_id, app_id }: IGetThemeConfig): string;
21
+ protected createStore(): {
22
+ state: IThemeStoreState;
23
+ onChange: OnChangeType;
24
+ };
25
+ protected fetchDataAndUpdateStore(state: IThemeStoreState, config: IGetThemeConfig): void;
26
+ }
27
+ export {};
@@ -0,0 +1,39 @@
1
+ import { createStore } from "@stencil/store";
2
+ import { QrveyCacheManager } from "./cache-manager";
3
+ import { getCurrentTheme, getThemeById } from "../services/api/Themes.api";
4
+ export class ThemeCacheManager extends QrveyCacheManager {
5
+ static getInstance() {
6
+ if (!window.themeCacheManager) {
7
+ window.themeCacheManager = new ThemeCacheManager();
8
+ }
9
+ return window.themeCacheManager;
10
+ }
11
+ getConfigPropertyName() {
12
+ return "theme_id";
13
+ }
14
+ getStorePropertyName() {
15
+ return "theme";
16
+ }
17
+ buildStoreId({ theme_id, app_id }) {
18
+ return `${app_id}-${theme_id !== null && theme_id !== void 0 ? theme_id : "current"}`;
19
+ }
20
+ createStore() {
21
+ return createStore({
22
+ theme: null,
23
+ loading: true,
24
+ error: null,
25
+ });
26
+ }
27
+ fetchDataAndUpdateStore(state, config) {
28
+ (config.theme_id ? getThemeById(config) : getCurrentTheme(config))
29
+ .then((theme) => {
30
+ state.theme = theme;
31
+ state.error = null;
32
+ state.loading = false;
33
+ })
34
+ .catch((e) => {
35
+ state.error = e;
36
+ state.loading = false;
37
+ });
38
+ }
39
+ }
@@ -0,0 +1,27 @@
1
+ import { OnChangeType, QrveyCacheManager } from "./cache-manager";
2
+ import { AnTheme } from "../interfaces/themes/an-theme";
3
+ export interface IGetThemeConfig {
4
+ qv_token?: string;
5
+ api_key?: string;
6
+ app_id?: string;
7
+ user_id?: string;
8
+ domain?: string;
9
+ theme_id?: string;
10
+ }
11
+ interface IThemeStoreState {
12
+ theme: AnTheme;
13
+ loading: boolean;
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;
20
+ protected buildStoreId({ theme_id, app_id }: IGetThemeConfig): string;
21
+ protected createStore(): {
22
+ state: IThemeStoreState;
23
+ onChange: OnChangeType;
24
+ };
25
+ protected fetchDataAndUpdateStore(state: IThemeStoreState, config: IGetThemeConfig): void;
26
+ }
27
+ export {};
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ThemeCacheManager = void 0;
4
+ const store_1 = require("@stencil/store");
5
+ const cache_manager_1 = require("./cache-manager");
6
+ const Themes_api_1 = require("../services/api/Themes.api");
7
+ class ThemeCacheManager extends cache_manager_1.QrveyCacheManager {
8
+ static getInstance() {
9
+ if (!window.themeCacheManager) {
10
+ window.themeCacheManager = new ThemeCacheManager();
11
+ }
12
+ return window.themeCacheManager;
13
+ }
14
+ getConfigPropertyName() {
15
+ return "theme_id";
16
+ }
17
+ getStorePropertyName() {
18
+ return "theme";
19
+ }
20
+ buildStoreId({ theme_id, app_id }) {
21
+ return `${app_id}-${theme_id !== null && theme_id !== void 0 ? theme_id : "current"}`;
22
+ }
23
+ createStore() {
24
+ return (0, store_1.createStore)({
25
+ theme: null,
26
+ loading: true,
27
+ error: null,
28
+ });
29
+ }
30
+ fetchDataAndUpdateStore(state, config) {
31
+ (config.theme_id ? (0, Themes_api_1.getThemeById)(config) : (0, Themes_api_1.getCurrentTheme)(config))
32
+ .then((theme) => {
33
+ state.theme = theme;
34
+ state.error = null;
35
+ state.loading = false;
36
+ })
37
+ .catch((e) => {
38
+ state.error = e;
39
+ state.loading = false;
40
+ });
41
+ }
42
+ }
43
+ exports.ThemeCacheManager = ThemeCacheManager;
@@ -0,0 +1,22 @@
1
+ export interface AnThemeStyle {
2
+ canvasBackgroundColor?: string;
3
+ panelIconsForegroundColor?: string;
4
+ font: string;
5
+ hideTitle: any;
6
+ chartTitles: string;
7
+ axisDataLabels: string;
8
+ values: string;
9
+ legends: string;
10
+ tooltips: string;
11
+ mainColor: string;
12
+ tableHeaderMainColor: string;
13
+ themePalette: any[];
14
+ showHeader?: boolean;
15
+ dataLabels?: string;
16
+ panelBackgroundColor?: string;
17
+ transparent?: boolean;
18
+ valuesSecondary?: string;
19
+ tableHeaderFont?: string;
20
+ tableVisualizationBarPositive?: string;
21
+ tableVisualizationBarNegative?: string;
22
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import { AnThemeStyle } from "./an-style-theme";
2
+ export interface AnTheme {
3
+ useInAllApplications: boolean;
4
+ currentChartTheme: boolean;
5
+ isDefaultTheme: boolean;
6
+ createDate?: string;
7
+ userId: string;
8
+ modifyDate?: string;
9
+ appId: string;
10
+ readOnly?: boolean;
11
+ chartThemeId?: string;
12
+ name: string;
13
+ style: AnThemeStyle;
14
+ lang?: string;
15
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,10 +1,3 @@
1
- export interface IFieldsConfig {
2
- type: string;
3
- column?: any;
4
- qrvey_id?: string;
5
- showBuckets?: boolean;
6
- showLinkedDatasets?: boolean;
7
- }
8
1
  export default class ChartsApi {
9
2
  config: any;
10
3
  abortCtrl: AbortController;
@@ -0,0 +1,3 @@
1
+ import { IGetThemeConfig } from "../../cache-managers/cache-theme-manager";
2
+ export declare function getThemeById(config: IGetThemeConfig): Promise<any>;
3
+ export declare function getCurrentTheme(config: IGetThemeConfig): Promise<any>;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCurrentTheme = exports.getThemeById = void 0;
4
+ const helpers_1 = require("../helpers");
5
+ const THEME_ENDPOINT_1 = require("../constants/THEME_ENDPOINT");
6
+ function getThemeById(config) {
7
+ return helpers_1.Request.get(Object.assign(Object.assign({}, config), { endpoint: THEME_ENDPOINT_1.CHART_THEMES_ENDPOINT }), `/${config.theme_id}`);
8
+ }
9
+ exports.getThemeById = getThemeById;
10
+ function getCurrentTheme(config) {
11
+ return helpers_1.Request.get(Object.assign(Object.assign({}, config), { endpoint: THEME_ENDPOINT_1.CHART_THEMES_ENDPOINT }), "?current=true");
12
+ }
13
+ exports.getCurrentTheme = getCurrentTheme;
@@ -0,0 +1,2 @@
1
+ import { IEndpointConfig } from "../interfaces/IEndpointConfig";
2
+ export declare const CHART_THEMES_ENDPOINT: IEndpointConfig;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CHART_THEMES_ENDPOINT = void 0;
4
+ exports.CHART_THEMES_ENDPOINT = {
5
+ uri: "/app/:app_id/qrvey/:qrvey_id/analytiq/themes",
6
+ version: 4,
7
+ };
@@ -0,0 +1,22 @@
1
+ export interface AnThemeStyle {
2
+ canvasBackgroundColor?: string;
3
+ panelIconsForegroundColor?: string;
4
+ font: string;
5
+ hideTitle: any;
6
+ chartTitles: string;
7
+ axisDataLabels: string;
8
+ values: string;
9
+ legends: string;
10
+ tooltips: string;
11
+ mainColor: string;
12
+ tableHeaderMainColor: string;
13
+ themePalette: any[];
14
+ showHeader?: boolean;
15
+ dataLabels?: string;
16
+ panelBackgroundColor?: string;
17
+ transparent?: boolean;
18
+ valuesSecondary?: string;
19
+ tableHeaderFont?: string;
20
+ tableVisualizationBarPositive?: string;
21
+ tableVisualizationBarNegative?: string;
22
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import { AnThemeStyle } from "./an-style-theme";
2
+ export interface AnTheme {
3
+ useInAllApplications: boolean;
4
+ currentChartTheme: boolean;
5
+ isDefaultTheme: boolean;
6
+ createDate?: string;
7
+ userId: string;
8
+ modifyDate?: string;
9
+ appId: string;
10
+ readOnly?: boolean;
11
+ chartThemeId?: string;
12
+ name: string;
13
+ style: AnThemeStyle;
14
+ lang?: string;
15
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,3 @@
1
- export interface IFieldsConfig {
2
- type: string;
3
- column?: any;
4
- qrvey_id?: string;
5
- showBuckets?: boolean;
6
- showLinkedDatasets?: boolean;
7
- }
8
1
  export default class ChartsApi {
9
2
  config: any;
10
3
  abortCtrl: AbortController;
@@ -0,0 +1,3 @@
1
+ import { IGetThemeConfig } from "../../cache-managers/cache-theme-manager";
2
+ export declare function getThemeById(config: IGetThemeConfig): Promise<any>;
3
+ export declare function getCurrentTheme(config: IGetThemeConfig): Promise<any>;
@@ -0,0 +1,8 @@
1
+ import { Request } from "../helpers";
2
+ import { CHART_THEMES_ENDPOINT } from "../constants/THEME_ENDPOINT";
3
+ export function getThemeById(config) {
4
+ return Request.get(Object.assign(Object.assign({}, config), { endpoint: CHART_THEMES_ENDPOINT }), `/${config.theme_id}`);
5
+ }
6
+ export function getCurrentTheme(config) {
7
+ return Request.get(Object.assign(Object.assign({}, config), { endpoint: CHART_THEMES_ENDPOINT }), "?current=true");
8
+ }
@@ -0,0 +1,2 @@
1
+ import { IEndpointConfig } from "../interfaces/IEndpointConfig";
2
+ export declare const CHART_THEMES_ENDPOINT: IEndpointConfig;
@@ -0,0 +1,4 @@
1
+ export const CHART_THEMES_ENDPOINT = {
2
+ uri: "/app/:app_id/qrvey/:qrvey_id/analytiq/themes",
3
+ version: 4,
4
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qrvey/utils",
3
- "version": "1.13.0-6.performance.1",
3
+ "version": "1.13.0-7.performance.0",
4
4
  "description": "Helper, Utils for all Qrvey Projects",
5
5
  "homepage": "https://bitbucket.org/qrvey/qrvey_utils/wiki/Home",
6
6
  "main": "dist/index.js",