diff --git a/src/app/contact/contact-form/contact-form.component.html b/src/app/contact/contact-form/contact-form.component.html index 755531840..f06ca93ce 100644 --- a/src/app/contact/contact-form/contact-form.component.html +++ b/src/app/contact/contact-form/contact-form.component.html @@ -1,47 +1,128 @@ -
-
- -
+
+
+ +
Contact Form -
- - -
- Name is required -
+
+ + +
+ + Name is required + +
-
- - -
- Valid Email is required -
+
+ + +
+ + Valid Email is required + +
-
- - - - - - -
- Valid Mobile Number is required. -
+
+ + + + - + + +
+ + Valid Mobile Number is required. + +
-
- - -
- Describe more with Minimum 100 characters. -
+
+ + +
+ + Describe more with Minimum 100 characters. + +
-
+
*All fields are mandatory - - Your Form has been submitted + + Your Form has been submitted
diff --git a/src/app/contact/contact-form/contact-form.component.ts b/src/app/contact/contact-form/contact-form.component.ts index 6fd8d875f..4c8c8c050 100644 --- a/src/app/contact/contact-form/contact-form.component.ts +++ b/src/app/contact/contact-form/contact-form.component.ts @@ -1,8 +1,12 @@ import { Component, OnInit, Output, EventEmitter } from '@angular/core'; -import { FormGroup, FormControl, FormBuilder, Validators } from '@angular/forms'; +import { + FormGroup, + FormControl, + FormBuilder, + Validators +} from '@angular/forms'; import { HttpClient, HttpHeaders } from '@angular/common/http'; import { countrycodearray } from '../../shared/countrycode/countrycode'; - @Component({ selector: 'contact-form', templateUrl: './contact-form.component.html', @@ -14,41 +18,50 @@ export class ContactFormComponent implements OnInit { public selectedValue = null; public countries = countrycodearray; @Output() hideContactForm: EventEmitter = new EventEmitter(); - - constructor( private http: HttpClient ) { } - + constructor(private http: HttpClient) {} ngOnInit() { this.contactForm = new FormGroup({ name: new FormControl('', [Validators.required]), - email: new FormControl('', [Validators.required, Validators.email]), + email: new FormControl('', [ + Validators.required, + Validators.email + ]), countrycode: new FormControl('', [Validators.required]), - telephone: new FormControl('', [Validators.required, Validators.minLength(10), Validators.pattern('^[0-9]*$')]), - message: new FormControl('', [Validators.required, Validators.minLength(100)]) - }); + telephone: new FormControl('', [ + Validators.required, + Validators.minLength(10), + Validators.pattern('^[0-9]*$') + ]), + message: new FormControl('', [ + Validators.required, + Validators.minLength(100) + ]) + }); } - public sendtosuperuser(user) { this.hideContactForm.emit(false); const headers = new HttpHeaders(); - const formObj = user.getRawValue(); + const formObj = this.contactForm.value; const data = JSON.stringify(formObj); - - headers.append('Content-Type', 'application/X-www-form-urlencoded'); headers.append('Accept', 'application/json'); - this.http.post('https://formspree.io/office@fossasia.org', data, { headers: headers }) - .subscribe((response) => { - this.http.post('https://formspree.io/office@fossasia.org', data, { headers: headers }) - .subscribe((responsesent) => { + this.http + .post('https://formspree.io/office@fossasia.org', data, { + headers: headers + }) + .subscribe(response => { + this.http + .post('https://formspree.io/office@fossasia.org', data, { + headers: headers + }) + .subscribe(responsesent => { console.log('Sent successfully'); }); }); } - public showSubmit() { this.submitted = true; } - } diff --git a/src/app/feed/info-box/info-box.component.html b/src/app/feed/info-box/info-box.component.html index b7f395af7..29375feb1 100644 --- a/src/app/feed/info-box/info-box.component.html +++ b/src/app/feed/info-box/info-box.component.html @@ -1,34 +1,62 @@ -
+
-
+

Top Twitterers

- {{item[1][0]}} - {{item[1][0].length}} + {{ item[1][0] }} + {{ + item[1][0].length + }} - @{{item[1][0]}} + @{{ item[1][0] }}
-
+

Top Hashtags

- + @@ -36,17 +64,31 @@

Top Hashtags

-
+

Top Mentions

-
{{item[1]}}
+
{{ item[1] }}
- #{{item[0]}} + #{{ item[0] }}
@@ -54,33 +96,70 @@

Top Mentions

- - +
  + +  diff --git a/src/app/feed/info-box/info-box.component.scss b/src/app/feed/info-box/info-box.component.scss index e671f4ea3..4e5a027c4 100644 --- a/src/app/feed/info-box/info-box.component.scss +++ b/src/app/feed/info-box/info-box.component.scss @@ -3,12 +3,14 @@ } .info-box { - -webkit-box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16), 0 0 0 1px rgba(0,0,0,0.08); - box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16), 0 0 0 1px rgba(0,0,0,0.08); - border-radius: 2px; - min-height: 420px; - width: 100%; - margin-bottom: 20px; + -webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), + 0 0 0 1px rgba(0, 0, 0, 0.08); + box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.08); + border-radius: 2px; + min-height: 420px; + width: 100%; + margin-bottom: 20px; + overflow: hidden; } .row:first-child { @@ -17,99 +19,100 @@ } .leaderboard-item { - text-align: left; - border-bottom: 2px solid #ccc; - padding: 4px 0; - font-size: 14px; - height: 40px; - img { - border-radius: 50%; - } - td { - position: relative; - padding-left: 10px; - padding-right: 0; - img { - height: 30px; - width: 30px; - } - } + text-align: left; + border-bottom: 2px solid #ccc; + padding: 4px 0; + font-size: 14px; + height: 40px; + img { + border-radius: 50%; + } + td { + position: relative; + padding-left: 10px; + padding-right: 0; + img { + height: 30px; + width: 30px; + } + } } .data { - display: inline-block; - text-decoration: none; - img { - height: 24px; - border-radius: 20%; - } - span { - padding: 5px; - vertical-align: super; - } + display: inline-block; + text-decoration: none; + img { + height: 24px; + border-radius: 20%; + } + span { + padding: 5px; + vertical-align: super; + } } .rss { - background-color: #F79128; - color: white; - height: 24px; - border-radius: 9%; + background-color: #f79128; + color: white; + height: 24px; + border-radius: 9%; } .json { - background-color: #5EBC62; - color: white; - height: 24px; - border-radius: 9%; + background-color: #5ebc62; + color: white; + height: 24px; + border-radius: 9%; } .leaderboard-count { - background-color: #337ab7; - height: 30px; - width: 30px; - padding: 8px 0; - text-align: center; - border-radius: 50%; - font-weight: bold; - font-size: 14px; - color: #fff; + background-color: #337ab7; + height: 30px; + width: 30px; + padding: 8px 0; + text-align: center; + border-radius: 50%; + font-weight: bold; + font-size: 14px; + color: #fff; } .leaderboard-label { - top: -8px; - font-size: 14px; - position: absolute; - left: 20px; - text-align: center; - line-height: 24px; - background-color: #337ab7; - border-radius: 50%; - color: #fff; - width: 23px; - height: 23px; + top: -8px; + font-size: 14px; + position: absolute; + left: 20px; + text-align: center; + line-height: 24px; + background-color: #337ab7; + border-radius: 50%; + color: #fff; + width: 23px; + height: 23px; } .leaderboard-text { - a { - font-size: 14px; - line-height: 21px; - } + a { + font-size: 14px; + line-height: 21px; + } } .link-sidebar-container { - -webkit-box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16), 0 0 0 1px rgba(0,0,0,0.08); - box-shadow: 0 2px 2px 0 rgba(0,0,0,0.16), 0 0 0 1px rgba(0,0,0,0.08); + -webkit-box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), + 0 0 0 1px rgba(0, 0, 0, 0.08); + box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.16), 0 0 0 1px rgba(0, 0, 0, 0.08); border-radius: 2px; width: 100%; - display:flex; + display: flex; flex-wrap: wrap; margin: 30px 0px; padding: 15px 10px; } .link-sidebar { - margin: 3px 7px; - padding: 0px 15px; + margin: 3px 7px; + padding: 0px 15px; } @media (max-width: 470px) { diff --git a/src/app/feed/info-box/info-box.component.ts b/src/app/feed/info-box/info-box.component.ts index cbd4b3047..74b2dfb0e 100644 --- a/src/app/feed/info-box/info-box.component.ts +++ b/src/app/feed/info-box/info-box.component.ts @@ -38,18 +38,24 @@ export class InfoBoxComponent implements OnChanges { public configUrl = defaultUrlConfig; - constructor( private store: Store ) {} + constructor(private store: Store) {} ngOnChanges() { - this.store.select(fromRoot.getQuery).subscribe(query => this.stringQuery = query.displayString); + this.store + .select(fromRoot.getQuery) + .subscribe(query => (this.stringQuery = query.displayString)); this.parseApiResponseData(); - if ( hashtagRegExp.exec(this.stringQuery) !== null ) { + if (hashtagRegExp.exec(this.stringQuery) !== null) { // Check for hashtag this.stringQuery - this.queryString = '%23' + hashtagRegExp.exec(this.stringQuery)[1] + '' + hashtagRegExp.exec(this.stringQuery)[0]; - } else if ( fromRegExp.exec(this.stringQuery) !== null ) { + this.queryString = + '%23' + + hashtagRegExp.exec(this.stringQuery)[1] + + '' + + hashtagRegExp.exec(this.stringQuery)[0]; + } else if (fromRegExp.exec(this.stringQuery) !== null) { // Check for from user this.stringQuery this.queryString = 'from%3A' + fromRegExp.exec(this.stringQuery)[1]; - } else if ( mentionRegExp.exec(this.stringQuery) !== null ) { + } else if (mentionRegExp.exec(this.stringQuery) !== null) { // Check for mention this.stringQuery this.queryString = '%40' + mentionRegExp.exec(this.stringQuery)[1]; } else { @@ -64,7 +70,10 @@ export class InfoBoxComponent implements OnChanges { for (const s in statistics) { if (s) { for (let i = 0; i < statistics[s].length; i++) { - if ( this.stringQuery.substring(1).toLowerCase() !== statistics[s][i].toLowerCase() ) { + if ( + this.stringQuery.substring(1).toLowerCase() !== + statistics[s][i].toLowerCase() + ) { stored.push(statistics[s][i]); } } @@ -73,7 +82,6 @@ export class InfoBoxComponent implements OnChanges { this.topHashtags = this.parseRawDataWithFrequency(stored); this.areTopHashtagsAvailable = this.topHashtags.length > 0; return this.topHashtags; - } else if (typeof statistics === 'undefined') { this.topHashtags = []; this.areTopHashtagsAvailable = false; @@ -86,17 +94,17 @@ export class InfoBoxComponent implements OnChanges { for (let i = 0; i < statistics.length; i++) { let check = true; for (let j = 0; j < temp.length; j++) { - if ( statistics[i][0] === temp[j][0] ) { + if (statistics[i][0] === temp[j][0]) { check = false; } } - if ( check ) { + if (check) { temp.push(statistics[i]); } } statistics = temp; - for ( let i = 0; i < statistics.length - 1; i++ ) { - for ( let j = i + 1; j < statistics.length; j++ ) { + for (let i = 0; i < statistics.length - 1; i++) { + for (let j = i + 1; j < statistics.length; j++) { if (statistics[i][0] === statistics[j][0]) { if (i !== j) { statistics.splice(j, 1); @@ -110,10 +118,10 @@ export class InfoBoxComponent implements OnChanges { sortable.push([s, statistics[s]]); } } - sortable.sort(function (a, b) { + sortable.sort(function(a, b) { return b[1] - a[1]; }); - sortable = (sortable.slice(0, 10)); + sortable = sortable.slice(0, 10); this.topTwitterers = sortable; this.areTopTwitterersAvailable = true; return this.topTwitterers; @@ -122,7 +130,6 @@ export class InfoBoxComponent implements OnChanges { this.topTwitterers = []; return this.topTwitterers; } - } sortMentions(statistics) { const stored = []; @@ -130,7 +137,10 @@ export class InfoBoxComponent implements OnChanges { for (const s in statistics) { if (s) { for (let i = 0; i < statistics[s][0].length; i++) { - if ( this.stringQuery.substring(1).toLowerCase() !== statistics[s][0][i].toLowerCase() ) { + if ( + this.stringQuery.substring(1).toLowerCase() !== + statistics[s][0][i].toLowerCase() + ) { stored.push(statistics[s][0][i]); } } @@ -148,20 +158,20 @@ export class InfoBoxComponent implements OnChanges { public parseRawDataWithFrequency(stored) { let topFrequencyData = []; - stored = stored.reduce(function (acc, curr) { + stored = stored.reduce(function(acc, curr) { if (typeof acc[curr] === 'undefined') { - acc[curr] = 1; + acc[curr] = 1; } else { acc[curr] += 1; } return acc; }, []); topFrequencyData = Object.keys(stored) - .map(key => key.trim()) - .filter(key => key !== '') - .map(key => ([key, stored[key]])) - .sort((a, b) => b[1] - a[1]) - .slice(0, 10); + .map(key => key.trim()) + .filter(key => key !== '') + .map(key => [key, stored[key]]) + .sort((a, b) => b[1] - a[1]) + .slice(0, 10); return topFrequencyData; } @@ -182,7 +192,7 @@ export class InfoBoxComponent implements OnChanges { const screenStrings = []; const mentionStrings = []; const createdStrings = []; - for ( let i = 0; i < this.ApiResponseResult.length; i++) { + for (let i = 0; i < this.ApiResponseResult.length; i++) { if (this.ApiResponseResult[i]['hashtags'].length !== 0) { tagStrings.push(this.ApiResponseResult[i]['hashtags']); } @@ -193,9 +203,7 @@ export class InfoBoxComponent implements OnChanges { ]); } if (this.ApiResponseResult[i]['mentions'].length !== 0) { - mentionStrings.push([ - this.ApiResponseResult[i]['mentions'] - ]); + mentionStrings.push([this.ApiResponseResult[i]['mentions']]); } if (this.ApiResponseResult[i]['created_at'].length !== 0) { createdStrings.push(this.ApiResponseResult[i]['created_at']); @@ -208,12 +216,13 @@ export class InfoBoxComponent implements OnChanges { } getChartData(statistics) { - for (let i = 0; i < statistics.length; i++) { statistics[i] = JSON.stringify(statistics[i]).substring(1, 11); } const count = {}; - statistics.forEach(function(i) { count[i] = (count[i] || 0) + 1; }); + statistics.forEach(function(i) { + count[i] = (count[i] || 0) + 1; + }); if (statistics !== undefined && statistics.length !== 0) { const data = []; const labels = [];
- {{item[0]}} - {{item[1]}} + {{ item[0] }} + {{ item[1] }} - @{{item[0]}} + @{{ item[0] }}