Skip to content

Commit

Permalink
Changed bulk mobile app scoping so that on the Apply button it would …
Browse files Browse the repository at this point in the history
…only update the changed scopes rather than all the app scopes
  • Loading branch information
Nathan Ahrens committed Feb 25, 2019
1 parent 8bb2aae commit b75a826
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions Bulk Mobile App Scoping/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
jamfapps = jamfInterface.getMobileApps()
devices = jamfInterface.getMobileDevices()
devicegroups = jamfInterface.getMobileGroups()
# newscopes is what we use in the "Apply" button
# so that we are only pushing scopes to apps that have
# actually been changed, rather than updating apps that haven't been changed.
newscopes = {}

class ScrollableFrame(Frame):
def __init__(self, master, height=350, width=225, **kwargs):
Expand Down Expand Up @@ -153,6 +157,8 @@ def exclude():
for group in selectedGroups:
if group['checked'] == 1:
app['scope']['exclusions']['mobile_device_groups'].append({"id":group['id']})
# Ensure that the new scope is what is used when we update the JSS app definition.
newscopes[app['id']] = app['scope']
cancel()

ttk.Button(btnFrame, text="Exclude Group", command=exclude).grid(column=0, row=0, sticky=W)
Expand Down Expand Up @@ -204,6 +210,8 @@ def exclude():
for dev in selectedDevices:
if dev['checked'] == 1:
app['scope']['exclusions']['mobile_devices'].append({"id":dev['id']})
# Ensure that the new scope is what is used when we update the JSS app definition.
newscopes[app['id']] = app['scope']
# Close the window
cancel()

Expand All @@ -218,7 +226,7 @@ def exclude():
pop.mainloop()

def cancel(*args):

root.destroy()

def add_group(*args):
Expand Down Expand Up @@ -258,6 +266,8 @@ def add():
for group in selectedGroups:
if group['checked'] == 1:
app['scope']['mobile_device_groups'].append({"id":group['id']})
# Ensure that the new scope is what is used when we update the JSS app definition.
newscopes[app['id']] = app['scope']
#close window
cancel()

Expand Down Expand Up @@ -310,6 +320,8 @@ def add():
for dev in selectedDevices:
if dev['checked'] == 1:
app['scope']['mobile_devices'].append({"id":dev['id']})
# Ensure that the new scope is what is used when we update the JSS app definition.
newscopes[app['id']] = app['scope']
# Close the window
cancel()

Expand All @@ -324,20 +336,25 @@ def add():
pop.mainloop()

def apply(*args):
global newscopes
# disable the buttons so they aren't pressed while updating.
disableButtons()
for app in jamfapps:
status.set("Applying scope to " + app['display_name'])
status_code = jamfInterface.applyScopeToApp(app['scope'], app['id'])
for app in newscopes:
status.set("Applying scope to app id: " + str(app))
status_code = jamfInterface.applyScopeToApp(newscopes[app], app)
if status_code == 201:
status.set("Success!")
else:
status.set("Fail. Error code: " + str(status_code))
print(app)
print(newscopes[app])
print()
newscopes = {}
# Re-enable the buttons
enableButtons()

def refresh():
global jamfapps, devices, devicegroups
global jamfapps, devices, devicegroups, newscopes

# disable the buttons so they aren't pressed while updating.
disableButtons()
Expand All @@ -350,6 +367,8 @@ def refresh():
devicegroups = jamfInterface.getMobileGroups()
status.set("")

newscopes = {}

# Re-enable the buttons
enableButtons()

Expand Down

0 comments on commit b75a826

Please sign in to comment.