Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/components/standalone/subscription/RemoteSupport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
NeInlineNotification,
NeButton,
NeSkeleton,
getAxiosErrorMessage
getAxiosErrorMessage,
formatDateLoc
} from '@nethesis/vue-components'
import { toRefs } from 'vue'
import { ubusCall } from '@/lib/standalone/ubus'
Expand All @@ -38,24 +39,29 @@ const isLoadingSessionStatus = ref(true)
const error = ref('')
const isProcessingRequest = ref(false)
const sessionId = ref('')
const expiresInSeconds = ref<number | null>(null)

async function startSession() {
const startDonResponse = await makeDonRequest('start')
sessionId.value = startDonResponse.data.session_id
expiresInSeconds.value = startDonResponse.data.expires_in_seconds
}

async function stopSession() {
await makeDonRequest('stop')
sessionId.value = ''
expiresInSeconds.value = null
}

async function getSessionStatus() {
isLoadingSessionStatus.value = true
const statusResponse = await makeDonRequest('status')
if (statusResponse.data.result === 'no_session') {
sessionId.value = ''
expiresInSeconds.value = null
} else {
sessionId.value = statusResponse.data.session_id
expiresInSeconds.value = statusResponse.data.expires_in_seconds
}
isLoadingSessionStatus.value = false
}
Expand Down Expand Up @@ -110,13 +116,26 @@ onMounted(() => {
:copy-value-label="t('standalone.subscription.copy_id')"
/>

<div class="mt-6 flex justify-end">
<!-- Session active notification -->
<NeInlineNotification
v-if="expiresInSeconds"
kind="info"
:title="t('standalone.subscription.remote_support_session_active')"
:description="
t('standalone.subscription.remote_support_session_description', {
date: formatDateLoc(new Date(Date.now() + expiresInSeconds * 1000), 'PPp')
})
"
class="mt-6"
/>

<div class="mt-6 flex justify-start">
<NeButton
kind="primary"
:disabled="isProcessingRequest"
:loading="isProcessingRequest"
@click="stopSession()"
>{{ t('standalone.subscription.end_session') }}</NeButton
>{{ t('standalone.subscription.stop_session') }}</NeButton
>
</div>
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,9 @@
"cancel_registration": "Cancel subscription",
"session_id": "Session ID",
"copy_id": "Copy ID",
"end_session": "End session",
"remote_support_session_active": "Remote support session active",
"remote_support_session_description": "The session will automatically close on {date}. You can stop it at any time.",
"stop_session": "Stop session",
"invalid_secret_or_server_not_found": "Invalid token or server not found",
"active": "Active",
"inactive": "Inactive",
Expand Down
Loading