Skip to content

Commit

Permalink
Visualizzazione dizionari
Browse files Browse the repository at this point in the history
  • Loading branch information
devVux committed May 2, 2024
1 parent 9d87437 commit 41c03cb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 28 deletions.
23 changes: 17 additions & 6 deletions backend/chatsql/adapter/incoming/web/ManagerController.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from chatsql.utils import Exceptions

from flask import Blueprint, request, jsonify
import os
import datetime

class ManagerController:

Expand Down Expand Up @@ -52,20 +54,29 @@ def handle_upload():
return 'Non è possibile caricare il file'

@manager_page.route('/files', methods=['GET'])
def handle_list_all():
def handle_list_files():

try:

data = []

data = self._visualizzaListaDizionariUseCase.list_all()
for filename in self._visualizzaListaDizionariUseCase.list_all():

return jsonify(data)
data.append({
'name': '.'.join(filename.split('.')[:-1]),
'loaded': filename == self._visualizzaDizionarioCorrenteUseCase.selected(),
'extension': filename.split('.')[-1],
'date': datetime.datetime.fromtimestamp(os.stat(os.path.join(os.getcwd(), 'uploads', filename)).st_ctime),
'size': f"{os.stat(os.path.join(os.getcwd(), 'uploads', filename)).st_size / 1024.0:.2f} Kb",
})

return jsonify(data)

except BaseException as e:
if hasattr(e, 'message'):
return e.message
else:
return 'Non è possibile caricare il file'


return e


return manager_page
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,3 @@ def __create_folder(self) -> bool:
if not os.path.exists(self._folder):
os.mkdir(self._folder)


@property
def folder(self) -> str:
return self._folder

@folder.setter
def folder(self, folder: str):
self._folder = folder
self.__create_folder()
1 change: 0 additions & 1 deletion backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ def heartbeat():
uploads_folder = os.path.join(os.getcwd(), 'uploads')

jsonRepository = JSONRepositoryAdapter()
jsonRepository.folder = uploads_folder

jsonService = JSONManagerService(jsonRepository)

Expand Down
6 changes: 3 additions & 3 deletions frontend/src/components/ViewDictionary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ export default {
* @param {number} size - The size of the entry.
* @param {boolean} load - The load status of the entry.
*/
function addNewEntry(id, name, extension, date, size, load) {
if (id && name && extension && date && size && load !== undefined) {
dictionaryEntries.value.push({ id: id, name: name, extension: extension, date: date, size: size, load: load });
function addNewEntry(name, extension, date, size, load) {
if (name && extension && date && size && load !== undefined) {
dictionaryEntries.value.push({ id: dictionaryEntries.value.length, name: name, extension: extension, date: date, size: size, load: load });
}
}
Expand Down
10 changes: 1 addition & 9 deletions frontend/src/views/ManagerPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,8 @@ export default {
*/
printDictionary(response) {
if(response && response.length > 0)
{
for(const row of response)
{
/*
Sotituire appena ci sarà la funzionalità nel backend
this.$refs.Dictionary.addNewEntry(row.id,row.name,row.extension,row.date,row.size,row.loaded);
*/
this.$refs.Dictionary.addNewEntry(1,row.name,row.extension,row.date,row.size,row.loaded);
}
}
this.$refs.Dictionary.addNewEntry(row.name,row.extension,row.date,row.size,row.loaded);
},
/**
Expand Down

0 comments on commit 41c03cb

Please sign in to comment.