This repository has been archived by the owner on Mar 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from pascal-zarrad/feature/notifications
Implement basic notification system
- Loading branch information
Showing
18 changed files
with
550 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<template> | ||
<div> | ||
<v-snackbar | ||
v-for="notification in notifications" | ||
:key="notification.id" | ||
:bottom="true" | ||
v-model="notification.show" | ||
> | ||
{{ notification.type }}: {{ notification.message }} | ||
<v-btn | ||
color="blue" | ||
text | ||
@click="submitCloseNotification(notification)" | ||
> | ||
Close | ||
</v-btn> | ||
</v-snackbar> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import NotificationInterface from "@/model/notification/NotificationInterface"; | ||
import { Component, Vue } from "vue-property-decorator"; | ||
/** | ||
* Component that handles notification display by making use of the | ||
* Vuetify Snackbar component | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
@Component({ | ||
name: "NotificationsComponent" | ||
}) | ||
export default class NotificationsComponent extends Vue { | ||
/** | ||
* A computed property that provides the notifications array | ||
* that provides all notifications that should be created by this component. | ||
* | ||
* @returns The (reactive) array that contains all visible notifications | ||
*/ | ||
get notifications(): NotificationInterface[] { | ||
return this.$softDocLinker.notificationManagement.notifications; | ||
} | ||
/** | ||
* Called when a notification is being closed manually by clicking | ||
* on the close button. | ||
* | ||
* @param notification The notification of which a close was triggered | ||
*/ | ||
private submitCloseNotification(notification: NotificationInterface): void { | ||
notification.show = false; | ||
this.$softDocLinker.notificationManagement.removeNotification( | ||
notification | ||
); | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* istanbul ignore file */ | ||
|
||
import NotificationInterface from "./NotificationInterface"; | ||
|
||
/** | ||
* Factory to create notifications. | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
export default class NotificationFactory { | ||
/** | ||
* Create a new notification. | ||
* | ||
* @param type The type of the notification to create | ||
* @param message The message of the notification | ||
* @returns A new notification with the given data | ||
*/ | ||
public create(type: string, message: string): NotificationInterface { | ||
return { | ||
type: type, | ||
message: message, | ||
show: false | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* istanbul ignore file */ | ||
|
||
/** | ||
* Model of the data required to display a notification. | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
export default interface NotificationInterface { | ||
/** | ||
* The message that is displayed by the notification. | ||
*/ | ||
message: string; | ||
|
||
/** | ||
* The type the displayed notification should have | ||
* | ||
* @see ./NotificationType | ||
*/ | ||
type: string; | ||
|
||
/** | ||
* State of this notification should be shown in the frontend. | ||
*/ | ||
show: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* istanbul ignore file */ | ||
|
||
/** | ||
* Notification type that provides different types for notifications | ||
* to categorize them. | ||
* | ||
* @since 2.0.0 | ||
*/ | ||
export default class NotificationType { | ||
/** | ||
* Notification level: INFO | ||
*/ | ||
public static readonly INFO = "INFO"; | ||
|
||
/** | ||
* Notification level: SUCCESS | ||
*/ | ||
public static readonly SUCCESS = "SUCCESS"; | ||
|
||
/** | ||
* Notification level: ERROR | ||
*/ | ||
public static readonly ERROR = "ERROR"; | ||
} |
Oops, something went wrong.