Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Merge pull request #263 from orange-alliance/dev
Browse files Browse the repository at this point in the history
March 2019 Release
  • Loading branch information
ofekashery committed Mar 1, 2019
2 parents b3617d6 + 041d4c9 commit 70cf193
Show file tree
Hide file tree
Showing 74 changed files with 2,661 additions and 1,529 deletions.
124 changes: 62 additions & 62 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "the-orange-alliance",
"version": "3.1.2",
"version": "3.1.3",
"license": "MIT",
"scripts": {
"ng": "ng",
Expand All @@ -13,7 +13,7 @@
},
"private": true,
"dependencies": {
"@angular-mdc/web": "^0.43.3",
"@angular-mdc/web": "^0.44.0",
"@angular/animations": "^7.2.0",
"@angular/cdk": "^6.4.6",
"@angular/common": "^7.2.0",
Expand Down
3 changes: 3 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ const routes: Routes = [
{ path: 'register', component: RegisterComponent },
{ path: 'events', component: AccountComponent },
{ path: 'new-event', component: AccountComponent },
{ path: 'users', component: AccountComponent },
{ path: 'cache', component: AccountComponent },
{ path: 'retriever', component: AccountComponent }
]
},
{ path: 'add-data', component: AddDataComponent },
Expand Down
187 changes: 93 additions & 94 deletions src/app/app.component.html

Large diffs are not rendered by default.

73 changes: 56 additions & 17 deletions src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@ import { Location } from '@angular/common';
import { LOCAL_STORAGE, StorageService } from 'angular-webstorage-service';
import { TranslateService } from '@ngx-translate/core';
import { FTCDatabase } from './providers/ftc-database';
import { CloudFunctions, Service } from './providers/cloud-functions';
import { AngularFireDatabase } from '@angular/fire/database';
import { AngularFireAuth } from '@angular/fire/auth';
import { NavigationEnd, Router } from '@angular/router';
import { EventFilter } from './util/event-utils';
import { TheOrangeAllianceGlobals } from './app.globals';
import { MdcTopAppBar, MdcTextField } from '@angular-mdc/web';
import { MdcTopAppBar, MdcDrawer } from '@angular-mdc/web';
import { environment } from '../environments/environment';
import Team from './models/Team';
import Event from './models/Event';
import mdcInfo from '../../node_modules/@angular-mdc/web/package.json'

const SMALL_WIDTH_BREAKPOINT = 1240;

