<commit_before>import { Component, OnInit } from '@angular/core';
import { CORE_DIRECTIVES } from '@angular/common';
import { Appointment, Room } from '../api';
import { AppointmentApi, RoomApi } from '../api';
import { Schedule } from 'primeng/primeng';

@Component({
  selector: 'appointments',
  providers: [AppointmentApi, RoomApi],
  template:
  `
<md-tab-group>
  <md-tab>
    <template md-tab-label>All</template>
    <template md-tab-content>
      <md-card>
        <p-schedule [header]="header" [locale]="locale" [events]="appointments"></p-schedule>
      </md-card>
    </template>
  </md-tab>
  <md-tab>
    <template md-tab-label>By Room</template>
    <template md-tab-content>
    <div class="appointment-by-room-container">
      <md-card *ngFor="let room of rooms" class="appointment-by-room-card">
        <md-card-title>
          {{room.name}}
        </md-card-title>
        <md-card-content>
          <p-schedule
          header="false"
          defaultView="agendaDay"
          [locale]="locale"
          [events]="appointments"
          [height]="800">
          </p-schedule>
        </md-card-content>
      </md-card>
    </div>
    </template>
  </md-tab>
</md-tab-group>
<ul>
  <li *ngFor="let appointment of appointments">
    {{ appointment.title }}
  </li>
</ul>
  `,
  directives: [CORE_DIRECTIVES, Schedule],
  styles: [ require('./appointments.style.scss') ]
})

export class Appointments implements OnInit {

  private appointments: Appointment[];
  private rooms: Room[];
  private header: any;
  private locale: any;

  constructor(private appointmentApi: AppointmentApi, private roomApi: RoomApi) { }

  ngOnInit() {
    this.getAllAppointments();
    this.getAllRooms();
    this.header = {
      left: 'prev,next today',
      center: 'title',
      right: 'month,agendaWeek,agendaDay'
    };
    this.locale = {
      lang: 'de'
    };
  }

  private getAllAppointments(): void {
    this.appointmentApi
    .appointmentFind()
    .subscribe(
      x => this.appointments = x,
      e => console.log(e),
      () => console.log('Get all appointments complete')
    );
  }

  private getAllRooms(): void {
    this.roomApi
    .roomFind()
    .subscribe(
      x => this.rooms = x,
      e => console.log(e),
      () => console.log('Get all rooms complete')
    );
  }
}<commit_msg>Changed appointments by room view to only display appointments in their respective room view.<commit_after>import { Component, OnInit } from '@angular/core';
import { CORE_DIRECTIVES } from '@angular/common';
import { Appointment, Room } from '../api';
import { AppointmentApi, RoomApi } from '../api';
import { Schedule } from 'primeng/primeng';

@Component({
  selector: 'appointments',
  providers: [AppointmentApi, RoomApi],
  template:
  `
<md-tab-group>
  <md-tab>
    <template md-tab-label>All</template>
    <template md-tab-content>
      <md-card>
        <p-schedule [header]="header" [locale]="locale" [events]="appointments"></p-schedule>
      </md-card>
    </template>
  </md-tab>
  <md-tab>
    <template md-tab-label>By Room</template>
    <template md-tab-content>
    <div class="appointment-by-room-container">
      <md-card *ngFor="let room of rooms" class="appointment-by-room-card">
        <md-card-title>
          {{room.name}}
        </md-card-title>
        <md-card-content>
          <p-schedule
          header="false"
          defaultView="agendaDay"
          [locale]="locale"
          [events]="appointmentsByRoom[room.id]"
          [height]="800">
          </p-schedule>
        </md-card-content>
      </md-card>
    </div>
    </template>
  </md-tab>
</md-tab-group>
<ul>
  <li *ngFor="let appointment of appointments">
    {{ appointment.title }}
  </li>
</ul>
  `,
  directives: [CORE_DIRECTIVES, Schedule],
  styles: [ require('./appointments.style.scss') ]
})

export class Appointments implements OnInit {

  private appointments: Appointment[];
  private appointmentsByRoom: Appointment[][] = [[]];
  private rooms: Room[];
  private header: any;
  private locale: any;

  constructor(private appointmentApi: AppointmentApi, private roomApi: RoomApi) { }

  ngOnInit() {
    this.getAllAppointments();
    this.getAllRooms();
    this.header = {
      left: 'prev,next today',
      center: 'title',
      right: 'month,agendaWeek,agendaDay'
    };
    this.locale = {
      lang: 'de'
    };
  }

  private getAllAppointments(): void {
    this.appointmentApi
    .appointmentFind()
    .subscribe(
      x => this.appointments = x,
      e => console.log(e),
      () => console.log('Get all appointments complete')
    );
  }

  private getAppointmentsByRoom(room: Room): void {
    this.appointmentApi
    .appointmentFind(`{"where": {"roomId": "${room.id}"}}`)
    .subscribe(
      x => this.appointmentsByRoom[room.id] = x,
      e => console.log(e),
      () => console.log(`Get all appointments for room ${room.name} complete`)
    );
  }

  private getAllRooms(): void {
    this.roomApi
    .roomFind()
    .subscribe(
      x =>  {
        this.rooms = x;
        for (let room of x) {
          this.getAppointmentsByRoom(room);
        }
      },
      e => console.log(e),
      () => console.log('Get all rooms complete')
    );
  }
}
{'fraction_non_alphanumeric': 0.16138273491214666, 'fraction_numerical': 0.001145912910618793, 'mean_word_length': 2.677668539325843, 'pattern_counts': {'":': 2, '<': 67, '<?xml version=': 0, '>': 82, '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': '6531733', 'n_tokens_mistral': 1726, 'n_tokens_neox': 1702, 'n_words': 355}