should add the custom element compile js file to the release.

This commit is contained in:
Snider 2025-11-09 19:06:05 +00:00
parent 9093ce16e9
commit 6fd424f562
11 changed files with 7989 additions and 788 deletions

View file

@ -27,6 +27,17 @@ jobs:
with:
go-version: stable
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
# - name: Build UI
# run: |
# cd ui
# npm install
# npm run build
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:

View file

@ -7,6 +7,8 @@ before:
hooks:
- go mod tidy
- go test ./...
# Build the UI for the release
- sh -c 'cd ui && npm install && npm run build'
builds:
- id: mining-cli
@ -45,6 +47,10 @@ archives:
files:
- README.md
- LICENSE
# Add the compiled UI to the archive.
# This will place the contents of ui/dist into a 'ui' directory in the archive.
- src: ui/dist/**/*
dst: ui
checksum:
name_template: 'checksums.txt'

View file

@ -105,7 +105,7 @@ package:
# Development workflow
dev: tidy docs build
@echo "Starting development server..."
./$(BINARY_NAME) serve --host 127.0.0.1 --port 9090 --namespace /api/v1/mining
./$(BINARY_NAME) serve --host localhost --port 9090 --namespace /api/v1/mining
# Help
help:

5
go.mod
View file

@ -5,6 +5,7 @@ go 1.24.0
require (
github.com/Masterminds/semver/v3 v3.3.1
github.com/adrg/xdg v0.5.3
github.com/gin-contrib/cors v1.7.6
github.com/gin-gonic/gin v1.11.0
github.com/shirou/gopsutil/v4 v4.25.10
github.com/spf13/cobra v1.8.1
@ -19,7 +20,7 @@ require (
github.com/bytedance/sonic/loader v0.3.0 // indirect
github.com/cloudwego/base64x v0.1.6 // indirect
github.com/ebitengine/purego v0.9.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.8 // indirect
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
github.com/gin-contrib/sse v1.1.0 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.22.1 // indirect
@ -35,7 +36,7 @@ require (
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.27.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/goccy/go-json v0.10.5 // indirect
github.com/goccy/go-yaml v1.18.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect

10
go.sum
View file

@ -16,8 +16,10 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ebitengine/purego v0.9.0 h1:mh0zpKBIXDceC63hpvPuGLiJ8ZAa3DfrFTudmfi8A4k=
github.com/ebitengine/purego v0.9.0/go.mod h1:iIjxzd6CiRiOG0UyXP+V1+jWqUXVjPKLAI0mRfJZTmQ=
github.com/gabriel-vasile/mimetype v1.4.8 h1:FfZ3gj38NjllZIeJAmMhr+qKL8Wu+nOoI3GqacKw1NM=
github.com/gabriel-vasile/mimetype v1.4.8/go.mod h1:ByKUIKGjh1ODkGM1asKUbQZOLGrPjydw3hYPU2YU9t8=
github.com/gabriel-vasile/mimetype v1.4.9 h1:5k+WDwEsD9eTLL8Tz3L0VnmVh9QxGjRmjBvAG7U/oYY=
github.com/gabriel-vasile/mimetype v1.4.9/go.mod h1:WnSQhFKJuBlRyLiKohA/2DtIlPFAbguNaG7QCHcyGok=
github.com/gin-contrib/cors v1.7.6 h1:3gQ8GMzs1Ylpf70y8bMw4fVpycXIeX1ZemuSQIsnQQY=
github.com/gin-contrib/cors v1.7.6/go.mod h1:Ulcl+xN4jel9t1Ry8vqph23a60FwH9xVLd+3ykmTjOk=
github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4=
github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk=
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
@ -58,8 +60,8 @@ github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJn
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.27.0 h1:w8+XrWVMhGkxOaaowyKH35gFydVHOvC0/uWoy2Fzwn4=
github.com/go-playground/validator/v10 v10.27.0/go.mod h1:I5QpIEbmr8On7W0TktmJAumgzX4CA1XNl4ZmDuVHKKo=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
github.com/goccy/go-yaml v1.18.0 h1:8W7wMFS12Pcas7KU+VVkaiCng+kG8QiFeFwzFb+rwuw=
github.com/goccy/go-yaml v1.18.0/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=

View file

@ -14,6 +14,7 @@ import (
"github.com/Masterminds/semver/v3"
"github.com/Snider/Mining/docs"
"github.com/gin-contrib/cors"
"github.com/gin-gonic/gin"
"github.com/shirou/gopsutil/v4/mem" // Import mem for memory stats
"github.com/swaggo/swag"
@ -50,6 +51,7 @@ func NewService(manager *Manager, listenAddr string, displayAddr string, swagger
func (s *Service) ServiceStartup(ctx context.Context) error {
s.Router = gin.Default()
s.Router.Use(cors.Default())
s.setupRoutes()
s.Server.Handler = s.Router

View file

@ -16,6 +16,9 @@
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": [
"zone.js"
],
"tsConfig": "tsconfig.app.json",
"assets": [
{
@ -25,11 +28,9 @@
],
"styles": [
"src/styles.css",
"node_modules/@shoelace-style/shoelace/dist/themes/light.css"
],
"scripts": [
"node_modules/@shoelace-style/shoelace/dist/shoelace.js"
"node_modules/@awesome.me/webawesome/dist/styles/themes/awesome.css"
],
"scripts": [],
"outputHashing": "none",
"namedChunks": false,
"optimization": true
@ -93,5 +94,8 @@
}
}
}
},
"cli": {
"analytics": false
}
}

8641
ui/package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -22,12 +22,17 @@
},
"private": true,
"dependencies": {
"@angular-devkit/build-angular": "^20.3.9",
"@angular/common": "^20.3.0",
"@angular/compiler": "^20.3.0",
"@angular/core": "^20.3.0",
"@angular/elements": "^20.3.10",
"@angular/forms": "^20.3.0",
"@angular/platform-browser": "^20.3.0",
"@angular/router": "^20.3.0",
"@awesome.me/webawesome": "^3.0.0",
"install": "^0.13.0",
"npm": "^11.6.2",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
@ -45,4 +50,4 @@
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.9.2"
}
}
}

