-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSidePanel.html
229 lines (190 loc) · 7.07 KB
/
SidePanel.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<div id="alertContainer" class="position-fixed bottom-0 end-0 p-3" style="z-index: 11;">
<!-- Alert container goes here -->
</div>
<img id="imageBox" src="https://i.pinimg.com/originals/6d/9e/37/6d9e379122670f4ace48b7862d394f8f.png">
<span class="close-btn" onclick="closeSidePanel()"><i class="fa fa-times" aria-hidden="true"></i></span>
<h2>IPOP Heatmap_V3</h2>
<br>
<hr>
<br>
<div class="row">
<div class="col-md-4">
<label for="cableSystemName" class="col-form-label">Cable System:</label>
</div>
<div class="col">
<select id="cableSystemName" name="cableSystemName" class=" form-select" aria-label="Default select example"
style="margin-bottom:10px;">
<option selected>Select cable sys..</option>
<option value="SJC">SJC</option>
<option value="tgnia">TGNIA</option>
<option value="SEAUS">SEA-US</option>
<option value="EACC2C">EAC-C2C</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-4">
<label for="pointName" class="col-form-label">Point Name:</label>
</div>
<div class="col">
<input type="text" id="pointName" class="form-control" aria-describedby="pointname" style="margin-bottom:10px;">
</div>
</div>
<div class="row">
<div class="col-md-4">
<label for="inputLongitude" class="col-form-label">Longitude:</label>
</div>
<div class="col">
<input type="text" id="longitude" class="form-control" aria-describedby="longitude" style="margin-bottom:10px;">
</div>
</div>
<div class="row">
<div class="col-md-4">
<label for="latitude" class="col-form-label">Latitude:</label>
</div>
<div class="col">
<input type="text" id="latitude" class="form-control" aria-describedby="latitude" style="margin-bottom:10px;">
</div>
</div>
<div class="row">
<div class="col"></div>
<div class="col">
<button type="button" class="btn btn-primary" onclick="addData()">Add Data</button>
</div>
</div>
<br>
<hr>
<script>
function addData() {
var cableSystemName = document.getElementById('cableSystemName').value;
var pointName = document.getElementById('pointName').value;
var longitude = document.getElementById('longitude').value;
var latitude = document.getElementById('latitude').value;
if (!cableSystemName || !pointName || !longitude || !latitude) {
alert("Please fill in all required fields.");
return; // Stop further processing
}
$('#spinnerModal').modal('show');
// Convert longitude and latitude to numbers for calculations
longitude = parseFloat(longitude);
latitude = parseFloat(latitude);
// Check if longitude is negative and adjust by adding 360
if (longitude < 0) {
longitude += 360;
}
// Check if latitude is negative and adjust by adding 360
if (latitude < 0) {
latitude += 360;
}
// Save adjusted longitude and latitude to the sheet
google.script.run.withSuccessHandler(function () {
// Update dropdown options after adding data
updateDropdownOptions();
$('#spinnerModal').modal('hide');
showGoogleScriptAlert(pointName + ' added successfully. Refresh the page.', 'success');
// Optionally, clear the form fields after adding data
document.getElementById('cableSystemName').value = '';
document.getElementById('pointName').value = '';
document.getElementById('latitude').value = '';
document.getElementById('longitude').value = '';
}).addDataToSheet(cableSystemName, pointName, longitude, latitude);
}
</script>
<!-- next group -->
<div class="row">
<div class="col-md-4">
<label for="cableSystem" class="col-form-label">Cable System:</label>
</div>
<div class="col">
<select id="cableSystem" name="cableSystem" class=" form-select" aria-label="Default select example"
style="margin-bottom:10px;">
<option selected>Select cable sys..</option>
<option value="SJC">SJC</option>
<option value="TGNIA">TGNIA</option>
<option value="SEAUS">SEA-US</option>
<option value="EAC-C2C">EAC-C2C</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-4">
<label for="cableName" class="col-form-label">Cable Name:</label>
</div>
<div class="col">
<input type="text" id="cableName" name="cableName" class="form-control" aria-describedby="cableName"
style="margin-bottom:10px;">
</div>
</div>
<div class="row">
<div class="col-md-4">
<label for="pointFrom" class="col-form-label">Point from:</label>
</div>
<div class="col">
<select id="pointFrom" name="pointFrom" class=" form-select" aria-label="Default select example"
style="margin-bottom:10px;">
</select>
</div>
</div>
<div class="row">
<div class="col-md-4">
<label for="pointTo" class="col-form-label">Point to:</label>
</div>
<div class="col">
<select id="pointTo" name="pointTo" class=" form-select" aria-label="Default select example"
style="margin-bottom:10px;">
</select>
</div>
</div>
<div class="row">
<div class="col"></div>
<div class="col">
<button type="button" class="btn btn-primary" onclick="addCableConnection()">Connect cables</button>
</div>
</div>
<br>
<hr>
<script>
// Fetch and populate dropdown options initially
updateDropdownOptions();
function updateDropdownOptions() {
var selectedCableSystem = document.getElementById('cableSystem').value;
google.script.run.withSuccessHandler(function (locations) {
var pointFromDropdown = document.getElementById('pointFrom');
var pointToDropdown = document.getElementById('pointTo');
// Clear existing options
pointFromDropdown.innerHTML = '';
pointToDropdown.innerHTML = '';
locations.forEach(function (location) {
if (location.cableSystem === selectedCableSystem) {
var option = new Option(location.pointName, location.pointName);
pointFromDropdown.add(option);
pointToDropdown.add(option.cloneNode(true));
}
});
}).getSJCLocations();
}
document.getElementById('cableSystem').addEventListener('change', function () {
updateDropdownOptions();
});
function addCableConnection() {
var pointFrom = document.getElementById('pointFrom').value;
var pointTo = document.getElementById('pointTo').value;
var cableName = document.getElementById('cableName').value;
var cableSystem = document.getElementById('cableSystem').value;
if (!pointFrom || !pointTo || !cableName || !cableSystem) {
alert("Please fill in all required fields.");
return; // Stop further processing
}
$('#spinnerModal').modal('show')
google.script.run.withSuccessHandler(function () {
// Update dropdown options after adding cable connection
updateDropdownOptions();
$('#spinnerModal').modal('hide');
showGoogleScriptAlert(cableName + ' added successfully. Refresh the page.', 'success');
// Optionally, reset the form after adding data
document.getElementById('pointFrom').value = '';
document.getElementById('pointTo').value = '';
document.getElementById('cableName').value = '';
}).addCableConnectionToSheet(pointFrom, pointTo, cableName, cableSystem);
}
</script>