Expand All @@ -24,7 +27,16 @@ const SMALL_WIDTH_BREAKPOINT = 1240;
@Injectable()
export class TheOrangeAllianceComponent implements OnInit {

server: { 'is_dev': boolean, 'last_commit': string, 'build_time': string, 'api_version': string, 'mdc_version': string } = {
'is_dev': false,
'last_commit': null,
'build_time': null,
'api_version': null,
'mdc_version': null
};

teams: Team[];
services = Service;

events: Event[];
eventsFilter: EventFilter;
Expand All @@ -33,26 +45,34 @@ export class TheOrangeAllianceComponent implements OnInit {
teamSearchResults: Team[];
eventSearchResults: Event[];
showSearch: boolean;
showMobileSearch: boolean;

current_year: any;
selectedLanguage = '';

user: firebase.User;
isAdmin: boolean = false;

matcher: MediaQueryList;
@ViewChild(MdcTopAppBar) appBar: MdcTopAppBar;
@ViewChild(MdcDrawer) drawer: MdcDrawer;
title: string;

constructor(public router: Router, private ftc: FTCDatabase, private ngZone: NgZone, private location: Location,
db: AngularFireDatabase, auth: AngularFireAuth, private translate: TranslateService,
db: AngularFireDatabase, auth: AngularFireAuth, private translate: TranslateService, private cloud: CloudFunctions,
@Inject(LOCAL_STORAGE) private storage: StorageService, private appBarService: AppBarService) {

translate.setDefaultLang('en'); // this language will be used as a fallback when a translation isn't found in the current language
this.selectedLanguage = this.storage.get('lang') || translate.getBrowserLang();
this.languageSelected();

this.router.routeReuseStrategy.shouldReuseRoute = function() {
return false;
};

this.router.events.subscribe(() => {
setTimeout(()=>{
this.showMobileSearch = false;
setTimeout(() => {
this.title = this.appBarService.titleLong;
});
});
Expand All @@ -65,17 +85,29 @@ export class TheOrangeAllianceComponent implements OnInit {

auth.authState.subscribe(user => {
this.user = user;

// Fix the old users
if (this.user && !this.user.displayName) {
db.object(`Users/${this.user.uid}/fullName`).query.once('value').then(name => {
this.user.updateProfile({displayName: name.val(), photoURL: null});
});
}

if (this.user && this.user.displayName) {
db.database.ref(`Users/${this.user.uid}/fullName`).set(this.user.displayName)
}
db.object(`Users/${this.user.uid}/level`).query.once('value').then(level => {
this.isAdmin = level.val() && level.val() >= 6;
if (this.isAdmin) {
this.ftc.getApiVersion().then((version: string) => {
this.server.api_version = version;
});
this.server.is_dev = !environment.production;
if (!this.server.is_dev) {
this.server.last_commit = environment.commit;

const d = new Date(environment.build_time);
const dateString = // 2019/02/24 16:03:57
d.getUTCFullYear() + '/' +
('0' + (d.getUTCMonth() + 1)).slice(-2) + '/' +
('0' + d.getUTCDate()).slice(-2) + ' ' +
('0' + d.getUTCHours()).slice(-2) + ':' +
('0' + d.getUTCMinutes()).slice(-2) + ':' +
('0' + d.getUTCSeconds()).slice(-2);
this.server.build_time = dateString;
}
this.server.mdc_version = mdcInfo.version;
}
});
});

this.current_year = new Date().getFullYear();
Expand Down Expand Up @@ -112,8 +144,12 @@ export class TheOrangeAllianceComponent implements OnInit {
this.location.back();
}

drawerItemClicked() {
this.drawer.open = false;
}

performSearch(): void {
const maxResults = 5;
const maxResults = this.showMobileSearch ? 8 : 5;
const query = this.search && this.search.trim().length > 0 ? this.search.toLowerCase().trim() : null;

if (query && this.teams && this.eventsFilter) {
Expand All @@ -136,7 +172,8 @@ export class TheOrangeAllianceComponent implements OnInit {
}
}

focusSearchInput(searchInput: MdcTextField): void {
showMobileSearchModal(searchInput): void {
this.showMobileSearch = true;
// When the modal opens, it takes the focus
// We'll wait 6ms until it opens
setTimeout(function () {
Expand Down Expand Up @@ -199,6 +236,9 @@ export class TheOrangeAllianceComponent implements OnInit {
this.translate.use(this.selectedLanguage);
}

updateService(service: Service) {
this.cloud.update(this.user, service);
}

sendAnalytic(category, action): void {
(<any>window).ga('send', 'event', {
Expand All @@ -208,5 +248,4 @@ export class TheOrangeAllianceComponent implements OnInit {
eventValue: 10
});
}

}
26 changes: 20 additions & 6 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ import { environment } from '../environments/environment';
import { TheOrangeAllianceComponent } from './app.component';
import { HomeComponent } from './views/home/home.component';
import { AddDataComponent } from './views/add-data/add-data.component';
import { ManageEventsComponent } from './views/account/subpages/manage-events/manage-events.component';
import { UsersComponent } from './views/account/subpages/users/users.component';
import { CreateEventComponent } from './views/account/subpages/create-event/create-event.component';
import { CacheComponent } from './views/account/subpages/cache/cache.component';
import { RetrieverComponent } from './views/account/subpages/retriever/retriever.component';
import { AccountComponent } from './views/account/account.component';
import { EventsComponent } from './views/events/events.component';
import { TeamsComponent } from './views/teams/teams.component';
Expand All @@ -36,16 +41,16 @@ import { TeamComponent } from './views/team/team.component';
import { StreamingComponent } from './views/stream/streaming.component';
import { PrivacyTermsComponent } from './views/privacy_terms/PrivacyTerms.component';
import { MatchesComponent } from './views/matches/matches.component';
import { VelocityVortexComponent } from './views/matches/years/1617/1617-velocity-vortex.component';
import { RelicRecoveryComponent } from './views/matches/years/1718/1718-relic-recovery-component';
import { AppMaterialModule } from './material.module';
import { DialogText } from './dialogs/text/dialog-text';
import { DialogMatch } from './dialogs/match/dialog-match';
import { MatchDetailsComponent } from './views/matches/details/match-details.component';
import { MatchTableComponent } from './components/match-table/match-table.component';
import { EventItemComponent } from './components/event/event.item.component';
import { TeamItemComponent } from './components/team/team.item.component';
import { AwardItemComponent } from './components/award/award.item.component';
import { LoginComponent } from './views/account/login/login.component';
import { RegisterComponent } from './views/account/register/register.component';
import { RoverRuckusComponent } from './views/matches/years/1819/1819-rover-ruckus.component';
import { TeamRobotComponent } from './views/team/subviews/team-robot/team-robot.component';
import { TeamResultsComponent } from './views/team/subviews/team-results/team-results.component';
import { StreamItemComponent } from './components/stream-item/stream-item.component';
Expand All @@ -60,6 +65,11 @@ export function HttpLoaderFactory(httpClient: HttpClient) {
TheOrangeAllianceComponent,
HomeComponent,
AddDataComponent,
ManageEventsComponent,
UsersComponent,
CreateEventComponent,
CacheComponent,
RetrieverComponent,
AccountComponent,
LoginComponent,
RegisterComponent,
Expand All @@ -81,16 +91,20 @@ export function HttpLoaderFactory(httpClient: HttpClient) {
ApiDocsComponent,
StreamingComponent,
PrivacyTermsComponent,
MatchDetailsComponent,
MatchesComponent,
VelocityVortexComponent,
RelicRecoveryComponent,
RoverRuckusComponent,
TeamRobotComponent,
DialogText,
DialogMatch,
MatchTableComponent,
EventItemComponent,
TeamItemComponent,
AwardItemComponent
],
entryComponents: [
DialogText,
DialogMatch
],
imports: [
AngularFireModule.initializeApp(environment.firebase, 'T'),
AngularFireDatabaseModule,
Expand Down
3 changes: 0 additions & 3 deletions src/app/app.server.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* Created by Kyle Flynn on 5/29/2017.
*/
import { NgModule } from '@angular/core';
import { ServerModule } from '@angular/platform-server';
import { AppModule } from './app.module';
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/event/event.item.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<a routerLink="/events/{{ event.eventKey }}" class="no-underline mdc-list--two-line">
<a [routerLink]="clickable ? '/events/' + event.eventKey : null" class="no-underline mdc-list--two-line">
<mdc-list-item interactive>
<div class="data-indicator" [dir]="'config.direction' | translate" *ngIf="event.teamCount > 0"></div>
<mdc-list-item-text>
Expand Down
1 change: 1 addition & 0 deletions src/app/components/event/event.item.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export class EventItemComponent {

@Input() event: Event;
@Input() hideLiveBadge: boolean;
@Input() clickable: boolean = true;

isLive(): boolean {
let liveData: boolean = this.event.teamCount > 0 || this.event.matchCount > 0 ;
Expand Down
Loading

0 comments on commit 70cf193

Please sign in to comment.