-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathwebForm.html
201 lines (183 loc) · 7.5 KB
/
webForm.html
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<!DOCTYPE html>
<html lang="en">
<head>
<title>Subscription Builder</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<style>
.bg-1 {
background-color: rgb(65, 179, 255);
/* light blue */
color: #ffffff;
}
.bg-2 {
background-color: rgb(251, 251, 251);
/* for browsers that don't support images */
background-image: url("spring-cloud.jpg");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
}
.bg-3 {
background-color: rgb(145, 211, 255);
/* for browsers that don't support images */
}
.container-fluid {
padding-top: 35px;
padding-bottom: 35px;
}
.hidden {
display: none;
}
</style>
</head>
<body>
<div class="container-fluid bg-1 text-center" id="title">
<h1 style="font-size:70px">Azure Subscription Builder</h1>
<hr>
<p style="font-size:20px">Welcome to the Azure Subscription Builder Service! We are excited to provide you a way
to provision secure and policy compliant Azure Subscriptions. Enjoy!</p>
</div>
<div class="container-fluid bg-2 text-center" id="body">
<div class="col-sm-6" id="variables">
<h2>Required Input Variables:</h2>
<p>To get started just fill in the following values and click the "Submit" button:</p>
<form class="form-horizontal" id="intake">
<div class="form-group">
<label class="control-label col-sm-5" for="bu">Business Unit:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="bu" placeholder="Enter Business Unit" name="businessUnit">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-5" for="location">Location:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="location" placeholder="Enter Azure Region" name="location">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-5" for="devTestSubCount">No. of DevTest Subscriptions:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="devTestSubCount" placeholder="Enter desired number of dev/test subscriptions"
name="devTestSubCount">
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-5" for="prodSubCount">No. of Production Subscriptions:</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="prodSubCount" placeholder="Enter desired number of production subscriptions"
name="prodSubCount">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-4">
<b id="submitButton" href="#" class="btn btn-default btn-md" align="center" style="color:blue;width:50%"
onclick="clearResults(this);displayValues(this)">Submit</b>
</div>
</div>
</form>
</div>
<div class="col-sm-6" id="build">
<h2>Review Your Selections before Deployment:</h2>
<div id="output"></div>
<a id="cancelButton" href="#" class="btn btn-default btn-md" align="center" style="color:red;width:20%"
onclick="cancel(this)">Cancel</a>
<b id="buildButton" href="#" class="btn btn-default btn-md hidden" align="center" style="color:green;width:20%"
onclick="buildValues(this);">BUILD</b>
</div>
</div>
<div class="container-fluid bg-3 text-center" id="results" style="height:300px">
<div id="apiresults"></div>
<div id="apiresponse"></div>
</div>
<script>
$(document).ready(function () {
var btn = $('#submitButton,#buildButton').click(function () { // bind click handler to both button
$(this).addClass('hidden'); // hide the clicked button
btn.not(this).removeClass('hidden'); // show the another button which is hidden
});
});
function cancel(el) {
window.location.reload()
}
function clearResults(el) {
document.getElementById('apiresults').innerHTML = "";
document.getElementById('apiresponse').innerHTML = "";
}
function displayValues(el) {
let businessUnit = document.getElementById('bu').value;
let location = document.getElementById('location').value;
let devTestSubCount = document.getElementById('devTestSubCount').value;
let prodSubCount = document.getElementById('prodSubCount').value;
let op =
`
<div class="alert alert-info" role="alert">
You have selected to deploy "${document.getElementById('devTestSubCount').value}" dev/test subscription(s) and "${document.getElementById('prodSubCount').value}" production subscriptions for the "${document.getElementById('bu').value}" business unit. These subscriptions will be deployed into the "${document.getElementById('location').value}" Azure Region. If you would like to proceed, click 'BUILD'. To cancel, press 'Cancel'
</div>
`
document.getElementById('output').innerHTML = op;
}
function buildValues(el) {
let businessUnit = document.getElementById('bu').value;
let location = document.getElementById('location').value;
let devTestSubCount = document.getElementById('devTestSubCount').value;
let prodSubCount = document.getElementById('prodSubCount').value;
let blueprintName = "sub-poc-blueprint";
fetch('LogicAppURL', {
method: 'POST',
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify([{
businessUnit: businessUnit,
location: location,
devTestSubCount: devTestSubCount,
prodSubCount: prodSubCount,
blueprintName: blueprintName
}])
})
.then((res) => processResponse(res))
document.getElementById('intake').reset();
document.getElementById('output').innerHTML = "";
document.getElementById('submitButton').removeClass('hidden');
document.getElementById('buildButton').addClass('hidden');
}
function processResponse(response) {
if (response.status === 202) {
results =
`
<div class="alert alert-success" role="alert">
Trigger was Successfull!!
</div>
`;
resp =
`
<div>Workflow ID: ${response.headers.get('x-ms-workflow-id')}</div>
<div>Workflow Run ID: ${response.headers.get('x-ms-workflow-run-id')}</div>
<div>Workflow Name: ${response.headers.get('x-ms-workflow-name')}</div>
`;
document.getElementById('apiresults').innerHTML = results;
document.getElementById('apiresponse').innerHTML = resp;
setTimeout('window.location.reload()', 10000);
} else {
results =
`
<div class="alert alert-danger" role="alert">
Oh no! Something went wrong :(
</div>
`;
resp =
`
<div>API STATUS CODE: ${response.status}</div>
`
document.getElementById('apiresults').innerHTML = results;
document.getElementById('apiresponse').innerHTML = resp;
setTimeout('window.location.reload()', 10000);
}
}
</script>
</body>
</html>