add missing data to public shared reports, add premium restrictions, add pdf download

This commit is contained in:
Gregor Vostrak
2024-12-03 15:03:28 +01:00
committed by Constantin Graf
parent bcb298bd6d
commit e3f981aac2
15 changed files with 525 additions and 149 deletions

View File

@@ -37,20 +37,22 @@ const props = defineProps<{
properties: CreateReportBodyProperties;
}>();
const report = ref<CreateReportBody>({
const report = ref({
name: '',
description: '',
is_public: false,
public_until: null,
properties: {},
});
const { handleApiRequestNotifications } = useNotificationsStore();
async function submit() {
report.value.properties = { ...props.properties };
await handleApiRequestNotifications(
() => createReportMutation.mutateAsync(report.value),
() =>
createReportMutation.mutateAsync({
...report.value,
properties: { ...props.properties },
}),
'Success',
'Error',
() => {
@@ -59,7 +61,6 @@ async function submit() {
description: '',
is_public: false,
public_until: null,
properties: {},
};
show.value = false;
}

View File

@@ -0,0 +1,41 @@
<script setup lang="ts">
import { SecondaryButton } from '@/packages/ui/src';
import ReportCreateModal from '@/Components/Common/Report/ReportCreateModal.vue';
import { h, ref } from 'vue';
import type { CreateReportBodyProperties } from '@/packages/api/src';
import { isAllowedToPerformPremiumAction } from '@/utils/billing';
import UpgradeModal from '@/Components/Common/UpgradeModal.vue';
defineProps<{
reportProperties: CreateReportBodyProperties;
}>();
const showCreateReportModal = ref(false);
const showPremiumModal = ref(false);
const SaveIcon = h('div', {
innerHTML:
'<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z"/><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7M7 3v4a1 1 0 0 0 1 1h7"/></g></svg>',
});
function onSaveReportClick() {
if (isAllowedToPerformPremiumAction()) {
showCreateReportModal.value = true;
} else {
showPremiumModal.value = true;
}
}
</script>
<template>
<ReportCreateModal
:properties="reportProperties"
v-model:show="showCreateReportModal"></ReportCreateModal>
<UpgradeModal v-model:show="showPremiumModal">
<strong>Sharable Reports</strong> is only available in solidtime
Professional.
</UpgradeModal>
<SecondaryButton :icon="SaveIcon" @click="onSaveReportClick"
>Save Report</SecondaryButton
>
</template>
<style scoped></style>