def update_data( imported_excel, reset_confirmed, graph_button_status, ): button_clicked = getIdButtonClicked() username = getUsername() user_data = UserDataPipeline(username) if "upload-excel" in button_clicked: if imported_excel != None: logging.info("@{}: Importing file ...".format(username)) user_data.user_files.saveUploadedFile(imported_excel) logging.info("@{}: File imported!".format(username)) elif "confirm-reset-dialog" in button_clicked: logging.info("@{}: Reseting data ...".format(username)) user_data.user_files.removeUserFolder() user_data.dumpUserOfAllTables() logging.info("@{}: Data is reseted".format(username)) return graph_button_status + 1 user_data.updateData() return graph_button_status + 1
def download_button_pressed(export_nclicks): username = getUsername() user_data = UserDataPipeline(username) df = user_data.getDataframeFromExcel() return dcc.send_data_frame(df.to_excel, "recount_excel.xlsx", sheet_name="Sheet_name_1")
def display_page(pathname): username = getUsername() dash.callback_context.response.set_cookie("username", username) if pathname == "/": return None elif pathname == "/home": return self.home_page.vue elif pathname == "/dashhome": return self.dashboard_home_page.vue elif pathname == "/notebook": return self.notebook_home_page.vue # elif pathname == "/reset": # update_data.removeAllDataForUser(username) # return "All data has been reseted :)" # elif pathname == "/test": # return self.vueTest.setThisVue() else: return "404 Page not found."
def update_graphs(selected_date, selected_period, refresh): username = getUsername() logging.info("@{}: Refresing graph ...".format(username)) user_graph = UserGraphPipeline(username) end_datetime = convertPeriodToDate(selected_date, selected_period) end_date = shapeDatetimeToSimpleDate(end_datetime) dataframe = user_graph.getExpenseRepaidForPeriod( selected_date, end_date) main_category_df = dataframe.copy() main_category_df["category"] = main_category_df["category"].apply( func=user_graph.selectMainCategory) list_dict_of_expenses = user_graph.getDataByColumn(main_category_df) scatter_graph = scatterGraph(list_dict_of_expenses, [selected_date, end_date]) list_dict_of_sum_expenses = user_graph.getSumDataByColumn( main_category_df) pie_graph = pieGraph(list_dict_of_sum_expenses) expenses_by_period = user_graph.getDataByDateDeltaAndColumn( main_category_df) mean_graph = meanGraph(expenses_by_period) # TODO: improve stability by defining default categories, imposed categories ? food_dataframe = dataframe[main_category_df["category"] == "alimentary"].copy() food_dataframe["category"] = food_dataframe["category"].apply( func=user_graph.selectSecondCategory) food_by_period = user_graph.getDataByDateDeltaAndColumn(food_dataframe) food_graph = meanGraph(food_by_period) logging.info("@{}: Graph refreshed!".format(username)) return scatter_graph, pie_graph, mean_graph, food_graph
def update_notebook(update_button_n_clicks): username = getUsername() user_data = UserDataPipeline(username) dataframe = user_data.getDataframeFromExcel() return {"display": "block"}, dataframe.to_dict("records")