mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-03 20:50:19 +08:00
fix: fix get version error (#1044)
* feat: fix get version error * feat: more safe * fix
This commit is contained in:
@ -19,6 +19,7 @@ RUN apk add curl
|
|||||||
RUN apk add ca-certificates && update-ca-certificates
|
RUN apk add ca-certificates && update-ca-certificates
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
|
COPY --from=BACK /go/src/casdoor/.git/refs/heads .git/refs/heads
|
||||||
COPY --from=BACK /go/src/casdoor/server ./server
|
COPY --from=BACK /go/src/casdoor/server ./server
|
||||||
COPY --from=BACK /go/src/casdoor/swagger ./swagger
|
COPY --from=BACK /go/src/casdoor/swagger ./swagger
|
||||||
COPY --from=BACK /go/src/casdoor/conf/app.conf ./conf/app.conf
|
COPY --from=BACK /go/src/casdoor/conf/app.conf ./conf/app.conf
|
||||||
@ -41,6 +42,7 @@ RUN apt update
|
|||||||
RUN apt install -y ca-certificates && update-ca-certificates
|
RUN apt install -y ca-certificates && update-ca-certificates
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
|
COPY --from=BACK /go/src/casdoor/.git/refs/heads .git/refs/heads
|
||||||
COPY --from=BACK /go/src/casdoor/server ./server
|
COPY --from=BACK /go/src/casdoor/server ./server
|
||||||
COPY --from=BACK /go/src/casdoor/swagger ./swagger
|
COPY --from=BACK /go/src/casdoor/swagger ./swagger
|
||||||
COPY --from=BACK /go/src/casdoor/docker-entrypoint.sh /docker-entrypoint.sh
|
COPY --from=BACK /go/src/casdoor/docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
|
@ -41,16 +41,19 @@ func (c *ApiController) GetSystemInfo() {
|
|||||||
user := object.GetUser(id)
|
user := object.GetUser(id)
|
||||||
if user == nil || !user.IsGlobalAdmin {
|
if user == nil || !user.IsGlobalAdmin {
|
||||||
c.ResponseError("You are not authorized to access this resource")
|
c.ResponseError("You are not authorized to access this resource")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
cpuUsage, err := util.GetCpuUsage()
|
cpuUsage, err := util.GetCpuUsage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.ResponseError(err.Error())
|
c.ResponseError(err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
memoryUsed, memoryTotal, err := util.GetMemoryUsage()
|
memoryUsed, memoryTotal, err := util.GetMemoryUsage()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.ResponseError(err.Error())
|
c.ResponseError(err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Data["json"] = SystemInfo{
|
c.Data["json"] = SystemInfo{
|
||||||
@ -71,6 +74,7 @@ func (c *ApiController) GitRepoVersion() {
|
|||||||
version, err := util.GetGitRepoVersion()
|
version, err := util.GetGitRepoVersion()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.ResponseError(err.Error())
|
c.ResponseError(err.Error())
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Data["json"] = version
|
c.Data["json"] = version
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
import {Card, Col, Divider, Progress, Row} from "antd";
|
import {Card, Col, Divider, Progress, Row, Spin} from "antd";
|
||||||
import * as SystemBackend from "./backend/SystemInfo";
|
import * as SystemBackend from "./backend/SystemInfo";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import * as Setting from "./Setting";
|
import * as Setting from "./Setting";
|
||||||
@ -26,8 +26,10 @@ class SystemInfo extends React.Component {
|
|||||||
cpuUsage: [],
|
cpuUsage: [],
|
||||||
memUsed: 0,
|
memUsed: 0,
|
||||||
memTotal: 0,
|
memTotal: 0,
|
||||||
latestVersion: "v1.0.0",
|
latestVersion: undefined,
|
||||||
intervalId: null,
|
intervalId: null,
|
||||||
|
href: "",
|
||||||
|
loading: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,6 +39,7 @@ class SystemInfo extends React.Component {
|
|||||||
cpuUsage: res.cpu_usage,
|
cpuUsage: res.cpu_usage,
|
||||||
memUsed: res.memory_used,
|
memUsed: res.memory_used,
|
||||||
memTotal: res.memory_total,
|
memTotal: res.memory_total,
|
||||||
|
loading: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const id = setInterval(() => {
|
const id = setInterval(() => {
|
||||||
@ -46,6 +49,8 @@ class SystemInfo extends React.Component {
|
|||||||
memUsed: res.memory_used,
|
memUsed: res.memory_used,
|
||||||
memTotal: res.memory_total,
|
memTotal: res.memory_total,
|
||||||
});
|
});
|
||||||
|
}).catch(error => {
|
||||||
|
Setting.showMessage("error", `System info failed to get: ${error}`);
|
||||||
});
|
});
|
||||||
}, 1000 * 3);
|
}, 1000 * 3);
|
||||||
this.setState({intervalId: id});
|
this.setState({intervalId: id});
|
||||||
@ -54,17 +59,37 @@ class SystemInfo extends React.Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
SystemBackend.getGitHubLatestReleaseVersion().then(res => {
|
SystemBackend.getGitHubLatestReleaseVersion().then(res => {
|
||||||
this.setState({latestVersion: res});
|
const href = res && res.length >= 8 ? `https://github.com/casdoor/casdoor/commit/${res}` : "";
|
||||||
|
const versionText = res && res.length >= 8 ? res.substring(0, 8) : i18next.t("system:Unknown Version");
|
||||||
|
this.setState({latestVersion: versionText, href: href});
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
Setting.showMessage("error", `get latest commit version failed: ${err}`);
|
Setting.showMessage("error", `get latest commit version failed: ${err}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
|
if (this.state.intervalId !== null) {
|
||||||
clearInterval(this.state.intervalId);
|
clearInterval(this.state.intervalId);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const CPUInfo = this.state.cpuUsage?.length > 0 ?
|
||||||
|
this.state.cpuUsage.map((usage, i) => {
|
||||||
|
return (
|
||||||
|
<Progress key={i} percent={Number(usage.toFixed(1))} />
|
||||||
|
);
|
||||||
|
}) : i18next.t("system:Get CPU Usage Failed");
|
||||||
|
|
||||||
|
const MemInfo = (
|
||||||
|
this.state.memUsed && this.state.memTotal && this.state.memTotal !== 0 ?
|
||||||
|
<div>
|
||||||
|
{Setting.getFriendlyFileSize(this.state.memUsed)} / {Setting.getFriendlyFileSize(this.state.memTotal)}
|
||||||
|
<br /> <br />
|
||||||
|
<Progress type="circle" percent={Number((Number(this.state.memUsed) / Number(this.state.memTotal) * 100).toFixed(2))} />
|
||||||
|
</div> : i18next.t("system:Get Memory Usage Failed")
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row>
|
<Row>
|
||||||
<Col span={6}></Col>
|
<Col span={6}></Col>
|
||||||
@ -72,21 +97,12 @@ class SystemInfo extends React.Component {
|
|||||||
<Row gutter={[10, 10]}>
|
<Row gutter={[10, 10]}>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Card title={i18next.t("system:CPU Usage")} bordered={true} style={{textAlign: "center"}}>
|
<Card title={i18next.t("system:CPU Usage")} bordered={true} style={{textAlign: "center"}}>
|
||||||
{
|
{this.state.loading ? <Spin size="large" /> : CPUInfo}
|
||||||
this.state.cpuUsage.length !== 0 &&
|
|
||||||
this.state.cpuUsage.map((usage, i) => {
|
|
||||||
return (
|
|
||||||
<Progress key={i} percent={Number(usage.toFixed(1))} />
|
|
||||||
);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Card title={i18next.t("system:Memory Usage")} bordered={true} style={{textAlign: "center"}}>
|
<Card title={i18next.t("system:Memory Usage")} bordered={true} style={{textAlign: "center"}}>
|
||||||
{(Number(this.state.memUsed) / 1024 / 1024).toFixed(2)} MB / {(Number(this.state.memTotal) / 1024 / 1024 / 1024).toFixed(2)} GB
|
{this.state.loading ? <Spin size="large" /> : MemInfo}
|
||||||
<br /> <br />
|
|
||||||
<Progress type="circle" percent={Number((Number(this.state.memUsed) / Number(this.state.memTotal) * 100).toFixed(2))} />
|
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
@ -95,7 +111,7 @@ class SystemInfo extends React.Component {
|
|||||||
<div>{i18next.t("system:An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS")}</div>
|
<div>{i18next.t("system:An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS")}</div>
|
||||||
GitHub: <a href="https://github.com/casdoor/casdoor">casdoor</a>
|
GitHub: <a href="https://github.com/casdoor/casdoor">casdoor</a>
|
||||||
<br />
|
<br />
|
||||||
{i18next.t("system:Version")}: <a href={`https://github.com/casdoor/casdoor/commit/${this.state.latestVersion}`}>{this.state.latestVersion.substring(0, 8)}</a>
|
{i18next.t("system:Version")}: <a href={this.state.href}>{this.state.latestVersion}</a>
|
||||||
<br />
|
<br />
|
||||||
{i18next.t("system:Official Website")}: <a href="https://casdoor.org/">casdoor.org</a>
|
{i18next.t("system:Official Website")}: <a href="https://casdoor.org/">casdoor.org</a>
|
||||||
<br />
|
<br />
|
||||||
|
@ -599,8 +599,11 @@
|
|||||||
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS",
|
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS",
|
||||||
"CPU Usage": "CPU Usage",
|
"CPU Usage": "CPU Usage",
|
||||||
"Community": "Community",
|
"Community": "Community",
|
||||||
|
"Get CPU Usage Failed": "Get CPU Usage Failed",
|
||||||
|
"Get Memory Usage Failed": "Get Memory Usage Failed",
|
||||||
"Memory Usage": "Memory Usage",
|
"Memory Usage": "Memory Usage",
|
||||||
"Official Website": "Official Website",
|
"Official Website": "Official Website",
|
||||||
|
"Unknown Version": "Unknown Version",
|
||||||
"Version": "Version"
|
"Version": "Version"
|
||||||
},
|
},
|
||||||
"token": {
|
"token": {
|
||||||
|
@ -599,8 +599,11 @@
|
|||||||
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS",
|
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS",
|
||||||
"CPU Usage": "CPU Usage",
|
"CPU Usage": "CPU Usage",
|
||||||
"Community": "Community",
|
"Community": "Community",
|
||||||
|
"Get CPU Usage Failed": "Get CPU Usage Failed",
|
||||||
|
"Get Memory Usage Failed": "Get Memory Usage Failed",
|
||||||
"Memory Usage": "Memory Usage",
|
"Memory Usage": "Memory Usage",
|
||||||
"Official Website": "Official Website",
|
"Official Website": "Official Website",
|
||||||
|
"Unknown Version": "Unknown Version",
|
||||||
"Version": "Version"
|
"Version": "Version"
|
||||||
},
|
},
|
||||||
"token": {
|
"token": {
|
||||||
|
@ -599,8 +599,11 @@
|
|||||||
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS",
|
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS",
|
||||||
"CPU Usage": "CPU Usage",
|
"CPU Usage": "CPU Usage",
|
||||||
"Community": "Community",
|
"Community": "Community",
|
||||||
|
"Get CPU Usage Failed": "Get CPU Usage Failed",
|
||||||
|
"Get Memory Usage Failed": "Get Memory Usage Failed",
|
||||||
"Memory Usage": "Memory Usage",
|
"Memory Usage": "Memory Usage",
|
||||||
"Official Website": "Official Website",
|
"Official Website": "Official Website",
|
||||||
|
"Unknown Version": "Unknown Version",
|
||||||
"Version": "Version"
|
"Version": "Version"
|
||||||
},
|
},
|
||||||
"token": {
|
"token": {
|
||||||
|
@ -599,8 +599,11 @@
|
|||||||
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS",
|
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS",
|
||||||
"CPU Usage": "CPU Usage",
|
"CPU Usage": "CPU Usage",
|
||||||
"Community": "Community",
|
"Community": "Community",
|
||||||
|
"Get CPU Usage Failed": "Get CPU Usage Failed",
|
||||||
|
"Get Memory Usage Failed": "Get Memory Usage Failed",
|
||||||
"Memory Usage": "Memory Usage",
|
"Memory Usage": "Memory Usage",
|
||||||
"Official Website": "Official Website",
|
"Official Website": "Official Website",
|
||||||
|
"Unknown Version": "Unknown Version",
|
||||||
"Version": "Version"
|
"Version": "Version"
|
||||||
},
|
},
|
||||||
"token": {
|
"token": {
|
||||||
|
@ -599,8 +599,11 @@
|
|||||||
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS",
|
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS",
|
||||||
"CPU Usage": "CPU Usage",
|
"CPU Usage": "CPU Usage",
|
||||||
"Community": "Community",
|
"Community": "Community",
|
||||||
|
"Get CPU Usage Failed": "Get CPU Usage Failed",
|
||||||
|
"Get Memory Usage Failed": "Get Memory Usage Failed",
|
||||||
"Memory Usage": "Memory Usage",
|
"Memory Usage": "Memory Usage",
|
||||||
"Official Website": "Official Website",
|
"Official Website": "Official Website",
|
||||||
|
"Unknown Version": "Unknown Version",
|
||||||
"Version": "Version"
|
"Version": "Version"
|
||||||
},
|
},
|
||||||
"token": {
|
"token": {
|
||||||
|
@ -599,8 +599,11 @@
|
|||||||
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS",
|
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS",
|
||||||
"CPU Usage": "CPU Usage",
|
"CPU Usage": "CPU Usage",
|
||||||
"Community": "Community",
|
"Community": "Community",
|
||||||
|
"Get CPU Usage Failed": "Get CPU Usage Failed",
|
||||||
|
"Get Memory Usage Failed": "Get Memory Usage Failed",
|
||||||
"Memory Usage": "Memory Usage",
|
"Memory Usage": "Memory Usage",
|
||||||
"Official Website": "Official Website",
|
"Official Website": "Official Website",
|
||||||
|
"Unknown Version": "Unknown Version",
|
||||||
"Version": "Version"
|
"Version": "Version"
|
||||||
},
|
},
|
||||||
"token": {
|
"token": {
|
||||||
|
@ -599,8 +599,11 @@
|
|||||||
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "一个支持 OAuth 2.0、OIDC、SAML 和 CAS 的 Web UI 的身份和访问管理 (IAM)/单点登录 (SSO) 平台",
|
"An Identity and Access Management (IAM) / Single-Sign-On (SSO) platform with web UI supporting OAuth 2.0, OIDC, SAML and CAS": "一个支持 OAuth 2.0、OIDC、SAML 和 CAS 的 Web UI 的身份和访问管理 (IAM)/单点登录 (SSO) 平台",
|
||||||
"CPU Usage": "CPU使用率",
|
"CPU Usage": "CPU使用率",
|
||||||
"Community": "社区",
|
"Community": "社区",
|
||||||
|
"Get CPU Usage Failed": "获取CPU使用率失败",
|
||||||
|
"Get Memory Usage Failed": "获取内存使用率失败",
|
||||||
"Memory Usage": "内存使用率",
|
"Memory Usage": "内存使用率",
|
||||||
"Official Website": "官方网站",
|
"Official Website": "官方网站",
|
||||||
|
"Unknown Version": "未知版本",
|
||||||
"Version": "版本"
|
"Version": "版本"
|
||||||
},
|
},
|
||||||
"token": {
|
"token": {
|
||||||
|
Reference in New Issue
Block a user