-
Notifications
You must be signed in to change notification settings - Fork 2
/
CreateUI.gs
101 lines (91 loc) · 3.11 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
/**
* 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) {
// No need to call onOpen here, it's automatically triggered on opening the sheet
}
// Creates the menu and sub-menu items under "Extensions"
function onOpen(e) {
SpreadsheetApp.getUi()
.createAddonMenu()
.addItem('Activate Application', 'activateApplication')
.addSeparator()
.addItem('Set up or Refresh Sheet', 'setupSheet')
.addSeparator()
.addItem('Run all scripts', 'promptRunAllScripts')
.addSeparator()
.addSubMenu(SpreadsheetApp.getUi().createMenu('Run Individual Scripts')
.addItem('List Customer Contact Info', '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 all scripts with a confirmation prompt
function promptRunAllScripts() {
var response = Browser.msgBox(
'Run All Scripts Confirmation',
'This will execute all scripts. Click OK to proceed. An external service (Cloudflare) will be used to return DNS results.',
Browser.Buttons.OK_CANCEL
);
if (response == 'ok') {
fetchInfo();
}
}
// 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. An external service (Cloudflare) will be used to return DNS results.',
Browser.Buttons.OK_CANCEL
);
if (response == 'ok') {
getDomainList();
}
}
// Function to run all scripts
function fetchInfo() {
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() {
// Perform activation steps here (if any)
const ui = SpreadsheetApp.getUi();
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
);
}