diff --git a/src/app/huddle/huddle.component.html b/src/app/huddle/huddle.component.html
index bcc9395..7cb0c1e 100644
--- a/src/app/huddle/huddle.component.html
+++ b/src/app/huddle/huddle.component.html
@@ -18,6 +18,9 @@
{{story.user ? story.user.username : '...'}}
{{story.created_at | date :'dd.MM. HH:mm' }}
+
+ Delete
+
diff --git a/src/app/huddle/huddle.component.scss b/src/app/huddle/huddle.component.scss
index 9131127..fb954f9 100644
--- a/src/app/huddle/huddle.component.scss
+++ b/src/app/huddle/huddle.component.scss
@@ -8,6 +8,13 @@
margin: 0 auto;
}
+.deleteStory {
+ cursor: pointer;
+ // position: absolute;
+ // right: 35px;
+ // top:20px;
+}
+
.storyImage.hasStory:before {
content: "";
position: relative;
diff --git a/src/app/huddle/huddle.component.ts b/src/app/huddle/huddle.component.ts
index 25c0154..8c3d528 100644
--- a/src/app/huddle/huddle.component.ts
+++ b/src/app/huddle/huddle.component.ts
@@ -23,6 +23,7 @@ export class HuddleComponent implements OnInit, OnDestroy {
selectedStory: Story;
stories: Story[] = [];
unsubscribe: Subject = new Subject();
+ user: SupabaseAuthUser;
constructor(
private modalService: NgbModal,
@@ -36,6 +37,9 @@ export class HuddleComponent implements OnInit, OnDestroy {
) {}
ngOnInit() {
+ this.supaService.client.auth.user()
+ .then(user => this.user = user)
+ .catch(error => console.error(error));
this.route.params.subscribe(
params => {
this.reset();
@@ -142,10 +146,11 @@ export class HuddleComponent implements OnInit, OnDestroy {
}
}
- async uploadStory(src: string) {
- console.log('uploadStory', event);
- const user: SupabaseAuthUser = await this.supaService.client.auth.user();
- const story = new Story(user.id, this.standup.id, src);
+ uploadStory(src: string) {
+ if (!this.standup || !this.user || !src) {
+ return;
+ }
+ const story = new Story(this.user.id, this.standup.id, src);
this.storyService.addOne(story).pipe(take(1)).subscribe(
data => {
console.log('Success', data);
@@ -155,6 +160,23 @@ export class HuddleComponent implements OnInit, OnDestroy {
}
);
}
+
+ deleteStory(story : Story) {
+ if (!story) {
+ return;
+ }
+ const confirm = window.confirm('Do you want to delete this story?')
+ if (confirm) {
+ this.storyService.deleteOne(story).pipe(take(1)).subscribe(
+ data => {
+ console.log('Success', data);
+ },
+ error => {
+ console.error('Failed', error);
+ }
+ );
+ }
+ }
loadStories(id: number) {
return this.storyService.getStories(id).pipe(