onSigninChange()

in src/app/main/main.component.ts [250:299]


  onSigninChange() {
    this._ngZone.run(() => {
      this.isSignedIn = this.dataService.isSignedIn;
      if (!this.dataService.isSignedIn) {
        return;
      }
      this.user = this.dataService.getUser();

      this.storageService.authorize(this.dataService.getCredential());
      this.dataService.getProjects()
        .then((projects) => {
          this.matchingProjects = projects;
          this._changeDetectorRef.detectChanges();
        });

      if (this._hasJobParams() && this._jobParamsValid()) {
        this.dataFormGroup.patchValue({
          sql: '/* Loading sql query from job... */',
          projectID: this.projectID,
          location: this.location
        });

        this.dataService.getQueryFromJob(this.jobID, this.location, this.projectID).then((queryText) => {
          this.dataFormGroup.patchValue({
            sql: queryText.sql,
          });
        });
      } else if (this._hasTableParams() && this._tableParamsValid()) {
        this.dataFormGroup.patchValue({
          sql: `SELECT *
                FROM \`${this.projectID}.${this.dataset}.${this.table}\`;`,
          projectID: this.projectID,
        });
      } else if (this.sharingId) {
        this.analyticsService.report('saved_state', 'load', 'from URL');
        this.restoreDataFromSharedStorage(this.sharingId).then((shareableValues) => {
          this.applyRetrievedSharingValues(shareableValues);
        }).catch((e) => this.showMessage(parseErrorMessage(e)));
      } else {
        const localStorageValues = this.loadDataFromLocalStorage();
        if (localStorageValues) {
          this.dataFormGroup.patchValue({
            sql: localStorageValues.sql,
            projectID: localStorageValues.projectID,
            location: localStorageValues.location
          });
        }
      }
    });
  }