-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCreateUI.gs
109 lines (96 loc) · 3.33 KB
/
CreateUI.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/**
* This code creates the UI button under the Extensions menu and runs all scripts or individual scripts based on admin selection.
*
*/
// Triggered on install
function onInstall(e) {
onOpen(e);
}
// Creates the menu and sub-menu items under "Add-ons"
function onOpen(e) {
SpreadsheetApp.getUi()
.createAddonMenu()
.addItem('Activate Application', 'activateApplication')
.addSeparator()
.addItem('Set up or Refresh Sheet', 'setupSheet') // Make sure 'setupSheet' function exists
.addSeparator()
.addSubMenu(SpreadsheetApp.getUi().createMenu('Inventory Workspace Settings')
.addItem('Check all policies', 'promptFetchAndListPolicies'))
.addSeparator()
.addSubMenu(SpreadsheetApp.getUi().createMenu('Run Reports')
.addItem('Run all reports', 'promptRunAllScripts')
.addSeparator()
.addItem('List General Account Settings', 'getDomainInfo')
.addItem('List Domains', 'promptGetDomainList')
.addItem('List Users', 'getUsersList')
.addItem('List Aliases', 'listAliases')
.addItem('List Mobile Devices', 'getMobileDevices')
.addItem('List License Assignments', 'getLicenseAssignments')
.addItem('List OAuth Tokens', 'getTokens')
.addItem('List App Passwords', 'getAppPasswords')
.addItem('List Organizational Units', 'getOrgUnits')
.addItem('List Shared Drives', 'getSharedDrives')
.addItem('List Group Settings', 'getGroupsSettings')
.addItem('List Group Members', 'getGroupMembers'))
.addSeparator()
.addItem('Get Support', 'contactPartner')
.addToUi();
}
// Function to run 'Check all policies' script with a confirmation prompt
function promptFetchAndListPolicies() {
var response = Browser.msgBox(
'Check All Policies Confirmation',
'This will perform an automated inventory of Workspace settings and dependencies including OU and Group inventory. This can take several minutes to complete.',
Browser.Buttons.OK_CANCEL
);
if (response == 'ok') {
fetchAndListPolicies();
}
}
// Function to run 'List Domains' script with a confirmation prompt
function promptGetDomainList() {
var response = Browser.msgBox(
'List Domains Confirmation',
'This will execute the script for listing domains and DNS records. Click OK to proceed. Calls will be made to Google DNS to return DNS records.',
Browser.Buttons.OK_CANCEL
);
if (response == 'ok') {
getDomainList();
}
}
function fetchInfo() {
Utilities.sleep(1000);
}
//Function to run all scripts
function promptRunAllScripts() {
getDomainInfo();
getDomainList();
getUsersList();
listAliases();
getMobileDevices();
getLicenseAssignments();
getTokens();
getAppPasswords();
getOrgUnits();
getSharedDrives();
getGroupMembers();
getGroupsSettings();
// Display alert notification when all scripts have completed
SpreadsheetApp.getUi().alert('All API scripts have successfully completed.');
}
function activateApplication() {
const ui = SpreadsheetApp.getUi();
const result = ui.alert(
'Activate Application',
'Application activated and connected to your Google Account. Next, use the "Set up or Refresh Sheet" button from the extensions menu.',
ui.ButtonSet.OK
);
}
function setupSheet() {
const ui = SpreadsheetApp.getUi();
ui.alert(
'Setup Sheet',
'Sheet setup complete!',
ui.ButtonSet.OK
);
}