Commit 37ead382 authored by unknown's avatar unknown

minor validation

parent 9fc5b493
Pipeline #3336 passed with stage
in 31 seconds
......@@ -16,6 +16,7 @@ class File:
"""
supported_extension = ('.c', 'py', 'java', 'cpp', '.h')
source_extension = re.compile(r'\w+.(\w+)')
report_extension = ('.txt', '.log')
def __init__(self, folder_id, create_directory=True):
self.id = folder_id
......@@ -61,7 +62,7 @@ class File:
for file in os.listdir(self.concrete_directory):
file_dir = os.path.join(self.concrete_directory, file)
if file.endswith('.txt'): # report
if file.endswith(self.report_extension): # report
with open(file_dir, "r") as concrete_file:
report = concrete_file.read()
......@@ -110,7 +111,7 @@ class File:
if file.endswith('json'):
with open(os.path.join(file_path, file), 'r') as concrete_file:
unified_report = json.load(concrete_file)
elif file.endswith('.txt'):
elif file.endswith(self.report_extension):
with open(os.path.join(file_path, file), 'r') as concrete_file:
raw_report = concrete_file.read()
else:
......
......@@ -43,6 +43,9 @@ class Core:
@param uploaded_files: uploaded source codes + report from frontend service
@param form: form object, that holds other information about incoming request, eg. data
"""
if self.__tool is not None:
self.__tool.internal_structure.clear()
folder_id = form.get('url')[1:]
file = ''
if folder_id == '':
......@@ -55,12 +58,14 @@ class Core:
except Exception as f_e:
Logger.error.log(
'Error occurred while parsing file: {}'.format(f_e))
raise Exception('Invalid files')
self.__choose_tool(form)
try:
self.__tool.parse()
except Exception as p_e:
Logger.error.log(
'Error occurred while parsing report: {}'.format(p_e))
raise Exception('Cannot parse report')
try:
file.save_unified_report(
......
......@@ -22,12 +22,6 @@ class ReportSet:
"""
self.__set.append(r)
def _decorator(foo):
def magic(self):
foo(self)
self.__set.clear()
return magic
def get(self, clear=False) -> List:
"""
......@@ -47,13 +41,9 @@ class ReportSet:
"""
return Report()
def clear(f):
def clear(self):
"""
Clears report set
@return: empty report set
"""
self.__set.clear()
def clean_set(self):
f(self)
return clean_set
......@@ -31,6 +31,8 @@ services:
volumes:
- ./frontend:/frontend
- /frontend/node_modules
environment:
- BACKEND_PORT=${BACKEND_PORT}
restart: always
privileged: true
volumes:
......
......@@ -25,6 +25,10 @@ RUN quasar info
# ---------------- PRODUCTION STAGE ----------------------
FROM nginx:1.16.0-alpine as production-stage
ARG BACKEND_PORT
ENV BACKEND_PORT ${BACKEND_PORT}
COPY --from=build-stage /frontend/dist/spa/ /usr/share/nginx/html
RUN rm /etc/nginx/conf.d/default.conf
COPY nginx/nginx.conf /etc/nginx/conf.d
......
......@@ -158,40 +158,19 @@ export default {
*/
highlightMode (editor) {
const editorName = editor.name
// let arr = [];
// /* Here we get top level reports */
// this.unified_report.forEach((item) => {
// if (item.file === editorName) {
// arr.push(item)
// }
// })
// let res = this.findName(this.unified_report, editorName)
// if (res !== undefined) arr.push(res)
this.registerEvents(editor)
// eslint-disable-next-line no-unused-vars
this.unified_report.forEach((item) => {
// ReportParser.then(report => {
// return report.setUp(item)
// }).then( value => {
// this.recursiveSearch(value, editor)
// })
//
const r = new R().setUp(item)
this.recursiveSearch(r, editor)
})
this.styleWidget()
this.visited.push(editorName)
/*
TODO If there will be more than 10 windows, it won't work,
TODO because each editor has name according to file name and then number from 0-9
TODO e.g. main1, test2, test_file3
TODO also it could be problem with files that has same name and differ suffix (extension)
TODO like test.c and test.h
*/
if (this.unified_report.length > 0) {
this.registerEvents(editor)
this.styleWidget()
this.visited.push(editorName)
} else {
this.removeDanglingWidgets()
}
},
/*
* Emit all keywords that will be highlighted in Report component
......@@ -288,6 +267,19 @@ export default {
noHScroll: true
}))
},
/*
* Remove line widget classes from dom
* */
removeDanglingWidgets () {
const classes = ['error-background-dark', 'error-background-white']
classes.forEach(cls => {
const widgets = document.getElementsByClassName(cls)
Array.from(widgets).forEach(widget => {
widget.classList.remove(cls)
})
})
},
/*
* Add additional styles to code mirrro line widget
*/
......
......@@ -79,6 +79,9 @@
input-style="font-size: 0.85em"
v-model="files"
hide-bottom-space
max-file-size="4096"
:filter="checkType"
@rejected="onRejected"
>
<template v-slot:prepend>
<q-icon name="attach_file"/>
......@@ -315,26 +318,24 @@ export default {
})
},
/*
* Check selected files
*/
checkType (files) {
if (!this.tools) {
this.showNotiff('You do not have selected parsing tool', 3000, 'negative', 'warning')
return false
}
let supportedExtensions = null
this.optionValues.forEach((item) => {
if (item.tool.name === this.tools) {
supportedExtensions = item.tool.supported_extensions
}
})
return files.filter((file) => {
return (supportedExtensions.includes(this.getExtension(file.name)) && file.type === 'text/plain')
})
const supportedExtensions = ['c', 'h', 'cpp', 'hpp', 'java', 'py', 'txt', 'log']
return files.filter(file => supportedExtensions.includes(this.getExtension(file.name)))
},
/*
* Get file extension
*/
getExtension (file) {
return file.split('.').pop()
},
/*
* This method will be called if any of selected files are rejected by the filter
*/
onRejected (rejectedEntries) {
this.showNotiff(`${rejectedEntries.length} file(s) are invalid`, 3000, 'negative', 'warning')
}
},
created () {
......
......@@ -14,7 +14,6 @@
padding-bottom: 0 !important;
padding-top: 0 !important;
width: inherit!important;
/*transition: height 0.5s;*/
}
.toggle-content {
......@@ -47,11 +46,9 @@
}
.context-name-dark {
/*border: 1px solid black!important;*/
}
.context-name {
/*border: 1px solid white;*/
margin-bottom: 2px;
margin-top: 2px;
max-width: 200px;
......@@ -61,7 +58,6 @@
}
.report-detail {
/*color: #9C27B0;*/
transition: height 0.4s ease-in-out;
font-weight: normal;
}
......@@ -86,10 +82,7 @@
#tooltip {
position: absolute;
/*bottom: 100%;*/
/*right: 100%;*/
left: 0!important;
/*visibility: hidden;*/
width: 150px;
color: #ffffff;
font-weight: 600;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment