mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
display icons based on mime type (#2271)
* display icons based on mime type * Update frontend/projects/marketplace/src/pipes/mime-type.pipe.ts Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com> * fixes --------- Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
<ion-item class="service-card" [routerLink]="['/marketplace', pkg.manifest.id]">
|
<ion-item class="service-card" [routerLink]="['/marketplace', pkg.manifest.id]">
|
||||||
<ion-thumbnail slot="start">
|
<ion-thumbnail slot="start">
|
||||||
<img alt="" [src]="'data:image/png;base64,' + pkg.icon | trustUrl" />
|
<img alt="" [src]="pkg | mimeType | trustUrl" />
|
||||||
</ion-thumbnail>
|
</ion-thumbnail>
|
||||||
<ion-label>
|
<ion-label>
|
||||||
<h2 class="montserrat">
|
<h2 class="montserrat">
|
||||||
|
|||||||
@@ -3,12 +3,18 @@ import { NgModule } from '@angular/core'
|
|||||||
import { IonicModule } from '@ionic/angular'
|
import { IonicModule } from '@ionic/angular'
|
||||||
import { RouterModule } from '@angular/router'
|
import { RouterModule } from '@angular/router'
|
||||||
import { SharedPipesModule } from '@start9labs/shared'
|
import { SharedPipesModule } from '@start9labs/shared'
|
||||||
|
|
||||||
import { ItemComponent } from './item.component'
|
import { ItemComponent } from './item.component'
|
||||||
|
import { MimeTypePipeModule } from '../../../pipes/mime-type.pipe'
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [CommonModule, IonicModule, RouterModule, SharedPipesModule],
|
|
||||||
declarations: [ItemComponent],
|
declarations: [ItemComponent],
|
||||||
exports: [ItemComponent],
|
exports: [ItemComponent],
|
||||||
|
imports: [
|
||||||
|
CommonModule,
|
||||||
|
IonicModule,
|
||||||
|
RouterModule,
|
||||||
|
SharedPipesModule,
|
||||||
|
MimeTypePipeModule,
|
||||||
|
],
|
||||||
})
|
})
|
||||||
export class ItemModule {}
|
export class ItemModule {}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export class DependenciesComponent {
|
|||||||
pkg!: MarketplacePkg
|
pkg!: MarketplacePkg
|
||||||
|
|
||||||
getImg(key: string): string {
|
getImg(key: string): string {
|
||||||
|
// @TODO fix when registry api is updated to include mimetype in icon url
|
||||||
return 'data:image/png;base64,' + this.pkg['dependency-metadata'][key].icon
|
return 'data:image/png;base64,' + this.pkg['dependency-metadata'][key].icon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
<div class="header montserrat">
|
<div class="header montserrat">
|
||||||
<img
|
<img class="logo" alt="" [src]="pkg | mimeType | trustUrl" />
|
||||||
class="logo"
|
|
||||||
alt=""
|
|
||||||
[src]="'data:image/png;base64,' + pkg.icon | trustUrl"
|
|
||||||
/>
|
|
||||||
<div class="text">
|
<div class="text">
|
||||||
<h1 ticker class="title">{{ pkg.manifest.title }}</h1>
|
<h1 ticker class="title">{{ pkg.manifest.title }}</h1>
|
||||||
<p class="version">{{ pkg.manifest.version | displayEmver }}</p>
|
<p class="version">{{ pkg.manifest.version | displayEmver }}</p>
|
||||||
|
|||||||
@@ -8,16 +8,18 @@ import {
|
|||||||
} from '@start9labs/shared'
|
} from '@start9labs/shared'
|
||||||
|
|
||||||
import { PackageComponent } from './package.component'
|
import { PackageComponent } from './package.component'
|
||||||
|
import { MimeTypePipeModule } from '../../../pipes/mime-type.pipe'
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
declarations: [PackageComponent],
|
||||||
|
exports: [PackageComponent],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
IonicModule,
|
IonicModule,
|
||||||
SharedPipesModule,
|
SharedPipesModule,
|
||||||
EmverPipesModule,
|
EmverPipesModule,
|
||||||
TickerModule,
|
TickerModule,
|
||||||
|
MimeTypePipeModule,
|
||||||
],
|
],
|
||||||
declarations: [PackageComponent],
|
|
||||||
exports: [PackageComponent],
|
|
||||||
})
|
})
|
||||||
export class PackageModule {}
|
export class PackageModule {}
|
||||||
|
|||||||
29
frontend/projects/marketplace/src/pipes/mime-type.pipe.ts
Normal file
29
frontend/projects/marketplace/src/pipes/mime-type.pipe.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { NgModule, Pipe, PipeTransform } from '@angular/core'
|
||||||
|
import { MarketplacePkg } from '../types'
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'mimeType',
|
||||||
|
})
|
||||||
|
export class MimeTypePipe implements PipeTransform {
|
||||||
|
transform(pkg: MarketplacePkg): string {
|
||||||
|
switch (pkg.manifest.assets.icon.split('.').pop()) {
|
||||||
|
case 'png':
|
||||||
|
return `data:image/png;base64,${pkg.icon}`
|
||||||
|
case 'jpeg':
|
||||||
|
case 'jpg':
|
||||||
|
return `data:image/jpeg;base64,${pkg.icon}`
|
||||||
|
case 'gif':
|
||||||
|
return `data:image/gif;base64,${pkg.icon}`
|
||||||
|
case 'svg':
|
||||||
|
return `data:image/svg+xml;base64,${pkg.icon}`
|
||||||
|
default:
|
||||||
|
return `data:image/png;base64,${pkg.icon}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NgModule({
|
||||||
|
declarations: [MimeTypePipe],
|
||||||
|
exports: [MimeTypePipe],
|
||||||
|
})
|
||||||
|
export class MimeTypePipeModule {}
|
||||||
@@ -22,6 +22,7 @@ export * from './pages/show/package/package.component'
|
|||||||
export * from './pages/show/package/package.module'
|
export * from './pages/show/package/package.module'
|
||||||
|
|
||||||
export * from './pipes/filter-packages.pipe'
|
export * from './pipes/filter-packages.pipe'
|
||||||
|
export * from './pipes/mime-type.pipe'
|
||||||
|
|
||||||
export * from './services/marketplace.service'
|
export * from './services/marketplace.service'
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,9 @@ export interface MarketplaceManifest<T = unknown> {
|
|||||||
short: string
|
short: string
|
||||||
long: string
|
long: string
|
||||||
}
|
}
|
||||||
|
assets: {
|
||||||
|
icon: string // ie. icon.png
|
||||||
|
}
|
||||||
replaces?: string[]
|
replaces?: string[]
|
||||||
'release-notes': string
|
'release-notes': string
|
||||||
license: string // type of license
|
license: string // type of license
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 18 KiB |
@@ -1,18 +1,18 @@
|
|||||||
import { NgModule } from '@angular/core'
|
import { NgModule } from '@angular/core'
|
||||||
import { CommonModule } from '@angular/common'
|
import { CommonModule } from '@angular/common'
|
||||||
import { Routes, RouterModule } from '@angular/router'
|
import { RouterModule, Routes } from '@angular/router'
|
||||||
import { IonicModule } from '@ionic/angular'
|
import { IonicModule } from '@ionic/angular'
|
||||||
import {
|
import {
|
||||||
SharedPipesModule,
|
|
||||||
EmverPipesModule,
|
EmverPipesModule,
|
||||||
MarkdownPipeModule,
|
MarkdownPipeModule,
|
||||||
|
SharedPipesModule,
|
||||||
TextSpinnerComponentModule,
|
TextSpinnerComponentModule,
|
||||||
} from '@start9labs/shared'
|
} from '@start9labs/shared'
|
||||||
import {
|
import {
|
||||||
PackageModule,
|
|
||||||
AboutModule,
|
AboutModule,
|
||||||
AdditionalModule,
|
AdditionalModule,
|
||||||
DependenciesModule,
|
DependenciesModule,
|
||||||
|
PackageModule,
|
||||||
} from '@start9labs/marketplace'
|
} from '@start9labs/marketplace'
|
||||||
import { MarketplaceStatusModule } from '../marketplace-status/marketplace-status.module'
|
import { MarketplaceStatusModule } from '../marketplace-status/marketplace-status.module'
|
||||||
import { MarketplaceShowPage } from './marketplace-show.page'
|
import { MarketplaceShowPage } from './marketplace-show.page'
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import { SkeletonListComponentModule } from 'src/app/components/skeleton-list/sk
|
|||||||
import { RoundProgressModule } from 'angular-svg-round-progressbar'
|
import { RoundProgressModule } from 'angular-svg-round-progressbar'
|
||||||
import { InstallProgressPipeModule } from 'src/app/pipes/install-progress/install-progress.module'
|
import { InstallProgressPipeModule } from 'src/app/pipes/install-progress/install-progress.module'
|
||||||
import { StoreIconComponentModule } from 'src/app/components/store-icon/store-icon.component.module'
|
import { StoreIconComponentModule } from 'src/app/components/store-icon/store-icon.component.module'
|
||||||
|
import { MimeTypePipeModule } from '@start9labs/marketplace'
|
||||||
|
|
||||||
const routes: Routes = [
|
const routes: Routes = [
|
||||||
{
|
{
|
||||||
@@ -23,6 +24,7 @@ const routes: Routes = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
declarations: [UpdatesPage, FilterUpdatesPipe],
|
||||||
imports: [
|
imports: [
|
||||||
CommonModule,
|
CommonModule,
|
||||||
IonicModule,
|
IonicModule,
|
||||||
@@ -35,7 +37,7 @@ const routes: Routes = [
|
|||||||
InstallProgressPipeModule,
|
InstallProgressPipeModule,
|
||||||
StoreIconComponentModule,
|
StoreIconComponentModule,
|
||||||
EmverPipesModule,
|
EmverPipesModule,
|
||||||
|
MimeTypePipeModule,
|
||||||
],
|
],
|
||||||
declarations: [UpdatesPage, FilterUpdatesPipe],
|
|
||||||
})
|
})
|
||||||
export class UpdatesPageModule {}
|
export class UpdatesPageModule {}
|
||||||
|
|||||||
@@ -33,9 +33,7 @@
|
|||||||
<ion-accordion *ngIf="data.localPkgs[pkg.manifest.id] as local">
|
<ion-accordion *ngIf="data.localPkgs[pkg.manifest.id] as local">
|
||||||
<ion-item lines="none" slot="header">
|
<ion-item lines="none" slot="header">
|
||||||
<ion-avatar slot="start" style="width: 50px; height: 50px">
|
<ion-avatar slot="start" style="width: 50px; height: 50px">
|
||||||
<img
|
<img [src]="pkg | mimeType | trustUrl" />
|
||||||
[src]="'data:image/png;base64,' + pkg.icon | trustUrl"
|
|
||||||
/>
|
|
||||||
</ion-avatar>
|
</ion-avatar>
|
||||||
<ion-label>
|
<ion-label>
|
||||||
<h1 style="line-height: 1.3">{{ pkg.manifest.title }}</h1>
|
<h1 style="line-height: 1.3">{{ pkg.manifest.title }}</h1>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
PackageState,
|
PackageState,
|
||||||
ServerStatusInfo,
|
ServerStatusInfo,
|
||||||
} from 'src/app/services/patch-db/data-model'
|
} from 'src/app/services/patch-db/data-model'
|
||||||
import { Metric, RR, NotificationLevel, ServerNotifications } from './api.types'
|
import { Metric, NotificationLevel, RR, ServerNotifications } from './api.types'
|
||||||
|
|
||||||
import { BTC_ICON, LND_ICON, PROXY_ICON } from './api-icons'
|
import { BTC_ICON, LND_ICON, PROXY_ICON } from './api-icons'
|
||||||
import { DependencyMetadata, MarketplacePkg } from '@start9labs/marketplace'
|
import { DependencyMetadata, MarketplacePkg } from '@start9labs/marketplace'
|
||||||
@@ -1873,7 +1873,7 @@ export module Mock {
|
|||||||
state: PackageState.Installed,
|
state: PackageState.Installed,
|
||||||
'static-files': {
|
'static-files': {
|
||||||
license: '/public/package-data/bitcoind/0.20.0/LICENSE.md',
|
license: '/public/package-data/bitcoind/0.20.0/LICENSE.md',
|
||||||
icon: '/assets/img/service-icons/bitcoind.png',
|
icon: '/assets/img/service-icons/bitcoind.svg',
|
||||||
instructions: '/public/package-data/bitcoind/0.20.0/INSTRUCTIONS.md',
|
instructions: '/public/package-data/bitcoind/0.20.0/INSTRUCTIONS.md',
|
||||||
},
|
},
|
||||||
manifest: MockManifestBitcoind,
|
manifest: MockManifestBitcoind,
|
||||||
@@ -1958,7 +1958,7 @@ export module Mock {
|
|||||||
'dependency-info': {
|
'dependency-info': {
|
||||||
bitcoind: {
|
bitcoind: {
|
||||||
manifest: Mock.MockManifestBitcoind,
|
manifest: Mock.MockManifestBitcoind,
|
||||||
icon: 'assets/img/service-icons/bitcoind.png',
|
icon: 'assets/img/service-icons/bitcoind.svg',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'marketplace-url': 'https://registry.start9.com/',
|
'marketplace-url': 'https://registry.start9.com/',
|
||||||
@@ -2014,7 +2014,7 @@ export module Mock {
|
|||||||
'dependency-info': {
|
'dependency-info': {
|
||||||
bitcoind: {
|
bitcoind: {
|
||||||
manifest: Mock.MockManifestBitcoind,
|
manifest: Mock.MockManifestBitcoind,
|
||||||
icon: 'assets/img/service-icons/bitcoind.png',
|
icon: 'assets/img/service-icons/bitcoind.svg',
|
||||||
},
|
},
|
||||||
'btc-rpc-proxy': {
|
'btc-rpc-proxy': {
|
||||||
manifest: Mock.MockManifestBitcoinProxy,
|
manifest: Mock.MockManifestBitcoinProxy,
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export const mockPatchData: DataModel = {
|
|||||||
state: PackageState.Installed,
|
state: PackageState.Installed,
|
||||||
'static-files': {
|
'static-files': {
|
||||||
license: '/public/package-data/bitcoind/0.20.0/LICENSE.md',
|
license: '/public/package-data/bitcoind/0.20.0/LICENSE.md',
|
||||||
icon: '/assets/img/service-icons/bitcoind.png',
|
icon: '/assets/img/service-icons/bitcoind.svg',
|
||||||
instructions: '/public/package-data/bitcoind/0.20.0/INSTRUCTIONS.md',
|
instructions: '/public/package-data/bitcoind/0.20.0/INSTRUCTIONS.md',
|
||||||
},
|
},
|
||||||
manifest: {
|
manifest: {
|
||||||
@@ -670,7 +670,7 @@ export const mockPatchData: DataModel = {
|
|||||||
manifest: {
|
manifest: {
|
||||||
title: 'Bitcoin Core',
|
title: 'Bitcoin Core',
|
||||||
} as Manifest,
|
} as Manifest,
|
||||||
icon: 'assets/img/service-icons/bitcoind.png',
|
icon: 'assets/img/service-icons/bitcoind.svg',
|
||||||
},
|
},
|
||||||
'btc-rpc-proxy': {
|
'btc-rpc-proxy': {
|
||||||
manifest: {
|
manifest: {
|
||||||
|
|||||||
Reference in New Issue
Block a user