Merge branch 'release/v0.1.0' of https://github.com/ONLYOFFICE/AppServer into release/v0.1.0

This commit is contained in:
Nikita Gopienko 2021-04-05 16:42:09 +03:00
commit cea14a9d4f
13 changed files with 233 additions and 42 deletions

View File

@ -0,0 +1,84 @@
map $http_host $this_host {
"" $host;
default $http_host;
}
map $http_x_forwarded_proto $the_scheme {
default $http_x_forwarded_proto;
"" $scheme;
}
map $http_x_forwarded_host $the_host {
default $http_x_forwarded_host;
"" $this_host;
}
server {
listen 80;
listen [::]:80;
server_name localhost;
set $X_REWRITER_URL $the_scheme://$the_host;
set $mobile_rewrite do_not_perform;
set $desktop "";
location / {
## redirect to mobile -> appserver ##
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
set $mobile_rewrite perform;
}
if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-)") {
set $mobile_rewrite perform;
}
if ($args ~ 'desktop_view=true') {
set $mobile_rewrite do_not_perform;
set $desktop "desktop_view=true";
}
if ($args ~ 'desktop_view=false') {
set $mobile_rewrite perform;
set $desktop "desktop_view=false";
}
add_header Set-Cookie "$desktop; Path=/" always;
if ($http_cookie ~ "desktop_view=true") {
set $mobile_rewrite do_not_perform;
}
if ($http_cookie ~ "desktop_view=false") {
set $mobile_rewrite perform;
}
if ($mobile_rewrite = perform) {
rewrite ^ /appserver$request_uri? redirect;
}
proxy_pass http://localhost:8081;
root /usr/share/nginx/html;
index index.html index.htm;
}
location ~* ^/appserver {
sub_filter '</head>' '</head><script language="javascript">window.APPSERVER_PROXY_URL=`/appserver`;</script>';
sub_filter_once on;
rewrite /appserver(.*) $1 break;
proxy_pass http://localhost:8092;
proxy_set_header Accept-Encoding "";
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}

View File

@ -21,34 +21,51 @@ server {
server_name localhost;
set $X_REWRITER_URL $the_scheme://$the_host;
set $mobile_rewrite do_not_perform;
set $desktop "";
location / {
if ($http_referer ~* /appserver) {
rewrite /(.*) /appserver/$1 last;
## redirect to mobile -> appserver ##
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
set $mobile_rewrite perform;
}
# if ($http_referer ~* /products/people/) {
# rewrite /(.*) /appserver/$1 last;
# }
# proxy_set_header Host portals;
if ($http_user_agent ~* "^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-)") {
set $mobile_rewrite perform;
}
if ($args ~ 'desktop_view=true') {
set $mobile_rewrite do_not_perform;
set $desktop "desktop_view=true";
}
if ($args ~ 'desktop_view=false') {
set $mobile_rewrite perform;
set $desktop "desktop_view=false";
}
add_header Set-Cookie "$desktop; Path=/" always;
if ($http_cookie ~ "desktop_view=true") {
set $mobile_rewrite do_not_perform;
}
if ($http_cookie ~ "desktop_view=false") {
set $mobile_rewrite perform;
}
if ($mobile_rewrite = perform) {
proxy_pass http://localhost:8092;
break;
}
proxy_pass http://localhost:8081;
root /usr/share/nginx/html;
index index.html index.htm;
}
location ~* ^/appserver/ {
rewrite /appserver(.*) $1 break;
proxy_pass http://localhost:8092;
proxy_set_header Accept-Encoding "";
proxy_set_header X-REWRITER-URL $X_REWRITER_URL;
# proxy_redirect ~*(.*)/login/(.*) $1/appserver/login/$2;
# proxy_redirect ~*(.*)/products/people/(.*) $1/appserver/products/people/$2;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {

View File

@ -44,9 +44,9 @@ export function deleteGroup(id) {
});
}
export function getGroupListFull() {
/*export function getGroupListFull() {
return request({
method: "get",
url: "/group/full",
});
}
}*/ //TODO: use after fixing problems on the server

View File

@ -1,8 +1,10 @@
const pks = require("../package.json");
const window = require("global/window");
const { proxy, api } = pks;
module.exports = {
proxyURL: (proxy && proxy.url) || "",
proxyURL:
(proxy && proxy.url) || (window && window.APPSERVER_PROXY_URL) || "",
apiPrefixURL: (api && api.url) || "/api/2.0",
apiTimeout: (api && api.timeout) || 30000,
};

View File

@ -14,5 +14,8 @@
},
"proxy": {
"url": ""
},
"dependencies": {
"global": "^4.4.0"
}
}

