import { FormBuilder, FormGroup } from '@angular/forms';
import { ModalDirective } from 'ng2-bootstrap/modal';
+import { NotificationsService } from 'angular2-notifications';
-import { FormReactive, VIDEO_REPORT_REASON } from '../../shared';
+import { FormReactive, VideoAbuseService, VIDEO_ABUSE_REASON } from '../../shared';
import { Video, VideoService } from '../shared';
@Component({
reason: ''
};
validationMessages = {
- reason: VIDEO_REPORT_REASON.MESSAGES
+ reason: VIDEO_ABUSE_REASON.MESSAGES
};
constructor(
private formBuilder: FormBuilder,
- private videoService: VideoService
+ private videoAbuseService: VideoAbuseService,
+ private notificationsService: NotificationsService
) {
super();
}
buildForm() {
this.form = this.formBuilder.group({
- reason: [ '', VIDEO_REPORT_REASON.VALIDATORS ]
+ reason: [ '', VIDEO_ABUSE_REASON.VALIDATORS ]
});
this.form.valueChanges.subscribe(data => this.onValueChanged(data));
}
report() {
- const reason = this.form.value['reason']
+ const reason = this.form.value['reason'];
- this.videoService.reportVideo(this.video.id, reason)
- .subscribe(
- // TODO: move alert to beautiful notifications
- ok => {
- alert('Video reported.');
- this.hide();
- },
+ this.videoAbuseService.reportVideo(this.video.id, reason)
+ .subscribe(
+ () => {
+ this.notificationsService.success('Success', 'Video reported.');
+ this.hide();
+ },
- err => alert(err.text)
- )
+ err => this.notificationsService.error('Error', err.text)
+ );
}
}