Commit fd4e39cc authored by unknown's avatar unknown

backend bug fix & tests update

parent 0487a601
Pipeline #3273 passed with stage
in 29 seconds
......@@ -55,7 +55,7 @@ class Core:
Logger.error.log('Error occurred while parsing report: {}'.format(pe))
try:
file.save_unified_report(self.__tool.internal_structure.get())
file.save_unified_report(self.__tool.internal_structure.get(clear=True))
except Exception as fe:
Logger.error.log('Error while creating json file: {}'.format(fe))
......
......@@ -133,17 +133,18 @@ container also servers as router inside docker subnet. Routing proved Nginx.
service.
- <b>nginx</b> Configuration of Nginx. Here is possible to set additional reverse proxy to another service.
- <b>node_modules</b> - All node modules required by frontend service. Do <b>NOT</b> manually edit.
- <b>public</b> - Main HTML template, with favicon icons. In this template, all javascript files
are injected.
- <b>public</b> - Favicon icons.
- <b>src</b> - Sources code of frontend project.
<hr>
- <b>assets</b> - Additionally images.
- <b>boots</b> - Vue init and import libraries.
- <b>components</b> - All *.vue components.
- <b>config</b> - Mapping url from docker environment variable to Vue runtime variable.
- <b>css</b> - Global application styles
- <b>helpers</b> - Helper classes.
- <b>pages</b> - All pages of application.
- <b>required</b> - CodeMirror basic style imports.
- <b>styles</b> - Global application styles
- <b>router</b> - Vue router.
<pre>
├───dist
......@@ -152,12 +153,13 @@ container also servers as router inside docker subnet. Routing proved Nginx.
├───public
└───src
├───assets
├───boot
├───components
├───config
├───css
├───helpers
├───pages
├───required
└───styles
└───router
</pre>
......
......@@ -16,6 +16,7 @@
"axios": "^0.18.1",
"core-js": "^3.6.5",
"quasar": "^1.0.0",
"vue-clipboard2": "^0.3.1",
"vue-codemirror": "^4.0.6",
"vue-text-highlight": "^2.0.10"
},
......
......@@ -19,7 +19,9 @@ module.exports = function (/* ctx */) {
// --> boot files are part of "main.js"
// https://quasar.dev/quasar-cli/boot-files
boot: [
'axios'
'axios',
'codeMirrorStyles',
'clipboard'
],
// https://quasar.dev/quasar-cli/quasar-conf-js#Property%3A-css
......
import VueClipboard from 'vue-clipboard2'
export default async ({ Vue }) => {
Vue.use(VueClipboard)
}
......@@ -10,6 +10,9 @@ import 'codemirror/mode/clike/clike.js'
import 'codemirror/mode/python/python.js'
import 'codemirror/addon/edit/closebrackets.js'
//
import 'codemirror/lib/codemirror.css'
import 'codemirror/addon/fold/brace-fold.js'
import 'codemirror/addon/fold/comment-fold.js'
import 'codemirror/addon/fold/foldcode.js'
......
<template>
<div class="q-ma-none bg-grey-2 row justify-center window-height" id="dem">
<div class="q-ma-none bg-grey-2 row justify-center window-height" id="dem" style="overflow: hidden!important;">
<div class="column col-12 ">
<upload
@ajax-start="ajaxStart"
......
......@@ -231,7 +231,7 @@
<script>
// import LocalStorageWrapper from "../helpers/LocalStorageWrapper";
import UploadedFilesParser from '../helpers/UploadedFilesParser'
import UploadedFilesParser from 'src/helpers/UploadedFilesParser'
const CONFIG = require('../config/config')
......
<template>
<div :class="dark" class="window-height">
<div :class="dark" class="window-height" style="overflow: hidden!important;">
<q-separator :color="separator"/>
<div class="" id="rep">
<div class="row">
......@@ -160,7 +160,8 @@ export default {
message: 'No available report to update',
type: 'warning',
position: 'bottom',
timeout: 3000
timeout: 3000,
textColor: 'white'
})
return
}
......@@ -183,7 +184,9 @@ export default {
message: message,
type: type,
position: 'bottom',
timeout: 3000
timeout: 3000,
textColor: 'white'
})
},
compare () {
......
......@@ -56,11 +56,9 @@
<script>
import '../required/imports.js'
import '../css/codeStyle.css'
import { codemirror } from 'vue-codemirror'
import 'codemirror/lib/codemirror.css'
import R from '../helpers/ReportStructure'
import R from 'src/helpers/ReportStructure'
const leftArrow = 37
const rightArrow = 39
......@@ -302,14 +300,13 @@ export default {
let text = e.path[4].innerText
const index = text.lastIndexOf('\n')
text = text.substr(0, index)
this.$copyText(text).then(() => {
this.$q.notify({
color: 'info',
message: 'Copied',
type: 'positive',
position: 'bottom',
textColor: 'black',
textColor: 'white',
timeout: 10000
})
}, () => {
......@@ -318,7 +315,8 @@ export default {
message: 'Error!',
type: 'warning',
position: 'bottom',
timeout: 1000
timeout: 1000,
textColor: 'white'
})
})
},
......@@ -578,7 +576,8 @@ export default {
this.setMode(editor)
},
setMode (editor) {
const ext = this.unified_report[0].file.split('.').pop()
const ext = editor.name.split('.').pop()
console.log('ext', ext)
if (ext === 'c' || ext === 'h') {
editor.editor.setOption('mode', 'text/x-csrc')
} else if (ext === 'py') {
......
<template>
<div :class="backgroundDark" class="q-pt-sm " id="adas">
<div class="row font" id="obalovaci">
<div class="col-10 column justify-end q-pb-sm" style="max-height: 90px">
<div class="col-6" style="margin-left: 57px">
<div class="q-pa-none row justify-center">
<div class="col-10 ">
<div class="q-gutter-sm row justify-center">
<q-icon
:color="helpIconDark"
name="help_outline"
size="sm"
style="padding-top: 5px"
>
<q-tooltip
:offset="[10,10]"
content-class="bg-grey-11 text-black"
:content-style="$q.dark.isActive ? 'font-size: 13px;' : 'font-size: 13px; border: 1px solid black'"
<div :class="backgroundDark" class="q-pt-sm " id="adas">
<div class="row font" id="obalovaci">
<div class="col-10 column justify-end q-pb-sm" style="max-height: 90px">
<div class="col-6" style="margin-left: 57px">
<div class="q-pa-none row justify-center">
<div class="col-10 ">
<div class="q-gutter-sm row justify-center">
<q-icon
:color="helpIconDark"
name="help_outline"
size="sm"
style="padding-top: 5px"
>
<q-tooltip
:offset="[10,10]"
content-class="bg-grey-11 text-black"
:content-style="$q.dark.isActive ? 'font-size: 13px;' : 'font-size: 13px; border: 1px solid black'"
>
Choose tool which will parse your report if guess failed
</q-tooltip>
</q-icon>
<q-select
:disable="checkBox"
:options="getOptionValues()"
class="bg-grey-2 col-12"
dense
label="Choose a tool"
option-label="test"
option-value="test_val"
style="max-width: 250px"
v-model="tools">
<template v-slot:prepend>
<q-icon class="q-ml-sm"
name="build"
/>
</template>
</q-select>
<q-checkbox
class="q-mr-lg q-ml-none"
color="green"
label="Guess tool"
size="30px"
style="color: white"
v-model="checkBox"
/>
</div>
</div>
</div>
</div>
<div class="col-6 " style="margin-left: 30px;">
<div class="q-pa-none row justify-center ">
<div class="col-10 ">
<div class="q-gutter-sm row justify-center">
<q-icon
:color="helpIconDark"
name="help_outline"
size="sm"
style="padding-top: 5px"
>
<q-tooltip
:offset="[10,10]"
content-class="bg-grey-3 text-black"
:content-style="$q.dark.isActive ? 'font-size: 13px;' : 'font-size: 13px; border: 1px solid black'"
>
Upload your source codes and report with .txt suffix
</q-tooltip>
</q-icon>
<q-file
class="bg-grey-2 col-12"
clearable
dense
filled
input-class="files"
label="Upload your files"
multiple
ref="qfile"
style="max-width: 250px"
v-model="files"
>
<template v-slot:prepend>
<q-icon name="attach_file"/>
</template>
</q-file>
<q-btn
:color="buttonDark"
@click="processFiles"
dense
label="Upload"
outline
style="width: 80px; max-height: 40px"
>
<template v-slot:loading>
<q-spinner-gears/>
</template>
</q-btn>
</div>
</div>
</div>
</div>
</div>
<div class="col-2 row items-end q-ma-none justify-end">
<div class="column q-pr-lg">
<div class="text-amber-1 text-weight-medium ">
Dark mode
</div>
<q-toggle
@input="saveDarkSate"
color="black"
v-model="dark"
>
Choose tool which will parse your report if guess failed
</q-tooltip>
</q-icon>
<q-select
:disable="checkBox"
:options="getOptionValues()"
class="bg-grey-2 col-12"
dense
label="Choose a tool"
option-label="test"
option-value="test_val"
style="max-width: 250px"
v-model="tools">
<template v-slot:prepend>
<q-icon class="q-ml-sm"
name="build"
/>
</div>
</template>
</q-select>
<q-checkbox
class="q-mr-lg q-ml-none"
color="green"
label="Guess tool"
size="30px"
style="color: white"
v-model="checkBox"
/>
</div>
</div>
</div>
</div>
<div class="col-6 " style="margin-left: 30px;">
<div class="q-pa-none row justify-center ">
<div class="col-10 ">
<div class="q-gutter-sm row justify-center">
<q-icon
:color="helpIconDark"
name="help_outline"
size="sm"
style="padding-top: 5px"
>
<q-tooltip
:offset="[10,10]"
content-class="bg-grey-3 text-black"
:content-style="$q.dark.isActive ? 'font-size: 13px;' : 'font-size: 13px; border: 1px solid black'"
>
Upload your source codes and report with .txt suffix
</q-tooltip>
</q-icon>
<q-file
class="bg-grey-2 col-12"
clearable
dense
filled
input-class="files"
label="Upload your files"
multiple
ref="qfile"
style="max-width: 250px"
v-model="files"
hide-bottom-space
>
<template v-slot:prepend>
<q-icon name="attach_file"/>
</template>
</q-file>
<q-btn
:color="buttonDark"
@click="processFiles"
dense
label="Upload"
outline
style="width: 80px; max-height: 40px"
>
<template v-slot:loading>
<q-spinner-gears/>
</template>
</q-btn>
</div>
</div>
<q-ajax-bar
color="positive"
position="bottom"
ref="bar"
size="10px"
skip-hijack
/>
<q-space/>
</div>
</div>
</div>
<div class="col-2 row items-end q-ma-none justify-end">
<div class="column q-pr-lg">
<div class="text-amber-1 text-weight-medium ">
Dark mode
</div>
<q-toggle
@input="saveDarkSate"
color="black"
v-model="dark"
/>
</div>
</div>
<q-ajax-bar
color="positive"
position="bottom"
ref="bar"
size="10px"
skip-hijack
/>
<q-space/>
</div>
</div>
</template>
<script>
const CONFIG = require('../config/config')
import UploadedFilesParser from '../helpers/UploadedFilesParser'
import LocalStorageWrapper from '../helpers/LocalStorageWrapper'
import UploadedFilesParser from 'src/helpers/UploadedFilesParser'
import LocalStorageWrapper from 'src/helpers/LocalStorageWrapper'
export default {
name: 'Upload',
......@@ -177,14 +178,14 @@ export default {
}
formData.append('url', window.location.pathname)
this.$axios.post(
`${CONFIG.BACKEND_API_LOCAL_URL}/files`,
formData,
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Access-Control-Allow-Origin': '*'
}
}
`${CONFIG.BACKEND_API_LOCAL_URL}/files`,
formData,
{
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Access-Control-Allow-Origin': '*'
}
}
)
.then((response) => {
this.files = null
......@@ -205,15 +206,16 @@ export default {
},
getFiles (id, folder) {
this.$axios.get(
`${CONFIG.BACKEND_API_LOCAL_URL}/file/${id}/${folder}`,
{
header: {
'Content-Type': 'application/x-www-form-urlencoded',
'Access-Control-Allow-Origin': '*'
}
}
`${CONFIG.BACKEND_API_LOCAL_URL}/file/${id}/${folder}`,
{
header: {
'Content-Type': 'application/x-www-form-urlencoded',
'Access-Control-Allow-Origin': '*'
}
}
)
.then((response) => {
console.log('response', response)
this.response = response.data
this.setUrlParam(window.location.pathname, id)
this.$emit('response-data', UploadedFilesParser.set(this.response))
......@@ -234,6 +236,10 @@ export default {
}
},
processFiles () {
if (!this.files) {
this.showNotiff('You dont have selected any files', 3000, 'negative', 'warning')
}
if (this.files.length === 0) {
this.showNotiff('You dont have selected any files', 3000, 'negative', 'warning')
return
......@@ -244,24 +250,26 @@ export default {
this.submitFiles()
}
},
showNotiff (text, tm, color, type) {
showNotiff (text, tm, color, type, textColor = 'white') {
this.$q.notify({
color: color,
message: text,
type: type,
position: 'bottom',
timeout: tm
timeout: tm,
textColor: textColor
})
},
synchronizeTools () {
this.$axios.get(
`${CONFIG.BACKEND_API_LOCAL_URL}/tools`,
{
headers: {
'Content-Type': 'multipart/form-data',
'Access-Control-Allow-Origin': '*'
}
}
`${CONFIG.BACKEND_API_LOCAL_URL}/tools`,
{
headers: {
'Content-Type': 'multipart/form-data',
'Access-Control-Allow-Origin': '*'
}
}
)
.then((response) => {
response.data.forEach((item) => {
......@@ -326,15 +334,15 @@ export default {
<style scoped>
.files {
background: red !important;
}
.files {
background: red !important;
}
.q-field--dark {
background: #3b3434 !important;
}
.q-field--dark {
background: #3b3434 !important;
}
.font {
font-family: "Yu Gothic UI Light"
}
.font {
font-family: "Yu Gothic UI Light"
}
</style>
......@@ -62,11 +62,6 @@ export default class LocalStorageWrapper {
localStorage.setItem(key, JSON.stringify(dataToStorage))
}
removeItem (index, key) {
console.log(index)
console.log(key)
}
destroy (key) {
if (!this.isString(key)) {
return
......
......@@ -11,12 +11,8 @@ const UploadedFilesParser = {
this.unified_report = bundle.unified_report
this.dir = bundle.dir ? bundle.dir : bundle.directory_path.slice(-8)
this.original_dir = this.dir
this.f()
return this
},
setUpReport () {
console.log(this.unified_report)
},
getFileNames () {
const arr = []
for (let i = 0; i < this.source_files.length; i++) {
......@@ -37,37 +33,6 @@ const UploadedFilesParser = {
})
}
return arr
},
search () {
// eslint-disable-next-line no-prototype-builtins
// if(!(obj.hasOwnProperty('Backtrace'))) return;
//
// for (const prop in obj) {
// if(obj[prop] == null) { // pokud jsme dosli na konec
// return;
// } else {
// this.search(obj[prop]) // rekurzivni hledani
// console.log(obj)// start parsing
// }
// }
},
f () {
// let test = {
// 'line': 1,
// 'Backtrace': {
// 'line': 2,
// 'Backtrace': {
// 'line': 3,
// 'Backtrace': null
// }
// }
// }
// let x = {
// 'Backtrace' : 10,
// }
this.search()
}
}
// convert to class
export default UploadedFilesParser
......@@ -9,11 +9,11 @@
<meta name="msapplication-tap-highlight" content="no">
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width<% if (ctx.mode.cordova || ctx.mode.capacitor) { %>, viewport-fit=cover<% } %>">
<link rel="icon" type="image/png" sizes="128x128" href="icons/favicon-128x128.png">
<link rel="icon" type="image/png" sizes="96x96" href="icons/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="32x32" href="icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="icons/favicon-16x16.png">
<link rel="icon" type="image/ico" href="favicon.ico">
<!-- <link rel="icon" type="image/png" sizes="128x128" href="icons/favicon-128x128.png">-->
<!-- <link rel="icon" type="image/png" sizes="96x96" href="icons/favicon-96x96.png">-->
<!-- <link rel="icon" type="image/png" sizes="32x32" href="icons/favicon-32x32.png">-->
<!-- <link rel="icon" type="image/png" sizes="16x16" href="icons/favicon-16x16.png">-->
<link rel="icon" type="image/ico" href="logo.png">
</head>
<body>
<!-- DO NOT touch the following DIV -->
......
......@@ -2494,6 +2494,15 @@ cli-width@^3.0.0: