mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
remove dup keys
This commit is contained in:
@@ -20,7 +20,6 @@ import Query from '../Types/Database/Query';
|
||||
import Select from '../Types/Database/Select';
|
||||
import Sort from '../Types/Database/Sort';
|
||||
import { LIMIT_PER_PROJECT } from 'Common/Types/Database/LimitMax';
|
||||
import Populate from '../Types/Database/RelationSelect';
|
||||
import PartialEntity from 'Common/Types/Database/PartialEntity';
|
||||
import { UserPermission } from 'Common/Types/Permission';
|
||||
import { IsBillingEnabled } from '../Config';
|
||||
@@ -298,7 +297,6 @@ export default class BaseAPI<
|
||||
req.body['select']
|
||||
) as Select<BaseModel>;
|
||||
|
||||
|
||||
sort = JSONFunctions.deserialize(
|
||||
req.body['sort']
|
||||
) as Sort<BaseModel>;
|
||||
@@ -364,12 +362,11 @@ export default class BaseAPI<
|
||||
const objectId: ObjectID = new ObjectID(req.params['id'] as string);
|
||||
await this.onBeforeGet(req, res);
|
||||
let select: Select<BaseModel> = {};
|
||||
|
||||
|
||||
if (req.body) {
|
||||
select = JSONFunctions.deserialize(
|
||||
req.body['select']
|
||||
) as Select<BaseModel>;
|
||||
|
||||
}
|
||||
|
||||
const item: BaseModel | null = await this.service.findOneById({
|
||||
|
||||
@@ -259,7 +259,6 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
const item: StatusPage | null =
|
||||
await this.service.findOneById({
|
||||
id: objectId,
|
||||
@@ -487,7 +486,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
currentMonitorStatusId: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
sort: {
|
||||
order: SortOrder.Ascending,
|
||||
},
|
||||
@@ -584,7 +583,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
sort: {
|
||||
createdAt: SortOrder.Ascending,
|
||||
},
|
||||
|
||||
|
||||
skip: 0,
|
||||
limit: LIMIT_PER_PROJECT,
|
||||
props: {
|
||||
@@ -649,7 +648,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
isAcknowledgedState: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
sort: {
|
||||
createdAt: SortOrder.Descending, // new note first
|
||||
},
|
||||
@@ -721,7 +720,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
sort: {
|
||||
createdAt: SortOrder.Ascending,
|
||||
},
|
||||
|
||||
|
||||
skip: 0,
|
||||
limit: LIMIT_PER_PROJECT,
|
||||
props: {
|
||||
@@ -759,7 +758,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
sort: {
|
||||
createdAt: SortOrder.Ascending,
|
||||
},
|
||||
|
||||
|
||||
skip: 0,
|
||||
limit: LIMIT_PER_PROJECT,
|
||||
props: {
|
||||
@@ -833,7 +832,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
isOngoingState: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
sort: {
|
||||
createdAt: SortOrder.Descending, // new note first
|
||||
},
|
||||
@@ -1220,7 +1219,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
currentMonitorStatusId: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
skip: 0,
|
||||
limit: LIMIT_PER_PROJECT,
|
||||
props: {
|
||||
@@ -1272,7 +1271,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
sort: {
|
||||
startsAt: SortOrder.Descending,
|
||||
},
|
||||
|
||||
|
||||
skip: 0,
|
||||
limit: LIMIT_PER_PROJECT,
|
||||
props: {
|
||||
@@ -1379,7 +1378,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
isOngoingState: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
sort: {
|
||||
createdAt: SortOrder.Descending, // new note first
|
||||
},
|
||||
@@ -1501,7 +1500,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
currentMonitorStatusId: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
skip: 0,
|
||||
limit: LIMIT_PER_PROJECT,
|
||||
props: {
|
||||
@@ -1572,7 +1571,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
currentMonitorStatusId: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
skip: 0,
|
||||
limit: LIMIT_PER_PROJECT,
|
||||
props: {
|
||||
@@ -1631,7 +1630,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
_id: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
skip: 0,
|
||||
limit: LIMIT_PER_PROJECT,
|
||||
props: {
|
||||
@@ -1668,7 +1667,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
sort: {
|
||||
createdAt: SortOrder.Descending,
|
||||
},
|
||||
|
||||
|
||||
skip: 0,
|
||||
limit: LIMIT_PER_PROJECT,
|
||||
props: {
|
||||
@@ -1732,7 +1731,7 @@ export default class StatusPageAPI extends BaseAPI<
|
||||
sort: {
|
||||
createdAt: SortOrder.Descending, // new note first
|
||||
},
|
||||
|
||||
|
||||
skip: 0,
|
||||
limit: LIMIT_PER_PROJECT,
|
||||
props: {
|
||||
|
||||
@@ -92,7 +92,7 @@ export default class AccessTokenService {
|
||||
_id: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
limit: LIMIT_MAX,
|
||||
skip: 0,
|
||||
props: {
|
||||
@@ -251,12 +251,11 @@ export default class AccessTokenService {
|
||||
},
|
||||
select: {
|
||||
permission: true,
|
||||
labels: true,
|
||||
labels: {
|
||||
_id: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
limit: LIMIT_MAX,
|
||||
skip: 0,
|
||||
props: {
|
||||
|
||||
@@ -39,7 +39,7 @@ export class Service extends DatabaseService<Model> {
|
||||
domain: true,
|
||||
domainVerificationText: true,
|
||||
},
|
||||
|
||||
|
||||
limit: 1,
|
||||
skip: 0,
|
||||
props: {
|
||||
|
||||
@@ -178,7 +178,7 @@ export class Service extends DatabaseService<Model> {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
|
||||
@@ -55,7 +55,7 @@ export class Service extends DatabaseService<Model> {
|
||||
...deleteBy.query,
|
||||
isAddedtoGreenlock: true,
|
||||
},
|
||||
|
||||
|
||||
skip: 0,
|
||||
limit: LIMIT_MAX,
|
||||
select: { fullDomain: true },
|
||||
|
||||
@@ -137,7 +137,7 @@ export class Service extends DatabaseService<Model> {
|
||||
query: {
|
||||
statusPageId: resource?.statusPageId!,
|
||||
},
|
||||
|
||||
|
||||
limit: LIMIT_MAX,
|
||||
skip: 0,
|
||||
props: {
|
||||
|
||||
@@ -136,7 +136,7 @@ export class Service extends DatabaseService<Model> {
|
||||
query: {
|
||||
statusPageId: group?.statusPageId!,
|
||||
},
|
||||
|
||||
|
||||
limit: LIMIT_MAX,
|
||||
skip: 0,
|
||||
props: {
|
||||
|
||||
@@ -137,7 +137,7 @@ export class Service extends DatabaseService<Model> {
|
||||
query: {
|
||||
statusPageId: resource?.statusPageId!,
|
||||
},
|
||||
|
||||
|
||||
limit: LIMIT_MAX,
|
||||
skip: 0,
|
||||
props: {
|
||||
|
||||
@@ -154,7 +154,7 @@ export class Service extends DatabaseService<Model> {
|
||||
statusPageGroupId:
|
||||
resource?.statusPageGroupId || QueryHelper.isNull(),
|
||||
},
|
||||
|
||||
|
||||
limit: LIMIT_MAX,
|
||||
skip: 0,
|
||||
props: {
|
||||
|
||||
@@ -157,7 +157,7 @@ export class TeamMemberService extends DatabaseService<TeamMember> {
|
||||
},
|
||||
limit: LIMIT_MAX,
|
||||
skip: 0,
|
||||
|
||||
|
||||
props: {
|
||||
isRoot: true,
|
||||
},
|
||||
@@ -284,7 +284,7 @@ export class TeamMemberService extends DatabaseService<TeamMember> {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
skip: 0,
|
||||
limit: LIMIT_MAX,
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ export class Service extends DatabaseService<Model> {
|
||||
name: true,
|
||||
isTeamEditable: true,
|
||||
},
|
||||
|
||||
|
||||
props: updateBy.props,
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@ export class Service extends DatabaseService<Model> {
|
||||
name: true,
|
||||
isTeamDeleteable: true,
|
||||
},
|
||||
|
||||
|
||||
props: deleteBy.props,
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,10 @@ export type SelectPropertyOptions<Property> = Property extends DatabaseProperty
|
||||
? boolean
|
||||
: Property extends JSONObject
|
||||
? boolean
|
||||
: FindOptionsSelectProperty<Property> | FindOptionsRelations<Property> | boolean;
|
||||
:
|
||||
| FindOptionsSelectProperty<Property>
|
||||
| FindOptionsRelations<Property>
|
||||
| boolean;
|
||||
|
||||
/**
|
||||
* Select find options.
|
||||
|
||||
@@ -47,7 +47,7 @@ export interface CheckReadPermissionType<TBaseModel extends BaseModel> {
|
||||
|
||||
export default class ModelPermission {
|
||||
public static async checkDeletePermission<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): TBaseModel },
|
||||
modelType: { new (): TBaseModel },
|
||||
query: Query<TBaseModel>,
|
||||
props: DatabaseCommonInteractionProps
|
||||
): Promise<Query<TBaseModel>> {
|
||||
@@ -69,7 +69,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
public static async checkUpdatePermissions<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): TBaseModel },
|
||||
modelType: { new (): TBaseModel },
|
||||
query: Query<TBaseModel>,
|
||||
data: QueryDeepPartialEntity<TBaseModel>,
|
||||
props: DatabaseCommonInteractionProps
|
||||
@@ -100,7 +100,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
public static checkCreatePermissions<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): TBaseModel },
|
||||
modelType: { new (): TBaseModel },
|
||||
data: TBaseModel,
|
||||
props: DatabaseCommonInteractionProps
|
||||
): void {
|
||||
@@ -124,7 +124,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
private static checkDataColumnPermissions<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): TBaseModel },
|
||||
modelType: { new (): TBaseModel },
|
||||
data: TBaseModel,
|
||||
props: DatabaseCommonInteractionProps,
|
||||
requestType: DatabaseRequestType
|
||||
@@ -182,7 +182,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
public static async checkReadPermission<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): TBaseModel },
|
||||
modelType: { new (): TBaseModel },
|
||||
query: Query<TBaseModel>,
|
||||
select: Select<TBaseModel> | null,
|
||||
props: DatabaseCommonInteractionProps
|
||||
@@ -248,7 +248,7 @@ export default class ModelPermission {
|
||||
tableColumnMetadata.modelType &&
|
||||
(tableColumnMetadata.type === TableColumnType.Entity ||
|
||||
tableColumnMetadata.type ===
|
||||
TableColumnType.EntityArray)
|
||||
TableColumnType.EntityArray)
|
||||
) {
|
||||
const accessControlIds: Array<ObjectID> =
|
||||
this.getAccessControlIdsForQuery(
|
||||
@@ -298,7 +298,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
private static serializeQuery<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): TBaseModel },
|
||||
modelType: { new (): TBaseModel },
|
||||
query: Query<TBaseModel>
|
||||
): Query<TBaseModel> {
|
||||
const model: BaseModel = new modelType();
|
||||
@@ -464,7 +464,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
private static getAccessControlIdsForQuery<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): BaseModel },
|
||||
modelType: { new (): BaseModel },
|
||||
query: Query<TBaseModel>,
|
||||
select: Select<TBaseModel> | null,
|
||||
props: DatabaseCommonInteractionProps
|
||||
@@ -511,7 +511,7 @@ export default class ModelPermission {
|
||||
for (const accessControlPermission of accessControlPermissions) {
|
||||
if (
|
||||
accessControlPermission.permission ===
|
||||
readPermissions &&
|
||||
readPermissions &&
|
||||
accessControlPermission.labelIds.length > 0
|
||||
) {
|
||||
labelIds = [
|
||||
@@ -528,7 +528,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
private static sanitizeSelect<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): BaseModel },
|
||||
modelType: { new (): BaseModel },
|
||||
select: Select<TBaseModel>
|
||||
): {
|
||||
select: Select<TBaseModel>;
|
||||
@@ -541,7 +541,10 @@ export default class ModelPermission {
|
||||
if (model.isEntityColumn(key)) {
|
||||
if (typeof (select as JSONObject)[key] === Typeof.Object) {
|
||||
(relationSelect as any)[key] = true;
|
||||
(select as any)[key] = { ...(select as any)[key], _id: true };
|
||||
(select as any)[key] = {
|
||||
...(select as any)[key],
|
||||
_id: true,
|
||||
};
|
||||
} else {
|
||||
// if you want to relationSelect the whole object, you only do the id because of security.
|
||||
(select as any)[key] = {
|
||||
@@ -557,7 +560,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
private static checkRelationQueryPermission<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): BaseModel },
|
||||
modelType: { new (): BaseModel },
|
||||
select: Select<TBaseModel>,
|
||||
props: DatabaseCommonInteractionProps
|
||||
): void {
|
||||
@@ -579,10 +582,10 @@ export default class ModelPermission {
|
||||
if (!tableColumnMetadata.modelType) {
|
||||
throw new BadDataException(
|
||||
'Select not supported on ' +
|
||||
key +
|
||||
' of ' +
|
||||
model.singularName +
|
||||
' because this column modelType is not found.'
|
||||
key +
|
||||
' of ' +
|
||||
model.singularName +
|
||||
' because this column modelType is not found.'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -622,7 +625,9 @@ export default class ModelPermission {
|
||||
);
|
||||
}
|
||||
|
||||
if (getRelatedTableColumnMetadata.canReadOnRelationQuery) {
|
||||
if (
|
||||
getRelatedTableColumnMetadata.canReadOnRelationQuery
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -648,8 +653,10 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
throw new NotAuthorizedException(
|
||||
`You do not have permissions to read ${relatedModel.singularName
|
||||
} on ${model.singularName
|
||||
`You do not have permissions to read ${
|
||||
relatedModel.singularName
|
||||
} on ${
|
||||
model.singularName
|
||||
}. You need one of these permissions: ${PermissionHelper.getPermissionTitles(
|
||||
readPermissions
|
||||
).join(', ')}`
|
||||
@@ -675,7 +682,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
private static checkQueryPermission<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): BaseModel },
|
||||
modelType: { new (): BaseModel },
|
||||
query: Query<TBaseModel>,
|
||||
props: DatabaseCommonInteractionProps
|
||||
): void {
|
||||
@@ -722,7 +729,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
private static async addTenantScopeToQuery<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): TBaseModel },
|
||||
modelType: { new (): TBaseModel },
|
||||
query: Query<TBaseModel>,
|
||||
select: Select<TBaseModel> | null,
|
||||
props: DatabaseCommonInteractionProps
|
||||
@@ -799,7 +806,7 @@ export default class ModelPermission {
|
||||
if (queries.length === 0) {
|
||||
throw new NotAuthorizedException(
|
||||
lastException?.message ||
|
||||
'Does not have permission to read ' + model.singularName
|
||||
'Does not have permission to read ' + model.singularName
|
||||
);
|
||||
}
|
||||
|
||||
@@ -810,7 +817,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
private static getModelColumnsByPermissions<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): TBaseModel },
|
||||
modelType: { new (): TBaseModel },
|
||||
userPermissions: Array<UserPermission>,
|
||||
requestType: DatabaseRequestType
|
||||
): Columns {
|
||||
@@ -860,7 +867,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
private static checkSelectPermission<TBaseModel extends BaseModel>(
|
||||
modelType: { new(): BaseModel },
|
||||
modelType: { new (): BaseModel },
|
||||
select: Select<TBaseModel>,
|
||||
props: DatabaseCommonInteractionProps
|
||||
): void {
|
||||
@@ -889,7 +896,8 @@ export default class ModelPermission {
|
||||
if (!canReadOnTheseColumns.columns.includes(key)) {
|
||||
if (!tableColumns.includes(key)) {
|
||||
throw new BadDataException(
|
||||
`Invalid select clause. Cannnot select on "${key}". This column does not exist on ${model.singularName
|
||||
`Invalid select clause. Cannnot select on "${key}". This column does not exist on ${
|
||||
model.singularName
|
||||
}. Here are the columns you can select on instead: ${tableColumns.join(
|
||||
', '
|
||||
)}`
|
||||
@@ -909,7 +917,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
private static getModelPermissions(
|
||||
modelType: { new(): BaseModel },
|
||||
modelType: { new (): BaseModel },
|
||||
type: DatabaseRequestType
|
||||
): Array<Permission> {
|
||||
let modelPermissions: Array<Permission> = [];
|
||||
@@ -935,7 +943,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
private static isPublicPermissionAllowed(
|
||||
modelType: { new(): BaseModel },
|
||||
modelType: { new (): BaseModel },
|
||||
type: DatabaseRequestType
|
||||
): boolean {
|
||||
let isPublicAllowed: boolean = false;
|
||||
@@ -946,7 +954,7 @@ export default class ModelPermission {
|
||||
}
|
||||
|
||||
public static checkIfUserIsLoggedIn(
|
||||
modelType: { new(): BaseModel },
|
||||
modelType: { new (): BaseModel },
|
||||
props: DatabaseCommonInteractionProps,
|
||||
type: DatabaseRequestType
|
||||
): void {
|
||||
@@ -960,14 +968,15 @@ export default class ModelPermission {
|
||||
|
||||
// this means the record is not publicly createable and the user is not logged in.
|
||||
throw new NotAuthenticatedException(
|
||||
`A user should be logged in to ${type} record of ${new modelType().singularName
|
||||
`A user should be logged in to ${type} record of ${
|
||||
new modelType().singularName
|
||||
}.`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private static checkModelLevelPermissions(
|
||||
modelType: { new(): BaseModel },
|
||||
modelType: { new (): BaseModel },
|
||||
props: DatabaseCommonInteractionProps,
|
||||
type: DatabaseRequestType
|
||||
): void {
|
||||
@@ -990,7 +999,8 @@ export default class ModelPermission {
|
||||
)
|
||||
) {
|
||||
throw new NotAuthorizedException(
|
||||
`You do not have permissions to ${type} ${new modelType().singularName
|
||||
`You do not have permissions to ${type} ${
|
||||
new modelType().singularName
|
||||
}. You need one of these permissions: ${PermissionHelper.getPermissionTitles(
|
||||
modelPermissions
|
||||
).join(', ')}`
|
||||
@@ -1025,8 +1035,8 @@ export default class ModelPermission {
|
||||
) {
|
||||
throw new PaymentRequiredException(
|
||||
'Please upgrade your plan to ' +
|
||||
model.createBillingPlan +
|
||||
' to access this feature'
|
||||
model.createBillingPlan +
|
||||
' to access this feature'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1044,8 +1054,8 @@ export default class ModelPermission {
|
||||
) {
|
||||
throw new PaymentRequiredException(
|
||||
'Please upgrade your plan to ' +
|
||||
model.createBillingPlan +
|
||||
' to access this feature'
|
||||
model.createBillingPlan +
|
||||
' to access this feature'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1063,8 +1073,8 @@ export default class ModelPermission {
|
||||
) {
|
||||
throw new PaymentRequiredException(
|
||||
'Please upgrade your plan to ' +
|
||||
model.createBillingPlan +
|
||||
' to access this feature'
|
||||
model.createBillingPlan +
|
||||
' to access this feature'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1079,8 +1089,8 @@ export default class ModelPermission {
|
||||
) {
|
||||
throw new PaymentRequiredException(
|
||||
'Please upgrade your plan to ' +
|
||||
model.createBillingPlan +
|
||||
' to access this feature'
|
||||
model.createBillingPlan +
|
||||
' to access this feature'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ const CustomFieldsDetail: FunctionComponent<ComponentProps> = (
|
||||
type: true,
|
||||
description: true,
|
||||
} as any,
|
||||
{},
|
||||
{}
|
||||
);
|
||||
|
||||
const item: BaseModel | null = await ModelAPI.getItem<BaseModel>(
|
||||
|
||||
@@ -229,8 +229,7 @@ const ModelForm: Function = <TBaseModel extends BaseModel>(
|
||||
let item: BaseModel | null = await ModelAPI.getItem(
|
||||
props.modelType,
|
||||
props.modelIdToEdit,
|
||||
{ ...getSelectFields(),
|
||||
...getRelationSelect()}
|
||||
{ ...getSelectFields(), ...getRelationSelect() }
|
||||
);
|
||||
|
||||
if (!(item instanceof BaseModel) && item) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import Detail from '../Detail/Detail';
|
||||
import API from '../../Utils/API/API';
|
||||
|
||||
export interface ComponentProps<TBaseModel extends BaseModel> {
|
||||
modelType: { new(): TBaseModel };
|
||||
modelType: { new (): TBaseModel };
|
||||
id: string;
|
||||
fields: Array<Field<TBaseModel>>;
|
||||
onLoadingChange?: undefined | ((isLoading: boolean) => void);
|
||||
@@ -114,12 +114,12 @@ const ModelDetail: Function = <TBaseModel extends BaseModel>(
|
||||
...field,
|
||||
getElement: field.getElement
|
||||
? (item: JSONObject): ReactElement => {
|
||||
return field.getElement!(
|
||||
item,
|
||||
onBeforeFetchData,
|
||||
fetchItem
|
||||
);
|
||||
}
|
||||
return field.getElement!(
|
||||
item,
|
||||
onBeforeFetchData,
|
||||
fetchItem
|
||||
);
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
@@ -128,12 +128,12 @@ const ModelDetail: Function = <TBaseModel extends BaseModel>(
|
||||
...field,
|
||||
getElement: field.getElement
|
||||
? (item: JSONObject): ReactElement => {
|
||||
return field.getElement!(
|
||||
item,
|
||||
onBeforeFetchData,
|
||||
fetchItem
|
||||
);
|
||||
}
|
||||
return field.getElement!(
|
||||
item,
|
||||
onBeforeFetchData,
|
||||
fetchItem
|
||||
);
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
@@ -164,7 +164,7 @@ const ModelDetail: Function = <TBaseModel extends BaseModel>(
|
||||
props.modelId,
|
||||
{
|
||||
...getSelectFields(),
|
||||
...getRelationSelect()
|
||||
...getRelationSelect(),
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ const ModelList: Function = <TBaseModel extends BaseModel>(
|
||||
0,
|
||||
props.select,
|
||||
{},
|
||||
|
||||
|
||||
props.fetchRequestOptions
|
||||
);
|
||||
}
|
||||
|
||||
@@ -69,14 +69,14 @@ export enum ShowTableAs {
|
||||
}
|
||||
|
||||
export interface ComponentProps<TBaseModel extends BaseModel> {
|
||||
modelType: { new(): TBaseModel };
|
||||
modelType: { new (): TBaseModel };
|
||||
id: string;
|
||||
onFetchInit?:
|
||||
| undefined
|
||||
| ((pageNumber: number, itemsOnPage: number) => void);
|
||||
| undefined
|
||||
| ((pageNumber: number, itemsOnPage: number) => void);
|
||||
onFetchSuccess?:
|
||||
| undefined
|
||||
| ((data: Array<TBaseModel>, totalCount: number) => void);
|
||||
| undefined
|
||||
| ((data: Array<TBaseModel>, totalCount: number) => void);
|
||||
cardProps?: CardComponentProps | undefined;
|
||||
columns: Columns<TBaseModel>;
|
||||
selectMoreFields?: Select<TBaseModel>;
|
||||
@@ -212,8 +212,8 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
alignItem: column.alignItem,
|
||||
getElement: column.getElement
|
||||
? (item: JSONObject): ReactElement => {
|
||||
return column.getElement!(item, onBeforeFetchData);
|
||||
}
|
||||
return column.getElement!(item, onBeforeFetchData);
|
||||
}
|
||||
: undefined,
|
||||
});
|
||||
|
||||
@@ -444,8 +444,7 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
[column.filterDropdownField.label]: true,
|
||||
[column.filterDropdownField.value]: true,
|
||||
},
|
||||
{},
|
||||
|
||||
{}
|
||||
);
|
||||
|
||||
classicColumn.filterDropdownOptions = [];
|
||||
@@ -494,8 +493,6 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
setOnBeforeFetchData(jobject);
|
||||
}
|
||||
|
||||
|
||||
|
||||
try {
|
||||
const listResult: ListResult<TBaseModel> =
|
||||
await ModelAPI.getList<TBaseModel>(
|
||||
@@ -508,12 +505,12 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
(currentPageNumber - 1) * itemsOnPage,
|
||||
{
|
||||
...getSelect(),
|
||||
...getRelationSelect()
|
||||
},
|
||||
...getRelationSelect(),
|
||||
},
|
||||
sortBy
|
||||
? {
|
||||
[sortBy as any]: sortOrder,
|
||||
}
|
||||
[sortBy as any]: sortOrder,
|
||||
}
|
||||
: {},
|
||||
props.fetchRequestOptions
|
||||
);
|
||||
@@ -599,7 +596,9 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
name: true,
|
||||
};
|
||||
} else if (key && model.isEntityColumn(key)) {
|
||||
(relationSelect as JSONObject)[key] = (column.field as any)[key];
|
||||
(relationSelect as JSONObject)[key] = (column.field as any)[
|
||||
key
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,8 +629,9 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
showTableAs !== ShowTableAs.OrderedStatesList
|
||||
) {
|
||||
headerbuttons.push({
|
||||
title: `${props.createVerb || 'Create'} ${props.singularName || model.singularName
|
||||
}`,
|
||||
title: `${props.createVerb || 'Create'} ${
|
||||
props.singularName || model.singularName
|
||||
}`,
|
||||
buttonStyle: ButtonStyleType.NORMAL,
|
||||
className:
|
||||
props.showFilterButton || props.showRefreshButton
|
||||
@@ -1049,9 +1049,9 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
|
||||
let getTitleElement:
|
||||
| ((
|
||||
item: JSONObject,
|
||||
onBeforeFetchData?: JSONObject | undefined
|
||||
) => ReactElement)
|
||||
item: JSONObject,
|
||||
onBeforeFetchData?: JSONObject | undefined
|
||||
) => ReactElement)
|
||||
| undefined = undefined;
|
||||
let getDescriptionElement:
|
||||
| ((item: JSONObject) => ReactElement)
|
||||
@@ -1095,10 +1095,10 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
onCreateNewItem={
|
||||
props.isCreateable
|
||||
? (order: number) => {
|
||||
setOrderedStatesListNewItemOrder(order);
|
||||
setModalType(ModalType.Create);
|
||||
setShowModal(true);
|
||||
}
|
||||
setOrderedStatesListNewItemOrder(order);
|
||||
setModalType(ModalType.Create);
|
||||
setShowModal(true);
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
singularLabel={
|
||||
@@ -1165,8 +1165,9 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
}}
|
||||
>
|
||||
<Pill
|
||||
text={`${new props.modelType().readBillingPlan
|
||||
} Plan`}
|
||||
text={`${
|
||||
new props.modelType().readBillingPlan
|
||||
} Plan`}
|
||||
color={Yellow}
|
||||
/>
|
||||
</span>
|
||||
@@ -1266,17 +1267,20 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
<ModelFormModal<TBaseModel>
|
||||
title={
|
||||
modalType === ModalType.Create
|
||||
? `${props.createVerb || 'Create'} New ${props.singularName || model.singularName
|
||||
}`
|
||||
? `${props.createVerb || 'Create'} New ${
|
||||
props.singularName || model.singularName
|
||||
}`
|
||||
: `Edit ${props.singularName || model.singularName}`
|
||||
}
|
||||
modalWidth={props.createEditModalWidth}
|
||||
name={
|
||||
modalType === ModalType.Create
|
||||
? `${props.name} > ${props.createVerb || 'Create'
|
||||
} New ${props.singularName || model.singularName}`
|
||||
: `${props.name} > Edit ${props.singularName || model.singularName
|
||||
}`
|
||||
? `${props.name} > ${
|
||||
props.createVerb || 'Create'
|
||||
} New ${props.singularName || model.singularName}`
|
||||
: `${props.name} > Edit ${
|
||||
props.singularName || model.singularName
|
||||
}`
|
||||
}
|
||||
initialValues={
|
||||
modalType === ModalType.Create
|
||||
@@ -1288,8 +1292,9 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
}}
|
||||
submitButtonText={
|
||||
modalType === ModalType.Create
|
||||
? `${props.createVerb || 'Create'} ${props.singularName || model.singularName
|
||||
}`
|
||||
? `${props.createVerb || 'Create'} ${
|
||||
props.singularName || model.singularName
|
||||
}`
|
||||
: `Save Changes`
|
||||
}
|
||||
onSuccess={async (item: TBaseModel) => {
|
||||
@@ -1384,8 +1389,9 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
|
||||
|
||||
{showViewIdModal && (
|
||||
<ConfirmModal
|
||||
title={`${props.singularName || model.singularName || ''
|
||||
} ID`}
|
||||
title={`${
|
||||
props.singularName || model.singularName || ''
|
||||
} ID`}
|
||||
description={
|
||||
<div>
|
||||
<span>
|
||||
|
||||
@@ -246,7 +246,7 @@ const App: FunctionComponent = () => {
|
||||
paymentProviderPlanId: true,
|
||||
},
|
||||
{},
|
||||
|
||||
|
||||
{
|
||||
isMultiTenantRequest: true,
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ const MonitorStepsElement: FunctionComponent<ComponentProps> = (
|
||||
isOperationalState: true,
|
||||
isOfflineState: true,
|
||||
},
|
||||
|
||||
|
||||
{}
|
||||
);
|
||||
|
||||
@@ -87,8 +87,7 @@ const MonitorStepsElement: FunctionComponent<ComponentProps> = (
|
||||
},
|
||||
{
|
||||
order: SortOrder.Ascending,
|
||||
},
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
if (incidentSeverityList.data) {
|
||||
|
||||
@@ -59,8 +59,7 @@ const MonitorStepsElement: FunctionComponent<ComponentProps> = (
|
||||
color: true,
|
||||
isOperationalState: true,
|
||||
},
|
||||
{},
|
||||
|
||||
{}
|
||||
);
|
||||
|
||||
if (monitorStatusList.data) {
|
||||
@@ -82,8 +81,7 @@ const MonitorStepsElement: FunctionComponent<ComponentProps> = (
|
||||
name: true,
|
||||
color: true,
|
||||
},
|
||||
{},
|
||||
|
||||
{}
|
||||
);
|
||||
|
||||
if (incidentSeverityList.data) {
|
||||
|
||||
@@ -120,8 +120,7 @@ const ChangeScheduledMaintenanceState: FunctionComponent<ComponentProps> = (
|
||||
isOngoingState: true,
|
||||
isScheduledState: true,
|
||||
},
|
||||
{},
|
||||
|
||||
{}
|
||||
);
|
||||
|
||||
let stateId: ObjectID | null = null;
|
||||
|
||||
@@ -162,8 +162,7 @@ const IncidentView: FunctionComponent<PageComponentProps> = (
|
||||
isAcknowledgedState: true,
|
||||
},
|
||||
},
|
||||
{},
|
||||
|
||||
{}
|
||||
);
|
||||
|
||||
return incidentTimelines;
|
||||
|
||||
@@ -70,7 +70,7 @@ const MonitorView: FunctionComponent<PageComponentProps> = (
|
||||
},
|
||||
{
|
||||
createdAt: SortOrder.Ascending,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
setData(monitorStatus.data);
|
||||
|
||||
@@ -76,7 +76,7 @@ const MonitorProbes: FunctionComponent<PageComponentProps> = (
|
||||
_id: true,
|
||||
},
|
||||
{},
|
||||
{},
|
||||
{}
|
||||
);
|
||||
|
||||
const globalProbeList: ListResult<Probe> = await ModelAPI.getList(
|
||||
|
||||
@@ -216,7 +216,7 @@ const ScheduledMaintenanceView: FunctionComponent<PageComponentProps> = (
|
||||
isScheduledState: true,
|
||||
},
|
||||
},
|
||||
{},
|
||||
{}
|
||||
);
|
||||
|
||||
return scheduledMaintenanceTimelines;
|
||||
|
||||
@@ -22,9 +22,7 @@ export default class ProjectUser {
|
||||
},
|
||||
},
|
||||
{},
|
||||
{
|
||||
|
||||
}
|
||||
{}
|
||||
);
|
||||
|
||||
return teamMembers.data.map((teamMember: TeamMember) => {
|
||||
|
||||
@@ -280,7 +280,10 @@ class User extends UserModel {
|
||||
|
||||
update: [Permission.CurrentUser],
|
||||
})
|
||||
@TableColumn({ type: TableColumnType.ObjectID, canReadOnRelationQuery: true })
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
canReadOnRelationQuery: true,
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: true,
|
||||
|
||||
@@ -48,7 +48,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
for (const incident of incidents) {
|
||||
@@ -147,7 +146,6 @@ RunCron(
|
||||
secure: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
for (const statuspage of statusPages) {
|
||||
|
||||
@@ -40,7 +40,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
for (const incident of incidents) {
|
||||
|
||||
@@ -114,7 +114,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -88,7 +88,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
for (const incidentOwnerUser of incidentOwnerUsers) {
|
||||
|
||||
@@ -47,7 +47,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
for (const incidentStateTimeline of incidentStateTimelines) {
|
||||
@@ -68,7 +67,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
if (!incidentWithSeverity) {
|
||||
|
||||
@@ -73,7 +73,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@@ -176,7 +175,6 @@ RunCron(
|
||||
secure: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
for (const statuspage of statusPages) {
|
||||
|
||||
@@ -48,7 +48,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
for (const incidentStateTimeline of incidentStateTimelines) {
|
||||
@@ -93,7 +92,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
@@ -185,7 +183,6 @@ RunCron(
|
||||
secure: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
for (const statuspage of statusPages) {
|
||||
|
||||
@@ -37,7 +37,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
for (const monitor of monitors) {
|
||||
|
||||
@@ -88,7 +88,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
for (const monitorOwnerUser of monitorOwnerUsers) {
|
||||
@@ -147,7 +146,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
if (!monitor) {
|
||||
|
||||
@@ -47,7 +47,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
for (const monitorStatusTimeline of monitorStatusTimelines) {
|
||||
|
||||
@@ -47,7 +47,6 @@ RunCron(
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
for (const scheduledMaintenanceStateTimeline of scheduledMaintenanceStateTimelines) {
|
||||
|
||||
@@ -31,7 +31,6 @@ RunCron(
|
||||
_id: true,
|
||||
title: true,
|
||||
description: true,
|
||||
statusPages: true,
|
||||
projectId: true,
|
||||
statusPages: {
|
||||
_id: true,
|
||||
|
||||
Reference in New Issue
Block a user