Skip to content

Commit

Permalink
[gui] Highlight options in the check command
Browse files Browse the repository at this point in the history
- Move check command dialog into separate component.
- Highlight options (--enabled, --disabled, --ctu, etc.) in the check commands.
  • Loading branch information
csordasmarton committed Apr 22, 2021
1 parent 4c9f5e5 commit 2f99572
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ import { ccService, handleThriftError } from "@cc-api";
import { AnalyzerStatisticsIcon } from "@/components/Icons";
export default {
name: "DeleteProductBtn",
name: "AnalyzerStatisticsDialog",
components: {
AnalyzerStatisticsIcon
},
Expand Down Expand Up @@ -161,7 +161,7 @@ export default {
methods: {
getAnalysisStatistics() {
if (!this.runId && !this.runHistoryId) return;
if (!this.dialog && !this.runId && !this.runHistoryId) return;
ccService.getClient().getAnalysisStatistics(this.runId,
this.runHistoryId, handleThriftError(stats => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

<script>
export default {
name: "ShowCheckCommandBtn",
name: "CheckCommandBtn",
};
</script>
143 changes: 143 additions & 0 deletions web/server/vue-cli/src/components/Run/CheckCommandDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<template>
<v-dialog
v-model="dialog"
content-class="check-command"
max-width="80%"
scrollable
>
<v-card>
<v-card-title
class="headline primary white--text"
primary-title
>
Check commands

<v-spacer />

<v-btn icon dark @click="dialog = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-card-title>
<v-card-text>
<v-container class="pa-0 pt-2">
<!-- eslint-disable vue/no-v-html -->
<div
v-for="cmd in checkCommands"
:key="cmd"
class="check-command mb-2"
v-html="cmd"
/>
</v-container>
</v-card-text>
</v-card>
</v-dialog>
</template>

<script>
import { ccService, handleThriftError } from "@cc-api";
export default {
name: "CheckCommandDialog",
props: {
value: { type: Boolean, default: false },
runId: { type: Object, default: () => null },
runHistoryId: { type: Object, default: () => null }
},
data() {
return {
checkCommands: [],
enabledCheckerRgx: new RegExp("^(--enable|-e[= ]*)", "i"),
disabledCheckerRgx: new RegExp("^(--disable|-d[= ]*)", "i"),
};
},
computed: {
dialog: {
get() {
return this.value;
},
set(val) {
this.$emit("update:value", val);
}
}
},
watch: {
runId() {
this.getCheckCommands();
},
runHistoryId() {
this.getCheckCommands();
}
},
mounted() {
this.getCheckCommands();
},
methods: {
highlightOptions(cmd) {
return cmd.split(" ").map(param => {
if (!param.startsWith("-")) {
return param;
}
const classNames = [ "param" ];
if (this.enabledCheckerRgx.test(param)) {
classNames.push("enabled-checkers");
} else if (this.disabledCheckerRgx.test(param)) {
classNames.push("disabled-checkers");
} else if (param.startsWith("--ctu")) {
classNames.push("ctu");
} else if (param.startsWith("--stats")) {
classNames.push("statistics");
}
return `<span class="${classNames.join(" ")}">${param}</span>`;
}).join(" ");
},
getCheckCommands() {
if (!this.dialog || (!this.runId && !this.runHistoryId)) return;
this.checkCommands = [];
ccService.getClient().getCheckCommand(this.runHistoryId, this.runId,
handleThriftError(cmd => {
const checkCmd =
cmd?.replace("multiple analyze calls:", "") || "Unavailable!";
this.checkCommands = checkCmd.split(";").map(cmd =>
this.highlightOptions(cmd)
);
}));
}
}
};
</script>
<style lang="scss" scoped>
::v-deep .check-command {
border: 1px solid grey;
padding: 4px;
.param {
background-color: rgba(0, 0, 0, 0.15);
font-weight: bold;
padding-left: 2px;
padding-right: 2px;
}
.enabled-checkers {
background-color: rgba(0, 142, 0, 0.15);
}
.disabled-checkers {
background-color: rgba(142, 0, 0, 0.15);
}
.ctu, .statistics {
background-color: rgba(0, 0, 142, 0.15);
}
}
</style>
8 changes: 4 additions & 4 deletions web/server/vue-cli/src/components/Run/ExpandedRun.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@

<v-divider class="mx-2 d-inline" inset vertical />

<show-check-command-btn
@click="openCheckCommandDialog(null, history.id)"
<check-command-btn
@click.native="openCheckCommandDialog(null, history.id)"
/>

<v-divider class="mx-2 d-inline" inset vertical />
Expand Down Expand Up @@ -140,15 +140,15 @@
import { format, parse } from "date-fns";
import { defaultReportFilterValues } from "@/components/Report/ReportFilter";
import AnalyzerStatisticsBtn from "./AnalyzerStatisticsBtn";
import ShowCheckCommandBtn from "./ShowCheckCommandBtn";
import CheckCommandBtn from "./CheckCommandBtn";
import ShowStatisticsBtn from "./ShowStatisticsBtn";
import VersionTag from "./VersionTag";
export default {
name: "ExpandedRun",
components: {
AnalyzerStatisticsBtn,
ShowCheckCommandBtn,
CheckCommandBtn,
ShowStatisticsBtn,
VersionTag
},
Expand Down
8 changes: 4 additions & 4 deletions web/server/vue-cli/src/components/Run/RunNameColumn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
vertical
/>

<show-check-command-btn
<check-command-btn
@click="openCheckCommandDialog(id)"
/>

Expand Down Expand Up @@ -72,7 +72,7 @@ import { defaultStatisticsFilterValues } from "@/components/Statistics";
import { DetectionStatusMixin } from "@/mixins";
import { DetectionStatusIcon } from "@/components/Icons";
import ShowCheckCommandBtn from "./ShowCheckCommandBtn";
import CheckCommandBtn from "./CheckCommandBtn";
import ShowStatisticsBtn from "./ShowStatisticsBtn";
import VersionTag from "./VersionTag";
Expand All @@ -81,13 +81,13 @@ export default {
components: {
DetectionStatusIcon,
RunDescription,
ShowCheckCommandBtn,
CheckCommandBtn,
ShowStatisticsBtn,
VersionTag
},
mixins: [ DetectionStatusMixin ],
props: {
id: { type: Number, required: true },
id: { type: Object, required: true },
name: { type: String, required: true },
description: { type: String, default: null },
versionTag: { type: String, default: null },
Expand Down
4 changes: 4 additions & 0 deletions web/server/vue-cli/src/components/Run/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import AnalyzerStatisticsBtn from "./AnalyzerStatisticsBtn";
import AnalyzerStatisticsDialog from "./AnalyzerStatisticsDialog";
import CheckCommandBtn from "./CheckCommandBtn";
import CheckCommandDialog from "./CheckCommandDialog";
import DeleteRunBtn from "./DeleteRunBtn";
import ExpandedRun from "./ExpandedRun";
import RunDescription from "./RunDescription";
Expand All @@ -9,6 +11,8 @@ import RunFilterToolbar from "./RunFilterToolbar";
export {
AnalyzerStatisticsBtn,
AnalyzerStatisticsDialog,
CheckCommandBtn,
CheckCommandDialog,
DeleteRunBtn,
ExpandedRun,
RunDescription,
Expand Down
56 changes: 12 additions & 44 deletions web/server/vue-cli/src/views/RunList.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
<template>
<v-card flat tile>
<v-dialog
v-model="showCheckCommandDialog"
content-class="check-command"
width="500"
>
<v-card>
<v-card-title
class="headline primary white--text"
primary-title
>
Check command

<v-spacer />

<v-btn icon dark @click="showCheckCommandDialog = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-card-title>
<v-card-text>
<v-container>
{{ checkCommand }}
</v-container>
</v-card-text>
</v-card>
</v-dialog>
<check-command-dialog
:value.sync="checkCommandDialog"
:run-id="selectedRunId"
:run-history-id="selectedRunHistoryId"
/>

<analyzer-statistics-dialog
:value.sync="analyzerStatisticsDialog"
Expand Down Expand Up @@ -90,7 +70,7 @@

<template #item.name="{ item }">
<run-name-column
:id="item.runId.toNumber()"
:id="item.runId"
:name="item.name"
:description="item.description"
:version-tag="item.versionTag"
Expand Down Expand Up @@ -180,6 +160,7 @@ import {
import {
AnalyzerStatisticsBtn,
AnalyzerStatisticsDialog,
CheckCommandDialog,
ExpandedRun,
RunFilterToolbar,
RunNameColumn
Expand All @@ -190,6 +171,7 @@ export default {
components: {
AnalyzerStatisticsBtn,
AnalyzerStatisticsDialog,
CheckCommandDialog,
ExpandedRun,
RunNameColumn,
RunFilterToolbar
Expand All @@ -207,7 +189,7 @@ export default {
return {
initialized: false,
showCheckCommandDialog: false,
checkCommandDialog: false,
checkCommand: null,
pagination: {
page: page,
Expand Down Expand Up @@ -316,10 +298,6 @@ export default {
this.fetchRuns();
},
deep: true
},
showCheckCommandDialog (val) {
val || this.closeCheckCommandDialog();
}
},
Expand Down Expand Up @@ -528,14 +506,9 @@ export default {
},
openCheckCommandDialog(runId, runHistoryId=null) {
ccService.getClient().getCheckCommand(runHistoryId, runId,
handleThriftError(checkCommand => {
if (!checkCommand) {
checkCommand = "Unavailable!";
}
this.checkCommand = checkCommand;
this.showCheckCommandDialog = true;
}));
this.selectedRunId = runId;
this.selectedRunHistoryId = runHistoryId;
this.checkCommandDialog = true;
},
openAnalyzerStatisticsDialog(report, history=null) {
Expand All @@ -544,11 +517,6 @@ export default {
this.analyzerStatisticsDialog = true;
},
closeCheckCommandDialog() {
this.showCheckCommandDialog = false;
this.checkCommand = null;
},
prettifyDuration(seconds) {
if (seconds >= 0) {
const durHours = Math.floor(seconds / 3600);
Expand Down

0 comments on commit 2f99572

Please sign in to comment.