-
Notifications
You must be signed in to change notification settings - Fork 63
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 #1926 from flowforge/feat-1911-start-stop-instances
Application Instances: Live statuses
- Loading branch information
Showing
28 changed files
with
520 additions
and
410 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,84 @@ | ||
<script> | ||
import InstanceApi from '../api/instances.js' | ||
const instanceTransitionStates = [ | ||
'loading', | ||
'installing', | ||
'starting', | ||
'stopping', | ||
'restarting', | ||
'suspending', | ||
'importing' | ||
] | ||
export default { | ||
props: { | ||
instance: { | ||
type: Object, | ||
required: true | ||
} | ||
}, | ||
emits: ['instance-updated'], | ||
data () { | ||
return { | ||
checkInterval: null, | ||
checkWaitTime: 1000 | ||
} | ||
}, | ||
watch: { | ||
instance: 'checkForUpdateIfNeeded', | ||
'instance.pendingStateChange': 'checkForUpdateIfNeeded', | ||
'instance.meta.state': 'checkForUpdateIfNeeded' | ||
}, | ||
mounted () { | ||
this.checkForUpdateIfNeeded() | ||
}, | ||
unmounted () { | ||
clearTimeout(this.checkInterval) | ||
}, | ||
methods: { | ||
checkForUpdateIfNeeded () { | ||
clearTimeout(this.checkInterval) | ||
if (!this.shouldCheckForUpdate(this.instance)) { | ||
this.checkWaitTime = 1000 | ||
return | ||
} | ||
this.scheduleUpdate(this.instance.id) | ||
}, | ||
scheduleUpdate () { | ||
this.checkInterval = setTimeout(async () => { | ||
this.checkWaitTime *= 1.15 | ||
if (this.instance.id) { | ||
const data = await InstanceApi.getInstance(this.instance.id) | ||
this.$emit('instance-updated', data) | ||
} | ||
}, this.checkWaitTime) | ||
}, | ||
shouldCheckForUpdate (instance) { | ||
// Server has not received state change request yet, no need to check for update | ||
if (instance.optimisticStateChange) { | ||
return false | ||
} | ||
// If instance is in a transition state, check for update | ||
if (instance.meta?.state && instanceTransitionStates.includes(instance.meta.state)) { | ||
return true | ||
} | ||
// Otherwise, if instance is known to have a pending state change, check for update | ||
if (instance.pendingStateChange) { | ||
return true | ||
} | ||
return false | ||
} | ||
} | ||
} | ||
</script> | ||
<!-- eslint-disable-next-line vue/valid-template-root --> | ||
<template /> |
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,61 @@ | ||
<template> | ||
<div v-if="!status" class="forge-badge"><RefreshIcon class="w-4 h-4 animate-spin" /></div> | ||
<div | ||
v-else | ||
class="forge-badge" | ||
:class="['forge-status-' + status, pendingChange ? 'opacity-40' : '']" | ||
> | ||
<ExclamationCircleIcon v-if="status === 'error'" class="w-4 h-4" /> | ||
<ExclamationIcon v-if="status === 'suspended'" class="w-4 h-4" /> | ||
<PlayIcon v-if="status === 'running'" class="w-4 h-4" /> | ||
<StopIcon v-if="status === 'stopping' || status === 'suspending'" class="w-4 h-4" /> | ||
<RefreshIcon v-if="status === 'restarting'" class="w-4 h-4" /> | ||
<DownloadIcon v-if="status === 'importing'" class="w-4 h-4" /> | ||
<DotsCircleHorizontalIcon v-if="status === 'starting'" class="w-4 h-4" /> | ||
<CloudUploadIcon v-if="status === 'loading'" class="w-4 h-4" /> | ||
<CloudDownloadIcon v-if="status === 'installing'" class="w-4 h-4" /> | ||
<SupportIcon v-if="status === 'safe'" class="w-4 h-4" /> | ||
<span class="ml-1">{{ status }}</span> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { | ||
CloudDownloadIcon, | ||
CloudUploadIcon, | ||
DotsCircleHorizontalIcon, | ||
DownloadIcon, | ||
ExclamationCircleIcon, | ||
ExclamationIcon, | ||
PlayIcon, | ||
RefreshIcon, | ||
StopIcon, | ||
SupportIcon | ||
} from '@heroicons/vue/outline' | ||
export default { | ||
name: 'InstanceStatusBadge', | ||
components: { | ||
CloudDownloadIcon, | ||
CloudUploadIcon, | ||
DotsCircleHorizontalIcon, | ||
DownloadIcon, | ||
ExclamationCircleIcon, | ||
ExclamationIcon, | ||
PlayIcon, | ||
RefreshIcon, | ||
StopIcon, | ||
SupportIcon | ||
}, | ||
props: { | ||
status: { | ||
type: String, | ||
default: null | ||
}, | ||
pendingChange: { | ||
type: Boolean, | ||
default: false | ||
} | ||
} | ||
} | ||
</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
2 changes: 1 addition & 1 deletion
2
frontend/src/pages/application/components/cells/DeploymentName.vue
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.