-
Notifications
You must be signed in to change notification settings - Fork 131
Add BlueOS cutomization #3930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
patrickelectric
wants to merge
15
commits into
bluerobotics:master
Choose a base branch
from
patrickelectric:custom-theme2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add BlueOS cutomization #3930
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
550a5c0
core: services: customization: First commit
patrickelectric 5826002
core: start-blueos-core: Add customization service
patrickelectric b6ab7d0
core: pyproject: Add customization service
patrickelectric 870d18a
core: tools: nginx: Add customization proxy
patrickelectric 2257e6f
core: frontend: vite.config: Add customization
patrickelectric 8c2077d
frontend: Add customization components, libraries, store and types
patrickelectric d6cac3e
frontend: types: frontend_services: register customization service
patrickelectric 14a8001
frontend: vehiclesetup: GenericViewer: Deal with model_override_path …
patrickelectric 1629356
frontend: vehiclesetup: GenericViewer: Add event listener and refresh…
patrickelectric 248e09f
frontend: vehiclesetup: GenericViewer: Deal with axios if it fails
patrickelectric 6a10cff
frontend: app: VehicleBanner: Handle custom banner
patrickelectric 26953cf
frontend: App: Deal with branding changes
patrickelectric 6eb2410
frontend: views: SettingsView: Show theme customization
patrickelectric 0b8f82b
frontend: app: VehicleBanner: Handle customization
patrickelectric 1aa82f2
frontend: app: VehicleBanner: Handle customization
patrickelectric File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
core/frontend/src/components/customization/BrandingUploader.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| <template> | ||
| <v-card outlined class="pa-3"> | ||
| <div class="d-flex align-center"> | ||
| <v-avatar tile size="64" color="grey lighten-3" class="mr-3"> | ||
| <v-img v-if="asset?.url" :src="asset.url" contain /> | ||
| <v-icon v-else color="grey"> | ||
| mdi-image-off-outline | ||
| </v-icon> | ||
| </v-avatar> | ||
| <div class="flex-grow-1"> | ||
| <div v-if="asset?.url" class="text-body-2"> | ||
| <a :href="asset.url" target="_blank" rel="noopener noreferrer"> | ||
| {{ asset.url.split('/').pop() }} | ||
| </a> | ||
| </div> | ||
| <div v-else class="text-caption text--secondary"> | ||
| {{ emptyLabel }} | ||
| </div> | ||
| <div v-if="asset?.size_bytes" class="text-caption text--secondary"> | ||
| {{ formatSize(asset.size_bytes) }} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| <div class="d-flex justify-end mt-2"> | ||
| <v-btn | ||
| v-tooltip="'Upload a new file'" | ||
| outlined | ||
| small | ||
| color="primary" | ||
| :loading="uploading" | ||
| @click="trigger_picker" | ||
| > | ||
| <v-icon left small> | ||
| mdi-upload | ||
| </v-icon> | ||
| {{ uploadLabel }} | ||
| </v-btn> | ||
| <v-btn | ||
| v-if="asset?.url" | ||
| v-tooltip="'Remove the custom file'" | ||
| outlined | ||
| small | ||
| color="error" | ||
| class="ml-2" | ||
| @click="$emit('remove')" | ||
| > | ||
| <v-icon left small> | ||
| mdi-trash-can | ||
| </v-icon> | ||
| Remove | ||
| </v-btn> | ||
| </div> | ||
| <label class="d-none"> | ||
| Upload file | ||
| <input | ||
| ref="file_input" | ||
| type="file" | ||
| :accept="accept" | ||
| @change="on_file_change" | ||
| > | ||
| </label> | ||
| </v-card> | ||
| </template> | ||
|
|
||
| <script lang="ts"> | ||
| import Vue, { PropType } from 'vue' | ||
|
|
||
| import { BrandingAsset } from '@/types/customization' | ||
| import { prettifySize } from '@/utils/helper_functions' | ||
|
|
||
| export default Vue.extend({ | ||
| name: 'BrandingUploader', | ||
|
|
||
| props: { | ||
| asset: { | ||
| type: Object as PropType<BrandingAsset | null>, | ||
| default: null, | ||
| }, | ||
| accept: { | ||
| type: String, | ||
| default: 'image/*', | ||
| }, | ||
| uploading: { | ||
| type: Boolean, | ||
| default: false, | ||
| }, | ||
| emptyLabel: { | ||
| type: String, | ||
| default: 'No file uploaded.', | ||
| }, | ||
| uploadLabel: { | ||
| type: String, | ||
| default: 'Upload', | ||
| }, | ||
| }, | ||
|
|
||
| methods: { | ||
| formatSize(bytes: number): string { | ||
| return prettifySize(bytes / 1024) | ||
| }, | ||
|
|
||
| trigger_picker(): void { | ||
| const input = this.$refs.file_input as HTMLInputElement | undefined | ||
| input?.click() | ||
| }, | ||
|
|
||
| on_file_change(event: Event): void { | ||
| const input = event.target as HTMLInputElement | ||
| const file = input.files?.[0] | ||
| if (file) { | ||
| this.$emit('upload', file) | ||
| } | ||
| input.value = '' | ||
| }, | ||
| }, | ||
| }) | ||
| </script> | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (bug_risk): Branding previews ignore the cache-busting logic used elsewhere for logo/vehicle images.
The store’s
brandingVersionis used to build cache-bustedlogoUrl/vehicleImageUrlwith?v=..., but this component bypasses that by usingasset.urldirectly. WhenThemeCustomizationpassescustomization_store.logo/vehicleImage, the preview can remain stale after updates. Please either pass in the already cache-busted URLs (e.g. dedicated preview URL props) or change this component to take a plainsrcso callers can handle cache-busting themselves.Suggested implementation:
To fully wire this up you should also:
Expose a
previewUrlprop (or equivalent) on this component<script>block ofBrandingUploader.vue, add apreviewUrl: { type: String, default: '' }prop (orpreviewUrl?: stringviadefinePropsif using<script setup>).assetprop if it’s still used for other metadata; it just won’t be used for the preview URL anymore.Update all call sites of
BrandingUploaderassetwith.urlthat should be cache-busted (e.g.customization_store.logo,vehicleImage), construct the URL with branding versioning and pass it in::preview-url="brandingStore.logoUrl"or:preview-url="${customization_store.logo.url}?v=${brandingVersion}"depending on your existing helpers.assetfor other data, continue to pass it alongsidepreview-url.Optional: backward compatibility
previewUrlthat falls back toasset?.urlwhen thepreviewUrlprop is not provided, then switch call sites gradually:previewUrlused in the template above.