View File

@ -169,3 +169,44 @@ export function isAdmin(currentUser, currentProductId) {
import combineUrlFunc from "./combineUrl";
export const combineUrl = combineUrlFunc;
export function getCookie(name) {
let matches = document.cookie.match(
new RegExp(
"(?:^|; )" +
name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, "\\$1") +
"=([^;]*)"
)
);
return matches ? decodeURIComponent(matches[1]) : undefined;
}
export function setCookie(name, value, options = {}) {
options = {
path: "/",
...options,
};
if (options.expires instanceof Date) {
options.expires = options.expires.toUTCString();
}
let updatedCookie =
encodeURIComponent(name) + "=" + encodeURIComponent(value);
for (let optionKey in options) {
updatedCookie += "; " + optionKey;
let optionValue = options[optionKey];
if (optionValue !== true) {
updatedCookie += "=" + optionValue;
}
}
document.cookie = updatedCookie;
}
export function deleteCookie(name) {
setCookie(name, "", {
"max-age": -1,
});
}

View File

@ -287,7 +287,7 @@ const SectionBodyContent = ({
opened={isHeadSelectorOpen}
selectedOption={
newGroupManager.default ||
newGroupManager.id === ID_NO_GROUP_MANAGER ||
newGroupManager.key === ID_NO_GROUP_MANAGER ||
newGroupManager.displayName === "profile removed"
? { ...newGroupManager, label: t("LblSelect") }
: newGroupManager

View File

@ -11,6 +11,11 @@ import toastr from "studio/toastr";
import Loaders from "@appserver/common/components/Loaders";
import { inject, observer } from "mobx-react";
import { showLoader, hideLoader } from "@appserver/common/utils";
import { withRouter } from "react-router";
import { AppServerConfig } from "@appserver/common/constants";
import { combineUrl } from "@appserver/common/utils";
import config from "../../../../../../package.json";
const InfoContainer = styled.div`
margin-bottom: 24px;
@ -99,12 +104,22 @@ class ProfileInfo extends React.PureComponent {
onGroupClick = (e) => {
const group = e.currentTarget.dataset.id;
const { filter, setIsLoading, fetchPeople } = this.props;
const { filter, setIsLoading, fetchPeople, history } = this.props;
const newFilter = filter.clone();
newFilter.group = group;
setIsLoading(true);
const urlFilter = newFilter.toUrlParams();
const url = combineUrl(
AppServerConfig.proxyURL,
config.homepage,
`/filter?${urlFilter}`
);
history.push(url);
fetchPeople(newFilter).finally(() => setIsLoading(false));
};
@ -351,15 +366,17 @@ class ProfileInfo extends React.PureComponent {
}
}
export default inject(({ auth, peopleStore }) => ({
groupCaption: auth.settingsStore.customNames.groupCaption,
regDateCaption: auth.settingsStore.customNames.regDateCaption,
userPostCaption: auth.settingsStore.customNames.userPostCaption,
userCaption: auth.settingsStore.customNames.userCaption,
guestCaption: auth.settingsStore.customNames.guestCaption,
fetchPeople: peopleStore.usersStore.getUsersList,
filter: peopleStore.filterStore.filter,
setIsLoading: peopleStore.setIsLoading,
isLoading: peopleStore.isLoading,
updateProfileCulture: peopleStore.targetUserStore.updateProfileCulture,
}))(observer(withTranslation("Profile")(ProfileInfo)));
export default withRouter(
inject(({ auth, peopleStore }) => ({
groupCaption: auth.settingsStore.customNames.groupCaption,
regDateCaption: auth.settingsStore.customNames.regDateCaption,
userPostCaption: auth.settingsStore.customNames.userPostCaption,
userCaption: auth.settingsStore.customNames.userCaption,
guestCaption: auth.settingsStore.customNames.guestCaption,
fetchPeople: peopleStore.usersStore.getUsersList,
filter: peopleStore.filterStore.filter,
setIsLoading: peopleStore.setIsLoading,
isLoading: peopleStore.isLoading,
updateProfileCulture: peopleStore.targetUserStore.updateProfileCulture,
}))(observer(withTranslation("Profile")(ProfileInfo)))
);

View File

@ -16,7 +16,7 @@ class GroupsStore {
}
getGroupList = async () => {
const res = await api.groups.getGroupListFull();
const res = await api.groups.getGroupList(); //TODO: replace with getGroupListFull() after fixing problems on the server
this.groups = res;
};

View File

@ -59,8 +59,15 @@ class SelectedGroupStore {
const { group, search, role, activationStatus, employeeStatus } = filter;
let countMembers;
groups.filter((el) => {
if (el.id === group) countMembers = el.members.length;
groups.filter(async (el) => {
if (el.id === group) {
if (!el.members) {
const currGroup = await getGroup(el.id);
countMembers = currGroup.members.length; // TODO: simplify after fixing server issues with getGroupListFull
} else {
countMembers = el.members.length;
}
}
});
const filterIsClear =

View File

@ -12,5 +12,6 @@
"LogoutButton": "Sign Out",
"Settings": "Settings",
"Version": "Version",
"AboutShort": "About"
"AboutShort": "About",
"TurnOnDesktopVersion": "Turn on desktop version"
}

View File

@ -12,5 +12,6 @@
"LogoutButton": "Выйти",
"Settings": "Настройки",
"Version": "Версия",
"AboutShort": "О программе"
"AboutShort": "О программе",
"TurnOnDesktopVersion": "Включить версию для ПК"
}

View File

@ -5,7 +5,7 @@ import NavItem from "./nav-item";
import ProfileActions from "./profile-actions";
import { useTranslation } from "react-i18next";
import { tablet } from "@appserver/components/utils/device";
import { combineUrl } from "@appserver/common/utils";
import { combineUrl, deleteCookie } from "@appserver/common/utils";
import { inject, observer } from "mobx-react";
import { withRouter } from "react-router";
import { AppServerConfig } from "@appserver/common/constants";
@ -51,12 +51,23 @@ const StyledNav = styled.nav`
`;
const HeaderNav = ({ history, modules, user, logout, isAuthenticated }) => {
const { t } = useTranslation("NavMenu");
const onProfileClick = useCallback(() => {
history.push(PROFILE_URL);
}, []);
const onAboutClick = useCallback(() => history.push(ABOUT_URL), []);
const onSwitchToDesktopClick = useCallback(() => {
deleteCookie("desktop_view");
window.open(
`${window.location.origin}?desktop_view=true`,
"_self",
"",
true
);
}, []);
const onLogoutClick = useCallback(() => logout && logout(), [logout]);
const getCurrentUserActions = useCallback(() => {
@ -67,6 +78,13 @@ const HeaderNav = ({ history, modules, user, logout, isAuthenticated }) => {
onClick: onProfileClick,
url: PROFILE_URL,
},
{
key: "SwitchToBtn",
label: t("TurnOnDesktopVersion"),
onClick: onSwitchToDesktopClick,
url: `${window.location.origin}?desktop_view=true`,
target: "_self",
},
{
key: "AboutBtn",
label: t("AboutCompanyTitle"),