<commit_before>import { Component } from '@angular/core';
import { VolunteerEvent } from '../../lib/model/volunteer-event';
import { VolunteerEventsService } from '../../lib/service/volunteer-events-service';
import { EventImage } from '../../lib/model/eventImage';
import { UserServices } from '../../lib/service/user';
import { EventDetailModal } from './eventdetail-modal';
import { ModalController, ViewController } from 'ionic-angular';
import { PopoverController, ToastController, LoadingController } from 'ionic-angular';
import {OpportunityPipe} from '../../lib/pipe/eventsortpipe';
import {ParseTimePipe} from '../../lib/pipe/moment.pipe';
import { AlertController } from 'ionic-angular';
import { EventDetail } from '../../lib/model/event-detail';
import { SignupAssistant } from '../../lib/service/signupassistant';
import Moment from "moment";
import {Nav} from 'ionic-angular';
import { RegisterIndividualProfilePage } from '../register-individual-profile/register-individual-profile';


@Component({
  templateUrl: 'events.html',
  selector: 'events',
  providers:[ParseTimePipe, OpportunityPipe]
})

export class EventPage {

  public loadingOverlay;
  eventDetail: EventDetail;
  public search: boolean = false;
  public events: Array<VolunteerEvent> = [];
  public searchedEvents: Array<VolunteerEvent> = [];
  public maxEvents: Array<VolunteerEvent> = [];
  public minEvents: Array<VolunteerEvent> = [];
  public stubEvents: Array<VolunteerEvent> = [];
  public monthNames: Array<String> = ["January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December"];

 // public preferenceModel: Array<MyPreferences> = [];
 // public currentPreferences: Array<MyPreferences> = [];
 // public selectedSort: string = '';
  public image: Array<EventImage>;
  public val: string = "";
  public values: Array<String>;
  public searching: Boolean = false;
  public noResults: Boolean = false;
  public eventDetails: VolunteerEvent;
  public showDetails: Array<Boolean> = [];

  public moreInterval = 30;
  public moreIntervalIncrease = 30;

  public eventCategories:Array<String> = [];
  public getPreferencesError = false;
  // datepicker
  public selectedStartDate;
  public selectedEndDate;
  public dateRangeError = false;
  public dateRangeErrorValue = "Start date can't be after end date";
  public minStartDate;
  public maxStartDate;

  constructor(public volunteerEventsService: VolunteerEventsService,
    public userServices: UserServices,
    public modalCtrl: ModalController,
    private popoverCtrl: PopoverController,
    public viewCtrl: ViewController,
    public loadingController: LoadingController,
    private parseTimePipe: ParseTimePipe,
    public alertCtrl: AlertController,    
    public toastController: ToastController,
    public signupassitant: SignupAssistant,
    public nav: Nav
    ) {
  }

  ngOnInit() {
    // select today and 30 days worth of events by default
    this.selectedStartDate = Moment().format("YYYY-MM-DD");
    this.selectedEndDate = Moment().add(30, 'day').format("YYYY-MM-DD");
    this.minStartDate = Moment().subtract(1, 'day').format("YYYY-MM-DD");
    this.maxStartDate = Moment().add(1, 'year').format("YYYY-MM-DD");
    this.loadEvents();
    this.volunteerEventsService.getEventCategories().subscribe(
      data => this.eventCategories=data,
      error => this.getPreferencesError=true
    );
  }

  onStartDateChange(evt) {
    let date = Moment(evt);
    if (date.isAfter(Moment(this.selectedEndDate))) {
      this.dateRangeError = true;
      return;
    } else {
      this.dateRangeError = false;
      this.loadEvents();
    }
  }

  onEndDateChange(evt) {
    let date = Moment(evt);
    if (date.isBefore(Moment(this.selectedStartDate))) {
      this.dateRangeError = true;
      return;
    } else {
      this.dateRangeError = false;
      this.loadEvents();
    }
  }

  showLoading() {
    this.loadingOverlay = this.loadingController.create({
      content: 'Please wait...'
    });
    this.loadingOverlay.present();
  }

  hideLoading() {
    this.loadingOverlay.dismiss();
  }

  presentToast(message: string) {
    let toast = this.toastController.create({
      message: message,
      duration: 2000,
      position: 'middle'
    });
    toast.present();
  }

