<commit_before>import { Component, OnInit } from '@angular/core';
import { MD_CARD_DIRECTIVES } from '@angular2-material/card';
import { MD_LIST_DIRECTIVES } from '@angular2-material/list';
import { MD_PROGRESS_CIRCLE_DIRECTIVES } from '@angular2-material/progress-circle';
import { MD_SLIDE_TOGGLE_DIRECTIVES } from '@angular2-material/slide-toggle';
import { MD_ICON_DIRECTIVES } from '@angular2-material/icon';
import { Member } from '../member';
import { DecimalPipe } from '@angular/common';
import { ROUTER_DIRECTIVES } from '@angular/router';
import { Group } from '../group';
import { GroupService } from '../group.service';
import { RouteSegment } from '@angular/router';
import { MemberService } from '../member.service';
import { MD_BUTTON_DIRECTIVES } from '@angular2-material/button';
import { LocationService } from '../location.service';
import { UserInfoService } from '../user-info.service';
import { UserInfo } from '../user-info';
import { NotificationService } from '../notification.service';

@Component({
    moduleId: module.id,
    selector: 'app-group-details',
    templateUrl: 'group-details.component.html',
    styleUrls: ['group-details.component.css'],
    directives: [
        MD_CARD_DIRECTIVES,
        MD_LIST_DIRECTIVES,
        MD_PROGRESS_CIRCLE_DIRECTIVES,
        MD_SLIDE_TOGGLE_DIRECTIVES,
        MD_ICON_DIRECTIVES,
        ROUTER_DIRECTIVES,
        MD_BUTTON_DIRECTIVES
    ],
    providers: [MemberService]
})
export class GroupDetailsComponent implements OnInit {
    group: Group;
    members: Member[];
    enabledMembers = {};
    map: google.maps.Map;
    bounds = new google.maps.LatLngBounds();
    decimalFormat = '1.4-4';
    isLoading = true;
    isSendingLocation = true;
    constructor(private groupService: GroupService,
        private routeSegment: RouteSegment,
        private memberService: MemberService,
        private locationService: LocationService,
        private userInfoService: UserInfoService,
        private notificationService: NotificationService) { }
    ngOnInit() {
        let groupId = this.routeSegment.getParam('groupId');

        this.groupService.read(groupId).then(group => this.group = group);

        this.memberService.list(groupId).then(members => {
            this.members = members;

            /* all members should be enabled initially */
            this.members.forEach(member => {
                this.enabledMembers[member.id] = true;
            });

            this.drawMap();
            this.isLoading = false;

            /* add self if not a member */
            this.userInfoService.read().then(userInfo => {
                let isMember = false;
                for (let i = 0, len = this.members.length; i < len; i++) {
                    if (userInfo.id === this.members[i].userId) {
                        isMember = true;
                        break;
                    }
                }
                if (!isMember) {
                    this.sendLocation();
                } else {
                    this.isSendingLocation = false;
                }
            });

        });
    }
    drawMap() {
        let center = { lat: 0, lng: 0 }, count = 0, london = { lat: 51.5074, lng: 0.1278, zoom: 7 }, formatDecimal = (decimal) => new DecimalPipe().transform(decimal, this.decimalFormat);
        this.map = new google.maps.Map(document.getElementById('map'), {
            mapTypeControlOptions: {
                mapTypeIds: []
            },
            streetViewControl: false
        });
        this.members.filter(member => this.enabledMembers[member.id]).forEach(member => {

            /* draw the Marker and include it in the bounds */
            this.bounds.extend(new google.maps.Marker({
                position: new google.maps.LatLng(member.lat, member.lng),
                map: this.map,
                label: member.name
            }).getPosition());

            center.lat += member.lat;
            center.lng += member.lng;
            count++;
        });

        /* add the center marker */
        if (count > 0) {
            center.lat = center.lat / count;
            center.lng = center.lng / count;

            /* add the info window */
            new google.maps.InfoWindow({
                content: `<h3>Geographic Center</h3><p>(${formatDecimal(center.lat)}, ${formatDecimal(center.lng)})</p>`
            }).open(this.map,
                new google.maps.Marker({
                    position: new google.maps.LatLng(center.lat, center.lng),
                    map: this.map,
                    animation: google.maps.Animation.DROP<commit_msg>move center marker to front<commit_after>import { Component, OnInit } from '@angular/core';
import { MD_CARD_DIRECTIVES } from '@angular2-material/card';
import { MD_LIST_DIRECTIVES } from '@angular2-material/list';
import { MD_PROGRESS_CIRCLE_DIRECTIVES } from '@angular2-material/progress-circle';
import { MD_SLIDE_TOGGLE_DIRECTIVES } from '@angular2-material/slide-toggle';
import { MD_ICON_DIRECTIVES } from '@angular2-material/icon';
import { Member } from '../member';
import { DecimalPipe } from '@angular/common';
import { ROUTER_DIRECTIVES } from '@angular/router';
import { Group } from '../group';
import { GroupService } from '../group.service';
import { RouteSegment } from '@angular/router';
import { MemberService } from '../member.service';
import { MD_BUTTON_DIRECTIVES } from '@angular2-material/button';
import { LocationService } from '../location.service';
import { UserInfoService } from '../user-info.service';
import { UserInfo } from '../user-info';
import { NotificationService } from '../notification.service';

@Component({
    moduleId: module.id,
    selector: 'app-group-details',
    templateUrl: 'group-details.component.html',
    styleUrls: ['group-details.component.css'],
    directives: [
        MD_CARD_DIRECTIVES,
        MD_LIST_DIRECTIVES,
        MD_PROGRESS_CIRCLE_DIRECTIVES,
        MD_SLIDE_TOGGLE_DIRECTIVES,
        MD_ICON_DIRECTIVES,
        ROUTER_DIRECTIVES,
        MD_BUTTON_DIRECTIVES
    ],
    providers: [MemberService]
})
export class GroupDetailsComponent implements OnInit {
    group: Group;
    members: Member[];
    enabledMembers = {};
    map: google.maps.Map;
    bounds = new google.maps.LatLngBounds();
    decimalFormat = '1.4-4';
    isLoading = true;
    isSendingLocation = true;
    constructor(private groupService: GroupService,
        private routeSegment: RouteSegment,
        private memberService: MemberService,
        private locationService: LocationService,
        private userInfoService: UserInfoService,
        private notificationService: NotificationService) { }
    ngOnInit() {
        let groupId = this.routeSegment.getParam('groupId');

        this.groupService.read(groupId).then(group => this.group = group);

        this.memberService.list(groupId).then(members => {
            this.members = members;

            /* all members should be enabled initially */
            this.members.forEach(member => {
                this.enabledMembers[member.id] = true;
            });

            this.drawMap();
            this.isLoading = false;

            /* add self if not a member */
            this.userInfoService.read().then(userInfo => {
                let isMember = false;
                for (let i = 0, len = this.members.length; i < len; i++) {
                    if (userInfo.id === this.members[i].userId) {
                        isMember = true;
                        break;
                    }
                }
                if (!isMember) {
                    this.sendLocation();
                } else {
                    this.isSendingLocation = false;
                }
            });

        });
    }
    drawMap() {
        let center = { lat: 0, lng: 0 }, count = 0, london = { lat: 51.5074, lng: 0.1278, zoom: 7 }, formatDecimal = (decimal) => new DecimalPipe().transform(decimal, this.decimalFormat);
        this.map = new google.maps.Map(document.getElementById('map'), {
            mapTypeControlOptions: {
                mapTypeIds: []
            },
            streetViewControl: false
        });
        this.members.filter(member => this.enabledMembers[member.id]).forEach(member => {

            /* draw the Marker and include it in the bounds */
            this.bounds.extend(new google.maps.Marker({
                position: new google.maps.LatLng(member.lat, member.lng),
                map: this.map,
                label: member.name
            }).getPosition());

            center.lat += member.lat;
            center.lng += member.lng;
            count++;
        });

        /* add the center marker */
        if (count > 0) {
            center.lat = center.lat / count;
            center.lng = center.lng / count;

            /* add the info window */
            new google.maps.InfoWindow({
                content: `<h3>Geographic Center</h3><p>(${formatDecimal(center.lat)}, ${formatDecimal(center.lng)})</p>`
            }).open(this.map,
                new google.maps.Marker({
                    position: new google.maps.LatLng(center.lat, center.lng),
                    map: this.map,
                    animation: google.maps.Animation.DROP,
                    zIndex: 1
{'fraction_non_alphanumeric': 0.12275610018273675, 'fraction_numerical': 0.006127055788455337, 'mean_word_length': 2.104437771104438, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 27, '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': '2008122', 'n_tokens_mistral': 2624, 'n_tokens_neox': 2529, 'n_words': 551}