Skip to content

Commit

Permalink
Merge pull request #47 from ullbergm/svelte-info-line
Browse files Browse the repository at this point in the history
Add the ability to display a description below the application name
  • Loading branch information
toboshii authored Sep 9, 2022
2 parents f028b53 + bec977c commit 8e1e921
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 4 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Hajimari looks for specific annotations on ingresses.
| `hajimari.io/group` | A custom group name. Use if you want the application to show in a different group than the namespace it is running in | `false` |
| `hajimari.io/instance` | A comma separated list of name/s of the Hajimari instance/s where you want this application to appear. Use when you have multiple Hajimari instances | `false` |
| `hajimari.io/url` | A URL for the Hajimari app (This will override the ingress URL). It MUST begin with a scheme i.e., `http://` or `https://` | `false` |
| `hajimari.io/info` | A short description of the Hajimari app | `false` |

### Config

Expand Down Expand Up @@ -94,6 +95,7 @@ If you want to add any apps that are not exposed through ingresses or are extern
| name | Name of the custom app | String |
| icon | URL of the icon for the custom app | String |
| url | URL of the custom app | String |
| info | Short description of the custom app | String |
| group | Group for the custom app | String |

#### Bookmarks
Expand Down
4 changes: 3 additions & 1 deletion configv2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ lightTheme: gazette
darkTheme: blackboard
showGreeting: true
showAppGroups: false
showAppInfo: true
showBookmarkGroups: true
customApps:
- group: Media
links:
apps:
- name: Test
url: 'https://example.com'
icon: test-tube
info: This is a test app
- name: Test2
url: 'https://example.net'
icon: test-tube
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/lib/AppList/AppGroup.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
export let group: any;
export let defaultIcon: string = 'mdi:application';
export let showUrl: boolean = true;
export let showInfo: boolean = true;
</script>


