<commit_before>import {Component, OnInit} from "@angular/core";
import {FormBuilder, FormGroup, Validators} from "@angular/forms";

import {AuthService} from "../services/auth.service";
import {Profile} from "../classes/profile";
import {ProfileService} from "../services/profile.services";
import {Report} from "../classes/report";
import {ReportService} from "../services/report.service";
import {Category} from "../classes/category";
import {CategoryService} from "../services/category.service";
import {Comment} from "../classes/comment";
import {CommentService} from "../services/comment.service";
import {Image} from "../classes/image";
import {ImageService} from "../services/image.service";
import {Status} from "../classes/status";


@Component({
	selector: "report-admin-view",
	templateUrl: "./templates/report-admin-view.html",
})

export class ReportAdminViewComponent implements OnInit {

	reportAdminViewForm: FormGroup;

	deleted: boolean = false;

	category: Category = new Category(null, null);

	report: Report = new Report(null, null, null, null, null, null, null);

	image: Image = new Image(null, null, null, null, null);

	comment: Comment = new Comment(null, null, null, null, null);

	profile: Profile = new Profile(null, null, null, null, null, null);

	//declare needed state variables for later use
	status: Status = null;

	constructor(private authService: AuthService, private formBuilder: FormBuilder, private profileService: ProfileService, private reportService: ReportService, private categoryService: CategoryService, private commentService: CommentService, private imageService: ImageService) {
	}

	ngOnInit() : void {

		this.getReport();

		this.reportAdminViewForm = this.formBuilder.group({
			reportStatus: ["", [Validators.required]],
			reportUrgency: ["", [Validators.required]],
			commentContent: ["", [Validators.maxLength(500), Validators.required]]
		});

		this.applyFormChanges();
	}

	applyFormChanges() : void {
		this.reportAdminViewForm.valueChanges.subscribe(values => {
			for(let field in values) {
				this.comment[field] = values[field];
			}
		});
	}

	getReport(): void {
		this.reportService.getReport(this.report.reportId)
			.subscribe(report => this.report = report);
	}

	deleteReport(): void {
		this.reportService.deleteReport(this.report.reportId)
			.subscribe(status => {
				this.status = status;
				if(this.status.status === 200) {
					this.deleted = true;
					this.report = new Report(null, null, null, null, null, null, null);
				}
			})
	}

	createComment(): void {
	let comment = new Comment(null, null, null, this.reportAdminViewForm.value.commentContent, null)

		this.commentService.createComment(comment)
			.subscribe(status =>{
				this.status = status;
				if(this.status.status === 200) {
					this.reportAdminViewForm.reset();
					alert(this.status.message);
				}
			})
	}

	deleteComment() : void {
		this.commentService.deleteComment(this.comment.commentId)
			.subscribe(status => {
				this.status = status;
				if(this.status.status === 200) {
					this.deleted = true;
					this.comment = new Comment(null, null, null, null, null);
				}
			})
	}

	editComment() : void {
		this.commentService.editComment(this.comment)
			.subscribe(status => this.status = status);
	}





}<commit_msg>still working on 'report-admin-view.component.ts'<commit_after>import {Component, OnInit} from "@angular/core";
import {FormBuilder, FormGroup, Validators} from "@angular/forms";

import {AuthService} from "../services/auth.service";
import {Profile} from "../classes/profile";
import {ProfileService} from "../services/profile.services";
import {Report} from "../classes/report";
import {ReportService} from "../services/report.service";
import {Category} from "../classes/category";
import {CategoryService} from "../services/category.service";
import {Comment} from "../classes/comment";
import {CommentService} from "../services/comment.service";
import {Image} from "../classes/image";
import {ImageService} from "../services/image.service";
import {Status} from "../classes/status";


@Component({
	selector: "report-admin-view",
	templateUrl: "./templates/report-admin-view.html",
})

export class ReportAdminViewComponent implements OnInit {

	reportAdminViewForm: FormGroup;

	deleted: boolean = false;

	category: Category = new Category(null, null);

	report: Report = new Report(null, null, null, null, null, null, null);

	image: Image = new Image(null, null, null, null, null);

	comment: Comment = new Comment(null, null, null, null, null);

	profile: Profile = new Profile(null, null, null, null, null, null);

	//declare needed state variables for later use
	status: Status = null;

	constructor(private authService: AuthService, private formBuilder: FormBuilder, private profileService: ProfileService, private reportService: ReportService, private categoryService: CategoryService, private commentService: CommentService, private imageService: ImageService) {
	}

	ngOnInit() : void {

		this.getReport();

		this.reportAdminViewForm = this.formBuilder.group({
			reportStatus: ["", [Validators.required]],
			reportUrgency: ["", [Validators.required]],
			commentContent: ["", [Validators.maxLength(500), Validators.required]]
		});

		this.applyFormChanges();
	}

	applyFormChanges() : void {
		this.reportAdminViewForm.valueChanges.subscribe(values => {
			for(let field in values) {
				this.comment[field] = values[field];
			}
		});
	}

	getReport(): void {
		this.reportService.getReport(this.report.reportId)
			.subscribe(report => this.report = report);
	}

	deleteReport(): void {
		this.reportService.deleteReport(this.report.reportId)
			.subscribe(status => {
				this.status = status;
				if(this.status.status === 200) {
					this.deleted = true;
					this.report = new Report(null, null, null, null, null, null, null);
				}
			})
	}

	createComment(): void {
	let comment = new Comment(null, null, null, this.reportAdminViewForm.value.commentContent, null)

		this.commentService.createComment(comment)
			.subscribe(status =>{
				this.status = status;
				if(this.status.status === 200) {
					this.reportAdminViewForm.reset();
					alert(this.status.message);
				}
			})
	}

	deleteComment() : void {
		this.commentService.deleteComment(this.comment.commentId)
			.subscribe(status => {
				this.status = status;
				if(this.status.status === 200) {
					this.deleted = true;
					this.comment = new Comment(null, null, null, null, null);
				}
			})
	}

	editComment() : void {
		this.commentService.editComment(this.comment)
			.subscribe(status => this.status = status);
	}
}
{'fraction_non_alphanumeric': 0.14651127591947935, 'fraction_numerical': 0.0036325109732102314, 'mean_word_length': 4.376729048006509, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '248300', 'n_tokens_mistral': 2160, 'n_tokens_neox': 1911, 'n_words': 469}