mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-04-17 15:17:49 +01:00
debug
This commit is contained in:
parent
0559ec5cb1
commit
cad718acc4
@ -2,14 +2,8 @@
|
|||||||
* @module SelfServe/Decorators
|
* @module SelfServe/Decorators
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { TFunction } from "i18next";
|
||||||
ChoiceItem,
|
import { ChoiceItem, Description, Info, NumberUiType, OnChangeCallback, RefreshParams } from "./SelfServeTypes";
|
||||||
Description,
|
|
||||||
Info,
|
|
||||||
NumberUiType,
|
|
||||||
OnChangeCallback,
|
|
||||||
RefreshParams
|
|
||||||
} from "./SelfServeTypes";
|
|
||||||
import { addPropertyToMap, buildSmartUiDescriptor, DecoratorProperties, SelfServeType } from "./SelfServeUtils";
|
import { addPropertyToMap, buildSmartUiDescriptor, DecoratorProperties, SelfServeType } from "./SelfServeUtils";
|
||||||
|
|
||||||
type ValueOf<T> = T[keyof T];
|
type ValueOf<T> = T[keyof T];
|
||||||
@ -135,22 +129,10 @@ const isDescriptionDisplayOptions = (inputOptions: InputOptions): inputOptions i
|
|||||||
};
|
};
|
||||||
|
|
||||||
const addToMap = (...decorators: Decorator[]): PropertyDecorator => {
|
const addToMap = (...decorators: Decorator[]): PropertyDecorator => {
|
||||||
console.log(decorators)
|
console.log(decorators);
|
||||||
return async (target, property) => {
|
return async (target, property) => {
|
||||||
console.log("--------------------------------------")
|
let className: string = getTargetName(target);
|
||||||
console.log(property);
|
|
||||||
// console.log((target as SelfServeBaseClass))
|
|
||||||
// console.log((target as SelfServeBaseClass).test)
|
|
||||||
// console.log((target as MaterializedViewsBuilder))
|
|
||||||
// console.log((target as MaterializedViewsBuilder).test)
|
|
||||||
let className: string;
|
|
||||||
if (target.constructor.toString().includes(SelfServeType.materializedviewsbuilder)) {
|
|
||||||
className = SelfServeType.materializedviewsbuilder;
|
|
||||||
} else if (target instanceof Function) {
|
|
||||||
className = target.constructor.name;
|
|
||||||
}
|
|
||||||
const propertyName = property.toString();
|
const propertyName = property.toString();
|
||||||
console.log(propertyName)
|
|
||||||
if (className === "Function") {
|
if (className === "Function") {
|
||||||
//eslint-disable-next-line @typescript-eslint/ban-types
|
//eslint-disable-next-line @typescript-eslint/ban-types
|
||||||
className = (target as Function).name;
|
className = (target as Function).name;
|
||||||
@ -158,7 +140,7 @@ const addToMap = (...decorators: Decorator[]): PropertyDecorator => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const propertyType = (Reflect.getMetadata("design:type", target, property)?.name as string)?.toLowerCase();
|
const propertyType = (Reflect.getMetadata("design:type", target, property)?.name as string)?.toLowerCase();
|
||||||
console.log(propertyType)
|
console.log(propertyType);
|
||||||
addPropertyToMap(target, propertyName, className, "type", propertyType);
|
addPropertyToMap(target, propertyName, className, "type", propertyType);
|
||||||
addPropertyToMap(target, propertyName, className, "dataFieldName", propertyName);
|
addPropertyToMap(target, propertyName, className, "dataFieldName", propertyName);
|
||||||
|
|
||||||
@ -226,14 +208,7 @@ export const Values = (inputOptions: InputOptions): PropertyDecorator => {
|
|||||||
*/
|
*/
|
||||||
export const IsDisplayable = (): ClassDecorator => {
|
export const IsDisplayable = (): ClassDecorator => {
|
||||||
return (target) => {
|
return (target) => {
|
||||||
let targetName: string;
|
let targetName: string = getTargetName(target);
|
||||||
console.log(target.prototype)
|
|
||||||
console.log(target.toString())
|
|
||||||
if (target.toString().includes(SelfServeType.materializedviewsbuilder)) {
|
|
||||||
targetName = SelfServeType.materializedviewsbuilder;
|
|
||||||
} else if (target instanceof Function) {
|
|
||||||
targetName = target.constructor.name;
|
|
||||||
}
|
|
||||||
buildSmartUiDescriptor(targetName, target.prototype);
|
buildSmartUiDescriptor(targetName, target.prototype);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@ -244,16 +219,26 @@ export const IsDisplayable = (): ClassDecorator => {
|
|||||||
* how often the auto refresh of the page occurs.
|
* how often the auto refresh of the page occurs.
|
||||||
*/
|
*/
|
||||||
export const RefreshOptions = (refreshParams: RefreshParams): ClassDecorator => {
|
export const RefreshOptions = (refreshParams: RefreshParams): ClassDecorator => {
|
||||||
console.log(refreshParams)
|
console.log(refreshParams);
|
||||||
return (target) => {
|
return (target) => {
|
||||||
console.log(target.prototype);
|
let targetName: string = getTargetName(target);
|
||||||
console.log(target.toString())
|
|
||||||
let targetName: string;
|
|
||||||
if (target.toString().includes(SelfServeType.materializedviewsbuilder)) {
|
|
||||||
targetName = SelfServeType.materializedviewsbuilder;
|
|
||||||
} else if (target instanceof Function) {
|
|
||||||
targetName = target.constructor.name;
|
|
||||||
}
|
|
||||||
addPropertyToMap(target.prototype, "root", targetName, "refreshParams", refreshParams);
|
addPropertyToMap(target.prototype, "root", targetName, "refreshParams", refreshParams);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getTargetName = (target: TFunction | object): string => {
|
||||||
|
const targetString: string = target.toString();
|
||||||
|
let targetName: string;
|
||||||
|
if (targetString.includes(SelfServeType.example)) {
|
||||||
|
targetName = SelfServeType.example;
|
||||||
|
} else if (targetString.includes(SelfServeType.graphapicompute)) {
|
||||||
|
targetName = SelfServeType.graphapicompute;
|
||||||
|
} else if (targetString.includes(SelfServeType.materializedviewsbuilder)) {
|
||||||
|
targetName = SelfServeType.materializedviewsbuilder;
|
||||||
|
} else if (targetString.includes(SelfServeType.sqlx)) {
|
||||||
|
targetName = SelfServeType.sqlx;
|
||||||
|
} else {
|
||||||
|
targetName = target.constructor.name;
|
||||||
|
}
|
||||||
|
return targetName;
|
||||||
|
};
|
||||||
|
@ -141,9 +141,9 @@ export const updateContextWithDecorator = <T extends keyof DecoratorProperties,
|
|||||||
descriptorName: keyof DecoratorProperties,
|
descriptorName: keyof DecoratorProperties,
|
||||||
descriptorValue: K,
|
descriptorValue: K,
|
||||||
): void => {
|
): void => {
|
||||||
console.log(context)
|
console.log(context);
|
||||||
console.log(propertyName)
|
console.log(propertyName);
|
||||||
console.log(className)
|
console.log(className);
|
||||||
if (!(context instanceof Map)) {
|
if (!(context instanceof Map)) {
|
||||||
throw new Error(`@IsDisplayable should be the first decorator for the class '${className}'.`);
|
throw new Error(`@IsDisplayable should be the first decorator for the class '${className}'.`);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user