Skip to content

add version to json #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/features/serialize/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DynamicChildrenProcessor } from "../dfdElements/dynamicChildren";
import { EditorModeController } from "../editorMode/editorModeController";
import { sendMessage } from "./webSocketHandler";
import { ConstraintRegistry } from "../constraintMenu/constraintRegistry";
import { SavedDiagram } from "./save";
import { CURRENT_VERSION, SavedDiagram } from "./save";
import { LoadingIndicator } from "../../common/loadingIndicator";

export interface AnalyzeDiagramAction extends Action {
Expand Down Expand Up @@ -62,6 +62,7 @@ export class AnalyzeDiagramCommand extends Command {
labelTypes: this.labelTypeRegistry?.getLabelTypes(),
constraints: this.constraintRegistry?.getConstraints(),
mode: this.editorModeController?.getCurrentMode(),
version: CURRENT_VERSION,
};
const diagramJson = JSON.stringify(diagram, undefined, 4);
sendMessage("Json:" + diagramJson);
Expand Down
3 changes: 2 additions & 1 deletion src/features/serialize/defaultDiagram.json
Original file line number Diff line number Diff line change
Expand Up @@ -619,5 +619,6 @@
"constraint": "data Sensitivity.Personal neverFlows vertex Location.nonEU"
}
],
"mode": "edit"
"mode": "edit",
"version": 1
}
3 changes: 3 additions & 0 deletions src/features/serialize/save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ export interface SavedDiagram {
labelTypes?: LabelType[];
constraints?: Constraint[];
mode?: EditorMode;
version: number;
}
export const CURRENT_VERSION = 1;

export interface SaveDiagramAction extends Action {
kind: typeof SaveDiagramAction.KIND;
Expand Down Expand Up @@ -66,6 +68,7 @@ export class SaveDiagramCommand extends Command {
labelTypes: this.labelTypeRegistry?.getLabelTypes(),
constraints: this.constraintRegistry?.getConstraints(),
mode: this.editorModeController?.getCurrentMode(),
version: CURRENT_VERSION,
};
const diagramJson = JSON.stringify(diagram, undefined, 4);
const jsonBlob = new Blob([diagramJson], { type: "application/json" });
Expand Down
3 changes: 2 additions & 1 deletion src/features/serialize/saveDFDandDD.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { LabelTypeRegistry } from "../labels/labelTypeRegistry";
import { DynamicChildrenProcessor } from "../dfdElements/dynamicChildren";
import { EditorModeController } from "../editorMode/editorModeController";
import { sendMessage } from "./webSocketHandler";
import { SavedDiagram } from "./save";
import { CURRENT_VERSION, SavedDiagram } from "./save";
import { ConstraintRegistry } from "../constraintMenu/constraintRegistry";
import { getModelFileName } from "../../index";

Expand Down Expand Up @@ -58,6 +58,7 @@ export class SaveDFDandDDCommand extends Command {
labelTypes: this.labelTypeRegistry?.getLabelTypes(),
constraints: this.constraintRegistry?.getConstraints(),
mode: this.editorModeController?.getCurrentMode(),
version: CURRENT_VERSION,
};
const diagramJson = JSON.stringify(diagram, undefined, 4);
sendMessage("Json2DFD:" + getModelFileName() + ":" + diagramJson);
Expand Down