refactor home project

This commit is contained in:
Simon Larsen
2023-07-08 14:18:05 +01:00
parent 8e78d74568
commit 031ed59108
16 changed files with 1018 additions and 1117 deletions

View File

@@ -6,6 +6,7 @@ import OnCallDutyPolicy from 'Model/Models/OnCallDutyPolicy';
import BadDataException from 'Common/Types/Exception/BadDataException';
import OnCallDutyPolicyExecutionLogService from './OnCallDutyPolicyExecutionLogService';
import UserNotificationEventType from 'Common/Types/UserNotification/UserNotificationEventType';
import OnCallDutyPolicyStatus from 'Common/Types/OnCallDutyPolicy/OnCallDutyPolicyStatus';
export class Service extends DatabaseService<OnCallDutyPolicy> {
public constructor(postgresDatabase?: PostgresDatabase) {
@@ -55,6 +56,8 @@ export class Service extends DatabaseService<OnCallDutyPolicy> {
log.projectId = policy.projectId!;
log.onCallDutyPolicyId = policyId;
log.userNotificationEventType = options.userNotificationEventType;
log.statusMessage = 'Scheduled.';
log.status = OnCallDutyPolicyStatus.Scheduled;
if (options.triggeredByIncidentId) {
log.triggeredByIncidentId = options.triggeredByIncidentId;

View File

@@ -45,7 +45,7 @@ const ListRow: FunctionComponent<ComponentProps> = (
<div>
{props.enableDragAndDrop && (
<div className="flex">
<td
<div
className="ml-0 -ml-2 w-10"
{...provided?.dragHandleProps}
>
@@ -54,7 +54,7 @@ const ListRow: FunctionComponent<ComponentProps> = (
thick={ThickProp.Thick}
className=" h-6 w-6 text-gray-500 hover:text-gray-700 m-auto cursor-ns-resize"
/>
</td>
</div>
<Detail
item={props.item}
fields={props.fields}

View File

@@ -8,6 +8,7 @@ import Query from '../../Utils/ModelAPI/Query';
import IconProp from 'Common/Types/Icon/IconProp';
import FieldType from '../Types/FieldType';
import { DropdownOption } from '../Dropdown/Dropdown';
export interface ActionButton {
buttonText: string;
@@ -33,6 +34,7 @@ export default interface Columns<TEntity> {
value: string;
}
| undefined;
filterDropdownOptions?: Array<DropdownOption> | undefined;
actionButtons?: Array<ActionButton>;
alignItem?: AlignItem | undefined;
noValueMessage?: string | undefined;

View File

@@ -402,6 +402,15 @@ const ModelTable: Function = <TBaseModel extends BaseModel>(
continue;
}
if (
column.filterDropdownOptions &&
column.filterDropdownOptions.length > 0
) {
classicColumn.filterDropdownOptions =
column.filterDropdownOptions;
continue;
}
if (
!(
column.type === FieldType.Entity ||

View File

@@ -14,7 +14,7 @@ const SideMenu: FunctionComponent<ComponentProps> = (props: ComponentProps) => {
return (
<aside className="py-6 px-2 sm:px-6 lg:col-span-2 md:col-span-3 lg:py-0 lg:px-0 mb-10">
<nav className="space-y-1">
<nav className="space-y-3">
{children.map((child: ReactElement) => {
return child;
})}

View File

@@ -9,10 +9,10 @@ const SideMenuItem: FunctionComponent<ComponentProps> = (
props: ComponentProps
) => {
return (
<>
<div>
<h6 className="text-sm text-gray-500">{props.title}</h6>
<div>{props.children}</div>
</>
</div>
);
};

View File

@@ -24,11 +24,18 @@ import OnCallDutyPolicyStatus from 'Common/Types/OnCallDutyPolicy/OnCallDutyPoli
import UserElement from '../../../Components/User/User';
import JSONFunctions from 'Common/Types/JSONFunctions';
import User from 'Model/Models/User';
import RouteParams from '../../../Utils/RouteParams';
import DropdownUtil from 'CommonUI/src/Utils/Dropdown';
const Settings: FunctionComponent<PageComponentProps> = (
_props: PageComponentProps
): ReactElement => {
const modelId: ObjectID = Navigation.getLastParamAsObjectID();
const modelId: ObjectID = new ObjectID(
Navigation.getParamByName(
RouteParams.ModelID,
RouteMap[PageMap.ON_CALL_DUTY_POLICY_VIEW_EXECUTION_LOGS]! as Route
) as string
);
const [showViewStatusMessageModal, setShowViewStatusMessageModal] =
useState<boolean>(false);
const [statusMessage, setStatusMessage] = useState<string>('');
@@ -77,7 +84,7 @@ const Settings: FunctionComponent<PageComponentProps> = (
modelType={OnCallDutyPolicyExecutionLog}
query={{
projectId: DashboardNavigation.getProjectId()?.toString(),
onCallPolicyId: modelId.toString(),
onCallDutyPolicyId: modelId.toString(),
}}
id="execution-logs-table"
name="On Call Policy > Logs"
@@ -162,6 +169,10 @@ const Settings: FunctionComponent<PageComponentProps> = (
title: 'Status',
type: FieldType.Element,
isFilterable: true,
filterDropdownOptions:
DropdownUtil.getDropdownOptionsFromEnum(
OnCallDutyPolicyStatus
),
getElement: (item: JSONObject): ReactElement => {
if (
item['status'] ===
@@ -215,21 +226,22 @@ const Settings: FunctionComponent<PageComponentProps> = (
},
{
field: {
acknowledgedBy: {
acknowledgedByUser: {
name: true,
email: true,
},
},
title: 'Acknowledged By',
type: FieldType.Element,
isFilterable: false,
getElement: (item: JSONObject): ReactElement => {
if (item['acknowledgedBy']) {
if (item['acknowledgedByUser']) {
return (
<UserElement
user={
JSONFunctions.fromJSON(
item[
'acknowledgedBy'
'acknowledgedByUser'
] as JSONObject,
User
) as User

View File

@@ -43,7 +43,7 @@ const DashboardSideMenu: FunctionComponent<ComponentProps> = (
/>
</SideMenuSection>
<SideMenuSection title="Advanced">
<SideMenuSection title="Logs">
<SideMenuItem
link={{
title: 'Execution Logs',
@@ -56,6 +56,9 @@ const DashboardSideMenu: FunctionComponent<ComponentProps> = (
}}
icon={IconProp.Logs}
/>
</SideMenuSection>
<SideMenuSection title="Advanced">
<SideMenuItem
link={{
title: 'Custom Fields',

View File

@@ -13,7 +13,7 @@ import Navigation from 'CommonUI/src/Utils/Navigation';
import FieldType from 'CommonUI/src/Components/Types/FieldType';
import { JSONObject } from 'Common/Types/JSON';
import Pill from 'CommonUI/src/Components/Pill/Pill';
import USerNotificationStatus from 'Common/Types/UserNotification/USerNotificationStatus';
import UserNotificationStatus from 'Common/Types/UserNotification/UserNotificationStatus';
import { Green, Red, Yellow } from 'Common/Types/BrandColors';
import { ButtonStyleType } from 'CommonUI/src/Components/Button/Button';
import ConfirmModal from 'CommonUI/src/Components/Modal/ConfirmModal';
@@ -122,43 +122,43 @@ const Settings: FunctionComponent<PageComponentProps> = (
isFilterable: true,
getElement: (item: JSONObject): ReactElement => {
if (
item['status'] === USerNotificationStatus.Sent
item['status'] === UserNotificationStatus.Sent
) {
return (
<Pill
color={Green}
text={USerNotificationStatus.Sent}
text={UserNotificationStatus.Sent}
/>
);
} else if (
item['status'] ===
USerNotificationStatus.Acknowledged
UserNotificationStatus.Acknowledged
) {
return (
<Pill
color={Green}
text={
USerNotificationStatus.Acknowledged
UserNotificationStatus.Acknowledged
}
/>
);
} else if (
item['status'] === USerNotificationStatus.Error
item['status'] === UserNotificationStatus.Error
) {
return (
<Pill
color={Yellow}
text={USerNotificationStatus.Error}
text={UserNotificationStatus.Error}
/>
);
} else if (
item['status'] ===
USerNotificationStatus.Skipped
UserNotificationStatus.Skipped
) {
return (
<Pill
color={Yellow}
text={USerNotificationStatus.Skipped}
text={UserNotificationStatus.Skipped}
/>
);
}
@@ -166,7 +166,7 @@ const Settings: FunctionComponent<PageComponentProps> = (
return (
<Pill
color={Red}
text={USerNotificationStatus.Error}
text={UserNotificationStatus.Error}
/>
);
},

View File

@@ -288,7 +288,7 @@ const RouteMap: Dictionary<Route> = {
),
[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`
),
[PageMap.ON_CALL_DUTY_POLICY_VIEW_CUSTOM_FIELDS]: new Route(

View File

@@ -809,14 +809,6 @@ app.use(
).getRouter()
);
app.use(
`/${APP_NAME.toLocaleLowerCase()}`,
new BaseAPI<OnCallDutyPolicy, OnCallDutyPolicyServiceType>(
OnCallDutyPolicy,
OnCallDutyPolicyService
).getRouter()
);
app.use(
`/${APP_NAME.toLocaleLowerCase()}`,
new BaseAPI<

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="text-gray-400 w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 12h-15" />
</svg>

After

Width:  |  Height:  |  Size: 231 B

View File

@@ -0,0 +1,7 @@
<!-- Heroicon name: mini/check -->
<svg class="h-5 w-5 flex-shrink-0 text-green-500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20"
fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd"
d="M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z"
clip-rule="evenodd" />
</svg>

After

Width:  |  Height:  |  Size: 392 B

View File

@@ -398,12 +398,18 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
@ColumnAccessControl({
create: [],
read: [],
read: [
Permission.ProjectOwner,
Permission.ProjectAdmin,
Permission.ProjectMember,
Permission.CanReadProjectOnCallDutyPolicyExecutionLog,
],
update: [],
})
@TableColumn({
manyToOneRelationColumn: 'acknowledgedByUserId',
type: TableColumnType.Entity,
modelType: User,
title: 'Acknowledged by User',
description:
'Relation to User who acknowledged this policy execution (if this policy was acknowledged by a User)',
@@ -598,14 +604,14 @@ export default class OnCallDutyPolicyExecutionLog extends BaseModel {
@Index()
@TableColumn({
type: TableColumnType.ObjectID,
required: true,
required: false,
canReadOnRelationQuery: true,
title: 'Last Executed Escalation Rule ID',
description: 'ID of your On Call Policy Last Executed Escalation Rule.',
})
@Column({
type: ColumnType.ObjectID,
nullable: false,
nullable: true,
transformer: ObjectID.getDatabaseTransformer(),
})
public lastExecutedEscalationRuleId?: ObjectID = undefined;

View File

@@ -41,7 +41,7 @@
"prerun": "bash configure.sh",
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js",
"uninstall": "bash uninstall.sh",
"lint": "ejslint home/views/*.ejs && eslint '**/*.ts*' -c .eslintrc.json --ignore-path .eslintignore ",
"lint": "ejslint **/*.ejs && eslint '**/*.ts*' -c .eslintrc.json --ignore-path .eslintignore ",
"fix-lint": " node --max_old_space_size=18192 ./node_modules/.bin/eslint '**/*.ts*' -c .eslintrc.json --ignore-path .eslintignore --fix ",
"fix": "npm run fix-lint",
"start": "sudo docker compose up --remove-orphans -d $npm_config_services",