diff --git a/Dockerfile b/Dockerfile
index 2862f5bf..fb17e7bf 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -19,6 +19,7 @@ RUN apk add curl
RUN apk add ca-certificates && update-ca-certificates
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/swagger ./swagger
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
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/swagger ./swagger
COPY --from=BACK /go/src/casdoor/docker-entrypoint.sh /docker-entrypoint.sh
diff --git a/controllers/system_info.go b/controllers/system_info.go
index 9b466996..d19fc127 100644
--- a/controllers/system_info.go
+++ b/controllers/system_info.go
@@ -41,16 +41,19 @@ func (c *ApiController) GetSystemInfo() {
user := object.GetUser(id)
if user == nil || !user.IsGlobalAdmin {
c.ResponseError("You are not authorized to access this resource")
+ return
}
cpuUsage, err := util.GetCpuUsage()
if err != nil {
c.ResponseError(err.Error())
+ return
}
memoryUsed, memoryTotal, err := util.GetMemoryUsage()
if err != nil {
c.ResponseError(err.Error())
+ return
}
c.Data["json"] = SystemInfo{
@@ -71,6 +74,7 @@ func (c *ApiController) GitRepoVersion() {
version, err := util.GetGitRepoVersion()
if err != nil {
c.ResponseError(err.Error())
+ return
}
c.Data["json"] = version
diff --git a/web/src/SystemInfo.js b/web/src/SystemInfo.js
index 97729ed7..09ffe5ae 100644
--- a/web/src/SystemInfo.js
+++ b/web/src/SystemInfo.js
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// 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 React from "react";
import * as Setting from "./Setting";
@@ -26,8 +26,10 @@ class SystemInfo extends React.Component {
cpuUsage: [],
memUsed: 0,
memTotal: 0,
- latestVersion: "v1.0.0",
+ latestVersion: undefined,
intervalId: null,
+ href: "",
+ loading: true,
};
}
@@ -37,6 +39,7 @@ class SystemInfo extends React.Component {
cpuUsage: res.cpu_usage,
memUsed: res.memory_used,
memTotal: res.memory_total,
+ loading: false,
});
const id = setInterval(() => {
@@ -46,6 +49,8 @@ class SystemInfo extends React.Component {
memUsed: res.memory_used,
memTotal: res.memory_total,
});
+ }).catch(error => {
+ Setting.showMessage("error", `System info failed to get: ${error}`);
});
}, 1000 * 3);
this.setState({intervalId: id});
@@ -54,17 +59,37 @@ class SystemInfo extends React.Component {
});
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 => {
Setting.showMessage("error", `get latest commit version failed: ${err}`);
});
}
componentWillUnmount() {
- clearInterval(this.state.intervalId);
+ if (this.state.intervalId !== null) {
+ clearInterval(this.state.intervalId);
+ }
}
render() {
+ const CPUInfo = this.state.cpuUsage?.length > 0 ?
+ this.state.cpuUsage.map((usage, i) => {
+ return (
+
+ );
+ }) : i18next.t("system:Get CPU Usage Failed");
+
+ const MemInfo = (
+ this.state.memUsed && this.state.memTotal && this.state.memTotal !== 0 ?
+
+ {Setting.getFriendlyFileSize(this.state.memUsed)} / {Setting.getFriendlyFileSize(this.state.memTotal)}
+
+
+
: i18next.t("system:Get Memory Usage Failed")
+ );
+
return (
@@ -72,21 +97,12 @@ class SystemInfo extends React.Component {
- {
- this.state.cpuUsage.length !== 0 &&
- this.state.cpuUsage.map((usage, i) => {
- return (
-
- );
- })
- }
+ {this.state.loading ? : CPUInfo}
- {(Number(this.state.memUsed) / 1024 / 1024).toFixed(2)} MB / {(Number(this.state.memTotal) / 1024 / 1024 / 1024).toFixed(2)} GB
-
-
+ {this.state.loading ? : MemInfo}
@@ -95,7 +111,7 @@ class SystemInfo extends React.Component {
{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")}
GitHub: casdoor
- {i18next.t("system:Version")}: {this.state.latestVersion.substring(0, 8)}
+ {i18next.t("system:Version")}: {this.state.latestVersion}
{i18next.t("system:Official Website")}: casdoor.org
diff --git a/web/src/locales/de/data.json b/web/src/locales/de/data.json
index 20a5443d..d7b74827 100644
--- a/web/src/locales/de/data.json
+++ b/web/src/locales/de/data.json
@@ -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",
"CPU Usage": "CPU Usage",
"Community": "Community",
+ "Get CPU Usage Failed": "Get CPU Usage Failed",
+ "Get Memory Usage Failed": "Get Memory Usage Failed",
"Memory Usage": "Memory Usage",
"Official Website": "Official Website",
+ "Unknown Version": "Unknown Version",
"Version": "Version"
},
"token": {
diff --git a/web/src/locales/en/data.json b/web/src/locales/en/data.json
index fc8c7bfb..06ea0dd0 100644
--- a/web/src/locales/en/data.json
+++ b/web/src/locales/en/data.json
@@ -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",
"CPU Usage": "CPU Usage",
"Community": "Community",
+ "Get CPU Usage Failed": "Get CPU Usage Failed",
+ "Get Memory Usage Failed": "Get Memory Usage Failed",
"Memory Usage": "Memory Usage",
"Official Website": "Official Website",
+ "Unknown Version": "Unknown Version",
"Version": "Version"
},
"token": {
diff --git a/web/src/locales/fr/data.json b/web/src/locales/fr/data.json
index a6385bc3..77e0b3d4 100644
--- a/web/src/locales/fr/data.json
+++ b/web/src/locales/fr/data.json
@@ -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",
"CPU Usage": "CPU Usage",
"Community": "Community",
+ "Get CPU Usage Failed": "Get CPU Usage Failed",
+ "Get Memory Usage Failed": "Get Memory Usage Failed",
"Memory Usage": "Memory Usage",
"Official Website": "Official Website",
+ "Unknown Version": "Unknown Version",
"Version": "Version"
},
"token": {
diff --git a/web/src/locales/ja/data.json b/web/src/locales/ja/data.json
index 8086b2ec..765de930 100644
--- a/web/src/locales/ja/data.json
+++ b/web/src/locales/ja/data.json
@@ -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",
"CPU Usage": "CPU Usage",
"Community": "Community",
+ "Get CPU Usage Failed": "Get CPU Usage Failed",
+ "Get Memory Usage Failed": "Get Memory Usage Failed",
"Memory Usage": "Memory Usage",
"Official Website": "Official Website",
+ "Unknown Version": "Unknown Version",
"Version": "Version"
},
"token": {
diff --git a/web/src/locales/ko/data.json b/web/src/locales/ko/data.json
index 8f5820ce..50f422ac 100644
--- a/web/src/locales/ko/data.json
+++ b/web/src/locales/ko/data.json
@@ -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",
"CPU Usage": "CPU Usage",
"Community": "Community",
+ "Get CPU Usage Failed": "Get CPU Usage Failed",
+ "Get Memory Usage Failed": "Get Memory Usage Failed",
"Memory Usage": "Memory Usage",
"Official Website": "Official Website",
+ "Unknown Version": "Unknown Version",
"Version": "Version"
},
"token": {
diff --git a/web/src/locales/ru/data.json b/web/src/locales/ru/data.json
index a37b8e02..1e7b7f64 100644
--- a/web/src/locales/ru/data.json
+++ b/web/src/locales/ru/data.json
@@ -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",
"CPU Usage": "CPU Usage",
"Community": "Community",
+ "Get CPU Usage Failed": "Get CPU Usage Failed",
+ "Get Memory Usage Failed": "Get Memory Usage Failed",
"Memory Usage": "Memory Usage",
"Official Website": "Official Website",
+ "Unknown Version": "Unknown Version",
"Version": "Version"
},
"token": {
diff --git a/web/src/locales/zh/data.json b/web/src/locales/zh/data.json
index 317cdc15..82cf18e5 100644
--- a/web/src/locales/zh/data.json
+++ b/web/src/locales/zh/data.json
@@ -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) 平台",
"CPU Usage": "CPU使用率",
"Community": "社区",
+ "Get CPU Usage Failed": "获取CPU使用率失败",
+ "Get Memory Usage Failed": "获取内存使用率失败",
"Memory Usage": "内存使用率",
"Official Website": "官方网站",
+ "Unknown Version": "未知版本",
"Version": "版本"
},
"token": {