Add version to ui

This commit is contained in:
Jannis Mattheis
2020-10-04 19:44:26 +02:00
parent ee0a831174
commit 56189c99ea
6 changed files with 42 additions and 31 deletions

View File

@@ -13,7 +13,7 @@ func Run(version, commitHash string) {
Name: "screego",
Version: fmt.Sprintf("%s; screego/server@%s", version, commitHash),
Commands: []cli.Command{
serveCmd,
serveCmd(version),
hashCmd,
},
}

View File

@@ -17,7 +17,8 @@ import (
"github.com/urfave/cli"
)
var serveCmd = cli.Command{
func serveCmd(version string) cli.Command {
return cli.Command{
Name: "serve",
Action: func(ctx *cli.Context) {
@@ -47,9 +48,10 @@ var serveCmd = cli.Command{
go rooms.Start()
r := router.Router(conf, rooms, users)
r := router.Router(conf, rooms, users, version)
if err := server.Start(r, conf.ServerAddress, conf.TLSCertFile, conf.TLSKeyFile); err != nil {
log.Fatal().Err(err).Msg("http server")
}
},
}
}

View File

@@ -16,9 +16,10 @@ type UIConfig struct {
AuthMode string `json:"authMode"`
User string `json:"user"`
LoggedIn bool `json:"loggedIn"`
Version string `json:"version"`
}
func Router(conf config.Config, rooms *ws.Rooms, users *auth.Users) *mux.Router {
func Router(conf config.Config, rooms *ws.Rooms, users *auth.Users, version string) *mux.Router {
router := mux.NewRouter()
router.Use(handlers.CORS(handlers.AllowedMethods([]string{"GET", "POST"}), handlers.AllowedOriginValidator(conf.CheckOrigin)))
router.HandleFunc("/stream", rooms.Upgrade)
@@ -30,6 +31,7 @@ func Router(conf config.Config, rooms *ws.Rooms, users *auth.Users) *mux.Router
AuthMode: conf.AuthMode,
LoggedIn: loggedIn,
User: user,
Version: version,
})
})

View File

@@ -12,6 +12,7 @@ import {
Select,
TextField,
Typography,
Link,
} from '@material-ui/core';
import {FCreateRoom, UseRoom} from './useRoom';
import {RoomMode, UIConfig} from './message';
@@ -144,6 +145,10 @@ export const RoomManage = ({room, config}: {room: FCreateRoom; config: UseConfig
)}
</Paper>
</Grid>
<div style={{position: 'absolute', margin: '0 auto', bottom: 0}}>
Screego {config.version} |{' '}
<Link href="https://github.com/screego/server/">GitHub</Link>
</div>
</Grid>
);
};

View File

@@ -9,6 +9,7 @@ export interface UIConfig {
authMode: 'turn' | 'none' | 'all';
user: string;
loggedIn: boolean;
version: string;
}
export interface RoomConfiguration {

View File

@@ -16,6 +16,7 @@ export const useConfig = (): UseConfig => {
user: 'guest',
loggedIn: false,
loading: true,
version: 'unknown',
});
const refetch = React.useCallback(() => {