Skip to content

Commit

Permalink
feat: Drill report
Browse files Browse the repository at this point in the history
  • Loading branch information
strogonoff committed Mar 19, 2020
1 parent 3f8d56a commit 4b13f53
Show file tree
Hide file tree
Showing 6 changed files with 659 additions and 22 deletions.
14 changes: 7 additions & 7 deletions src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,32 @@ export interface BCDrill {
bcPlanID: string
bcDrillPlanRevisionID: number
startTime: Date
endTime: Date
endTime?: Date

report: BCDrillReport
}


/* Drill reporting */

interface BCDrillReport {
export interface BCDrillReport {
followUpAction: string
steps: BCDrillStepReport[]
authors: BCDrillParticipant[]
}

interface BCDrillStepReport {
export interface BCDrillStepReport {
plan: BCDrillStepPlan

responsible: BCDrillParticipant[]
participants: BCDrillParticipant[]
result: string
type: BCDrillType
startTime: Date
endTime: Date
activityType: BCDrillActivityType
startTime?: Date
endTime?: Date
}

type BCDrillType = 'Tabletop' | 'Live' | 'Discussion';
export type BCDrillActivityType = 'Tabletop' | 'Live' | 'Discussion';


/* Drill planning */
Expand Down
16 changes: 16 additions & 0 deletions src/renderer/plans/drill-history.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//import moment from 'moment';
import React from 'react';
//import { app } from 'renderer';
//import { BCPlan } from 'models';


interface DrillHistoryProps {
planID: string
}
export const DrillHistory: React.FC<DrillHistoryProps> = function ({ planID }) {
//const bcPlan = app.useOne<BCPlan, string>('plan', planID);

return (
<p>Drill history here…</p>
);
};
5 changes: 3 additions & 2 deletions src/renderer/plans/edit-drill-plan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ export const EditDrillPlan: React.FC<EditDrillPlanProps> = function ({ planID })
}

return (
<div className={styles.drillPlanBase}>
<div className={styles.actions}>
<div className={styles.mainPaneInner}>
<div className={styles.toolbar}>
<span className={styles.title}>
BC drill plan: {revision.revisionID < 1
? <>initial revision</>
Expand All @@ -250,6 +250,7 @@ export const EditDrillPlan: React.FC<EditDrillPlanProps> = function ({ planID })
large
onClick={commitInProgress ? undefined : () => commitChanges()}
active={commitInProgress}
icon="git-commit"
disabled={
(selectedRevisionID !== null && !isLatestRevision) ||
sanitizedPlanRevision === undefined ||
Expand Down
69 changes: 60 additions & 9 deletions src/renderer/plans/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { conf as rendererConf } from 'renderer';
import { app } from 'renderer';
import styles from './styles.scss';
import { EditDrillPlan } from './edit-drill-plan';
import { RunDrill } from './run-drill';
import { DrillHistory } from './drill-history';


interface RetireableQuery {
Expand Down Expand Up @@ -52,8 +54,11 @@ const Window: React.FC<WindowComponentProps> = function () {
() => setEditMode(false),
handleActivityUpdate,
handlePlanUpdate,
handleShowDrillPlan,
handleDrillStart));

mod,
handleShowDrillHistory,
handleDrillStart,
handleEditDrillPlan));
}, [
JSON.stringify(activities.objects),
JSON.stringify(plans.objects),
Expand All @@ -71,6 +76,8 @@ const Window: React.FC<WindowComponentProps> = function () {
databaseStatusComponents={rendererConf.databaseStatusComponents} />
), Object.keys(appConf.databases));

const [mod, setMod] = useState<Module>('edit-plan');


async function handleActivityUpdate(activity: BCActivity) {
if (activity.id === NEW_ID_PLACEHOLDER) {
Expand Down Expand Up @@ -124,9 +131,15 @@ const Window: React.FC<WindowComponentProps> = function () {
}

async function handleDrillStart(activityID: string, planID: string) {
setMod('run-drill');
}

async function handleShowDrillPlan(activityID: string, planID: string) {
async function handleShowDrillHistory(activityID: string, planID: string) {
setMod('show-history');
}

async function handleEditDrillPlan(activityID: string, planID: string) {
setMod('edit-plan');
}

async function handleNodeClick(node: ITreeNode, nodePath: number[]) {
Expand All @@ -147,6 +160,21 @@ const Window: React.FC<WindowComponentProps> = function () {
}
}

let mainPane: JSX.Element;
if (selectedPlanID !== null) {
if (mod === 'run-drill') {
mainPane = <RunDrill planID={selectedPlanID} />;
} else if (mod === 'show-history') {
mainPane = <DrillHistory planID={selectedPlanID} />;
} else if (mod === 'edit-plan') {
mainPane = <EditDrillPlan planID={selectedPlanID} />;
} else {
throw new Error("Unknown BC plan module");
}
} else {
mainPane = <NonIdealState title="No BC plan selected" />;
}


return (
<div className={styles.base}>
Expand Down Expand Up @@ -176,10 +204,8 @@ const Window: React.FC<WindowComponentProps> = function () {
</div>
</div>

<div className={styles.drillPlan}>
{selectedPlanID !== null
? <EditDrillPlan planID={selectedPlanID} />
: <NonIdealState title="No BC plan selected" />}
<div className={styles.mainPane}>
{mainPane}
</div>

</div>
Expand All @@ -197,8 +223,11 @@ function buildAcitvityNodes(

onUpdateActivity: (activity: BCActivity) => void,
onUpdatePlan: (plan: BCPlan) => void,
onShowDrillPlan: (activityID: string, planID: string) => void,

mod: Module,
onShowDrillReports: (activityID: string, planID: string) => void,
onDrillStart: (activityID: string, planID: string) => void,
onReviseDrillPlan: (activityID: string, planID: string) => void,
): ITreeNode[] {

const orderedActivities = [
Expand Down Expand Up @@ -318,8 +347,28 @@ function buildAcitvityNodes(
intent="danger"
small
minimal
active={isSelected && mod === 'run-drill'}
title="Start drill…"
icon="record"
/>
<Button
key="view-reports"
onClick={() => onShowDrillReports(activity.id, plan.id)}
small
minimal
active={isSelected && mod === 'show-history'}
title="View past drill reports…"
icon="history"
/>
<Button
key="edit-plan"
onClick={() => onReviseDrillPlan(activity.id, plan.id)}
small
minimal
active={isSelected && mod === 'edit-plan'}
title="Edit drill plan…"
icon="edit"
/>
<Popover
position={Position.RIGHT}
content={<Menu>
Expand All @@ -342,4 +391,6 @@ function buildAcitvityNodes(
}


export default Window;
export default Window;

type Module = 'show-history' | 'run-drill' | 'edit-plan';
Loading

0 comments on commit 4b13f53

Please sign in to comment.