Skip to content

Commit

Permalink
Deployable and buildable
Browse files Browse the repository at this point in the history
  • Loading branch information
fabianlinkflink committed Nov 21, 2024
1 parent 6c06ded commit 01078eb
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 32 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- main

jobs:
deploy:
runs-on: ubuntu-latest

steps:
# Check out the repository
- name: Checkout repository
uses: actions/checkout@v3

# Set up Node.js
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20.11

# Install dependencies
- name: Install dependencies
run: npm ci

# Build the project
- name: Build project
run: npm run build

# Deploy to GitHub Pages
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
1 change: 0 additions & 1 deletion src/components/DetailBar/ResultsBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<Bar
class="max-h-full"
:data="chartData"
:options="chartOptions"
/>
<!--<label class="text-center"
>Emissions: {{ amountSelected }} objects <br />
Expand Down
10 changes: 5 additions & 5 deletions src/components/Mapping/MaterialBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ export default defineComponent({
const barStyle = computed(() => {
let backgroundColor: string
if (typeof color.value === 'string') {
backgroundColor = color.value
} else if (typeof color.value === 'object' && color.value !== null) {
if ('hex' in color.value && typeof color.value.hex === 'string') {
backgroundColor = color.value.hex
if ('hex' in color.value && typeof color.value === 'string') {
backgroundColor = color.value
} else {
backgroundColor = props.product.metaData.color
}
Expand Down Expand Up @@ -116,8 +116,8 @@ export default defineComponent({
if (typeof newColor === 'string') {
newHexColor = newColor
} else if (typeof newColor === 'object' && newColor !== null) {
if ('hex' in newColor && typeof newColor.hex === 'string') {
newHexColor = newColor.hex
if ('hex' in newColor && typeof newColor === 'string') {
newHexColor = newColor
} else {
newHexColor = props.product.metaData.color
}
Expand Down
15 changes: 7 additions & 8 deletions src/components/Misc/SearchBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ import { getNestedPropertyValue } from '@/utils/material'
import { Source } from '@/models/material'
import { getEnumEntries } from '@/utils/dataUtils'
import { isProduct, isAssembly } from '@/utils/dataUtils'
import {
Menu,
Expand Down Expand Up @@ -132,7 +133,7 @@ export default defineComponent({
props: {
data: {
//This is set as Product Assembly since its used for that now, can be anything
type: Array as () => Product[] | Assembly[],
type: Array as () => (Product | Assembly)[],
required: true,
},
filterParam: {
Expand Down Expand Up @@ -187,21 +188,19 @@ export default defineComponent({
const filteredData = computed(() => {
return props.data.filter((item) => {
// Filter by search query
// Common filtering logic
const matchesSearch = item.name
.toLowerCase()
.includes(searchQuery.value.toLowerCase())
.includes(searchQuery.value.toLowerCase());
// Filter by selected filters
const matchesFilters = Object.entries(selectedFilters.value).every(
([key, selectedOptions]) => {
if (selectedOptions.length === 0) return true
if (selectedOptions.length === 0) return true;
const value = getNestedPropertyValue(item, key)
return selectedOptions.includes(value)
const value = getNestedPropertyValue(item, key);
return selectedOptions.includes(value);
}
)
return matchesSearch && matchesFilters
})
})
Expand Down
4 changes: 2 additions & 2 deletions src/models/material.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export type MetricUnits = "m" | "m2" | "m3" | "pcs" | "kg" | "l" | "tonnes"
* Array of possible impact categories to use, increase as needed
*/
export type ExtendedImpactCategoryKey = 'gwp-total' | 'gwp-fossil' | 'gwp-biogenic' | 'gwp-LULUC' | ImpactCategoryKey
export const extendedImpactCategoryKeys: ExtendedImpactCategoryKey[] = [
export const extendedImpactCategoryKeys: readonly ExtendedImpactCategoryKey[] = [
'gwp',
'gwp-total',
'gwp-fossil',
Expand All @@ -99,7 +99,7 @@ export const extendedImpactCategoryKeys: ExtendedImpactCategoryKey[] = [
'pocp',
] as const

export const LifeCycleStages: LifeCycleStage[] = [
export const LifeCycleStages: readonly LifeCycleStage[] = [
'a1a3',
'a4',
'a5',
Expand Down
29 changes: 15 additions & 14 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,22 @@ const beforeEachGuard = async (to: RouteLocationNormalized) => {
// Fetch if the user is authenticated.
await speckleStore.updateUser().then(() => {
logMessageToSentry("Updated current user to: " + speckleStore.getUserInfo?.name, 'info');
})
.then(() => {
// If the route requires authentication and the user is not authenticated, return to the login page.
if (to.meta.requiresAuth && !speckleStore.isAuthenticated) {
if (settingsStore.keySettings.speckleConfig.id == undefined || settingsStore.keySettings.speckleConfig.secret == undefined) {
console.log("Speckle credentials are not set, redirecting to project.")
navigationStore.toggleSettingsModal()
return { name: 'Projects' }
} else {
//logMessageToSentry("User is not authenticated, but the route required it.", 'warning')
console.log("User is not authenticated, but the route required it and keys exists.")
speckleStore.login()
}
}).then(() => {
// If the route requires authentication and the user is not authenticated, return to the login page.
if (to.meta.requiresAuth && !speckleStore.isAuthenticated) {
if (settingsStore.keySettings.speckleConfig.id == undefined || settingsStore.keySettings.speckleConfig.secret == undefined) {
console.log("Speckle credentials are not set, redirecting to project.")
navigationStore.toggleSettingsModal()
return { name: 'Projects' }
} else {
//logMessageToSentry("User is not authenticated, but the route required it.", 'warning')
console.log("User is not authenticated, but the route required it and keys exists.")
speckleStore.login()
return { name: 'Login' }
}
});
}
return true
})
}

router.beforeEach(beforeEachGuard)
Expand Down
4 changes: 2 additions & 2 deletions src/tests/composable.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { FilterRegistry } from '@/models/filters'
import { createStandardFilters } from '@/utils/projectUtils'
//import { createStandardFilters } from '@/utils/projectUtils'
import { useProjectStore } from '@/stores/main'

import type { Group } from '@/models/filters'
import type { GeometryObject } from '@/models/geometryObject'
import type { Project } from '@/models/project'
import type { Unit } from 'lcax'
//import type { Unit } from 'lcax'

import crypto from 'node:crypto'
import { expect, test } from 'vitest'
Expand Down
19 changes: 19 additions & 0 deletions src/utils/dataUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { toRaw, isProxy } from 'vue'

import type { Product, Assembly } from '@/models/material'

/**
* Removes all nested reactivity and returns a raw object
* @param obj json object to convert
Expand Down Expand Up @@ -56,4 +58,21 @@ export const getEnumEntries = (enumObj: any) => {
return Object.keys(enumObj)
.filter((key) => isNaN(Number(key)))
.map((key) => ({ label: key, value: enumObj[key] }))
}

export function isProduct(item: unknown): item is Product {
return (
item !== null &&
typeof item === 'object' &&
'referenceServiceLife' in item
)
}


export function isAssembly(item: unknown): item is Assembly {
return (
item !== null &&
typeof item === 'object' &&
'products' in item
)
}
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default defineConfig({
/**
* Generate sourcemaps for debugging.
*/
outDir: 'dist',
sourcemap: true
},

Expand Down

0 comments on commit 01078eb

Please sign in to comment.