mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-01-29 01:28:59 -05:00
feat: show version and show button if new release is available on admin page
This commit is contained in:
parent
167f0f8c7a
commit
71658ad39d
8 changed files with 103 additions and 47 deletions
4
backend/package-lock.json
generated
4
backend/package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "pingvin-share-backend",
|
"name": "pingvin-share-backend",
|
||||||
"version": "0.0.1",
|
"version": "0.5.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pingvin-share-backend",
|
"name": "pingvin-share-backend",
|
||||||
"version": "0.0.1",
|
"version": "0.5.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@nestjs/common": "^9.2.1",
|
"@nestjs/common": "^9.2.1",
|
||||||
"@nestjs/config": "^2.2.0",
|
"@nestjs/config": "^2.2.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "pingvin-share-backend",
|
"name": "pingvin-share-backend",
|
||||||
"version": "0.0.1",
|
"version": "0.5.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nest build",
|
"build": "nest build",
|
||||||
"dev": "nest start --watch",
|
"dev": "nest start --watch",
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
/** @type {import('next').NextConfig} */
|
/** @type {import('next').NextConfig} */
|
||||||
|
|
||||||
|
const { version } = require('./package.json');
|
||||||
|
|
||||||
const withPWA = require("next-pwa")({
|
const withPWA = require("next-pwa")({
|
||||||
dest: "public",
|
dest: "public",
|
||||||
disable: process.env.NODE_ENV == "development",
|
disable: process.env.NODE_ENV == "development",
|
||||||
});
|
});
|
||||||
|
|
||||||
module.exports = withPWA({ output: "standalone" });
|
module.exports = withPWA({
|
||||||
|
output: "standalone", env: {
|
||||||
|
VERSION: version,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
8
frontend/package-lock.json
generated
8
frontend/package-lock.json
generated
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "pingvin-share",
|
"name": "pingvin-share-frontend",
|
||||||
"version": "0.0.1",
|
"version": "0.5.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "pingvin-share",
|
"name": "pingvin-share-frontend",
|
||||||
"version": "0.0.1",
|
"version": "0.5.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@emotion/react": "^11.10.5",
|
"@emotion/react": "^11.10.5",
|
||||||
"@emotion/server": "^11.10.0",
|
"@emotion/server": "^11.10.0",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "pingvin-share",
|
"name": "pingvin-share-frontend",
|
||||||
"version": "0.0.1",
|
"version": "0.5.0",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
|
|
|
@ -28,7 +28,6 @@ function App({ Component, pageProps }: AppProps) {
|
||||||
const systemTheme = useColorScheme();
|
const systemTheme = useColorScheme();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const preferences = usePreferences();
|
const preferences = usePreferences();
|
||||||
|
|
||||||
const [colorScheme, setColorScheme] = useState<ColorScheme>("light");
|
const [colorScheme, setColorScheme] = useState<ColorScheme>("light");
|
||||||
const [isLoading, setIsLoading] = useState(true);
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
const [user, setUser] = useState<CurrentUser | null>(null);
|
const [user, setUser] = useState<CurrentUser | null>(null);
|
||||||
|
@ -89,7 +88,7 @@ function App({ Component, pageProps }: AppProps) {
|
||||||
<Container>
|
<Container>
|
||||||
<Component {...pageProps} />
|
<Component {...pageProps} />
|
||||||
</Container>
|
</Container>
|
||||||
</UserContext.Provider>{" "}
|
</UserContext.Provider>
|
||||||
</ConfigContext.Provider>
|
</ConfigContext.Provider>
|
||||||
)}
|
)}
|
||||||
</GlobalLoadingContext.Provider>
|
</GlobalLoadingContext.Provider>
|
||||||
|
|
|
@ -1,19 +1,17 @@
|
||||||
import { Col, createStyles, Grid, Paper, Text } from "@mantine/core";
|
import {
|
||||||
|
Center,
|
||||||
|
Col,
|
||||||
|
createStyles,
|
||||||
|
Grid,
|
||||||
|
Paper,
|
||||||
|
Stack,
|
||||||
|
Text,
|
||||||
|
Title,
|
||||||
|
} from "@mantine/core";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { TbSettings, TbUsers } from "react-icons/tb";
|
import { useEffect, useState } from "react";
|
||||||
|
import { TbRefresh, TbSettings, TbUsers } from "react-icons/tb";
|
||||||
const managementOptions = [
|
import configService from "../../services/config.service";
|
||||||
{
|
|
||||||
title: "User management",
|
|
||||||
icon: TbUsers,
|
|
||||||
route: "/admin/users",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: "Configuration",
|
|
||||||
icon: TbSettings,
|
|
||||||
route: "/admin/config",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const useStyles = createStyles((theme) => ({
|
const useStyles = createStyles((theme) => ({
|
||||||
item: {
|
item: {
|
||||||
|
@ -33,27 +31,69 @@ const useStyles = createStyles((theme) => ({
|
||||||
const Admin = () => {
|
const Admin = () => {
|
||||||
const { classes, theme } = useStyles();
|
const { classes, theme } = useStyles();
|
||||||
|
|
||||||
|
const [managementOptions, setManagementOptions] = useState([
|
||||||
|
{
|
||||||
|
title: "User management",
|
||||||
|
icon: TbUsers,
|
||||||
|
route: "/admin/users",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "Configuration",
|
||||||
|
icon: TbSettings,
|
||||||
|
route: "/admin/config",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
configService.isNewReleaseAvailable().then((isNewReleaseAvailable) => {
|
||||||
|
if (isNewReleaseAvailable) {
|
||||||
|
setManagementOptions([
|
||||||
|
...managementOptions,
|
||||||
|
{
|
||||||
|
title: "Update",
|
||||||
|
icon: TbRefresh,
|
||||||
|
route:
|
||||||
|
"https://github.com/stonith404/pingvin-share/releases/tag/v0.5.0",
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper withBorder p={40}>
|
<>
|
||||||
<Grid mt="md">
|
<Title mb={30} order={3}>
|
||||||
{managementOptions.map((item) => {
|
Administration
|
||||||
return (
|
</Title>
|
||||||
<Col xs={6} key={item.route}>
|
<Stack justify="space-between" style={{ height: "calc(100vh - 180px)" }}>
|
||||||
<Paper
|
<Paper withBorder p={40}>
|
||||||
withBorder
|
<Grid>
|
||||||
component={Link}
|
{managementOptions.map((item) => {
|
||||||
href={item.route}
|
return (
|
||||||
key={item.title}
|
<Col xs={6} key={item.route}>
|
||||||
className={classes.item}
|
<Paper
|
||||||
>
|
withBorder
|
||||||
<item.icon color={theme.colors.victoria[8]} size={35} />
|
component={Link}
|
||||||
<Text mt={7}>{item.title}</Text>
|
href={item.route}
|
||||||
</Paper>
|
key={item.title}
|
||||||
</Col>
|
className={classes.item}
|
||||||
);
|
>
|
||||||
})}
|
<item.icon color={theme.colors.victoria[8]} size={35} />
|
||||||
</Grid>
|
<Text mt={7}>{item.title}</Text>
|
||||||
</Paper>
|
</Paper>
|
||||||
|
</Col>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</Grid>
|
||||||
|
</Paper>
|
||||||
|
|
||||||
|
<Center>
|
||||||
|
<Text size="xs" color="dimmed">
|
||||||
|
Version {process.env.VERSION}
|
||||||
|
</Text>
|
||||||
|
</Center>
|
||||||
|
</Stack>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import axios from "axios";
|
||||||
import Config, { AdminConfig, UpdateConfig } from "../types/config.type";
|
import Config, { AdminConfig, UpdateConfig } from "../types/config.type";
|
||||||
import api from "./api.service";
|
import api from "./api.service";
|
||||||
|
|
||||||
|
@ -36,6 +37,15 @@ const sendTestEmail = async (email: string) => {
|
||||||
await api.post("/configs/admin/testEmail", { email });
|
await api.post("/configs/admin/testEmail", { email });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isNewReleaseAvailable = async () => {
|
||||||
|
const response = (
|
||||||
|
await axios.get(
|
||||||
|
"https://api.github.com/repos/stonith404/pingvin-share/releases/latest"
|
||||||
|
)
|
||||||
|
).data;
|
||||||
|
return response.tag_name.replace("v", "") != process.env.VERSION;
|
||||||
|
};
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
list,
|
list,
|
||||||
listForAdmin,
|
listForAdmin,
|
||||||
|
@ -43,4 +53,5 @@ export default {
|
||||||
get,
|
get,
|
||||||
finishSetup,
|
finishSetup,
|
||||||
sendTestEmail,
|
sendTestEmail,
|
||||||
|
isNewReleaseAvailable,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue