Skip to content

Commit

Permalink
Add Open and Save feature to web application to support Open Threat M…
Browse files Browse the repository at this point in the history
…odel (OTM) format
  • Loading branch information
jgadsden authored Nov 29, 2023
2 parents b6cc737 + bbde8d3 commit 73142a8
Show file tree
Hide file tree
Showing 11 changed files with 529 additions and 25 deletions.
11 changes: 10 additions & 1 deletion td.vue/src/components/Graph.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,18 @@ export default {
threatSelected(threatId) {
this.$refs.threatEditDialog.editThreat(threatId);
},
saved() {
savedtd() {
const updated = Object.assign({}, this.diagram);
updated.cells = this.graph.toJSON().cells;
updated.format = "td";
this.$store.dispatch(tmActions.diagramUpdated, updated);
this.$store.dispatch(tmActions.save);
this.$store.dispatch(tmActions.unmodified);
},
savedotm() {
const updated = Object.assign({}, this.diagram);
updated.cells = this.graph.toJSON().cells;
updated.format = "otm";
this.$store.dispatch(tmActions.diagramUpdated, updated);
this.$store.dispatch(tmActions.save);
this.$store.dispatch(tmActions.unmodified);
Expand Down
16 changes: 9 additions & 7 deletions td.vue/src/components/GraphButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@
icon="times"
:text="$t('forms.close')" />

<td-form-button
:isPrimary="true"
:onBtnClick="save"
icon="save"
:text="$t('forms.save')" />
<b-dropdown right :isPrimary="true" icon="save" :text="$t('forms.save')">
<b-dropdown-item-button :text="$t('forms.savetd')" icon="savetd" @click="savetd">{{$t('forms.savetd')}}</b-dropdown-item-button>
<b-dropdown-item-button :text="$t('forms.saveotm')" icon="saveotm" @click="saveotm">{{$t('forms.saveotm')}}</b-dropdown-item-button>
</b-dropdown>

</b-btn-group>
</template>
Expand All @@ -76,8 +75,11 @@ export default {
}
},
methods: {
save() {
this.$emit('saved');
savetd() {
this.$emit('savedtd');
},
saveotm() {
this.$emit('savedotm');
},
async closeDiagram() {
this.$emit('closed');
Expand Down
2 changes: 2 additions & 0 deletions td.vue/src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ const eng = {
remove: 'Remove',
report: 'Report',
save: 'Save',
savetd: 'Threat Dragon Format',
saveotm: 'OTM Format',
saveAs: 'Save As',
saveHtml: 'Save HTML',
saveModel: 'Save Model',
Expand Down
Loading

0 comments on commit 73142a8

Please sign in to comment.