-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
29 changed files
with
1,219 additions
and
1,274 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
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
54 changes: 31 additions & 23 deletions
54
spring-boot-admin-server-ui/src/main/frontend/composables/useApplicationStore.ts
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 |
---|---|---|
@@ -1,39 +1,47 @@ | ||
import { ref } from 'vue'; | ||
import {Ref, ref, UnwrapRef} from 'vue'; | ||
|
||
import ApplicationStore from '../store.js'; | ||
import Application from "@/services/application"; | ||
|
||
let applicationStore: ApplicationStore | null = null; | ||
const applications = ref([]); | ||
const applications = ref([] as Application[]); | ||
const applicationsInitialized = ref(false); | ||
const error = ref(null); | ||
|
||
export function createApplicationStore() { | ||
if (applicationStore) throw new Error('ApplicationStore already created!'); | ||
if (applicationStore) throw new Error('ApplicationStore already created!'); | ||
|
||
applicationStore = new ApplicationStore(); | ||
return applicationStore; | ||
applicationStore = new ApplicationStore(); | ||
return applicationStore; | ||
} | ||
|
||
export function useApplicationStore() { | ||
applicationStore.addEventListener('connected', () => { | ||
applicationsInitialized.value = true; | ||
error.value = null; | ||
}); | ||
type ApplicationStoreValue = { | ||
applications: Ref<UnwrapRef<Application[]>>; | ||
applicationsInitialized: Ref<boolean>; | ||
error: Ref<any>; | ||
applicationStore: ApplicationStore; | ||
} | ||
|
||
export function useApplicationStore(): ApplicationStoreValue { | ||
applicationStore.addEventListener('connected', () => { | ||
applicationsInitialized.value = true; | ||
error.value = null; | ||
}); | ||
|
||
applicationStore.addEventListener('changed', (newApplications) => { | ||
applicationsInitialized.value = true; | ||
applications.value = newApplications; | ||
error.value = null; | ||
}); | ||
applicationStore.addEventListener('changed', (newApplications) => { | ||
applicationsInitialized.value = true; | ||
applications.value = newApplications; | ||
error.value = null; | ||
}); | ||
|
||
applicationStore.addEventListener('error', (errorResponse) => { | ||
applicationsInitialized.value = true; | ||
error.value = errorResponse; | ||
}); | ||
applicationStore.addEventListener('error', (errorResponse) => { | ||
applicationsInitialized.value = true; | ||
error.value = errorResponse; | ||
}); | ||
|
||
applicationStore.addEventListener('removed', () => { | ||
applicationsInitialized.value = false; | ||
}); | ||
applicationStore.addEventListener('removed', () => { | ||
applicationsInitialized.value = false; | ||
}); | ||
|
||
return { applications, applicationsInitialized, error, applicationStore }; | ||
return {applications, applicationsInitialized, error, applicationStore}; | ||
} |
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
Oops, something went wrong.