Skip to content

Commit b8f418e

Browse files
committed
first working implementation
1 parent 5fd0246 commit b8f418e

File tree

1 file changed

+68
-15
lines changed

1 file changed

+68
-15
lines changed

web/server/vue-cli/src/views/Reports.vue

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<splitpanes class="default-theme">
33
<pane size="20" :style="{ 'min-width': '300px' }">
44
<report-filter
5+
ref="reportFilter"
56
v-fill-height
67
:namespace="namespace"
78
:report-count="totalItems"
@@ -236,8 +237,9 @@
236237
<v-treeview
237238
:items="formattedDirectoriesForTreeViewRunResults"
238239
activatable
239-
item-key="name"
240+
item-key="fullPath"
240241
open-on-click
242+
@update:active="onTreeFileClick"
241243
>
242244
<template #prepend="{ item, open }">
243245
<v-icon v-if="item.children.length > 0">
@@ -260,8 +262,9 @@
260262
<v-treeview
261263
:items="formattedDirectoriesForTreeViewFileCounts"
262264
activatable
263-
item-key="name"
265+
item-key="fullPath"
264266
open-on-click
267+
@update:active="onTreeFileClick"
265268
>
266269
<template #prepend="{ item, open }">
267270
<v-icon v-if="item.children.length > 0">
@@ -286,10 +289,13 @@
286289
<script>
287290
import { Pane, Splitpanes } from "splitpanes";
288291
289-
import { mapGetters } from "vuex";
292+
import { mapGetters, mapMutations } from "vuex";
290293
291294
import { ccService, handleThriftError } from "@cc-api";
292-
import { Checker, Order, SortMode, SortType } from "@cc/report-server-types";
295+
import {
296+
Checker, Order, SortMode, SortType
297+
} from "@cc/report-server-types";
298+
import { SET_REPORT_FILTER } from "@/store/mutations.type";
293299
294300
import { FillHeight } from "@/directives";
295301
import { BugPathLengthColorMixin, DetectionStatusMixin } from "@/mixins";
@@ -329,11 +335,12 @@ const TreeItem = {
329335
`
330336
};
331337
332-
// codechecker analyze enable all + store it + show in tree view
333-
// measure the time between current impelementation and the one with getCheckerCounts
334-
// implementation A and B for thesis documentation
335-
// getFileCounts(report server.thrift)
336-
//
338+
// codechecker analyze enable all + store it + show in tree view DONE
339+
// measure the time between current impelementation and the one with getCheckerCounts DONE
340+
// implementation A and B for thesis documentation DONE
341+
// getFileCounts(report server.thrift) DONE
342+
343+
// getCheckerCounts(report server.thrift) - if performance with getFileCounts is not good, we can try to implement this and use it instead, but it is needed to add new endpoint to get counts for all checkers and not only total count, so it is going to be filename, checker name -> count DONE
337344
// Introduce new hash in table, in some cases when different checkers report to the same line they may report the same error, so it is needed to group them up
338345
// In cases the reports are different we should do mapping table to a bug type and add that to hash again
339346
// Filename, line, bug type -> new hash
@@ -563,13 +570,18 @@ export default {
563570
this.allReportsRunResults.forEach(report => {
564571
const pathParts = report.checkedFile.split("/").slice(0, -1);
565572
let currentLevel = items;
573+
let currentPath = "";
566574
pathParts.forEach(part => {
567575
if (part === "") return;
568576
569-
let existingPart = currentLevel.find(item => item.name === part);
577+
currentPath += "/" + part;
578+
let existingPart = currentLevel.find(
579+
item => item.name === part
580+
);
570581
if (!existingPart) {
571582
existingPart = {
572583
name: part,
584+
fullPath: currentPath,
573585
children: [],
574586
findings: 0
575587
};
@@ -579,14 +591,19 @@ export default {
579591
});
580592
581593
// append filename as a child of the last directory
582-
const fileName = report.checkedFile.split("/").slice(-1)[0];
594+
const fileName = report.checkedFile
595+
.split("/").slice(-1)[0];
583596
if (fileName) {
584-
let existingFile = currentLevel.find(item => item.name === fileName);
597+
const filePath = currentPath + "/" + fileName;
598+
const existingFile = currentLevel.find(
599+
item => item.name === fileName
600+
);
585601
if (existingFile) {
586602
existingFile.findings += 1;
587603
} else {
588604
currentLevel.push({
589605
name: fileName,
606+
fullPath: filePath,
590607
children: [],
591608
findings: 1
592609
});
@@ -613,17 +630,24 @@ export default {
613630
formattedDirectoriesForTreeViewFileCounts() {
614631
const items = [];
615632
616-
Object.entries(this.allReportsFileCounts || {}).forEach(([filePath, count]) => {
633+
Object.entries(
634+
this.allReportsFileCounts || {}
635+
).forEach(([ filePath, count ]) => {
617636
if (!filePath) return;
618637
const pathParts = filePath.split("/").slice(0, -1);
619638
let currentLevel = items;
639+
let currentPath = "";
620640
pathParts.forEach(part => {
621641
if (part === "") return;
622642
623-
let existingPart = currentLevel.find(item => item.name === part);
643+
currentPath += "/" + part;
644+
let existingPart = currentLevel.find(
645+
item => item.name === part
646+
);
624647
if (!existingPart) {
625648
existingPart = {
626649
name: part,
650+
fullPath: currentPath,
627651
children: [],
628652
findings: 0
629653
};
@@ -635,12 +659,15 @@ export default {
635659
// append filename as a child of the last directory
636660
const fileName = filePath.split("/").slice(-1)[0];
637661
if (fileName) {
638-
let existingFile = currentLevel.find(item => item.name === fileName);
662+
const existingFile = currentLevel.find(
663+
item => item.name === fileName
664+
);
639665
if (existingFile) {
640666
existingFile.findings += count;
641667
} else {
642668
currentLevel.push({
643669
name: fileName,
670+
fullPath: filePath,
644671
children: [],
645672
findings: count
646673
});
@@ -692,6 +719,32 @@ export default {
692719
},
693720
694721
methods: {
722+
...mapMutations(namespace, {
723+
setReportFilter: SET_REPORT_FILTER
724+
}),
725+
726+
onTreeFileClick(activeItems) {
727+
// activeItems is an array of item-key values (fullPath)
728+
if (!activeItems || activeItems.length === 0) return;
729+
730+
const filePath = activeItems[0];
731+
if (!filePath) return;
732+
733+
// Find the FilePathFilter instance inside ReportFilter
734+
// and call its setSelectedItems to select this file.
735+
const filters = this.$refs.reportFilter.$refs.filters;
736+
const filePathFilter = filters.find(
737+
f => f.id === "filepath"
738+
);
739+
if (filePathFilter) {
740+
filePathFilter.setSelectedItems([
741+
{ id: filePath, title: filePath, count: "N/A" }
742+
]);
743+
}
744+
745+
this.viewMode = "table";
746+
},
747+
695748
itemExpanded(expandedItem) {
696749
if (expandedItem.item.sameReports) return;
697750

0 commit comments

Comments
 (0)