  loadEvents() {
    let now = new Date(Moment(this.selectedStartDate).hour(0).minute(0).toISOString());
    let until = new Date(Moment(this.selectedEndDate).hour(23).minute(59).toISOString());
    this.showLoading();
    this.getEventsTimeRange(now.toISOString(), until.toISOString());<commit_msg>[def301] use default date picker     only lookup events if date changed<commit_after>import { Component } from '@angular/core';
import { VolunteerEvent } from '../../lib/model/volunteer-event';
import { VolunteerEventsService } from '../../lib/service/volunteer-events-service';
import { EventImage } from '../../lib/model/eventImage';
import { UserServices } from '../../lib/service/user';
import { EventDetailModal } from './eventdetail-modal';
import { ModalController, ViewController } from 'ionic-angular';
import { PopoverController, ToastController, LoadingController } from 'ionic-angular';
import {OpportunityPipe} from '../../lib/pipe/eventsortpipe';
import {ParseTimePipe} from '../../lib/pipe/moment.pipe';
import { AlertController } from 'ionic-angular';
import { EventDetail } from '../../lib/model/event-detail';
import { SignupAssistant } from '../../lib/service/signupassistant';
import Moment from "moment";
import {Nav} from 'ionic-angular';
import { RegisterIndividualProfilePage } from '../register-individual-profile/register-individual-profile';


@Component({
  templateUrl: 'events.html',
  selector: 'events',
  providers:[ParseTimePipe, OpportunityPipe]
})

export class EventPage {

  public loadingOverlay;
  eventDetail: EventDetail;
  public search: boolean = false;
  public events: Array<VolunteerEvent> = [];
  public searchedEvents: Array<VolunteerEvent> = [];
  public maxEvents: Array<VolunteerEvent> = [];
  public minEvents: Array<VolunteerEvent> = [];
  public stubEvents: Array<VolunteerEvent> = [];
  public monthNames: Array<String> = ["January", "February", "March", "April", "May", "June",
  "July", "August", "September", "October", "November", "December"];

 // public preferenceModel: Array<MyPreferences> = [];
 // public currentPreferences: Array<MyPreferences> = [];
 // public selectedSort: string = '';
  public image: Array<EventImage>;
  public val: string = "";
  public values: Array<String>;
  public searching: Boolean = false;
  public noResults: Boolean = false;
  public eventDetails: VolunteerEvent;
  public showDetails: Array<Boolean> = [];

  public moreInterval = 30;
  public moreIntervalIncrease = 30;

  public eventCategories:Array<String> = [];
  public getPreferencesError = false;
  // datepicker
  public selectedStartDate;
  public selectedEndDate;
  public currentStartDate; // hold selected start date for comparison on change in onStartDateChange
  public currentEndDate; // hold selected end date for comparison on change in onEndDateChange
  public dateRangeError = false;
  public dateRangeErrorValue = "Start date can't be after end date";
  public minStartDate;
  public maxStartDate;

  constructor(public volunteerEventsService: VolunteerEventsService,
    public userServices: UserServices,
    public modalCtrl: ModalController,
    private popoverCtrl: PopoverController,
    public viewCtrl: ViewController,
    public loadingController: LoadingController,
    private parseTimePipe: ParseTimePipe,
    public alertCtrl: AlertController,    
    public toastController: ToastController,
    public signupassitant: SignupAssistant,
    public nav: Nav
    ) {
  }

  ngOnInit() {
    // select today and 30 days worth of events by default
    this.selectedStartDate = Moment().format("YYYY-MM-DD");
    this.selectedEndDate = Moment().add(30, 'day').format("YYYY-MM-DD");
    this.minStartDate = Moment().format("YYYY-MM-DD");
    this.maxStartDate = Moment().add(1, 'year').format("YYYY-MM-DD");
    this.currentStartDate = this.selectedStartDate.slice();
    this.currentEndDate = this.selectedEndDate.slice();
    this.loadEvents();
    this.volunteerEventsService.getEventCategories().subscribe(
      data => this.eventCategories=data,
      error => this.getPreferencesError=true
    );
  }

  onStartDateChange(evt) {
    let date = Moment(evt);
    if (evt === this.currentStartDate) {
      return;
    }else {
      this.currentStartDate = evt;
      if (date.isAfter(Moment(this.selectedEndDate))) {
        this.dateRangeError = true;
        return;
      } else {
        this.dateRangeError = false;
        this.loadEvents();
      }
    }
  }

  onEndDateChange(evt) {
    let date = Moment(evt);
    if (evt === this.currentEndDate) {
      return;
    } else {
      if (date.isBefore(Moment(this.selectedStartDate))) {
        this.dateRangeError = true;
        return;
      } else {
        this.dateRangeError = false;
        this.loadEvents();
      }
    }
  }

  showLoading() {
    this.loadingOverlay = this.loadingController.create({
      content: 'Please wait...'
    });
    this.loadingOverlay.present();
  }

  hideLoading() {
    this.loadingOverlay.dismiss();
  }

  presentToast(message: string) {
    let toast = this.toastController.create({
      message: message,
      duration: 2000,
      position: 'middle'
    });
    toast.present();
  }

  loadEvents() {
    let now = new Date(Moment(this.selectedStartDate).hour(0).minute(0).toISOString());
    let until = new Date(Moment(this.selectedEndDate).hour(23).minute(59).toISOString());
    this.showLoading();
    this.getEventsTimeRange(now.toISOString(), until.toISOString());
{'fraction_non_alphanumeric': 0.13481420820964274, 'fraction_numerical': 0.0042993141570273315, 'mean_word_length': 3.9343434343434343, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1849809', 'n_tokens_mistral': 2914, 'n_tokens_neox': 2799, 'n_words': 646}