mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-23 07:42:10 +00:00
add user emails for notifications.
This commit is contained in:
parent
b8ee827068
commit
6a64b8658a
@ -94,6 +94,8 @@ enum IconProp {
|
||||
TransparentCube = 'TransparentCube',
|
||||
Logs = 'Logs',
|
||||
Bolt = 'Bolt',
|
||||
BarsArrowUp = 'BarsArrowUp',
|
||||
BarsArrowDown = 'BarsArrowDown',
|
||||
}
|
||||
|
||||
export default IconProp;
|
||||
|
@ -421,6 +421,20 @@ const Icon: FunctionComponent<ComponentProps> = ({
|
||||
d="M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418"
|
||||
/>
|
||||
);
|
||||
} else if (icon === IconProp.BarsArrowDown) {
|
||||
return getSvgWrapper(
|
||||
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0l-3.75-3.75M17.25 21L21 17.25" />
|
||||
|
||||
|
||||
);
|
||||
} else if (icon === IconProp.BarsArrowUp) {
|
||||
return getSvgWrapper(
|
||||
|
||||
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M3 4.5h14.25M3 9h9.75M3 13.5h9.75m4.5-4.5v12m0 0l-3.75-3.75M17.25 21L21 17.25" />
|
||||
|
||||
);
|
||||
} else if (icon === IconProp.CheckCircle) {
|
||||
return getSvgWrapper(
|
||||
<path
|
||||
|
@ -48,7 +48,7 @@ const OnCallDutyPage: FunctionComponent<PageComponentProps> = (
|
||||
id="on-call-duty-table"
|
||||
isDeleteable={false}
|
||||
name="On Call > Policies"
|
||||
isEditable={true}
|
||||
isEditable={false}
|
||||
isCreateable={true}
|
||||
isViewable={true}
|
||||
cardProps={{
|
||||
|
@ -30,26 +30,40 @@ const DashboardSideMenu: FunctionComponent<ComponentProps> = (
|
||||
/>
|
||||
|
||||
<SideMenuItem
|
||||
link={{
|
||||
title: 'Escalation Rules',
|
||||
to: RouteUtil.populateRouteParams(
|
||||
RouteMap[
|
||||
PageMap.ON_CALL_DUTY_POLICY_VIEW_ESCALATION
|
||||
] as Route,
|
||||
{ modelId: props.modelId }
|
||||
),
|
||||
}}
|
||||
icon={IconProp.BarsArrowDown}
|
||||
/>
|
||||
|
||||
|
||||
</SideMenuSection>
|
||||
|
||||
<SideMenuSection title="Advanced">
|
||||
<SideMenuItem
|
||||
link={{
|
||||
title: 'Execution Logs',
|
||||
to: RouteUtil.populateRouteParams(
|
||||
RouteMap[
|
||||
PageMap.ON_CALL_DUTY_POLICY_VIEW_EXECUTION_LOGS
|
||||
PageMap.ON_CALL_DUTY_POLICY_VIEW_EXECUTION_LOGS
|
||||
] as Route,
|
||||
{ modelId: props.modelId }
|
||||
),
|
||||
}}
|
||||
icon={IconProp.Logs}
|
||||
/>
|
||||
</SideMenuSection>
|
||||
|
||||
<SideMenuSection title="Advanced">
|
||||
<SideMenuItem
|
||||
link={{
|
||||
title: 'Delete Policy',
|
||||
to: RouteUtil.populateRouteParams(
|
||||
RouteMap[
|
||||
PageMap.ON_CALL_DUTY_POLICY_VIEW_DELETE
|
||||
PageMap.ON_CALL_DUTY_POLICY_VIEW_DELETE
|
||||
] as Route,
|
||||
{ modelId: props.modelId }
|
||||
),
|
||||
|
@ -267,23 +267,23 @@ const RouteMap: Dictionary<Route> = {
|
||||
),
|
||||
|
||||
[PageMap.ON_CALL_DUTY_POLICY_VIEW]: new Route(
|
||||
`/dashboard/${RouteParams.ProjectID}/on-call-duty/policies${RouteParams.ModelID}`
|
||||
`/dashboard/${RouteParams.ProjectID}/on-call-duty/policies/${RouteParams.ModelID}`
|
||||
),
|
||||
|
||||
[PageMap.ON_CALL_DUTY_POLICY_VIEW_DELETE]: new Route(
|
||||
`/dashboard/${RouteParams.ProjectID}/on-call-duty/policies${RouteParams.ModelID}/delete`
|
||||
`/dashboard/${RouteParams.ProjectID}/on-call-duty/policies/${RouteParams.ModelID}/delete`
|
||||
),
|
||||
|
||||
[PageMap.ON_CALL_DUTY_POLICY_VIEW_EXECUTION_LOGS]: new Route(
|
||||
`/dashboard/${RouteParams.ProjectID}/on-call-duty/policies${RouteParams.ModelID}/execution-logs/${RouteParams.SubModelID}`
|
||||
`/dashboard/${RouteParams.ProjectID}/on-call-duty/policies/${RouteParams.ModelID}/execution-logs/${RouteParams.SubModelID}`
|
||||
),
|
||||
|
||||
[PageMap.ON_CALL_DUTY_POLICY_VIEW_EXECUTION_LOG_VIEW]: new Route(
|
||||
`/dashboard/${RouteParams.ProjectID}/on-call-duty/policies${RouteParams.ModelID}/execution-logs/`
|
||||
`/dashboard/${RouteParams.ProjectID}/on-call-duty/policies/${RouteParams.ModelID}/execution-logs/`
|
||||
),
|
||||
|
||||
[PageMap.ON_CALL_DUTY_POLICY_VIEW_ESCALATION]: new Route(
|
||||
`/dashboard/${RouteParams.ProjectID}/on-call-duty/policies${RouteParams.ModelID}/escalations`
|
||||
`/dashboard/${RouteParams.ProjectID}/on-call-duty/policies/${RouteParams.ModelID}/escalations`
|
||||
),
|
||||
|
||||
[PageMap.REPORTS]: new Route(
|
||||
|
306
Model/Models/UserCall.ts
Normal file
306
Model/Models/UserCall.ts
Normal file
@ -0,0 +1,306 @@
|
||||
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm';
|
||||
import ColumnType from 'Common/Types/Database/ColumnType';
|
||||
import ColumnLength from 'Common/Types/Database/ColumnLength';
|
||||
import TableColumn from 'Common/Types/Database/TableColumn';
|
||||
import CrudApiEndpoint from 'Common/Types/Database/CrudApiEndpoint';
|
||||
import Route from 'Common/Types/API/Route';
|
||||
import TableColumnType from 'Common/Types/Database/TableColumnType';
|
||||
import TableAccessControl from 'Common/Types/Database/AccessControl/TableAccessControl';
|
||||
import Permission from 'Common/Types/Permission';
|
||||
import ColumnAccessControl from 'Common/Types/Database/AccessControl/ColumnAccessControl';
|
||||
import CurrentUserCanAccessRecordBy from 'Common/Types/Database/CurrentUserCanAccessRecordBy';
|
||||
import TableMetadata from 'Common/Types/Database/TableMetadata';
|
||||
import IconProp from 'Common/Types/Icon/IconProp';
|
||||
import AllowAccessIfSubscriptionIsUnpaid from 'Common/Types/Database/AccessControl/AllowAccessIfSubscriptionIsUnpaid';
|
||||
import ObjectID from 'Common/Types/ObjectID';
|
||||
import BaseModel from 'Common/Models/BaseModel';
|
||||
import User from './User';
|
||||
import Phone from 'Common/Types/Phone';
|
||||
import Project from './Project';
|
||||
|
||||
@AllowAccessIfSubscriptionIsUnpaid()
|
||||
@TableAccessControl({
|
||||
create: [Permission.CurrentUser],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
delete: [Permission.CurrentUser],
|
||||
update: [Permission.CurrentUser],
|
||||
})
|
||||
@CrudApiEndpoint(new Route('/user-call'))
|
||||
@Entity({
|
||||
name: 'UserCall',
|
||||
})
|
||||
@TableMetadata({
|
||||
tableName: 'UserCall',
|
||||
singularName: 'User Phone Number for Calls',
|
||||
pluralName: 'User Phone Numbers for Calls',
|
||||
icon: IconProp.Call,
|
||||
tableDescription: 'Phone Number which will be used for call notifications.',
|
||||
})
|
||||
@CurrentUserCanAccessRecordBy('userId')
|
||||
class UserCall extends BaseModel {
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.CurrentUser],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
manyToOneRelationColumn: 'projectId',
|
||||
type: TableColumnType.Entity,
|
||||
modelType: Project,
|
||||
title: 'Project',
|
||||
description:
|
||||
'Relation to Project Resource in which this object belongs',
|
||||
})
|
||||
@ManyToOne(
|
||||
(_type: string) => {
|
||||
return Project;
|
||||
},
|
||||
{
|
||||
eager: false,
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
orphanedRowAction: 'nullify',
|
||||
}
|
||||
)
|
||||
@JoinColumn({ name: 'projectId' })
|
||||
public project?: Project = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.CurrentUser],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@Index()
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
required: true,
|
||||
canReadOnRelationQuery: true,
|
||||
title: 'Project ID',
|
||||
description:
|
||||
'ID of your OneUptime Project in which this object belongs',
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: false,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
public projectId?: ObjectID = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.CurrentUser],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
title: 'Phone',
|
||||
required: true,
|
||||
unique: true,
|
||||
type: TableColumnType.Phone,
|
||||
canReadOnRelationQuery: true,
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.Phone,
|
||||
length: ColumnLength.Phone,
|
||||
unique: true,
|
||||
nullable: false,
|
||||
transformer: Phone.getDatabaseTransformer(),
|
||||
})
|
||||
public phone?: Phone = undefined;
|
||||
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
manyToOneRelationColumn: 'user',
|
||||
type: TableColumnType.Entity,
|
||||
modelType: User,
|
||||
title: 'User',
|
||||
description:
|
||||
'Relation to User who this email belongs to',
|
||||
})
|
||||
@ManyToOne(
|
||||
(_type: string) => {
|
||||
return User;
|
||||
},
|
||||
{
|
||||
eager: false,
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
orphanedRowAction: 'nullify',
|
||||
}
|
||||
)
|
||||
@JoinColumn({ name: 'userId' })
|
||||
public user?: User = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
title: 'User ID',
|
||||
description:
|
||||
'User ID who this email belongs to',
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: true,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
@Index()
|
||||
public userId?: ObjectID = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
manyToOneRelationColumn: 'createdByUserId',
|
||||
type: TableColumnType.Entity,
|
||||
modelType: User,
|
||||
title: 'Created by User',
|
||||
description:
|
||||
'Relation to User who created this object (if this object was created by a User)',
|
||||
})
|
||||
@ManyToOne(
|
||||
(_type: string) => {
|
||||
return User;
|
||||
},
|
||||
{
|
||||
eager: false,
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
orphanedRowAction: 'nullify',
|
||||
}
|
||||
)
|
||||
@JoinColumn({ name: 'createdByUserId' })
|
||||
public createdByUser?: User = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
title: 'Created by User ID',
|
||||
description:
|
||||
'User ID who created this object (if this object was created by a User)',
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: true,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
public createdByUserId?: ObjectID = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
manyToOneRelationColumn: 'deletedByUserId',
|
||||
type: TableColumnType.Entity,
|
||||
title: 'Deleted by User',
|
||||
description:
|
||||
'Relation to User who deleted this object (if this object was deleted by a User)',
|
||||
})
|
||||
@ManyToOne(
|
||||
(_type: string) => {
|
||||
return User;
|
||||
},
|
||||
{
|
||||
cascade: false,
|
||||
eager: false,
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
orphanedRowAction: 'nullify',
|
||||
}
|
||||
)
|
||||
@JoinColumn({ name: 'deletedByUserId' })
|
||||
public deletedByUser?: User = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
title: 'Deleted by User ID',
|
||||
description:
|
||||
'User ID who deleted this object (if this object was deleted by a User)',
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: true,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
public deletedByUserId?: ObjectID = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [Permission.CurrentUser],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({ title: 'Is Verified',
|
||||
description:
|
||||
'Is this verified?',isDefaultValueColumn: true, type: TableColumnType.Boolean })
|
||||
@Column({
|
||||
type: ColumnType.Boolean,
|
||||
default: false,
|
||||
})
|
||||
public isVerified?: boolean = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({ title: 'Verification Code',
|
||||
description:
|
||||
'Temporary Verification Code',isDefaultValueColumn: false, type: TableColumnType.ShortText })
|
||||
@Column({
|
||||
type: ColumnType.ShortText,
|
||||
nullable: false,
|
||||
length: ColumnLength.ShortText,
|
||||
})
|
||||
public verificationCode?: boolean = undefined;
|
||||
}
|
||||
|
||||
export default UserCall;
|
310
Model/Models/UserEmail.ts
Normal file
310
Model/Models/UserEmail.ts
Normal file
@ -0,0 +1,310 @@
|
||||
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm';
|
||||
import ColumnType from 'Common/Types/Database/ColumnType';
|
||||
import ColumnLength from 'Common/Types/Database/ColumnLength';
|
||||
import Email from 'Common/Types/Email';
|
||||
import TableColumn from 'Common/Types/Database/TableColumn';
|
||||
import CrudApiEndpoint from 'Common/Types/Database/CrudApiEndpoint';
|
||||
import Route from 'Common/Types/API/Route';
|
||||
import TableColumnType from 'Common/Types/Database/TableColumnType';
|
||||
import TableAccessControl from 'Common/Types/Database/AccessControl/TableAccessControl';
|
||||
import Permission from 'Common/Types/Permission';
|
||||
import ColumnAccessControl from 'Common/Types/Database/AccessControl/ColumnAccessControl';
|
||||
import CurrentUserCanAccessRecordBy from 'Common/Types/Database/CurrentUserCanAccessRecordBy';
|
||||
import TableMetadata from 'Common/Types/Database/TableMetadata';
|
||||
import IconProp from 'Common/Types/Icon/IconProp';
|
||||
import AllowAccessIfSubscriptionIsUnpaid from 'Common/Types/Database/AccessControl/AllowAccessIfSubscriptionIsUnpaid';
|
||||
import ObjectID from 'Common/Types/ObjectID';
|
||||
import BaseModel from 'Common/Models/BaseModel';
|
||||
import User from './User';
|
||||
import Project from './Project';
|
||||
|
||||
@AllowAccessIfSubscriptionIsUnpaid()
|
||||
@TableAccessControl({
|
||||
create: [Permission.CurrentUser],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
delete: [Permission.CurrentUser],
|
||||
update: [Permission.CurrentUser],
|
||||
})
|
||||
@CrudApiEndpoint(new Route('/user-email'))
|
||||
@Entity({
|
||||
name: 'UserEmail',
|
||||
})
|
||||
@TableMetadata({
|
||||
tableName: 'UserEmail',
|
||||
singularName: 'User Email',
|
||||
pluralName: 'User Emails',
|
||||
icon: IconProp.Email,
|
||||
tableDescription: 'Emails which will be used for notifications.',
|
||||
})
|
||||
@CurrentUserCanAccessRecordBy('userId')
|
||||
class UserEmail extends BaseModel {
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.CurrentUser],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
manyToOneRelationColumn: 'projectId',
|
||||
type: TableColumnType.Entity,
|
||||
modelType: Project,
|
||||
title: 'Project',
|
||||
description:
|
||||
'Relation to Project Resource in which this object belongs',
|
||||
})
|
||||
@ManyToOne(
|
||||
(_type: string) => {
|
||||
return Project;
|
||||
},
|
||||
{
|
||||
eager: false,
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
orphanedRowAction: 'nullify',
|
||||
}
|
||||
)
|
||||
@JoinColumn({ name: 'projectId' })
|
||||
public project?: Project = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.CurrentUser],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@Index()
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
required: true,
|
||||
canReadOnRelationQuery: true,
|
||||
title: 'Project ID',
|
||||
description:
|
||||
'ID of your OneUptime Project in which this object belongs',
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: false,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
public projectId?: ObjectID = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.CurrentUser],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
title: 'Email',
|
||||
required: true,
|
||||
unique: true,
|
||||
type: TableColumnType.Email,
|
||||
canReadOnRelationQuery: true,
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.Email,
|
||||
length: ColumnLength.Email,
|
||||
unique: true,
|
||||
nullable: false,
|
||||
transformer: Email.getDatabaseTransformer(),
|
||||
})
|
||||
public email?: Email = undefined;
|
||||
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
manyToOneRelationColumn: 'user',
|
||||
type: TableColumnType.Entity,
|
||||
modelType: User,
|
||||
title: 'User',
|
||||
description:
|
||||
'Relation to User who this email belongs to',
|
||||
})
|
||||
@ManyToOne(
|
||||
(_type: string) => {
|
||||
return User;
|
||||
},
|
||||
{
|
||||
eager: false,
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
orphanedRowAction: 'nullify',
|
||||
}
|
||||
)
|
||||
@JoinColumn({ name: 'userId' })
|
||||
public user?: User = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
title: 'User ID',
|
||||
description:
|
||||
'User ID who this email belongs to',
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: true,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
@Index()
|
||||
public userId?: ObjectID = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
manyToOneRelationColumn: 'createdByUserId',
|
||||
type: TableColumnType.Entity,
|
||||
modelType: User,
|
||||
title: 'Created by User',
|
||||
description:
|
||||
'Relation to User who created this object (if this object was created by a User)',
|
||||
})
|
||||
@ManyToOne(
|
||||
(_type: string) => {
|
||||
return User;
|
||||
},
|
||||
{
|
||||
eager: false,
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
orphanedRowAction: 'nullify',
|
||||
}
|
||||
)
|
||||
@JoinColumn({ name: 'createdByUserId' })
|
||||
public createdByUser?: User = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
title: 'Created by User ID',
|
||||
description:
|
||||
'User ID who created this object (if this object was created by a User)',
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: true,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
public createdByUserId?: ObjectID = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
manyToOneRelationColumn: 'deletedByUserId',
|
||||
type: TableColumnType.Entity,
|
||||
title: 'Deleted by User',
|
||||
description:
|
||||
'Relation to User who deleted this object (if this object was deleted by a User)',
|
||||
})
|
||||
@ManyToOne(
|
||||
(_type: string) => {
|
||||
return User;
|
||||
},
|
||||
{
|
||||
cascade: false,
|
||||
eager: false,
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
orphanedRowAction: 'nullify',
|
||||
}
|
||||
)
|
||||
@JoinColumn({ name: 'deletedByUserId' })
|
||||
public deletedByUser?: User = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
title: 'Deleted by User ID',
|
||||
description:
|
||||
'User ID who deleted this object (if this object was deleted by a User)',
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: true,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
public deletedByUserId?: ObjectID = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [Permission.CurrentUser],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({ title: 'Is Verified',
|
||||
description:
|
||||
'Is this verified?',isDefaultValueColumn: true, type: TableColumnType.Boolean })
|
||||
@Column({
|
||||
type: ColumnType.Boolean,
|
||||
default: false,
|
||||
})
|
||||
public isVerified?: boolean = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({ title: 'Verification Code',
|
||||
description:
|
||||
'Temporary Verification Code',isDefaultValueColumn: false, type: TableColumnType.ShortText })
|
||||
@Column({
|
||||
type: ColumnType.ShortText,
|
||||
nullable: false,
|
||||
length: ColumnLength.ShortText,
|
||||
})
|
||||
public verificationCode?: boolean = undefined;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default UserEmail;
|
0
Model/Models/UserNotificationRule.ts
Normal file
0
Model/Models/UserNotificationRule.ts
Normal file
307
Model/Models/UserSMS.ts
Normal file
307
Model/Models/UserSMS.ts
Normal file
@ -0,0 +1,307 @@
|
||||
import { Column, Entity, Index, JoinColumn, ManyToOne } from 'typeorm';
|
||||
import ColumnType from 'Common/Types/Database/ColumnType';
|
||||
import ColumnLength from 'Common/Types/Database/ColumnLength';
|
||||
import TableColumn from 'Common/Types/Database/TableColumn';
|
||||
import CrudApiEndpoint from 'Common/Types/Database/CrudApiEndpoint';
|
||||
import Route from 'Common/Types/API/Route';
|
||||
import TableColumnType from 'Common/Types/Database/TableColumnType';
|
||||
import TableAccessControl from 'Common/Types/Database/AccessControl/TableAccessControl';
|
||||
import Permission from 'Common/Types/Permission';
|
||||
import ColumnAccessControl from 'Common/Types/Database/AccessControl/ColumnAccessControl';
|
||||
import CurrentUserCanAccessRecordBy from 'Common/Types/Database/CurrentUserCanAccessRecordBy';
|
||||
import TableMetadata from 'Common/Types/Database/TableMetadata';
|
||||
import IconProp from 'Common/Types/Icon/IconProp';
|
||||
import AllowAccessIfSubscriptionIsUnpaid from 'Common/Types/Database/AccessControl/AllowAccessIfSubscriptionIsUnpaid';
|
||||
import ObjectID from 'Common/Types/ObjectID';
|
||||
import BaseModel from 'Common/Models/BaseModel';
|
||||
import User from './User';
|
||||
import Phone from 'Common/Types/Phone';
|
||||
import Project from './Project';
|
||||
|
||||
@AllowAccessIfSubscriptionIsUnpaid()
|
||||
@TableAccessControl({
|
||||
create: [Permission.CurrentUser],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
delete: [Permission.CurrentUser],
|
||||
update: [Permission.CurrentUser],
|
||||
})
|
||||
@CrudApiEndpoint(new Route('/user-sms'))
|
||||
@Entity({
|
||||
name: 'UserSMS',
|
||||
})
|
||||
@TableMetadata({
|
||||
tableName: 'UserSMS',
|
||||
singularName: 'User Phone Number for SMS',
|
||||
pluralName: 'User Phone Number for SMS',
|
||||
icon: IconProp.SMS,
|
||||
tableDescription: 'Phone Number which will be used for SMS notifications.',
|
||||
})
|
||||
@CurrentUserCanAccessRecordBy('userId')
|
||||
class UserSMS extends BaseModel {
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.CurrentUser],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
manyToOneRelationColumn: 'projectId',
|
||||
type: TableColumnType.Entity,
|
||||
modelType: Project,
|
||||
title: 'Project',
|
||||
description:
|
||||
'Relation to Project Resource in which this object belongs',
|
||||
})
|
||||
@ManyToOne(
|
||||
(_type: string) => {
|
||||
return Project;
|
||||
},
|
||||
{
|
||||
eager: false,
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
orphanedRowAction: 'nullify',
|
||||
}
|
||||
)
|
||||
@JoinColumn({ name: 'projectId' })
|
||||
public project?: Project = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.CurrentUser],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@Index()
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
required: true,
|
||||
canReadOnRelationQuery: true,
|
||||
title: 'Project ID',
|
||||
description:
|
||||
'ID of your OneUptime Project in which this object belongs',
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: false,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
public projectId?: ObjectID = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [Permission.CurrentUser],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
title: 'Phone',
|
||||
required: true,
|
||||
unique: true,
|
||||
type: TableColumnType.Phone,
|
||||
canReadOnRelationQuery: true,
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.Phone,
|
||||
length: ColumnLength.Phone,
|
||||
unique: true,
|
||||
nullable: false,
|
||||
transformer: Phone.getDatabaseTransformer(),
|
||||
})
|
||||
public phone?: Phone = undefined;
|
||||
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
manyToOneRelationColumn: 'user',
|
||||
type: TableColumnType.Entity,
|
||||
modelType: User,
|
||||
title: 'User',
|
||||
description:
|
||||
'Relation to User who this email belongs to',
|
||||
})
|
||||
@ManyToOne(
|
||||
(_type: string) => {
|
||||
return User;
|
||||
},
|
||||
{
|
||||
eager: false,
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
orphanedRowAction: 'nullify',
|
||||
}
|
||||
)
|
||||
@JoinColumn({ name: 'userId' })
|
||||
public user?: User = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
title: 'User ID',
|
||||
description:
|
||||
'User ID who this email belongs to',
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: true,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
@Index()
|
||||
public userId?: ObjectID = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
manyToOneRelationColumn: 'createdByUserId',
|
||||
type: TableColumnType.Entity,
|
||||
modelType: User,
|
||||
title: 'Created by User',
|
||||
description:
|
||||
'Relation to User who created this object (if this object was created by a User)',
|
||||
})
|
||||
@ManyToOne(
|
||||
(_type: string) => {
|
||||
return User;
|
||||
},
|
||||
{
|
||||
eager: false,
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
orphanedRowAction: 'nullify',
|
||||
}
|
||||
)
|
||||
@JoinColumn({ name: 'createdByUserId' })
|
||||
public createdByUser?: User = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
read: [
|
||||
Permission.CurrentUser
|
||||
],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
title: 'Created by User ID',
|
||||
description:
|
||||
'User ID who created this object (if this object was created by a User)',
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: true,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
public createdByUserId?: ObjectID = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
manyToOneRelationColumn: 'deletedByUserId',
|
||||
type: TableColumnType.Entity,
|
||||
title: 'Deleted by User',
|
||||
description:
|
||||
'Relation to User who deleted this object (if this object was deleted by a User)',
|
||||
})
|
||||
@ManyToOne(
|
||||
(_type: string) => {
|
||||
return User;
|
||||
},
|
||||
{
|
||||
cascade: false,
|
||||
eager: false,
|
||||
nullable: true,
|
||||
onDelete: 'CASCADE',
|
||||
orphanedRowAction: 'nullify',
|
||||
}
|
||||
)
|
||||
@JoinColumn({ name: 'deletedByUserId' })
|
||||
public deletedByUser?: User = undefined;
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({
|
||||
type: TableColumnType.ObjectID,
|
||||
title: 'Deleted by User ID',
|
||||
description:
|
||||
'User ID who deleted this object (if this object was deleted by a User)',
|
||||
})
|
||||
@Column({
|
||||
type: ColumnType.ObjectID,
|
||||
nullable: true,
|
||||
transformer: ObjectID.getDatabaseTransformer(),
|
||||
})
|
||||
public deletedByUserId?: ObjectID = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [Permission.CurrentUser],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({ title: 'Is Verified',
|
||||
description:
|
||||
'Is this verified?',isDefaultValueColumn: true, type: TableColumnType.Boolean })
|
||||
@Column({
|
||||
type: ColumnType.Boolean,
|
||||
default: false,
|
||||
})
|
||||
public isVerified?: boolean = undefined;
|
||||
|
||||
|
||||
@ColumnAccessControl({
|
||||
create: [],
|
||||
read: [],
|
||||
update: [],
|
||||
})
|
||||
@TableColumn({ title: 'Verification Code',
|
||||
description:
|
||||
'Temporary Verification Code',isDefaultValueColumn: false, type: TableColumnType.ShortText })
|
||||
@Column({
|
||||
type: ColumnType.ShortText,
|
||||
nullable: false,
|
||||
length: ColumnLength.ShortText,
|
||||
})
|
||||
public verificationCode?: boolean = undefined;
|
||||
}
|
||||
|
||||
export default UserSMS;
|
Loading…
Reference in New Issue
Block a user