add theming changes for onprem
This commit is contained in:
@@ -1093,6 +1093,7 @@ func handleInfo(resp http.ResponseWriter, request *http.Request) {
|
||||
Priorities: orgPriorities,
|
||||
Licensed: licensed,
|
||||
ActiveApps: activatedAppIds,
|
||||
Theme: userInfo.Theme,
|
||||
}
|
||||
|
||||
returnData, err := json.Marshal(returnValue)
|
||||
@@ -5104,6 +5105,7 @@ func initHandlers() {
|
||||
r.HandleFunc("/api/v1/users/{key}/get2fa", shuffle.HandleGet2fa).Methods("GET", "OPTIONS")
|
||||
r.HandleFunc("/api/v1/users/{key}/set2fa", shuffle.HandleSet2fa).Methods("POST", "OPTIONS")
|
||||
r.HandleFunc("/api/v1/users", shuffle.HandleGetUsers).Methods("GET", "OPTIONS")
|
||||
r.HandleFunc("/api/v1/users/{userid}/theme", shuffle.HandleSetUserTheme).Methods("POST", "OPTIONS")
|
||||
|
||||
// General - duplicates and old.
|
||||
r.HandleFunc("/api/v1/getusers", shuffle.HandleGetUsers).Methods("GET", "OPTIONS")
|
||||
|
||||
@@ -192,6 +192,11 @@ const App = (message, props) => {
|
||||
{ path: "/" }
|
||||
);
|
||||
}
|
||||
if (responseJson?.theme?.length > 0) {
|
||||
handleThemeChange(responseJson.theme)
|
||||
}else{
|
||||
handleThemeChange("dark")
|
||||
}
|
||||
}
|
||||
|
||||
// Handling Ethereum update
|
||||
|
||||
@@ -449,6 +449,36 @@ const LeftSideBar = ({ userdata, serverside, globalUrl, notifications, }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleUpdateTheme = (newTheme) => {
|
||||
|
||||
const data = {
|
||||
"theme": newTheme,
|
||||
}
|
||||
|
||||
const url = globalUrl + `/api/v1/users/${userdata?.id}/theme`;
|
||||
fetch(url, {
|
||||
mode: "cors",
|
||||
method: "POST",
|
||||
body: JSON.stringify(data),
|
||||
credentials: "include",
|
||||
crossDomain: true,
|
||||
withCredentials: true,
|
||||
headers: {
|
||||
"Content-Type": "application/json; charset=utf-8",
|
||||
},
|
||||
}).then((response) =>
|
||||
response.json().then((responseJson) => {
|
||||
if (responseJson["success"] === false) {
|
||||
toast("Failed updating theme: ", responseJson.reason);
|
||||
} else {
|
||||
handleThemeChange(newTheme);
|
||||
setCurrentSelectedTheme(newTheme);
|
||||
}
|
||||
})
|
||||
).catch((error) => {
|
||||
console.log("Error changing theme: ", error);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const removeCookie = (name, path = "/") => {
|
||||
@@ -543,7 +573,7 @@ const LeftSideBar = ({ userdata, serverside, globalUrl, notifications, }) => {
|
||||
},
|
||||
}}
|
||||
>
|
||||
{userdata && (
|
||||
{userdata && (userdata?.org_status?.includes("integration_partner") && userdata?.org_status?.includes("sub_org")) ? null : (
|
||||
<>
|
||||
<ToggleButtonGroup
|
||||
value={currentSelectedTheme}
|
||||
@@ -555,7 +585,11 @@ const LeftSideBar = ({ userdata, serverside, globalUrl, notifications, }) => {
|
||||
if (newTheme === currentSelectedTheme) {
|
||||
return;
|
||||
}
|
||||
handleChangeTheme(newTheme);
|
||||
if (userdata?.org_status?.includes("integration_partner")){
|
||||
handleChangeTheme(newTheme);
|
||||
}else {
|
||||
handleUpdateTheme(newTheme);
|
||||
}
|
||||
}}
|
||||
aria-label="theme"
|
||||
style={{display: 'flex', justifyContent: "center", marginBottom: 10, }}
|
||||
|
||||
Reference in New Issue
Block a user