Cleanup socketio stuff for typescript
This commit is contained in:
parent
3ad4422a94
commit
5e4ca8ef83
22 changed files with 246 additions and 210 deletions
52
resources/assets/scripts/mixins/flash.ts
Normal file
52
resources/assets/scripts/mixins/flash.ts
Normal file
|
@ -0,0 +1,52 @@
|
|||
export const flash = {
|
||||
methods: {
|
||||
/**
|
||||
* Flash a message to the event stream in the browser.
|
||||
*/
|
||||
flash: function (message: string, title: string, severity: string = 'info'): void {
|
||||
severity = severity || 'info';
|
||||
if (['danger', 'fatal', 'error'].includes(severity)) {
|
||||
severity = 'error';
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
window.events.$emit('flash', { message, title, severity });
|
||||
},
|
||||
|
||||
/**
|
||||
* Clear all of the flash messages from the screen.
|
||||
*/
|
||||
clearFlashes: function (): void {
|
||||
// @ts-ignore
|
||||
window.events.$emit('clear-flashes');
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper function to flash a normal success message to the user.
|
||||
*/
|
||||
success: function (message: string): void {
|
||||
this.flash(message, 'Success', 'success');
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper function to flash a normal info message to the user.
|
||||
*/
|
||||
info: function (message: string): void {
|
||||
this.flash(message, 'Info', 'info');
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper function to flash a normal warning message to the user.
|
||||
*/
|
||||
warning: function (message: string): void {
|
||||
this.flash(message, 'Warning', 'warning');
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper function to flash a normal error message to the user.
|
||||
*/
|
||||
error: function (message: string): void {
|
||||
this.flash(message, 'Error', 'danger');
|
||||
},
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue