Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
CodexAdrian committed Oct 13, 2023
1 parent 7314526 commit 84b20cd
Show file tree
Hide file tree
Showing 10 changed files with 770 additions and 122 deletions.
5 changes: 4 additions & 1 deletion assets/styles/layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@

.page-header__icon {
grid-area: icon;
background-color: var(--color-raised-bg);

&.avatar, .avatar {
background-color: var(--color-raised-bg);
}
}

.page-header__buttons {
Expand Down
7 changes: 7 additions & 0 deletions pages/[type]/[id].vue
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,13 @@
}/versions`,
shown: versions.length > 0 || !!currentMember,
},
{
label: 'Analytics',
href: `/${project.project_type}/${
project.slug ? project.slug : project.id
}/analytics`,
shown: !!currentMember,
},
{
label: 'Moderation',
href: `/${project.project_type}/${
Expand Down
19 changes: 9 additions & 10 deletions pages/[type]/[id]/analytics.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ const totalData = ref({
const selectedDataType = ref('downloads')
const finishedLoading = ref(false)
let downloadData, viewData, viewDownloadRatio, countryData
const body = {
project_ids: [ props.project.id ]
}
const body = `project_ids=["${props.project.id}"]`
try {
;[
{ data: downloadData },
{ data: viewData },
{ data: viewDownloadRatio },
{ data: countryData },
] = await Promise.all([
useAsyncData('analytics/views', () => useBaseFetch('analytics/views', { body }), {
useAsyncData(`analytics/downloads?${body}`, () => useBaseFetch(`analytics/downloads?${body}`), {
transform: (analytics) => {
const labels = []
const data = []
Expand All @@ -51,7 +49,7 @@ try {
}
}
}),
useAsyncData('analytics/views', () => useBaseFetch('analytics/views', { body }), {
useAsyncData(`analytics/views?${body}`, () => useBaseFetch(`analytics/views?${body}`), {
transform: (analytics) => {
const labels = []
const data = []
Expand All @@ -73,7 +71,7 @@ try {
}
}
}),
useAsyncData('analytics/countries/views', () => useBaseFetch('analytics/countries/views', { body }), {
useAsyncData(`analytics/countries/views?${body}`, () => useBaseFetch(`analytics/countries/views?${body}`), {
transform: (analytics) => {
const finalData = {
title: 'Views',
Expand All @@ -92,13 +90,12 @@ try {
return finalData
}
}),
useAsyncData('analytics/countries/downloads', () => useBaseFetch('analytics/countries/downloads', { body }), {
useAsyncData(`analytics/countries/downloads?${body}`, () => useBaseFetch(`analytics/countries/downloads?${body}`), {
transform: (analytics) => {
const finalData = {
title: 'Views',
data: []
}
for (const rawData of Object.values(analytics)) {
for (const [key, data] of Object.entries(rawData)) {
finalData.data.push({
Expand Down Expand Up @@ -432,27 +429,29 @@ const countryData = ref({
gap: var(--gap-lg);
width: 100%;
padding: var(--gap-xl);
.chart {
width: 100% !important;
height: calc(100% - 8rem) !important;
border-radius: var(--radius-lg);
background-color: var(--color-bg);
padding: var(--gap-xl);
object-fit: cover;
}
.relative-chart {
display: flex;
flex-direction: column;
justify-content: center;
gap: var(--gap-md);
margin: -3rem 0;
}
.title {
color: var(--color-heading);
font-weight: bold;
font-size: var(--font-size-lg);
}
}
.bar-graph {
width: 100%;
background-color: var(--color-bg);
Expand Down
99 changes: 99 additions & 0 deletions pages/[type]/[id]/version/[version].vue
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,97 @@ export default defineNuxtComponent({
oldFileTypes = version.files.map((x) => fileTypes.find((y) => y.value === x.file_type))
const order = ['required', 'optional', 'incompatible', 'embedded']
const defaultLicenses = shallowRef([
{ friendly: 'Custom', short: '' },
{
friendly: 'All Rights Reserved/No License',
short: 'All-Rights-Reserved',
},
{ friendly: 'Apache License 2.0', short: 'Apache-2.0' },
{
friendly: 'BSD 2-Clause "Simplified" License',
short: 'BSD-2-Clause',
},
{
friendly: 'BSD 3-Clause "New" or "Revised" License',
short: 'BSD-3-Clause',
},
{
friendly: 'CC Zero (Public Domain equivalent)',
short: 'CC0-1.0',
},
{ friendly: 'CC-BY 4.0', short: 'CC-BY-4.0' },
{
friendly: 'CC-BY-SA 4.0',
short: 'CC-BY-SA-4.0',
},
{
friendly: 'CC-BY-NC 4.0',
short: 'CC-BY-NC-4.0',
},
{
friendly: 'CC-BY-NC-SA 4.0',
short: 'CC-BY-NC-SA-4.0',
},
{
friendly: 'CC-BY-ND 4.0',
short: 'CC-BY-ND-4.0',
},
{
friendly: 'CC-BY-NC-ND 4.0',
short: 'CC-BY-NC-ND-4.0',
},
{
friendly: 'GNU Affero General Public License v3',
short: 'AGPL-3.0',
requiresOnlyOrLater: true,
},
{
friendly: 'GNU Lesser General Public License v2.1',
short: 'LGPL-2.1',
requiresOnlyOrLater: true,
},
{
friendly: 'GNU Lesser General Public License v3',
short: 'LGPL-3.0',
requiresOnlyOrLater: true,
},
{
friendly: 'GNU General Public License v2',
short: 'GPL-2.0',
requiresOnlyOrLater: true,
},
{
friendly: 'GNU General Public License v3',
short: 'GPL-3.0',
requiresOnlyOrLater: true,
},
{ friendly: 'ISC License', short: 'ISC' },
{ friendly: 'MIT License', short: 'MIT' },
{ friendly: 'Mozilla Public License 2.0', short: 'MPL-2.0' },
{ friendly: 'zlib License', short: 'Zlib' },
])
const licenseUrl = ref(props.project.license.url)
const licenseId = props.project.license.id
const trimmedLicenseId = licenseId
.replaceAll('-only', '')
.replaceAll('-or-later', '')
.replaceAll('LicenseRef-', '')
const license = ref(
defaultLicenses.value.find((x) => x.short === trimmedLicenseId) ?? {
friendly: 'Custom',
short: licenseId.replaceAll('LicenseRef-', ''),
}
)
if (licenseId === 'LicenseRef-Unknown') {
license.value = {
friendly: 'Unknown',
short: licenseId.replaceAll('LicenseRef-', ''),
}
}
return {
auth,
Expand Down Expand Up @@ -926,6 +1017,9 @@ export default defineNuxtComponent({
(a, b) => order.indexOf(a.dependency_type) - order.indexOf(b.dependency_type)
)
),
defaultLicenses,
licenseUrl,
license,
}
},
data() {
Expand All @@ -947,6 +1041,11 @@ export default defineNuxtComponent({
showKnownErrors: false,
shouldPreventActions: false,
licenseUrl: '',
license: { friendly: '', short: '', requiresOnlyOrLater: false },
allowOrLater: this.project.license.id.includes('-or-later'),
nonSpdxLicense: this.project.license.id.includes('LicenseRef-'),
}
},
computed: {
Expand Down
Loading

0 comments on commit 84b20cd

Please sign in to comment.