Expand All @@ -27,6 +28,9 @@
{#if showUrl === true}
<span class="app_address">{app.url}</span>
{/if}
{#if showInfo === true}
<span class="app_info">{app.info}</span>
{/if}
</div>
</div>
{:else}
Expand Down Expand Up @@ -80,6 +84,10 @@
.app_address {
overflow-wrap: break-word;
}
.app_info {
overflow-wrap: break-word;
}
.app_status {
/* background-image: linear-gradient(to right, black 0 50%, transparent 50% 100%); */
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/lib/AppList/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
export let showGroups: boolean;
export let defaultIcon: string = 'mdi:application';
export let showUrls: boolean = true;
export let showInfo: boolean = true;
</script>
<div class="apps">
<h3>Applications</h3>
Expand All @@ -17,11 +18,11 @@
<div class="links_item">
<h4>{group.group}</h4>
<div class="apps_group">
<AppGroup {group} showUrl={showUrls} defaultIcon={defaultIcon}/>
<AppGroup {group} showUrl={showUrls} showInfo={showInfo} defaultIcon={defaultIcon}/>
</div>
</div>
{:else}
<AppGroup {group} showUrl={showUrls} defaultIcon={defaultIcon}/>
<AppGroup {group} showUrl={showUrls} showInfo={showInfo} defaultIcon={defaultIcon}/>
{/if}
{/each}
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/routes/[...slug]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Greeting name={data.startpage.name} />
{/if}

<AppList apps={data.apps} showGroups={data.startpage.showAppGroups} showUrls={data.startpage.showAppUrls}/>
<AppList apps={data.apps} showGroups={data.startpage.showAppGroups} showUrls={data.startpage.showAppUrls} showInfo={data.startpage.showAppInfo}/>

<BookmarkList bookmarks={data.startpage.bookmarks} showGroups={data.startpage.showBookmarkGroups}/>

Expand Down
1 change: 1 addition & 0 deletions frontend/src/routes/[...slug]/+page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type Startpage = {
showGreeting: boolean;
showAppGroups: boolean;
showAppUrls: boolean;
showAppInfo: boolean;
showBookmarkGroups: boolean;
showGlobalBookmarks: boolean;
bookmarks: any;
Expand Down
2 changes: 2 additions & 0 deletions internal/annotations/annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const (
HajimariInstanceAnnotation = "hajimari.io/instance"
// HajimariURLAnnotation const used for specifying the URL for the hajimari app
HajimariURLAnnotation = "hajimari.io/url"
// HajimariInfoAnnotation const used for specifying the info line for the hajimari app
HajimariInfoAnnotation = "hajimari.io/info"
// HajimariStatusCheckAnnotation boolean used for enabling status indicators.
HajimariStatusCheckEnabledAnnotation = "hajimari.io/statusCheckEnabled"
)
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type Config struct {
ShowGreeting bool `default:"true" json:"showGreeting"`
ShowAppGroups bool `default:"false" json:"showAppGroups"`
ShowAppUrls bool `default:"true" json:"showAppUrls"`
ShowAppInfo bool `default:"true" json:"showAppInfo"`
ShowBookmarkGroups bool `default:"true" json:"showBookmarkGroups"`
ShowGlobalBookmarks bool `default:"false" json:"showGlobalBookmarks"`
CustomApps []models.AppGroup `default:"[]" json:"customApps"`
Expand Down
2 changes: 2 additions & 0 deletions internal/hajimari/ingressapps/apps.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func convertIngressesToHajimariApps(ingresses []v1.Ingress, rsg util.ReplicaStat
Name: wrapper.GetName(),
Icon: wrapper.GetAnnotationValue(annotations.HajimariIconAnnotation),
URL: wrapper.GetURL(),
Info: wrapper.GetInfo(),
Replicas: models.ReplicaInfo{
Total: replicaStatus.GetReplicas(),
Available: replicaStatus.GetAvailableReplicas(),
Expand All @@ -100,6 +101,7 @@ func convertIngressesToHajimariApps(ingresses []v1.Ingress, rsg util.ReplicaStat
Name: wrapper.GetName(),
Icon: wrapper.GetAnnotationValue(annotations.HajimariIconAnnotation),
URL: wrapper.GetURL(),
Info: wrapper.GetInfo(),
})
}
}
Expand Down
8 changes: 8 additions & 0 deletions internal/kube/wrappers/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ func (iw *IngressWrapper) GetGroup() string {
return iw.GetNamespace()
}

// GetGroup func extracts group name from the ingress
func (iw *IngressWrapper) GetInfo() string {
if infoFromAnnotation := iw.GetAnnotationValue(annotations.HajimariInfoAnnotation); infoFromAnnotation != "" {
return infoFromAnnotation
}
return ""
}

// GetStatusCheckEnabled func extracts statusCheck feature gate from the ingress
// @default true
func (iw *IngressWrapper) GetStatusCheckEnabled() bool {
Expand Down
1 change: 1 addition & 0 deletions internal/models/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ type App struct {
Name string `json:"name"`
Icon string `json:"icon"`
URL string `json:"url"`
Info string `json:"info"`
Replicas ReplicaInfo `json:"replicas"`
}
1 change: 1 addition & 0 deletions internal/models/startpage.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ type Startpage struct {
ShowGreeting *bool `json:"showGreeting"`
ShowAppGroups *bool `json:"showAppGroups"`
ShowAppUrls *bool `json:"showAppUrls"`
ShowAppInfo *bool `json:"showAppInfo"`
ShowBookmarkGroups *bool `json:"showBookmarkGroups"`
ShowGlobalBookmarks *bool `json:"showGlobalBookmarks"`
Bookmarks []BookmarkGroup `json:"bookmarks"`
Expand Down
1 change: 1 addition & 0 deletions internal/stores/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var startpages = []*models.Startpage{
ShowAppGroups: pointer.Of(false),
ShowGlobalBookmarks: pointer.Of(true),
ShowAppUrls: pointer.Of(true),
ShowAppInfo: pointer.Of(true),
Bookmarks: []models.BookmarkGroup{
{
Group: "Media",
Expand Down

0 comments on commit 8e1e921

Please sign in to comment.