From 215f46658eda9c3c19b6ea3f9335904c23bbee30 Mon Sep 17 00:00:00 2001 From: Rumperuu Date: Sun, 21 Mar 2021 16:35:04 +0000 Subject: [PATCH] Add topic creation for organisation users --- src/app/dashboard/dashboard.module.ts | 2 + src/app/dashboard/dashboard.routing.ts | 11 +++++ .../send-push-notification.component.ts | 4 +- src/app/dashboard/topics-edit.component.html | 37 ++++++++++++++++ src/app/dashboard/topics-edit.component.ts | 43 +++++++++++++++++++ src/app/layouts/full-layout.component.html | 8 ++++ src/app/providers/api-service.ts | 18 +++++--- 7 files changed, 116 insertions(+), 7 deletions(-) create mode 100644 src/app/dashboard/topics-edit.component.html create mode 100644 src/app/dashboard/topics-edit.component.ts diff --git a/src/app/dashboard/dashboard.module.ts b/src/app/dashboard/dashboard.module.ts index 9e3a8b7..fe9a5e5 100644 --- a/src/app/dashboard/dashboard.module.ts +++ b/src/app/dashboard/dashboard.module.ts @@ -15,6 +15,7 @@ import { DashboardCustomerComponent } from './dashboard-customer.component'; import { AccountEditComponent } from './account-edit.component'; import { AddDataComponent } from './add-data.component'; import { FeedbackComponent } from './feedback.component'; +import { TopicsEditComponent } from './topics-edit.component'; import { SendPushNotificationComponent } from './send-push-notification.component'; import { TransactionLogComponent } from './transaction-log.component'; import { CategoryMonthComponent } from './category-month.component'; @@ -86,6 +87,7 @@ import { environment } from '../../environments/environment'; MapComponent, TrailMapComponent, FeedbackComponent, + TopicsEditComponent, SendPushNotificationComponent, GraphWidget, OrgBarSnippetComponent, diff --git a/src/app/dashboard/dashboard.routing.ts b/src/app/dashboard/dashboard.routing.ts index 7689784..332b7ed 100644 --- a/src/app/dashboard/dashboard.routing.ts +++ b/src/app/dashboard/dashboard.routing.ts @@ -19,6 +19,7 @@ import { MapComponent } from './map.component'; import { TrailMapComponent } from './trail-map.component'; import { MoreStuffComponent } from './more-graphs-and-tables.component'; import { SuppliersComponent } from './suppliers.component'; +import { TopicsEditComponent } from './topics-edit.component'; import { SendPushNotificationComponent } from './send-push-notification.component'; // Using child path to allow for FullLayout theming @@ -56,6 +57,16 @@ const routes: Routes = [ component: SendPushNotificationComponent, data: { title: 'Send Message' }, }, + { + path: 'edit-topics', + component: TopicsEditComponent, + data: { title: 'Edit Topics' }, + }, + { + path: 'edit-subscriptions', + component: SubscriptionsEditComponent, + data: { title: 'Edit Subscriptions' }, + }, { path: 'leaderboard', component: LeaderboardComponent, diff --git a/src/app/dashboard/send-push-notification.component.ts b/src/app/dashboard/send-push-notification.component.ts index a100710..7207732 100644 --- a/src/app/dashboard/send-push-notification.component.ts +++ b/src/app/dashboard/send-push-notification.component.ts @@ -43,10 +43,10 @@ export class SendPushNotificationComponent implements OnInit { } if (!this.loggedInEmail) { - console.log('email not found in storage'); + console.warn('email not found in storage'); this.api.accountFullLoad().subscribe( result => { - console.log(result); + console.debug(result); this.sendMessageForm.patchValue({ email: result.email, }); diff --git a/src/app/dashboard/topics-edit.component.html b/src/app/dashboard/topics-edit.component.html new file mode 100644 index 0000000..7fa0dce --- /dev/null +++ b/src/app/dashboard/topics-edit.component.html @@ -0,0 +1,37 @@ +
+
+
+
+
+ Create New Topic + Required Data marked in bold. +
+
+
+
+ +
+ +
+
+
+
+
+ + +
+
+
+
+ +
+
+
+
+
diff --git a/src/app/dashboard/topics-edit.component.ts b/src/app/dashboard/topics-edit.component.ts new file mode 100644 index 0000000..16ad43e --- /dev/null +++ b/src/app/dashboard/topics-edit.component.ts @@ -0,0 +1,43 @@ +import { Component } from '@angular/core'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; +import { ApiService } from '../providers/api-service'; + +@Component({ + templateUrl: 'topics-edit.component.html', +}) +export class TopicsEditComponen { + createTopicForm: FormGroup; + loggedInEmail: string; + createTopicFormStatus: string; + createTopicFormStatusSuccess: string; + createTopicFormStatusError = 'Error received, please try again.'; + + constructor(private api: ApiService) { + this.createTopicForm = new FormGroup({ + topic: new FormControl('', Validators.required), + }); + } + + onSubmit(): void { + this.api + .createTopic(this.createTopicForm.value) + .subscribe( + result => { + console.debug('Topic successfully created.'); + this.createTopicFormStatus = 'success'; + this.createTopicForm.patchValue({ + topic: '', + }); + }, + error => { + console.error('Topic creation failed.'); + try { + this.createTopicFormStatusError = '"' + error.error.error + '" Error, ' + error.error.message; + } catch (e) { + this.createTopicFormStatusError = 'There was a server error, please try again later.'; + } + this.createTopicFormStatus = 'create_failed'; + } + ); + } +} diff --git a/src/app/layouts/full-layout.component.html b/src/app/layouts/full-layout.component.html index 4d0ff3e..db68f0e 100644 --- a/src/app/layouts/full-layout.component.html +++ b/src/app/layouts/full-layout.component.html @@ -52,6 +52,14 @@ +