Skip to content

Commit

Permalink
Merge branch 'master' into bleepbop/VIRTS-4594/emu-docker-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
bleepbop committed Jun 28, 2023
2 parents e563c59 + 6507725 commit 874912c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
1 change: 0 additions & 1 deletion static/css/shared.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
/* toggle buttons */
.toggleContainer {
display: flex;
align-items: center;
}

.toggleContainer label {
Expand Down
35 changes: 33 additions & 2 deletions templates/operations.html
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ <h2>Operations</h2>
</span>
</template>
<template x-if="isOperationRunning">
<div class="toggleContainer">
<div class="toggleContainer flex is-flex-direction-column is-align-items-left">
<div>
<label for="toggleAutonomous">Manual</label>
<div class="toggleSwitch mx-2">
<input type="checkbox"
Expand All @@ -153,6 +154,22 @@ <h2>Operations</h2>
</span>
</div>
<label for="toggleAutonomous">Autonomous</label>
</div>
<div class="mt-4">
<label for="toggleScroll">Autoscroll</label>
<div class="toggleSwitch">
<input type="checkbox"
id="toggleAutonomous"
x-model="linkScrollHistory.isEnabled"
x-bind:checked="linkScrollHistory.isEnabled ? 'checked' : null"/>
<span class="toggleSlider toggleSliderRound"
title="Toggle autoscrolling"
x-on:click="linkScrollHistory.isEnabled = (linkScrollHistory.isEnabled === false) ? true : false"
x-bind:class="linkScrollHistory.isEnabled ? 'toggle-on' : 'toggle-off'">
<span x-bind:class="linkScrollHistory.isEnabled ? 'toggle-slider-on' : 'toggle-slider-off'"></span>
</span>
</div>
</div>
</div>
</template>
</div>
Expand Down Expand Up @@ -220,7 +237,7 @@ <h2>Operations</h2>
<template x-for="(link, index) in selectedOperation.chain" :key="link.id">
<tbody>
<tr x-bind:id="link.id"
x-on:click="selectedLink = link">
x-on:click="selectedLink = link" x-ref="linkRow" x-init="$nextTick(() => scrollToLastLink($refs.linkRow, index))">
<td class="decideColumn">
<span class="has-text-grey-light" x-text="getReadableTime(link.decide)"></span>
</td>
Expand Down Expand Up @@ -1228,6 +1245,7 @@ <h2>Operations</h2>
selectedLinkFacts: null,
selectedLinkPlaintextCommand: null,
selectedLinkCommand: null,
linkScrollHistory: {operationID: -1, shouldScroll: true, isEnabled: true},
selectedReportType: 'full-report',
isAgentOutputSelected: false,
openModal: null,
Expand Down Expand Up @@ -1367,6 +1385,13 @@ <h2>Operations</h2>
});
},

scrollToLastLink(linkRow, index){
// Check if link is the last link and that we haven't just switched operations
if (index === this.selectedOperation.chain.length - 1 && this.linkScrollHistory.shouldScroll && this.linkScrollHistory.isEnabled){
linkRow.scrollIntoView();
}
},

//
// API CALLS
//
Expand Down Expand Up @@ -1446,6 +1471,12 @@ <h2>Operations</h2>

apiV2('GET', `${this.ENDPOINT}/${this.selectedOperationID}`).then((res) => {
this.selectedOperation = res;
if (this.linkScrollHistory.operationID != this.selectedOperationID){
this.linkScrollHistory.shouldScroll = false;
}else{
this.linkScrollHistory.shouldScroll = true;
}
this.linkScrollHistory.operationID = this.selectedOperationID;
this.generateAddedLinksList();
}).catch(() => {
toast('Error getting operation');
Expand Down
21 changes: 21 additions & 0 deletions templates/sources.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ <h2>Fact Sources</h2>
<span class="icon"><em class="fas fa-copy"></em></span>
<span>Duplicate Source</span>
</button>
<button class="button is-primary is-small mb-2" @click="downloadSource()"
x-bind:disabled="!selectedSourceId">
<span class="icon"><em class="fas fa-arrow-down"></em></span>
<span>Download Source</span>
</button>
<div class="hr"></div>
<button class="button is-small mb-2 is-danger is-outlined"
@click="openModal = { isOpen: true, name: 'Delete Source' }">
Expand Down Expand Up @@ -1260,6 +1265,22 @@ <h2>Fact Sources</h2>
});
},

downloadSource() {
apiV2('GET', `/api/v2/sources/${this.selectedSourceId}`)
.then((res) => {
const dataURL = `data:text/json;charset=utf-8,${encodeURIComponent(JSON.stringify(res, null, 2))}`
const fileName = `${this.selectedSource.name}.json`
const elem = document.createElement('a');
elem.setAttribute('href', dataURL);
elem.setAttribute('download', fileName);
elem.click();
elem.remove();
}).catch((error) => {
toast('Error downloading source');
console.error(error)
});
},

resetSearch() {
this.abilitySearch = {
query: '',
Expand Down

0 comments on commit 874912c

Please sign in to comment.