|
1 | | -import flet as ft # Must be version 0.23.2 for now |
| 1 | +import flet as ft |
2 | 2 | import the_shell |
3 | 3 | import datetime, json, re, subprocess, ctypes, os, time, socket, pathlib, csv |
4 | 4 | from tutorial_btn import TutorialBtn |
5 | 5 | import text_values as text_values # Long text values stored in separate file |
6 | 6 | from dynamic_modal import DynamicModal |
7 | 7 | from are_you_sure import YouSure |
| 8 | +from donate_view import donate_view |
8 | 9 | from settings_values import * |
9 | 10 |
|
10 | 11 | # Create settings.json if not exists and/or load saved values |
|
17 | 18 | init_data = {"computers":[]} |
18 | 19 | json.dump(init_data, file, indent=4) |
19 | 20 |
|
20 | | -computerlist_path = "assets/settings/lists/computers.txt" |
21 | | - |
22 | 21 | #Cleanup old files |
23 | 22 | printers_path = "assets/results/Printers" |
24 | 23 | clearspace_path = "assets/results/ClearSpace" |
@@ -359,7 +358,7 @@ def close_dialog(e = None): |
359 | 358 | scroll=ft.ScrollMode.ADAPTIVE |
360 | 359 | ), |
361 | 360 | bgcolor=settings_values['app_color'], |
362 | | - border_radius=20 |
| 361 | + border_radius=10 |
363 | 362 | ) |
364 | 363 |
|
365 | 364 | def show_processes_modal(e): |
@@ -402,10 +401,10 @@ def process_not_running(name, computer): |
402 | 401 | return False |
403 | 402 | return True |
404 | 403 |
|
405 | | - def add_new_process(process_object): |
| 404 | + def add_new_process(process_dict): |
406 | 405 | nonlocal running_processes_count |
407 | 406 | running_processes_count += 1 |
408 | | - list_of_processes.append(process_object) |
| 407 | + list_of_processes.append(process_dict) |
409 | 408 | running_processes_count_text.value = f"{running_processes_count}" |
410 | 409 | update_processes() |
411 | 410 | page.update() |
@@ -436,6 +435,9 @@ def update_processes(): |
436 | 435 | ]) |
437 | 436 | ) |
438 | 437 | running_processes_controls.append(new_proc_card) |
| 438 | + |
| 439 | + running_processes_container.content.controls = running_processes_controls |
| 440 | + |
439 | 441 | if len(list_of_processes) > 0: |
440 | 442 | loading_ring.visible = True |
441 | 443 | else: |
@@ -468,7 +470,7 @@ def new_process(name, computers, date, id): |
468 | 470 |
|
469 | 471 | # -------------------- NAVIGATION -------------------- |
470 | 472 | def navigate_view(e): |
471 | | - #If called by a control set equal to control value |
| 473 | + # If called by a control set equal to control value |
472 | 474 | # Otherwise we are likely passing a specific index |
473 | 475 | try: |
474 | 476 | index = e.control.selected_index |
@@ -738,7 +740,7 @@ def update_results(title_text = None, data = None, id = None, computer = None, * |
738 | 740 | bgcolor=settings_values['app_color'], |
739 | 741 | expand=True, |
740 | 742 | alignment=ft.alignment.top_left, |
741 | | - border_radius=20 |
| 743 | + border_radius=10 |
742 | 744 | ) |
743 | 745 |
|
744 | 746 | # Holds controls we removed from result_data |
@@ -928,7 +930,7 @@ def select(e): |
928 | 930 | ], expand=1) |
929 | 931 | ]), |
930 | 932 | bgcolor=settings_values['app_color'], |
931 | | - border_radius=20, |
| 933 | + border_radius=10, |
932 | 934 | border=ft.border.all(1, settings_values['app_color']) |
933 | 935 | ) |
934 | 936 |
|
@@ -1100,7 +1102,7 @@ def generate_result_card(leading, title, date, data, id, computer, action, **kwa |
1100 | 1102 | printer_wiz_list_container = ft.Container( |
1101 | 1103 | bgcolor=settings_values['app_color'], |
1102 | 1104 | content=printer_wiz_listview, |
1103 | | - border_radius=20, |
| 1105 | + border_radius=10, |
1104 | 1106 | expand=True, |
1105 | 1107 | ) |
1106 | 1108 |
|
@@ -1594,7 +1596,7 @@ def open_tutorial_modal(e): |
1594 | 1596 | ft.Row([ |
1595 | 1597 | ft.Text(f"{help_text}"), |
1596 | 1598 | ], wrap=True, width=500), |
1597 | | - border_radius=20, |
| 1599 | + border_radius=10, |
1598 | 1600 | border=ft.border.all(1, settings_values['app_color']), |
1599 | 1601 | padding=10, |
1600 | 1602 | ) |
@@ -2130,9 +2132,11 @@ def get_user_ids(e): |
2130 | 2132 | ) |
2131 | 2133 |
|
2132 | 2134 | def open_pc_list(e): |
2133 | | - |
2134 | | - powershell.open_pc_list() |
2135 | | - |
| 2135 | + if not os.path.exists(computerlist_path): |
| 2136 | + with open(computerlist_path, "w") as file: |
| 2137 | + print("Computer list file created.") |
| 2138 | + os.system(f'notepad.exe {computerlist_path}') |
| 2139 | + |
2136 | 2140 | delete_users_checkbox = ft.Checkbox(label="Remove user profiles", value=False) |
2137 | 2141 | logout_users_checkbox = ft.Checkbox(label="Logout users before deletion", value=False) |
2138 | 2142 | use_list_checkbox = ft.Checkbox(label="Use list of PCs", value=False) |
@@ -2427,7 +2431,7 @@ def sort_scripts_by_index(dict): # Use this to sort scripts by index before appe |
2427 | 2431 | ) |
2428 | 2432 | ]) |
2429 | 2433 | ]), |
2430 | | - border_radius=20, |
| 2434 | + border_radius=10, |
2431 | 2435 | padding=10, |
2432 | 2436 | data=script_data |
2433 | 2437 | ) |
@@ -3244,7 +3248,7 @@ def check_for_changes(e): |
3244 | 3248 | ), |
3245 | 3249 | bgcolor=settings_values['app_color'], |
3246 | 3250 | expand = 1, |
3247 | | - border_radius=20 |
| 3251 | + border_radius=10 |
3248 | 3252 | ) |
3249 | 3253 |
|
3250 | 3254 | actions_view = ft.Column([ |
@@ -3311,7 +3315,7 @@ def select_script(e: ft.FilePickerResultEvent): |
3311 | 3315 | content=scripts_list_view, |
3312 | 3316 | expand=True, |
3313 | 3317 | bgcolor=settings_values['app_color'], |
3314 | | - border_radius=20, |
| 3318 | + border_radius=10, |
3315 | 3319 | padding=ft.padding.only(10,0,10,0) |
3316 | 3320 | ) |
3317 | 3321 |
|
@@ -3407,68 +3411,6 @@ def reset_script_search(e): |
3407 | 3411 |
|
3408 | 3412 | ], expand=True) |
3409 | 3413 |
|
3410 | | - def on_donate_hover(e): |
3411 | | - e.control.bgcolor = "grey" if e.data == "true" else None |
3412 | | - e.control.content.controls[1].color = "black" if e.data == "true" else "white" |
3413 | | - e.control.border_radius = 20 if e.data =="true" else 0 |
3414 | | - e.control.update() |
3415 | | - |
3416 | | - def on_github_hover(e): |
3417 | | - e.control.bgcolor = "white" if e.data == "true" else None |
3418 | | - e.control.border_radius = 50 if e.data =="true" else 0 |
3419 | | - e.control.update() |
3420 | | - |
3421 | | - donate_view = ft.Column([ |
3422 | | - ft.Row([ |
3423 | | - ft.Column([ |
3424 | | - ft.Text("Created by:", size=40), |
3425 | | - ]), |
3426 | | - ft.Column([ |
3427 | | - ft.Stack([ |
3428 | | - ft.Image( |
3429 | | - src="https://avatars.githubusercontent.com/u/56776962?v=4", |
3430 | | - border_radius=ft.border_radius.all(60), |
3431 | | - width=210 |
3432 | | - ), |
3433 | | - ft.Container( |
3434 | | - content=ft.Image(src="images/Github.png", width=70), |
3435 | | - url="https://github.com/knightlygains/it-remote", |
3436 | | - offset=ft.transform.Offset(2, 2), |
3437 | | - on_hover=on_github_hover, |
3438 | | - tooltip="https://github.com/knightlygains" |
3439 | | - ) |
3440 | | - ]), |
3441 | | - ft.Text("Steven Whitney (KnightlyGains)", weight=ft.FontWeight.BOLD) |
3442 | | - ]), |
3443 | | - ], alignment=ft.MainAxisAlignment.CENTER, spacing=30), |
3444 | | - ft.Divider(), |
3445 | | - ft.Row([ |
3446 | | - ft.Text("If you like this app and would like to support me, please consider donating:"), |
3447 | | - ], spacing=15, alignment=ft.MainAxisAlignment.CENTER), |
3448 | | - ft.Row([ |
3449 | | - ft.Container( |
3450 | | - content=ft.Column([ |
3451 | | - ft.Image(src="images/ko-fi.png", width=70), |
3452 | | - ft.Text("Ko-Fi", weight=ft.FontWeight.BOLD) |
3453 | | - ], horizontal_alignment=ft.CrossAxisAlignment.CENTER), |
3454 | | - margin=ft.margin.only(top=20), |
3455 | | - url="https://ko-fi.com/knightlygains", |
3456 | | - on_hover=on_donate_hover, |
3457 | | - padding=10 |
3458 | | - ), |
3459 | | - ft.Container( |
3460 | | - content=ft.Column([ |
3461 | | - ft.Image(src="images/patreon.png", width=70), |
3462 | | - ft.Text("Patreon", weight=ft.FontWeight.BOLD) |
3463 | | - ], horizontal_alignment=ft.CrossAxisAlignment.CENTER), |
3464 | | - margin=ft.margin.only(top=20), |
3465 | | - url="https://www.patreon.com/KnightlyGains", |
3466 | | - on_hover=on_donate_hover, |
3467 | | - padding=10 |
3468 | | - ) |
3469 | | - ], alignment=ft.MainAxisAlignment.CENTER, spacing=30) |
3470 | | - ], expand=1) |
3471 | | - |
3472 | 3414 | # We assign different views to this in navigation |
3473 | 3415 | current_view = ft.Row([home], expand=True) |
3474 | 3416 | navigate_view(settings_values['home_tab']) #Set view to home tab saved in settings |
|
0 commit comments