1
0
Fork 0
mirror of https://gitlab.com/bramw/baserow.git synced 2025-03-15 04:54:50 +00:00
bramw_baserow/premium/web-frontend/modules/baserow_premium/pages/admin/licenses.vue

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

223 lines
7 KiB
Vue
Raw Permalink Normal View History

2021-10-20 19:28:51 +00:00
<template>
<div class="layout__col-2-scroll layout__col-2-scroll--white-background">
<div v-if="orderedLicenses.length === 0" class="placeholder">
<div class="placeholder__icon">
2023-09-28 13:39:41 +00:00
<i class="iconoir-shield-check"></i>
2021-10-20 19:28:51 +00:00
</div>
2022-01-11 12:13:53 +00:00
<h1 class="placeholder__title">
{{ $t('licenses.titleNoLicenses') }}
</h1>
2021-10-20 19:28:51 +00:00
<p class="placeholder__content">
2022-01-11 12:13:53 +00:00
{{ $t('licenses.noLicensesDescription') }}
2021-10-20 19:28:51 +00:00
</p>
2022-11-21 16:23:47 +00:00
<div class="licenses__features margin-bottom-2">
<div
v-for="licenseType in licenseTypesWithFeatureComponent"
:key="licenseType.type"
>
<h2>{{ licenseType.getName() }}</h2>
<component
:is="licenseType.getFeaturesComponent()"
class="margin-bottom-2"
></component>
</div>
</div>
2021-10-20 19:28:51 +00:00
<div class="placeholder__action">
2024-04-15 11:29:17 +00:00
<Button
type="primary"
size="large"
icon="iconoir-plus"
@click="$refs.registerModal.show()"
>
2022-01-11 12:13:53 +00:00
{{ $t('licenses.registerLicense') }}
2024-04-15 11:29:17 +00:00
</Button>
<RedirectToBaserowModal
2021-10-20 19:28:51 +00:00
:href="'https://baserow.io/get-license/' + instanceId + '/'"
target="_blank"
>{{ $t('licenses.getLicense') }}</RedirectToBaserowModal
2021-10-20 19:28:51 +00:00
>
</div>
<p>
2022-01-11 12:13:53 +00:00
{{ $t('licenses.baserowInstanceId') }}
2021-10-20 19:28:51 +00:00
<br />
<span class="licenses__instance-id">{{ instanceId }}</span>
<a
class="licenses__instance-id-copy"
@click.prevent="
;[copyToClipboard(instanceId), $refs.instanceIdCopied.show()]
"
>
2022-01-11 12:13:53 +00:00
{{ $t('action.copy') }}
2021-10-20 19:28:51 +00:00
<Copied ref="instanceIdCopied"></Copied>
</a>
</p>
</div>
<div v-else class="licenses">
<div class="licenses__head">
2022-01-11 12:13:53 +00:00
<h1 class="margin-bottom-0">
{{ $t('licenses.titleLicenses') }}
</h1>
2021-10-20 19:28:51 +00:00
<div>
2024-04-15 11:29:17 +00:00
<Button
type="primary"
icon="iconoir-plus"
2021-10-20 19:28:51 +00:00
@click="$refs.registerModal.show()"
>
2022-01-11 12:13:53 +00:00
{{ $t('licenses.registerLicense') }}
2024-04-15 11:29:17 +00:00
</Button>
<RedirectToBaserowModal
2021-10-20 19:28:51 +00:00
:href="'https://baserow.io/get-license/' + instanceId + '/'"
target="_blank"
2024-04-15 11:29:17 +00:00
size="regular"
>{{ $t('licenses.getLicense') }}</RedirectToBaserowModal
2021-10-20 19:28:51 +00:00
>
</div>
</div>
<div class="margin-bottom-3">
2022-01-11 12:13:53 +00:00
{{ $t('licenses.baserowInstanceId') }}
2021-10-20 19:28:51 +00:00
<span class="licenses__instance-id">{{ instanceId }}</span>
<a
class="licenses__instance-id-copy"
@click.prevent="
;[copyToClipboard(instanceId), $refs.instanceIdCopied.show()]
"
>
2022-01-11 12:13:53 +00:00
{{ $t('action.copy') }}
2021-10-20 19:28:51 +00:00
<Copied ref="instanceIdCopied"></Copied>
</a>
</div>
2021-10-20 19:28:51 +00:00
<div class="licenses__items">
<nuxt-link
v-for="license in orderedLicenses"
:key="license.id"
:to="{ name: 'admin-license', params: { id: license.id } }"
class="licenses__item"
>
2023-09-28 13:39:41 +00:00
<span class="licenses__item-icon-hover">
<i class="iconoir-arrow-right"></i>
</span>
2021-10-20 19:28:51 +00:00
<div class="licenses__item-head">
<div class="licenses__item-title">
2022-01-11 12:13:53 +00:00
{{ $t('licenses.licenceId') }}
2021-10-20 19:28:51 +00:00
<span class="licenses__item-title-license">{{
license.license_id
}}</span>
</div>
2024-04-15 11:29:17 +00:00
<Badge
:color="getLicenseType(license).getLicenseBadgeColor()"
bold
class="margin-right-1"
>
2023-11-14 11:51:49 +00:00
{{ getLicenseType(license).getName() }}</Badge
2021-10-20 19:28:51 +00:00
>
2024-04-15 11:29:17 +00:00
<Badge v-if="!license.is_active" color="red">{{
$t('licenses.expired')
}}</Badge>
2021-10-20 19:28:51 +00:00
</div>
<div class="licenses__item-validity">
2022-01-11 12:13:53 +00:00
{{
$t('licenses.validity', {
start: localDate(license.valid_from),
end: localDate(license.valid_through),
})
}}
2021-10-20 19:28:51 +00:00
</div>
<ul class="licenses__item-details">
2023-09-28 13:39:41 +00:00
<li class="licenses__item-detail-item">
2022-01-11 12:13:53 +00:00
{{ license.seats_taken }} / {{ license.seats }}
{{ $t('licenses.seats') }}
</li>
2023-09-28 13:39:41 +00:00
2022-11-21 16:23:47 +00:00
<li
2023-09-28 13:39:41 +00:00
class="licenses__item-detail-item"
2022-11-21 16:23:47 +00:00
v-for="(feature, index) in licenseFeatureDescription(license)"
:key="index"
>
{{ feature.name }}
<i
2023-09-28 13:39:41 +00:00
class="iconoir-check licenses__item-detail-item-icon"
2022-11-21 16:23:47 +00:00
:class="{
2023-09-28 13:39:41 +00:00
'iconoir-check license-yes': feature.enabled,
'iconoir-cancel license-no': !feature.enabled,
2022-11-21 16:23:47 +00:00
}"
></i>
2021-10-20 19:28:51 +00:00
</li>
</ul>
</nuxt-link>
</div>
</div>
<RegisterLicenseModal ref="registerModal"></RegisterLicenseModal>
</div>
</template>
<script>
import LicenseService from '@baserow_premium/services/license'
import RegisterLicenseModal from '@baserow_premium/components/license/RegisterLicenseModal'
import RedirectToBaserowModal from '@baserow_premium/components/RedirectToBaserowModal'
import PremiumFeatures from '@baserow_premium/components/PremiumFeatures'
2022-11-21 16:23:47 +00:00
import EnterpriseFeatures from '@baserow_enterprise/components/EnterpriseFeatures'
2021-10-20 19:28:51 +00:00
import moment from '@baserow/modules/core/moment'
import SettingsService from '@baserow/modules/core/services/settings'
import { copyToClipboard } from '@baserow/modules/database/utils/clipboard'
export default {
2022-11-21 16:23:47 +00:00
components: {
RedirectToBaserowModal,
RegisterLicenseModal,
PremiumFeatures,
EnterpriseFeatures,
},
2021-10-20 19:28:51 +00:00
layout: 'app',
middleware: 'staff',
async asyncData({ app, error }) {
try {
const { data: instanceData } = await SettingsService(
app.$client
).getInstanceID()
const { data } = await LicenseService(app.$client).fetchAll()
return {
licenses: data,
instanceId: instanceData.instance_id,
}
} catch {
return error({
statusCode: 400,
message: 'Something went wrong while fetching the licenses.',
})
}
},
computed: {
orderedLicenses() {
return this.licenses
.slice()
.sort(
(a, b) =>
new Date(a.valid_from).getTime() - new Date(b.valid_from).getTime()
)
.sort((a, b) =>
a.is_active === b.is_active ? 0 : a.is_active ? -1 : 1
)
},
2022-11-21 16:23:47 +00:00
licenseTypesWithFeatureComponent() {
return Object.values(this.$registry.getAll('license')).filter(
(licenseType) => licenseType.getFeaturesComponent() !== null
)
},
2021-10-20 19:28:51 +00:00
},
methods: {
localDate(date) {
return moment.utc(date).local().format('ll')
},
copyToClipboard(value) {
copyToClipboard(value)
},
getLicenseType(license) {
return this.$registry.get('license', license.product_code)
},
2022-10-13 19:18:34 +00:00
licenseFeatureDescription(license) {
return this.getLicenseType(license).getFeaturesDescription()
},
2021-10-20 19:28:51 +00:00
},
}
</script>