Skip to content
This repository has been archived by the owner on Jun 6, 2022. It is now read-only.

Commit

Permalink
further wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pocc committed Aug 27, 2018
1 parent 48c32fc commit 1fc17ff
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
6 changes: 4 additions & 2 deletions src/gui/main_window.py
Expand Up @@ -79,9 +79,10 @@ def show_main_menu(self):
# Set entered dashboard email/redacted password to be shown by default
self.main_window_ui.set_dashboard_user_layout()
org_list = self.browser.get_org_names()
current_org = org_list[self.browser.get_active_org_index()]
self.org_dropdown.addItems(org_list)
# Get the data we need and remove the cruft we don't
current_org = org_list[self.browser.get_active_org_index()]
print('main window orgs', org_list)
self.status.showMessage("Status: Fetching networks in " +
current_org + "...")
# Remove all elements from the network UI dropdown
Expand Down Expand Up @@ -113,7 +114,7 @@ def change_organization(self):
networks for this organization. This makes it so we don't need
to get the network list twice for the same organization
"""
selected_org_index = self.org_dropdown.currentIndex()
selected_org_index = self.org_dropdown.currentIndex()-1
self.browser.set_active_org_index(selected_org_index)
print("In change_organization and this is the network list "
+ str(self.browser.get_active_org_networks()))
Expand Down Expand Up @@ -162,6 +163,7 @@ def refresh_network_dropdown(self):
self.network_dropdown.clear()

current_org_network_list = self.browser.get_active_org_networks()
print('current_org_network_list', current_org_network_list)
self.network_dropdown.addItems(current_org_network_list)

def tshoot_vpn_fail_gui(self):
Expand Down
1 change: 1 addition & 0 deletions src/gui/main_window_ui.py
Expand Up @@ -75,6 +75,7 @@ def __init__(self, app):

# Title is an NSIS uninstall reference (see Modern.nsh)
app.org_dropdown = QComboBox()
app.org_dropdown.addItem('-- Select an Organization --')
app.network_dropdown = QComboBox()
app.network_dropdown.setEnabled(False)

Expand Down
12 changes: 2 additions & 10 deletions src/gui/menu_bars.py
Expand Up @@ -48,13 +48,9 @@ def __init__(self, bar):
self.help_menu = bar.addMenu('&Help')

def generate_menu_bars(self):
"""Short desc
"""Create each of the menu bars.
NOTE: Some of the menu additions here are ideas and not implemented.
Args:
Returns:
Returns:
"""

# File options
Expand All @@ -78,7 +74,7 @@ def generate_menu_bars(self):
self.edit_menu.addAction(edit_preferences)
self.help_menu.addAction(help_about)

file_quit.triggered.connect(self.file_sysprefs)
file_sysprefs.triggered.connect(self.file_sysprefs)
file_quit.triggered.connect(self.file_quit_action)
edit_preferences.triggered.connect(self.edit_prefs_action)
help_about.triggered.connect(self.help_about_action)
Expand All @@ -87,10 +83,6 @@ def generate_menu_bars(self):
def file_sysprefs():
"""Open system VPN settings
Even if errors are raised, they will only be shown after the program
closes because Qt supresses some messages (there are ways to get
around this.)
Raises:
FileNotFoundError: If vpn settings are not found
"""
Expand Down
18 changes: 14 additions & 4 deletions src/modules/dashboard_browser.py
Expand Up @@ -82,7 +82,7 @@ def __init__(self):
self.org_urls = []

self.is_network_admin = False # Most admins are org admins
self.org_qty = 0
self.org_qty = 1
self.active_org_id = 0
self.active_network_id = 0

Expand Down Expand Up @@ -192,6 +192,11 @@ def org_data_setup(self):
administered_orgs[org_id],
['wired']
)
if self.org_qty > 1:
for index, org_id in enumerate(self.orgs_dict):
self.orgs_dict[org_id]['url'] = self.org_urls[index]
self.active_network_id = list(self.orgs_dict[self.active_org_id][
'networks'])[0]

def bypass_org_choose_page(self, page):
"""Bypass page for admins with 2+ orgs that normally requires user input
Expand Down Expand Up @@ -356,7 +361,11 @@ def filter_org_data(org_dict, network_types):

def scrape_network_vars(self, network_index):
"""Change the current network."""
self.set_active_org_index(network_index)
print('in scrape network vars. org id',
self.active_org_id, 'network index', network_index)
selected_network_id = list(self.orgs_dict[self.active_org_id][
'networks'])[network_index]
self.active_network_id = selected_network_id
self.scrape_psk()
self.scrape_ddns_and_ip()

Expand Down Expand Up @@ -419,13 +428,14 @@ def get_active_org_index(self):

def set_active_org_index(self, org_index):
"""Set the the org index to the param."""
self.scrape_administered_orgs()
print('in set active org index', org_index)
self.active_org_id = list(self.orgs_dict)[org_index]
self.scrape_administered_orgs()

def get_active_network_url(self):
"""Return the active network's base url"""
return self.orgs_dict[self.active_org_id]['networks'][
self.active_network_id]['url']
self.active_network_id]['base_url']

def get_active_org_name(self):
"""Return the active org name."""
Expand Down

0 comments on commit 1fc17ff

Please sign in to comment.