-
Notifications
You must be signed in to change notification settings - Fork 0
/
responsive.component.html
399 lines (334 loc) · 21 KB
/
responsive.component.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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<div class="wrapper pt-3 mx-auto">
<div class="searchform pt-5 pb-5">
<p class="h3 text-center pb-3">
Weather Search
</p>
<form [formGroup]="angForm" id="theForm" class="formtag needs-validation" novalidate>
<div class="form-group row">
<label for="street" class="col-md-2 ml-2 mr-2 col-form-label">Street<span class="red">*</span></label>
<div class="col-md-6 ml-2 mr-2">
<input type="text" class="form-control" formControlName="street" id="street" placeholder="Enter Street Name" value="">
</div>
</div>
<div *ngIf="angForm.controls['street'].invalid && (angForm.controls['street'].dirty || angForm.controls['street'].touched)">
<div *ngIf="angForm.controls['street'].errors.required">
<small class="row ErrorMsg mt-n3">
<b>Please enter a street.</b>
</small>
</div>
</div>
<div class="form-group row">
<label for="city" class="col-md-2 ml-2 mr-2 col-form-label">City<span class="red">*</span></label>
<div class="col-md-6 ml-2 mr-2">
<input type="text" matInput formControlName="city" class="form-control" name="city" id="city" placeholder="Enter City Name" [matAutocomplete]="auto" (keyup)="autocompleteHelper()">
<mat-autocomplete #auto="matAutocomplete">
<mat-option *ngFor="let option of autocompleteOptions" [value]="option">{{option}}</mat-option>
</mat-autocomplete>
</div>
</div>
<div *ngIf="angForm.controls['city'].invalid && (angForm.controls['city'].dirty || angForm.controls['city'].touched)">
<div *ngIf="angForm.controls['city'].errors.required">
<small class="row ErrorMsg mt-n3">
<b>Please enter a city.</b>
</small>
</div>
</div>
<div class="form-group row">
<label for="state" class="col-md-2 ml-2 mr-2 col-form-label">State<span class="red">*</span></label>
<div class="col-md-4 ml-2 mr-2">
<select class="form-control" id="state" formControlName="state">
<option value="" selected>Select State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="DC">District Of Columbia</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</div>
</div>
<div class="form-check row">
<input class="ml-2 form-check-input" formControlName="currentLocation" type="checkbox" value="" id="currentLocation" (change)="toggleEditable($event)">
<label class="ml-4 form-check-label" for="currentLocation">Current Location</label>
</div>
<div class="form-group row mt-3">
<button type="submit" [disabled]="angForm.invalid" class="btn btn-default ml-4 col-xs-3 btncolor" (click)="loadJSON(1)">
<i class="material-icons">search</i>Search
</button>
<button type="button" class="btn btn-default ml-4 col-xs-3 btncolor" (click)="clearForm()" (click)="t.select('tab-selectbyid1')">
<i class="material-icons">clear_all</i>Clear
</button>
</div>
</form>
</div>
<!--2 Button begins here-->
<div class="pt-4">
<ngb-tabset type="pills" #t="ngbTabset">
<ngb-tab id="tab-selectbyid1" title="Results">
<ng-template ngbTabContent>
<div class= "dynamicContent mt-5" *ngIf="(darkskyJSON | json) != '{}';else dynamicContentElseBlock">
<div class="pl-2 pr-3">
<ul class="nav nav-tabs secondNav row" role="tablist">
<li class="nav-item col-md-1.5 col-xs-1.5">
<a class="nav-link active" id="current-tab" data-toggle="tab" href="#current" role="tab" aria-controls="current" aria-selected="true">Current</a>
</li>
<li class="nav-item col-md-1.5 col-xs-1.5">
<a class="nav-link" id="hourly-tab" data-toggle="tab" href="#hourly" role="tab" aria-controls="hourly" aria-selected="false">Hourly</a>
</li>
<li class="nav-item col-md-1.5 col-xs-1.5">
<a class="nav-link" id="weekly-tab" data-toggle="tab" href="#weekly" role="tab" aria-controls="weekly" aria-selected="false" (click)="loadWeekly()">Weekly</a>
</li>
<span class="col md-4.5 col-xs-4.5"></span>
<a class="twitter-share-button rightShiftIcons col-md-0.5 col-xs-0.5"
href="https://twitter.com/intent/tweet?text=The%20current%20temperature%20at%20{{currentcity}}%20is%20{{darkskyJSON.currently.temperature | number:'1.0-0'}}
.%20The%20weather%20conditions%20are%20{{darkskyJSON.currently.summary}}.&hashtags=CSCI571WeatherSearch"
target="_blank">
<img class="twitterImg " src="http://csci571.com/hw/hw8/Images/Twitter.png">
</a>
<a href="#" class="col-md-0.5 col-xs-0.5 ml-2" (click)="favoritesAdd()" #favoriteIconToggle>
<span *ngIf="!goldStarBoolean; else goldStarBooleanElseBlock">
<i id="favoriteImg1" class="material-icons">
star_border
</i>
</span>
<ng-template #goldStarBooleanElseBlock>
<i id="favoriteImg2" class="material-icons">
grade
</i>
</ng-template>
</a>
</ul>
<div class="tab-content" id="myTabContent">
<!--For the Current Tab-->
<div class="tab-pane fade show active" id="current" role="tabpanel" aria-labelledby="current-tab">
<div class="row mt-5 mb-2">
<div class="col-sm-2"></div>
<div class="col-sm-8 pt-3 navbarCurrent">
<div class="table-responsive">
<table class="table table-borderless customizingTable">
<tr>
<th scope="col"><h2 class="nCCity">{{currentcity}}</h2></th>
<th></th>
</tr>
<tr>
<td>
<span class="nCTimezone">{{darkskyJSON.timezone}}</span>
</td>
<td scope="col" rowspan="3"> <img class="apiimage" src="{{customImageURL.link}}"></td>
</tr>
<tr>
<td>
<h2 class="nCTemperature">{{darkskyJSON.currently.temperature | number:'1.0-0'}}°F</h2>
</td>
</tr>
<tr>
<td>
<span class="nCSummary">{{darkskyJSON.currently.summary}}</span>
</td>
</tr>
</table>
</div>
<div class="row ImgTable pl-3 table-responsive">
<table class="table table-borderless currentTable">
<thead>
<tr>
<th class="" scope="col" *ngIf="(darkskyJSON.currently.humidity)">
<img ngbTooltip="Humidity" placement="top" class='img_table' src='https://cdn2.iconfinder.com/data/icons/weather-74/24/weather-16-512.png'>
</th>
<th scope="col" *ngIf="(darkskyJSON.currently.pressure)">
<img ngbTooltip='Pressure' placement="top" class='img_table' src='https://cdn2.iconfinder.com/data/icons/weather-74/24/weather-25-512.png'>
</th>
<th scope="col" *ngIf="(darkskyJSON.currently.windSpeed)">
<img ngbTooltip='WindSpeed'placement="top" class='img_table' src='https://cdn2.iconfinder.com/data/icons/weather-74/24/weather-27-512.png'>
</th>
<th scope="col" *ngIf="(darkskyJSON.currently.visibility)">
<img ngbTooltip='Visibility' placement="top" class='img_table' src='https://cdn2.iconfinder.com/data/icons/weather-74/24/weather-30-512.png'>
</th>
<th scope="col" *ngIf="(darkskyJSON.currently.cloudCover)">
<img ngbTooltip='Cloud Cover' placement="top" class='img_table' src='https://cdn2.iconfinder.com/data/icons/weather-74/24/weather-28-512.png'>
</th>
<th scope="col" *ngIf="(darkskyJSON.currently.ozone)">
<img ngbTooltip='Ozone' placement="top" class='img_table' src='https://cdn2.iconfinder.com/data/icons/weather-74/24/weather-24-512.png'>
</th>
</tr>
<tr>
<td scope="row" *ngIf="(darkskyJSON.currently.humidity)">{{darkskyJSON.currently.humidity}}</td>
<td *ngIf="(darkskyJSON.currently.pressure)">{{darkskyJSON.currently.pressure}}</td>
<td *ngIf="(darkskyJSON.currently.windSpeed)">{{darkskyJSON.currently.windSpeed}}</td>
<td *ngIf="(darkskyJSON.currently.visibility)">{{darkskyJSON.currently.visibility}}</td>
<td *ngIf="(darkskyJSON.currently.cloudCover)">{{darkskyJSON.currently.cloudCover}}</td>
<td *ngIf="(darkskyJSON.currently.ozone)">{{darkskyJSON.currently.ozone}}</td>
</tr>
</thead>
</table>
</div>
</div>
<div class="col-sm-2"></div>
</div>
</div>
<!--For the Hourly Tab-->
<div class="tab-pane fade mt-5 mb-2" id="hourly" role="tabpanel" aria-labelledby="hourly-tab">
<select #hourly class="form-control col-md-4" id="hourlyField" (change)="selectedField(hourly.value)">
<option value="hourlyTemperature" selected>Temperature</option>
<option value="hourlyPressure">Pressure</option>
<option value="hourlyHumidity">Humidity</option>
<option value="hourlyOzone">Ozone</option>
<option value="hourlyVisibility">Visibility</option>
<option value="hourlyWindSpeed">Wind Speed</option>
</select>
<div>
<div style="display: block">
<canvas baseChart
[datasets]="barChartData"
[labels]="barChartLabels"
[options]="barChartOptions"
[legend]="barChartLegend"
[chartType]="barChartType">
</canvas>
</div>
</div>
</div>
<!-- For the Weekly Tab-->
<div class="tab-pane fade mt-5 mb-2" id="weekly" role="tabpanel" aria-labelledby="weekly-tab">
<div id="chartContainer" style="height: 370px;width: 100%;"></div>
</div>
</div>
</div>
</div>
<ng-template #dynamicContentElseBlock >
<div id="addressError" class="alert alert-warning mt-5 " *ngIf="invalidAddressBoolean" role="alert">
Invalid Address
</div>
</ng-template>
</ng-template>
</ngb-tab>
<ngb-tab id="tab-selectbyid2" title="Favorites" >
<ng-template ngbTabContent>
<!--Favorites Tab: Add conditions accordingly-->
<div id="favorites" class="mt-5">
<div *ngIf="favoriteArray.length>0; else favoriteElseBlock">
<table class="table table-borderless favTable">
<tbody>
<tr>
<th scope="col">#</th>
<th scope="col">Image</th>
<th scope="col">City</th>
<th scope="col">State</th>
<th scope="col">Favorites</th>
</tr>
<tr *ngFor="let entry of favoriteArray; index as i">
<td>{{i+1}}</td>
<td><img class="favoriteImg" src="{{entry.stateImg}}"></td>
<td><a href="#" ngbTooltip="{{entry.city}}" placement="bottom" (click)="loadFromFavorite(i)" (click)="t.select('tab-selectbyid1')" style="text-decoration: none;">{{entry.city}}</a></td>
<td>{{entry.state}}</td>
<td><button class="material-icons" style='color:goldenrod;' (click)="deleteFavorite(i)">delete</button></td>
</tr>
</tbody>
</table>
</div>
<ng-template #favoriteElseBlock>
<div class="alert alert-warning mt-5" role="alert">
No Records.
</div>
</ng-template>
</div>
</ng-template>
</ngb-tab>
</ngb-tabset>
</div>
<!--Progress Bar-->
<div class="mt-5 progress" *ngIf="progressBoolean">
<div class="progress-bar progress-bar-striped bg-info progress-bar-animated" role="progressbar" aria-valuenow="50" aria-valuemin="0" aria-valuemax="100" style="width: 50%"></div>
</div>
<!-- Modal -->
<ng-template #content let-modal>
<div class="modal-header" id="modalHead">
<h5 class="modal-title">{{darkskyMODALData.date}}</h5>
<button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body pl-5" id="modalBody">
<div class="table-responsive mb-n4">
<table class="table table-borderless customizingTable">
<tr>
<th scope="col"><h2>{{currentcity}}</h2></th>
<th></th>
</tr>
<tr>
<td>
<h2>{{darkskyMODALData.temperature | number:'1.0-0'}}°F</h2>
</td>
<td scope="col" rowspan="2"><img src="{{darkskyMODALData.image}}" id="modalImg"></td>
</tr>
<tr>
<td>
{{darkskyMODALData.summary}}
</td>
</tr>
</table>
</div>
</div>
<div class="footerContainer pl-5 pr-5">
<div class="modal-footer" id="modalFoot">
<div class="modalContent">
Precipitation: {{darkskyMODALData.precipitation}}
<br>
Chance of Rain: {{darkskyMODALData.rain}}%
<br>
Wind Speed: {{darkskyMODALData.wind}} mph
<br>
Humidity: {{darkskyMODALData.humidity}}%
<br>
Visibility: {{darkskyMODALData.visibility}} miles
<br>
</div>
</div>
</div>
</ng-template>
</div>