Advertisement
FiringBlanks

Autocomplete Search (4) Showing all at first

Oct 28th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.84 KB | None | 0 0
  1.  
  2. // import {map, startWith, filter, scan} from 'rxjs/operators';
  3. import { Component, OnInit, OnDestroy, Pipe, PipeTransform, Input, HostListener, Injectable } from '@angular/core';
  4. import { FormControl } from '@angular/forms';
  5. import { Observable, of } from 'rxjs';
  6. import * as firebase from 'firebase';
  7. import { MatDialog, MatSnackBar } from '@angular/material';
  8. import { DialogAddSchoolComponent } from '../dialog-add-school/dialog-add-school.component';
  9. import { PersistingDataService } from '../persisting-data/persisting-data.service';
  10. import { Router } from '@angular/router';
  11. import { AngularFirestoreCollection, AngularFirestore, AngularFirestoreDocument } from '@angular/fire/firestore';
  12. import { AuthService } from '../core/auth.service';
  13. import { CommonService } from '../SvcCommon/common.service';
  14. import { PaymentService } from '../SvcPayment/payment.service';
  15. import { DialogNewUserComponent } from '../dialog-new-user/dialog-new-user.component';
  16. import { User, Action, Assignment, SvcInterfacesService } from '../SvcInterfaces/svc-interfaces.service';
  17. import { DialogAdminPanelComponent } from '../dialog-admin-panel/dialog-admin-panel.component';
  18. import { DialogEditSchoolComponent } from '../dialog-edit-school/dialog-edit-school.component';
  19. import { debounceTime, map, tap, take } from 'rxjs/operators';
  20. import { SlicePipe } from '@angular/common';
  21. import { HttpClient } from '@angular/common/http';
  22. import { DialogOpenSubmissionsComponent } from '../dialog-open-submissions/dialog-open-submissions.component';
  23. import { DialogTutorialComponent } from '../dialog-tutorial/dialog-tutorial.component';
  24. // import 'rxjs/add/operator/toPromise';
  25.  
  26. // declare const google: any;
  27.  
  28.  
  29. // export class School {
  30. // constructor(public name: string, public city: string, public state: string, public type: string) { }
  31. // }
  32.  
  33. interface School {
  34. name: string,
  35. schoolNameDisplay: string,
  36. city: string,
  37. state: string,
  38. type: string
  39. }
  40.  
  41. interface Class {
  42. className: string;
  43. classSubmittedDate: number;
  44. classUID: string;
  45. submittersName: string;
  46. submittersUID: string;
  47. teacher: string;
  48. school: string;
  49. }
  50.  
  51. @Pipe({name: 'orderBy', pure: false})
  52. export class OrderBy implements PipeTransform {
  53.  
  54. static _orderByComparator(a:any, b:any):number{
  55.  
  56. if((isNaN(parseFloat(a)) || !isFinite(a)) || (isNaN(parseFloat(b)) || !isFinite(b))){
  57. //Isn't a number so lowercase the string to properly compare
  58. // if(a.toLowerCase() < b.toLowerCase()) return -1;
  59. // if(a.toLowerCase() > b.toLowerCase()) return 1;
  60. }
  61. else{
  62. //Parse strings as numbers to compare properly
  63. if(parseFloat(a) < parseFloat(b)) return -1;
  64. if(parseFloat(a) > parseFloat(b)) return 1;
  65. }
  66.  
  67. return 0; //equal each other
  68. }
  69.  
  70. transform(input:any, [config = '+']): any{
  71.  
  72. if(!Array.isArray(input)) return input;
  73.  
  74. if(!Array.isArray(config) || (Array.isArray(config) && config.length == 1)){
  75. var propertyToCheck:string = !Array.isArray(config) ? config : config[0];
  76. var desc = propertyToCheck.substr(0, 1) == '-';
  77.  
  78. //Basic array
  79. if(!propertyToCheck || propertyToCheck == '-' || propertyToCheck == '+'){
  80. return !desc ? input.sort() : input.sort().reverse();
  81. }
  82. else {
  83. var property:string = propertyToCheck.substr(0, 1) == '+' || propertyToCheck.substr(0, 1) == '-'
  84. ? propertyToCheck.substr(1)
  85. : propertyToCheck;
  86.  
  87. return input.sort(function(a:any,b:any){
  88. return !desc ?
  89. OrderBy._orderByComparator(a[property], b[property])
  90. : -OrderBy._orderByComparator(a[property], b[property]);
  91. });
  92. }
  93. }
  94. else {
  95. //Loop over property of the array in order and sort
  96. return input.sort(function(a:any,b:any){
  97. for(var i:number = 0; i < config.length; i++){
  98. var desc = config[i].substr(0, 1) == '-';
  99. var property = config[i].substr(0, 1) == '+' || config[i].substr(0, 1) == '-'
  100. ? config[i].substr(1)
  101. : config[i];
  102.  
  103. var comparison = !desc ?
  104. OrderBy._orderByComparator(a[property], b[property])
  105. : -OrderBy._orderByComparator(a[property], b[property]);
  106.  
  107. //Don't return 0 yet in case of needing to sort by next property
  108. if(comparison != 0) return comparison;
  109. }
  110.  
  111. return 0; //equal each other
  112. });
  113. }
  114. }
  115. }
  116.  
  117. @Injectable({
  118. providedIn: 'root'
  119. })
  120. export class MyService {
  121.  
  122. constructor(private afs: AngularFirestore) { }
  123.  
  124. private schools = [];
  125.  
  126. fetchSchools() {
  127. console.log('---------------');
  128.  
  129. if(this.schools && this.schools.length) {
  130. console.log('Returning first data');
  131. return of(this.schools);
  132. } else {
  133. console.log('Returning else data');
  134. return this.afs.collection('Schools', ref => {
  135. return ref.orderBy('schoolNameDisplay')
  136. }).valueChanges()
  137. }
  138. }
  139. }
  140.  
  141. @Component({
  142. selector: 'app-page-home',
  143. templateUrl: './page-home.component.html',
  144. styleUrls: ['./page-home.component.css']
  145. })
  146. export class PageHomeComponent implements OnInit {
  147.  
  148. pinnedClassesCollection: AngularFirestoreCollection<Class>;
  149. pinnedClasses: Observable<Class[]>;
  150.  
  151. moderatingClassesCollection: AngularFirestoreCollection<Class>;
  152. moderatingClasses: Observable<Class[]>;
  153.  
  154. schoolsCollection: AngularFirestoreCollection<School>;
  155. schools: Observable<School[]>;
  156. // schools;
  157. schoolsArr: School[];
  158.  
  159. assignmentsCollection: AngularFirestoreCollection<Assignment>;
  160. assignments: Observable<Assignment[]>;
  161.  
  162. createdSchoolsCollection: AngularFirestoreCollection<School>;
  163. createdSchools: Observable<School[]>;
  164.  
  165. schoolsDocs: AngularFirestoreDocument<School>;
  166.  
  167. schoolCtrl: FormControl;
  168. filteredSchools: Observable<any[]>
  169.  
  170. searchedSchool;
  171.  
  172. user: User;
  173. userExists;
  174.  
  175. currentlySelectedPinnedClassUID;
  176. currentlySelectedPinnedClass;
  177. currentlySelectedPinnedTeacher;
  178. currentlySelectedPinnedSchool;
  179.  
  180. pinnedSize;
  181. moderatingSize;
  182.  
  183. pinsFetched; //'fetched' or 'stopped'
  184. modsFetched; //'fetched' or 'stopped'
  185.  
  186. windowWidth;
  187. windowHeight;
  188.  
  189. toolbarElevated;
  190.  
  191. usersPosition;
  192. usersPositionLoopCounter = 0;
  193. locationFetched = false;
  194. usersMetaHot;
  195.  
  196.  
  197.  
  198. @HostListener('window:resize', ['$event'])
  199. onresize(event) {
  200. this.windowWidth = window.innerWidth;
  201. this.windowHeight = window.innerHeight;
  202. console.log(`Window resolution: ${this.windowWidth} x ${this.windowHeight}`);
  203. }
  204.  
  205. constructor(private dialog: MatDialog, private persistingData: PersistingDataService, private router: Router, private afs: AngularFirestore, private auth: AuthService, private common: CommonService, private payment: PaymentService, private myService: MyService, private snackbar: MatSnackBar, private httpClient: HttpClient) { }
  206.  
  207. schoolsObs = [];
  208. searchModel = '';
  209. schoolSubscriber = null;
  210. originalSchoolList = [];
  211.  
  212. ngOnInit() {
  213.  
  214. this.persistingData.changeViewWithContainer(true);
  215. this.persistingData.toolbarElevated.subscribe(message => this.toolbarElevated = message);
  216.  
  217. // this.router.events.subscribe((val) => {
  218. // console.log('ngOnInit router changed');
  219. // this.persistingData.changeToggleDisplayGradient(false)
  220. // })
  221.  
  222. this.windowWidth = window.innerWidth;
  223. this.windowHeight = window.innerHeight;
  224.  
  225. this.schoolSubscriber = this.myService.fetchSchools().subscribe(schoolList => {
  226. this.originalSchoolList = schoolList
  227. this.schoolsObs = schoolList
  228. })
  229.  
  230. // this.fetchSchools();
  231. // this.filterSchools();
  232.  
  233. this.persistingData.loggedInUser.subscribe(user => {
  234.  
  235. if(user){
  236. this.user = user;
  237. this.userExists = true;
  238. this.fetchPinnedClasses();
  239. this.fetchModeratingClasses();
  240. this.fetchCreatedSchools();
  241. this.fetchLocation();
  242. } else {
  243. this.userExists = false;
  244. this.pinsFetched = 'stopped';
  245. this.modsFetched = 'stopped';
  246. }
  247.  
  248. console.log('persistingData loggedinUser subscription:');
  249. if(user){
  250. console.log('user: ');
  251. console.log(user);
  252. }
  253.  
  254. this.user = user;
  255. });
  256.  
  257. }
  258.  
  259. // filterSchools(){
  260. // console.log('Running filterSchools()');
  261.  
  262. // this.schoolsObs = this.myService.fetchSchools().pipe(
  263. // debounceTime(300),
  264. // map((data) => this.performFilter(data))
  265. // );
  266. // }
  267.  
  268.  
  269. filterSchools(){
  270. this.schoolsObs = this.performFilter(this.originalSchoolList)
  271. }
  272.  
  273.  
  274. performFilter(schoolsObs){
  275. console.log('Running performFilter()');
  276.  
  277. console.log('schoolsObs:');
  278. console.log(schoolsObs);
  279.  
  280. console.log('this.schools:');
  281. console.log(this.schools);
  282.  
  283. return schoolsObs.filter((x) => {
  284. return x.name.toLowerCase().match(this.searchModel.trim().toLowerCase());
  285. }).slice(0,4);
  286.  
  287. }
  288.  
  289. ngOnDestroy(){
  290. console.log('Running onDestroy()');
  291. this.persistingData.changeToggleDisplayGradient(false);
  292. this.persistingData.changeToolbarElevated(true);
  293. if(this.schoolSubscriber)
  294. this.schoolSubscriber.unsubscribe()
  295.  
  296. }
  297.  
  298. updateUsersMeta(ipResponse){
  299. console.log('Running updateUsersMeta()');
  300.  
  301. //Update user's position property in firestore if current city different than stored city
  302. if(this.user.usersMeta){
  303. console.log('User has existing usersMeta obj');
  304.  
  305. if(this.user.usersMeta.city != ipResponse.city){
  306. console.log('Updating users usersMeta prop');
  307.  
  308. this.afs.collection('Users').doc(this.user.uid).ref.update({
  309. usersMeta: ipResponse
  310. }).then(() => {
  311. console.log('Finished updating user with usersMeta prop');
  312. });
  313. } else {
  314. console.log('Users city is the same as before. No need to update.');
  315.  
  316. }
  317.  
  318. } else {
  319. console.log('User does not yet have usersMeta obj');
  320.  
  321. this.afs.collection('Users').doc(this.user.uid).ref.update({
  322. usersMeta: ipResponse
  323. }).then(() => {
  324. console.log('Finished updating user with usersMeta prop');
  325. });
  326. }
  327.  
  328. }
  329.  
  330.  
  331.  
  332. // fetchSchools(){
  333. // console.log('Running fetchSchools');
  334.  
  335. // this.schoolsCollection = this.afs.collection('Schools', ref => {
  336. // console.log('In afs.collection');
  337. // // return ref.orderBy('name').limit(4);
  338. // return ref.orderBy('name');
  339. // });
  340.  
  341. // this.schools = this.schoolsCollection.valueChanges();
  342.  
  343. // console.log('schoolsCollection:');
  344. // console.log(this.schoolsCollection);
  345.  
  346. // console.log('Retreived schools:');
  347. // console.log(this.schools);
  348.  
  349. // }
  350.  
  351.  
  352. fetchPinnedClasses() {
  353. console.log('Loading Pinned classes now...');
  354.  
  355. //Get reference to current user's Users/user.uid/Pinned collection
  356. let pathPinned = 'Users/' + this.user.uid + '/Pinned';
  357.  
  358. this.pinnedClassesCollection = this.afs.collection(pathPinned, ref => {
  359. ref.get().then(coll => {
  360. this.pinnedSize = coll.size;
  361. this.pinsFetched = 'fetched';
  362. console.log(`pinnedSize: ${this.pinnedSize}`);
  363. });
  364.  
  365. return ref.orderBy('className');
  366. });
  367. this.pinnedClasses = this.pinnedClassesCollection.valueChanges();
  368. }
  369.  
  370. moderatingClassesSnap: any;
  371.  
  372. fetchModeratingClasses() {
  373. console.log('Loading Moderating classes now...');
  374.  
  375. //Get reference to current user's Users/user.uid/Pinned collection
  376. let pathModerating = 'Users/' + this.user.uid + '/Moderating';
  377.  
  378. this.moderatingClassesCollection = this.afs.collection(pathModerating, ref => {
  379. ref.get().then(coll => {
  380. this.moderatingSize = coll.size;
  381. this.modsFetched = 'fetched';
  382. console.log(`moderatingSize: ${this.moderatingSize}`);
  383. });
  384.  
  385. return ref.orderBy('class');
  386. });
  387. this.moderatingClasses = this.moderatingClassesCollection.valueChanges();
  388.  
  389. // this.moderatingClassesSnap = this.moderatingClassesCollection.snapshotChanges().pipe(map(changes => {
  390. // return changes.map(a => {
  391. // const data = a.payload.doc.data();
  392. // console.log('moderatingClassesSnap data:');
  393.  
  394. // console.log(data);
  395. // return data;
  396. // });
  397. // })).subscribe();
  398.  
  399. }
  400.  
  401. fetchAssignments(pinnedClass, i){
  402. console.log('Fetching assignment of pinnedClass instance:');
  403. console.log(pinnedClass);
  404.  
  405. let path = `Schools/${pinnedClass.school}/Teachers/${pinnedClass.teacher}/Classes/${pinnedClass.className}/Assignments`;
  406. console.log(path);
  407.  
  408. console.log('index: ' + i);
  409.  
  410. this.assignmentsCollection = this.afs.collection(path, ref => {
  411. return ref.orderBy('weekDue');
  412. });
  413. this.assignments = this.assignmentsCollection.valueChanges();
  414.  
  415. }
  416.  
  417. fetchCreatedSchools(){
  418. console.log('Loading Created classes now...');
  419.  
  420. //Get reference to current user's Users/user.uid/Pinned collection
  421. let pathCreated = 'Users/' + this.user.uid + '/Created Schools';
  422.  
  423. this.createdSchoolsCollection = this.afs.collection(pathCreated);
  424. this.createdSchools = this.createdSchoolsCollection.valueChanges();
  425. }
  426.  
  427. fetchLocation(){
  428. console.log('Running fetchLocation()');
  429.  
  430. //If user is signed in and their city/metadata is unknown, check their location
  431. if(this.locationFetched == false){
  432. console.log('LocationFetch has not yet been attempted for page');
  433. this.locationFetched = true;
  434.  
  435. //Run only if users city is unknown
  436. if(!this.user.usersMeta){
  437. console.log('Users usersMeta has no value. Fetching ip...');
  438.  
  439. this.common.getLocation().subscribe(locationData => {
  440. console.log('Returning getLocation() locationData');
  441. console.log(locationData);
  442. this.updateUsersMeta(locationData);
  443. })
  444. }
  445.  
  446. }
  447. }
  448.  
  449. searchButton(input){
  450.  
  451. if(input.length < 4){
  452. console.log('Input length is too short: ' + input.length);
  453. this.snackbar.open('Please enter more characters', 'Ok', {duration: 2000});
  454. return null;
  455. }
  456.  
  457. //Save away search
  458. this.searchedSchool = input;
  459. console.log('Searching for school: ' + this.searchedSchool);
  460.  
  461. //Persist school search
  462. this.persistingData.changeSchool(this.searchedSchool);
  463.  
  464. //Navigate to Browse Teachers page
  465. let navPath = this.searchedSchool;
  466. this.router.navigateByUrl(navPath);
  467. }
  468.  
  469. openDialogAddSchool() {
  470. console.log('Opening dialog Add School');
  471. this.dialog.open(DialogAddSchoolComponent, {width: '500px'});
  472. }
  473.  
  474. navigateToClass(school, teacher, className) {
  475. console.group('navigateToClass()')
  476. console.log('Navigating to class: ');
  477. console.log('School: ' + school);
  478. console.log('Teacher: ' + teacher);
  479. console.log('className: ' + className);
  480. console.groupEnd()
  481.  
  482. //Persist data
  483. this.persistingData.changeSchool(school);
  484. this.persistingData.changeTeacher(teacher);
  485. this.persistingData.changeClass(className);
  486.  
  487. let pathToNav = school + '/' + teacher;
  488. this.router.navigateByUrl(pathToNav);
  489.  
  490. //Move scroll back up to the top of the page (smoothly)
  491. window.scrollTo({
  492. top: 0,
  493. behavior: 'smooth'
  494. });
  495. }
  496.  
  497. unpinClass(schoolName, teacherName, className, classUID){
  498. console.log('Unpinning class...');
  499.  
  500. let classSnap = {
  501. name: className
  502. }
  503.  
  504. this.common.removeClassFromUsersPinnedCollSimple(this.user, schoolName, teacherName, classUID, className);
  505. this.common.removeUserFromClassPinners(this.user.uid, schoolName, teacherName, className);
  506. this.common.bumpTeachersPinnedCount(schoolName, teacherName, classSnap, -1);
  507.  
  508. }
  509.  
  510. asyncTest(){
  511.  
  512. var p1 = new Promise((resolve, reject) => {
  513. setTimeout(() => {
  514. console.log('In p1');
  515. resolve('p1 resolved');
  516. }, 600);
  517. });
  518.  
  519. var p2 = new Promise((resolve, reject) => {
  520. setTimeout(() => {
  521. console.log('In p2');
  522. resolve('p2 resolved');
  523. }, 200);
  524. });
  525.  
  526. var p3 = new Promise((resolve, reject) => {
  527. setTimeout(() => {
  528. console.log('In p3');
  529. resolve('p3 resolved');
  530. }, 300);
  531. });
  532.  
  533. Promise.all([p1, p2, p3]).then(() => {
  534. console.log('Running PromiseAll then');
  535. })
  536.  
  537.  
  538. }
  539.  
  540. updateCounts(request, response, counts) {
  541.  
  542. let schoolsSize;
  543. let usersSize;
  544.  
  545. console.log('Running updateCounts');
  546.  
  547.  
  548. //Get count of schools
  549. var p1 = new Promise((resolve, reject) => {
  550.  
  551. console.log('in p1');
  552.  
  553. this.afs.collection('Schools').ref.get().then(snap => {
  554. console.log('in p1 then');
  555. schoolsSize = snap.size;
  556. console.log('schoolsSize: ' + schoolsSize);
  557. resolve(schoolsSize);
  558. // return counts.schoolsCount = schoolsSize;
  559. }).catch(error => {
  560. console.log(error);
  561. response.status(500).send(error);
  562. });
  563.  
  564. });
  565.  
  566. //Get count of users
  567. var p2 = new Promise((resolve, reject) => {
  568.  
  569. console.log('in p2');
  570.  
  571. this.afs.collection('Users').ref.get().then(snap => {
  572. console.log('in p2 then');
  573. usersSize = snap.size;
  574. console.log('usersSize: ' + usersSize);
  575. resolve(usersSize);
  576. // counts.usersCount = usersSize;
  577. }).catch(error => {
  578. console.log(error);
  579. response.status(500).send(error);
  580. });
  581.  
  582. });
  583.  
  584. Promise.all([p1, p2]).then(values => {
  585. console.log('in Promise.all then');
  586. console.log('Promise.all values: ' + values);
  587. // console.log('Promise.all count: ' + counts);
  588. console.log('schoolsSize: ' + schoolsSize);
  589. console.log('usersSize: ' + usersSize);
  590. // response.send(values);
  591. });
  592.  
  593. }
  594.  
  595. showNewUserDialog(){
  596. console.log('Running showNewUserDialog');
  597. this.dialog.open(DialogNewUserComponent, { width: '400px' });
  598. }
  599.  
  600. splashPicClicked(){
  601. console.log('Running splashPicClicked()');
  602. document.getElementById('searchInput').blur();
  603. }
  604.  
  605. setCurrentPinnedVariables(classVar){
  606. console.log('classVar.school:');
  607. console.log(classVar.school);
  608.  
  609. this.currentlySelectedPinnedClassUID = classVar.classUID;
  610. this.currentlySelectedPinnedClass = classVar.className;
  611. this.currentlySelectedPinnedTeacher = classVar.teacher;
  612. this.currentlySelectedPinnedSchool = classVar.school;
  613.  
  614. // this.currentlySelectedPinnedClass = classVar;
  615. }
  616.  
  617. fetchCusID(usr){
  618. console.log('Running fetchCusID() for usr: ');
  619. console.log(usr);
  620.  
  621. this.afs.collection('Customers').ref.where('userUID', '==', usr.uid).get().then(customers => {
  622. console.log('Customers: ');
  623. if(!customers.empty){
  624. customers.forEach(customer => {
  625. console.log(`${customer.data().displayName}'s customerID: ${customer.data().customerID}`);
  626. this.addCustomerIDToUser(customer.data().userUID, customer.data().customerID);
  627. });
  628. } else {
  629. console.log('No Customer UID found for user');
  630. }
  631. });
  632. }
  633.  
  634. addCustomerIDToUser(userUID, customerID){
  635. console.log('Running addCustomerIDToUser()');
  636.  
  637. this.afs.doc(`Users/${userUID}`).ref.update({
  638. customerID: customerID
  639. });
  640.  
  641. }
  642.  
  643. openAdminPanel(){
  644. console.log('Running openAdminPanel()');
  645. this.dialog.open(DialogAdminPanelComponent);
  646. }
  647.  
  648. toggleDisplayGradient(val){
  649. this.persistingData.changeToggleDisplayGradient(val);
  650. }
  651.  
  652. toggleElevateToolbar(val){
  653. this.persistingData.changeToolbarElevated(val);
  654. }
  655.  
  656. editSchool(school){
  657. console.log('Opening editSchoolDialog with school obj:');
  658. console.log(school);
  659.  
  660. console.log('school.schoolName');
  661. console.log(school.schoolName);
  662.  
  663. //Persist school search (since Edit School dialog works off of currently persisted school)
  664. this.persistingData.changeSchool(school.schoolName);
  665.  
  666. this.dialog.open(DialogEditSchoolComponent);
  667. }
  668.  
  669. addSchoolDisabledClick(){
  670. console.log('Running addSchoolDisabledClick()');
  671. this.snackbar.open('You must be signed in to add a school', 'Ok', {duration: 2000});
  672. }
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679. sendAlertTest(){
  680. console.log('Running sendAlertTest');
  681. this.persistingData.changeMassDelete(true);
  682. this.common.alertUser(this.user.uid, "Test alert 10 - SettingMD");
  683. }
  684.  
  685. sendAlertTestWithoutSettingMassDelete(){
  686. console.log('Running sendAlertTestWithout');
  687. this.common.alertUser(this.user.uid, "Test alert 10 - NoMD");
  688. }
  689.  
  690. doAsync(){
  691. console.log('Starting doAsync');
  692.  
  693. this.delay(2000).then(() => {
  694. console.log('Done doing async. Aaaah...');
  695. })
  696. }
  697.  
  698. delay(time){
  699. console.log('Reached delay function');
  700.  
  701. return new Promise((resolve, reject) => {
  702. setTimeout(resolve, time);
  703. })
  704. }
  705.  
  706. testButton(){
  707. console.log('running testButton()');
  708.  
  709. this.dialog.open(DialogTutorialComponent, { width: '600px'});
  710.  
  711. // this.afs.doc(`Users/${this.user.uid}`).ref.update({
  712. // "misc.item3": firebase.firestore.FieldValue.increment(1)
  713. // });
  714.  
  715. }
  716.  
  717. onLoadFunc(){
  718. console.log('Thing loaded!');
  719. }
  720.  
  721. navigateToAboutPage(){
  722. console.log('Running navigateToAboutPage()');
  723.  
  724. this.persistingData.changeViewWithContainer(false);
  725.  
  726. this.router.navigateByUrl('about');
  727.  
  728. //Move scroll back up to the top of the page (smoothly)
  729. window.scrollTo({
  730. top: 0,
  731. behavior: 'smooth'
  732. });
  733.  
  734. }
  735.  
  736. openPinnedClassAssignment(selectedClass, assignment){
  737. console.log('Running openPinnedClassAssignment()');
  738. console.log(assignment);
  739. console.log(selectedClass);
  740.  
  741. this.persistingData.changeSchool(selectedClass.school);
  742. this.persistingData.changeTeacher(selectedClass.teacher);
  743. this.persistingData.changeClass(selectedClass.className);
  744.  
  745. //Set persisting data
  746. this.persistingData.changeLoadedSubmissionsType('assignments');
  747. this.persistingData.changeAssignmentObj(assignment); //Phase out old way for this new way
  748.  
  749. //Old way, but active
  750. this.persistingData.changeAssignmentUID(assignment.uid);
  751. this.persistingData.changeAssignmentName(assignment.title);
  752. // this.persistingData.changeAssignmentDueDate(assignment.dueDate);
  753. this.persistingData.changeAssignmentWeekDue(assignment.weekDue);
  754. this.persistingData.changeAssignmentType(assignment.type)
  755.  
  756. // this.dialog.open(DialogOpenSubmissionsComponent, { minWidth: '900px'});
  757. this.dialog.open(DialogOpenSubmissionsComponent, { minWidth: '800px', width: '50%'});
  758.  
  759. }
  760.  
  761.  
  762.  
  763.  
  764.  
  765. }
  766.  
  767. const data = [
  768. {'city': 'Sacramento', 'name': 'Sacramento State' },
  769. {'city': 'Rocklin', 'name': 'Sierra College' },
  770. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement