feat: support i18n in backend err messages (#1232)

* feat: support i18n in backend err messages

* use gofumpt to fmt code

* fix review problems

* support auto generate err message

* delete beego/i18n moudle

* fix Github action test problems

* fix review problems

* use gofumpt to format code

* use gofumpt to fmt code
This commit is contained in:
Mr Forest
2022-10-23 15:16:24 +08:00
committed by GitHub
parent 7c77519069
commit d86f3c88c7
64 changed files with 1838 additions and 194 deletions

View File

@ -559,6 +559,10 @@ export function changeLanguage(language) {
// window.location.reload(true);
}
export function getAcceptLanguage() {
return i18next.language + ";q=0.9,en;q=0.8";
}
export function changeMomentLanguage(language) {
// if (language === "zh") {
// moment.locale("zh", {

View File

@ -13,11 +13,15 @@
// limitations under the License.
import {authConfig} from "./Auth";
import * as Setting from "../Setting";
export function getAccount(query) {
return fetch(`${authConfig.serverUrl}/api/get-account${query}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -26,6 +30,9 @@ export function signup(values) {
method: "POST",
credentials: "include",
body: JSON.stringify(values),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +41,9 @@ export function getEmailAndPhone(values) {
method: "POST",
credentials: "include",
body: JSON.stringify(values),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then((res) => res.json());
}
@ -51,6 +61,9 @@ export function getApplicationLogin(oAuthParams) {
return fetch(`${authConfig.serverUrl}/api/get-app-login${oAuthParamsToQuery(oAuthParams)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -59,6 +72,9 @@ export function login(values, oAuthParams) {
method: "POST",
credentials: "include",
body: JSON.stringify(values),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -67,6 +83,9 @@ export function loginCas(values, params) {
method: "POST",
credentials: "include",
body: JSON.stringify(values),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -74,6 +93,9 @@ export function logout() {
return fetch(`${authConfig.serverUrl}/api/logout`, {
method: "POST",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -82,6 +104,9 @@ export function unlink(values) {
method: "POST",
credentials: "include",
body: JSON.stringify(values),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -89,6 +114,9 @@ export function getSamlLogin(providerId, relayState) {
return fetch(`${authConfig.serverUrl}/api/get-saml-login?id=${providerId}&relayState=${relayState}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -97,5 +125,8 @@ export function loginWithSaml(values, param) {
method: "POST",
credentials: "include",
body: JSON.stringify(values),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getAdapters(owner, page = "", pageSize = "", field = "", value =
return fetch(`${Setting.ServerUrl}/api/get-adapters?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getAdapter(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-adapter?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +40,9 @@ export function updateAdapter(owner, name, Adapter) {
method: "POST",
credentials: "include",
body: JSON.stringify(newAdapter),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -43,6 +52,9 @@ export function addAdapter(Adapter) {
method: "POST",
credentials: "include",
body: JSON.stringify(newAdapter),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -52,6 +64,9 @@ export function deleteAdapter(Adapter) {
method: "POST",
credentials: "include",
body: JSON.stringify(newAdapter),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -59,5 +74,8 @@ export function syncPolicies(owner, name) {
return fetch(`${Setting.ServerUrl}/api/sync-policies?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getApplications(owner, page = "", pageSize = "", field = "", val
return fetch(`${Setting.ServerUrl}/api/get-applications?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getApplicationsByOrganization(owner, organization) {
return fetch(`${Setting.ServerUrl}/api/get-organization-applications?owner=${owner}&organization=${organization}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -32,6 +38,9 @@ export function getApplication(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-application?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -39,6 +48,9 @@ export function getUserApplication(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-user-application?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -48,6 +60,9 @@ export function updateApplication(owner, name, application) {
method: "POST",
credentials: "include",
body: JSON.stringify(newApplication),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -58,6 +73,9 @@ export function addApplication(application) {
method: "POST",
credentials: "include",
body: JSON.stringify(newApplication),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -67,6 +85,9 @@ export function deleteApplication(application) {
method: "POST",
credentials: "include",
body: JSON.stringify(newApplication),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -74,5 +95,8 @@ export function getSamlMetadata(owner, name) {
return fetch(`${Setting.ServerUrl}/api/saml/metadata?application=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.text());
}

View File

@ -18,6 +18,9 @@ export function getCerts(owner, page = "", pageSize = "", field = "", value = ""
return fetch(`${Setting.ServerUrl}/api/get-certs?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getCert(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-cert?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +40,9 @@ export function updateCert(owner, name, cert) {
method: "POST",
credentials: "include",
body: JSON.stringify(newCert),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -43,6 +52,9 @@ export function addCert(cert) {
method: "POST",
credentials: "include",
body: JSON.stringify(newCert),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -52,5 +64,8 @@ export function deleteCert(cert) {
method: "POST",
credentials: "include",
body: JSON.stringify(newCert),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getLdaps(owner) {
return fetch(`${Setting.ServerUrl}/api/get-ldaps?owner=${owner}`, {
method: "POST",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getLdap(id) {
return fetch(`${Setting.ServerUrl}/api/get-ldap?id=${id}`, {
method: "POST",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -33,6 +39,9 @@ export function addLdap(body) {
method: "POST",
credentials: "include",
body: JSON.stringify(body),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -41,6 +50,9 @@ export function deleteLdap(body) {
method: "POST",
credentials: "include",
body: JSON.stringify(body),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -49,6 +61,9 @@ export function updateLdap(body) {
method: "POST",
credentials: "include",
body: JSON.stringify(body),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -57,6 +72,9 @@ export function getLdapUser(body) {
method: "POST",
credentials: "include",
body: JSON.stringify(body),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -65,6 +83,9 @@ export function syncUsers(owner, ldapId, body) {
method: "POST",
credentials: "include",
body: JSON.stringify(body),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -73,5 +94,8 @@ export function checkLdapUsersExist(owner, body) {
method: "POST",
credentials: "include",
body: JSON.stringify(body),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getModels(owner, page = "", pageSize = "", field = "", value = "
return fetch(`${Setting.ServerUrl}/api/get-models?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getModel(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-model?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +40,9 @@ export function updateModel(owner, name, model) {
method: "POST",
credentials: "include",
body: JSON.stringify(newModel),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -43,6 +52,9 @@ export function addModel(model) {
method: "POST",
credentials: "include",
body: JSON.stringify(newModel),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -52,5 +64,8 @@ export function deleteModel(model) {
method: "POST",
credentials: "include",
body: JSON.stringify(newModel),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getOrganizations(owner, page = "", pageSize = "", field = "", va
return fetch(`${Setting.ServerUrl}/api/get-organizations?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getOrganization(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-organization?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +40,9 @@ export function updateOrganization(owner, name, organization) {
method: "POST",
credentials: "include",
body: JSON.stringify(newOrganization),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -43,6 +52,9 @@ export function addOrganization(organization) {
method: "POST",
credentials: "include",
body: JSON.stringify(newOrganization),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -52,6 +64,9 @@ export function deleteOrganization(organization) {
method: "POST",
credentials: "include",
body: JSON.stringify(newOrganization),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -59,5 +74,8 @@ export function getDefaultApplication(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-default-application?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getPayments(owner, page = "", pageSize = "", field = "", value =
return fetch(`${Setting.ServerUrl}/api/get-payments?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getPayment(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-payment?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +40,9 @@ export function updatePayment(owner, name, payment) {
method: "POST",
credentials: "include",
body: JSON.stringify(newPayment),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -43,6 +52,9 @@ export function addPayment(payment) {
method: "POST",
credentials: "include",
body: JSON.stringify(newPayment),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -52,6 +64,9 @@ export function deletePayment(payment) {
method: "POST",
credentials: "include",
body: JSON.stringify(newPayment),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -59,5 +74,8 @@ export function invoicePayment(owner, name) {
return fetch(`${Setting.ServerUrl}/api/invoice-payment?id=${owner}/${encodeURIComponent(name)}`, {
method: "POST",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getPermissions(owner, page = "", pageSize = "", field = "", valu
return fetch(`${Setting.ServerUrl}/api/get-permissions?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getPermissionsBySubmitter() {
return fetch(`${Setting.ServerUrl}/api/get-permissions-by-submitter`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -32,6 +38,9 @@ export function getPermission(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-permission?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -41,6 +50,9 @@ export function updatePermission(owner, name, permission) {
method: "POST",
credentials: "include",
body: JSON.stringify(newPermission),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -50,6 +62,9 @@ export function addPermission(permission) {
method: "POST",
credentials: "include",
body: JSON.stringify(newPermission),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -59,5 +74,8 @@ export function deletePermission(permission) {
method: "POST",
credentials: "include",
body: JSON.stringify(newPermission),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getProducts(owner, page = "", pageSize = "", field = "", value =
return fetch(`${Setting.ServerUrl}/api/get-products?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getProduct(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-product?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +40,9 @@ export function updateProduct(owner, name, product) {
method: "POST",
credentials: "include",
body: JSON.stringify(newProduct),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -43,6 +52,9 @@ export function addProduct(product) {
method: "POST",
credentials: "include",
body: JSON.stringify(newProduct),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -52,6 +64,9 @@ export function deleteProduct(product) {
method: "POST",
credentials: "include",
body: JSON.stringify(newProduct),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -59,5 +74,8 @@ export function buyProduct(owner, name, providerId) {
return fetch(`${Setting.ServerUrl}/api/buy-product?id=${owner}/${encodeURIComponent(name)}&providerName=${providerId}`, {
method: "POST",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getProviders(owner, page = "", pageSize = "", field = "", value
return fetch(`${Setting.ServerUrl}/api/get-providers?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getProvider(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-provider?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +40,9 @@ export function updateProvider(owner, name, provider) {
method: "POST",
credentials: "include",
body: JSON.stringify(newProvider),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -43,6 +52,9 @@ export function addProvider(provider) {
method: "POST",
credentials: "include",
body: JSON.stringify(newProvider),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -52,5 +64,8 @@ export function deleteProvider(provider) {
method: "POST",
credentials: "include",
body: JSON.stringify(newProvider),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,5 +18,8 @@ export function getRecords(page, pageSize, field = "", value = "", sortField = "
return fetch(`${Setting.ServerUrl}/api/get-records?pageSize=${pageSize}&p=${page}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getResources(owner, user, page = "", pageSize = "", field = "",
return fetch(`${Setting.ServerUrl}/api/get-resources?owner=${owner}&user=${user}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getResource(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-resource?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +40,9 @@ export function updateResource(owner, name, resource) {
method: "POST",
credentials: "include",
body: JSON.stringify(newResource),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -43,6 +52,9 @@ export function addResource(resource) {
method: "POST",
credentials: "include",
body: JSON.stringify(newResource),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -52,6 +64,9 @@ export function deleteResource(resource, provider = "") {
method: "POST",
credentials: "include",
body: JSON.stringify(newResource),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -63,5 +78,8 @@ export function uploadResource(owner, user, tag, parent, fullFilePath, file, pro
body: formData,
method: "POST",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getRoles(owner, page = "", pageSize = "", field = "", value = ""
return fetch(`${Setting.ServerUrl}/api/get-roles?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getRole(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-role?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +40,9 @@ export function updateRole(owner, name, role) {
method: "POST",
credentials: "include",
body: JSON.stringify(newRole),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -43,6 +52,9 @@ export function addRole(role) {
method: "POST",
credentials: "include",
body: JSON.stringify(newRole),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -52,5 +64,8 @@ export function deleteRole(role) {
method: "POST",
credentials: "include",
body: JSON.stringify(newRole),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getSyncers(owner, page = "", pageSize = "", field = "", value =
return fetch(`${Setting.ServerUrl}/api/get-syncers?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getSyncer(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-syncer?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +40,9 @@ export function updateSyncer(owner, name, syncer) {
method: "POST",
credentials: "include",
body: JSON.stringify(newSyncer),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -43,6 +52,9 @@ export function addSyncer(syncer) {
method: "POST",
credentials: "include",
body: JSON.stringify(newSyncer),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -52,6 +64,9 @@ export function deleteSyncer(syncer) {
method: "POST",
credentials: "include",
body: JSON.stringify(newSyncer),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -59,5 +74,8 @@ export function runSyncer(owner, name) {
return fetch(`${Setting.ServerUrl}/api/run-syncer?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getSystemInfo(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-system-info?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,5 +28,8 @@ export function getGitHubLatestReleaseVersion() {
return fetch(`${Setting.ServerUrl}/api/get-release`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getTokens(owner, page = "", pageSize = "", field = "", value = "
return fetch(`${Setting.ServerUrl}/api/get-tokens?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getToken(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-token?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +40,9 @@ export function updateToken(owner, name, token) {
method: "POST",
credentials: "include",
body: JSON.stringify(newToken),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -43,6 +52,9 @@ export function addToken(token) {
method: "POST",
credentials: "include",
body: JSON.stringify(newToken),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -52,5 +64,8 @@ export function deleteToken(token) {
method: "POST",
credentials: "include",
body: JSON.stringify(newToken),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -19,6 +19,9 @@ export function getGlobalUsers(page, pageSize, field = "", value = "", sortField
return fetch(`${Setting.ServerUrl}/api/get-global-users?p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -26,6 +29,9 @@ export function getUsers(owner, page = "", pageSize = "", field = "", value = ""
return fetch(`${Setting.ServerUrl}/api/get-users?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -33,6 +39,9 @@ export function getUser(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-user?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -42,6 +51,9 @@ export function updateUser(owner, name, user) {
method: "POST",
credentials: "include",
body: JSON.stringify(newUser),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -51,6 +63,9 @@ export function addUser(user) {
method: "POST",
credentials: "include",
body: JSON.stringify(newUser),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -60,6 +75,9 @@ export function deleteUser(user) {
method: "POST",
credentials: "include",
body: JSON.stringify(newUser),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -85,6 +103,9 @@ export function setPassword(userOwner, userName, oldPassword, newPassword) {
method: "POST",
credentials: "include",
body: formData,
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -101,6 +122,9 @@ export function sendCode(checkType, checkId, checkKey, dest, type, applicationId
method: "POST",
credentials: "include",
body: formData,
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json()).then(res => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t("user:Code Sent"));
@ -121,6 +145,9 @@ export function verifyCaptcha(captchaType, captchaToken, clientSecret) {
method: "POST",
credentials: "include",
body: formData,
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json()).then(res => {
if (res.status === "ok") {
if (res.data) {
@ -145,11 +172,17 @@ export function resetEmailOrPhone(dest, type, code) {
method: "POST",
credentials: "include",
body: formData,
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
export function getCaptcha(owner, name, isCurrentProvider) {
return fetch(`${Setting.ServerUrl}/api/get-captcha?applicationId=${owner}/${encodeURIComponent(name)}&isCurrentProvider=${isCurrentProvider}`, {
method: "GET",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json()).then(res => res.data);
}

View File

@ -18,6 +18,9 @@ export function registerWebauthnCredential() {
return fetch(`${Setting.ServerUrl}/api/webauthn/signup/begin`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
})
.then(res => res.json())
.then((credentialCreationOptions) => {
@ -62,6 +65,9 @@ export function deleteUserWebAuthnCredential(credentialID) {
credentials: "include",
body: form,
dataType: "text",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}

View File

@ -18,6 +18,9 @@ export function getWebhooks(owner, page = "", pageSize = "", field = "", value =
return fetch(`${Setting.ServerUrl}/api/get-webhooks?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -25,6 +28,9 @@ export function getWebhook(owner, name) {
return fetch(`${Setting.ServerUrl}/api/get-webhook?id=${owner}/${encodeURIComponent(name)}`, {
method: "GET",
credentials: "include",
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -34,6 +40,9 @@ export function updateWebhook(owner, name, webhook) {
method: "POST",
credentials: "include",
body: JSON.stringify(newWebhook),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -43,6 +52,9 @@ export function addWebhook(webhook) {
method: "POST",
credentials: "include",
body: JSON.stringify(newWebhook),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}
@ -52,5 +64,8 @@ export function deleteWebhook(webhook) {
method: "POST",
credentials: "include",
body: JSON.stringify(newWebhook),
headers: {
"Accept-Language": Setting.getAcceptLanguage(),
},
}).then(res => res.json());
}