View file

@ -1,13 +1,21 @@
import { Component, OnInit, Input, OnDestroy, ElementRef, ViewEncapsulation } from '@angular/core';
import {
Component,
OnInit,
Input,
OnDestroy,
ElementRef,
ViewEncapsulation,
CUSTOM_ELEMENTS_SCHEMA
} from '@angular/core';
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { CommonModule } from '@angular/common';
import { interval, Subscription } from 'rxjs';
import { switchMap, startWith } from 'rxjs/operators';
import "@awesome.me/webawesome/dist/webawesome.js";
// Import Shoelace components
import '@shoelace-style/shoelace/dist/components/card/card.js';
import '@shoelace-style/shoelace/dist/components/button/button.js';
import '@shoelace-style/shoelace/dist/components/icon/icon.js';
import '@awesome.me/webawesome/dist/components/card/card.js';
import '@awesome.me/webawesome/dist/components/button/button.js';
import '@awesome.me/webawesome/dist/components/icon/icon.js';
// Add other Shoelace components as needed for your UI
interface HashratePoint {
@ -18,11 +26,12 @@ interface HashratePoint {
@Component({
selector: 'mde-mining-dashboard', // This will be your custom element tag
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [CommonModule, HttpClientModule], // HttpClientModule is needed for HttpClient
template: `
<sl-card class="mining-dashboard-card">
<wa-card class="mining-dashboard-card">
<div slot="header" class="card-header">
<sl-icon name="cpu"></sl-icon>
<wa-icon name="cpu"></wa-icon>
<h3>Mining Dashboard: {{ minerName }}</h3>
</div>
@ -45,42 +54,42 @@ interface HashratePoint {
</div>
<div slot="footer" class="card-footer">
<sl-button variant="primary" (click)="fetchHashrate()">Refresh</sl-button>
<sl-button variant="text" (click)="toggleDetails()">{{ showDetails ? 'Hide Details' : 'Show Details' }}</sl-button>
<wa-button variant="brand" (click)="fetchHashrate()">Refresh</wa-button>
<wa-button variant="neutral" (click)="toggleDetails()">{{ showDetails ? 'Hide Details' : 'Show Details' }}</wa-button>
</div>
<div *ngIf="showDetails" class="details-section">
<h5>Raw History Data:</h5>
<pre>{{ hashrateHistory | json }}</pre>
</div>
</sl-card>
</wa-card>
`,
styles: [`
.mining-dashboard-card {
width: 100%;
max-width: 500px;
margin: 20px auto;
border: 1px solid var(--sl-color-neutral-300);
border-radius: var(--sl-border-radius-medium);
box-shadow: var(--sl-shadow-medium);
border: 1px solid var(--wa-color-neutral-300);
border-radius: var(--wa-border-radius-medium);
box-shadow: var(--wa-shadow-medium);
}
.card-header {
display: flex;
align-items: center;
gap: 10px;
padding: var(--sl-spacing-medium);
border-bottom: 1px solid var(--sl-color-neutral-200);
padding: var(--wa-spacing-medium);
border-bottom: 1px solid var(--wa-color-neutral-200);
}
.card-header h3 {
margin: 0;
font-size: var(--sl-font-size-large);
font-size: var(--wa-font-size-large);
}
.card-header sl-icon {
font-size: var(--sl-font-size-x-large);
color: var(--sl-color-primary-500);
font-size: var(--wa-font-size-x-large);
color: var(--wa-color-primary-500);
}
.error-message {
color: var(--sl-color-danger-500);
color: var(--wa-color-danger-500);
font-weight: bold;
}
.history-list {
@ -88,14 +97,14 @@ interface HashratePoint {
padding: 0;
max-height: 150px;
overflow-y: auto;
border: 1px solid var(--sl-color-neutral-100);
border-radius: var(--sl-border-radius-small);
padding: var(--sl-spacing-x-small);
background-color: var(--sl-color-neutral-50);
border: 1px solid var(--wa-color-neutral-100);
border-radius: var(--wa-border-radius-small);
padding: var(--wa-spacing-x-small);
background-color: var(--wa-color-neutral-50);
}
.history-list li {
padding: var(--sl-spacing-2x-small) 0;
border-bottom: 1px dotted var(--sl-color-neutral-100);
padding: var(--wa-spacing-2x-small) 0;
border-bottom: 1px dotted var(--wa-color-neutral-100);
}
.history-list li:last-child {
border-bottom: none;
@ -103,21 +112,21 @@ interface HashratePoint {
.card-footer {
display: flex;
justify-content: flex-end;
gap: var(--sl-spacing-small);
padding-top: var(--sl-spacing-medium);
border-top: 1px solid var(--sl-color-neutral-200);
gap: var(--wa-spacing-small);
padding-top: var(--wa-spacing-medium);
border-top: 1px solid var(--wa-color-neutral-200);
}
.details-section {
margin-top: var(--sl-spacing-medium);
padding: var(--sl-spacing-small);
background-color: var(--sl-color-neutral-50);
border: 1px solid var(--sl-color-neutral-200);
border-radius: var(--sl-border-radius-small);
margin-top: var(--wa-spacing-medium);
padding: var(--wa-spacing-small);
background-color: var(--wa-color-neutral-50);
border: 1px solid var(--wa-color-neutral-200);
border-radius: var(--wa-border-radius-small);
}
.details-section pre {
white-space: pre-wrap;
word-break: break-all;
font-size: var(--sl-font-size-x-small);
font-size: var(--wa-font-size-x-small);
max-height: 200px;
overflow-y: auto;
}
@ -126,7 +135,7 @@ interface HashratePoint {
})
export class MiningDashboardElementComponent implements OnInit, OnDestroy {
@Input() minerName: string = 'xmrig'; // Default miner name
@Input() apiBaseUrl: string = 'http://127.0.0.1:9090/api/v1/mining'; // Default API base URL
@Input() apiBaseUrl: string = 'http://localhost:9090/api/v1/mining'; // Default API base URL
hashrateHistory: HashratePoint[] = [];
currentHashrate: number = 0;

View file

@ -8,6 +8,6 @@
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<app-root></app-root>
<mde-mining-dashboard></mde-mining-dashboard>
</body>
</html>