forked from tsai/budibase
42 changed files with 734 additions and 567 deletions
@ -1,7 +1,15 @@ |
|||||
<script> |
<script> |
||||
|
import { onMount } from "svelte" |
||||
import { email } from "stores/portal" |
import { email } from "stores/portal" |
||||
|
import { notifications } from "@budibase/bbui" |
||||
|
|
||||
email.templates.fetch() |
onMount(async () => { |
||||
|
try { |
||||
|
await email.templates.fetch() |
||||
|
} catch (error) { |
||||
|
notifications.error("Error fetching email templates") |
||||
|
} |
||||
|
}) |
||||
</script> |
</script> |
||||
|
|
||||
<slot /> |
<slot /> |
||||
|
|||||
@ -0,0 +1,86 @@ |
|||||
|
export const buildConfigEndpoints = API => ({ |
||||
|
/** |
||||
|
* Saves a global config. |
||||
|
* @param config the config to save |
||||
|
*/ |
||||
|
saveConfig: async config => { |
||||
|
return await API.post({ |
||||
|
url: "/api/global/configs", |
||||
|
body: config, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Gets a global config of a certain type. |
||||
|
* @param type the type to fetch |
||||
|
*/ |
||||
|
getConfig: async type => { |
||||
|
return await API.get({ |
||||
|
url: `/api/global/configs/${type}`, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Gets the config for a certain tenant. |
||||
|
* @param tenantId the tenant ID to get the config for |
||||
|
*/ |
||||
|
getTenantConfig: async tenantId => { |
||||
|
return await API.get({ |
||||
|
url: `/api/global/configs/public?tenantId=${tenantId}`, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Gets the OIDC config for a certain tenant. |
||||
|
* @param tenantId the tenant ID to get the config for |
||||
|
*/ |
||||
|
getOIDCConfig: async tenantId => { |
||||
|
return await API.get({ |
||||
|
url: `/api/global/configs/public/oidc?tenantId=${tenantId}`, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Gets the checklist for a specific tenant. |
||||
|
* @param tenantId the tenant ID to get the checklist for |
||||
|
*/ |
||||
|
getChecklist: async tenantId => { |
||||
|
return await API.get({ |
||||
|
url: `/api/global/configs/checklist?tenantId=${tenantId}`, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Updates the company logo for the environment. |
||||
|
* @param data the logo form data |
||||
|
*/ |
||||
|
uploadLogo: async data => { |
||||
|
return await API.post({ |
||||
|
url: "/api/global/configs/upload/settings/logoUrl", |
||||
|
body: data, |
||||
|
json: false, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Uploads a logo for an OIDC provider. |
||||
|
* @param name the name of the OIDC provider |
||||
|
* @param data the logo form data to upload |
||||
|
*/ |
||||
|
uploadOIDCLogo: async ({ name, data }) => { |
||||
|
return await API.post({ |
||||
|
url: `/api/global/configs/upload/logos_oidc/${name}`, |
||||
|
body: data, |
||||
|
json: false, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Gets the list of OIDC logos. |
||||
|
*/ |
||||
|
getOIDCLogos: async () => { |
||||
|
return await API.get({ |
||||
|
url: "/api/global/configs/logos_oidc", |
||||
|
}) |
||||
|
}, |
||||
|
}) |
||||
@ -0,0 +1,19 @@ |
|||||
|
export const buildOtherEndpoints = API => ({ |
||||
|
/** |
||||
|
* TODO: find out what this is |
||||
|
*/ |
||||
|
checkImportComplete: async () => { |
||||
|
return await API.get({ |
||||
|
url: "/api/cloud/import/complete", |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Gets the current environment details. |
||||
|
*/ |
||||
|
getEnvironment: async () => { |
||||
|
return await API.get({ |
||||
|
url: "/api/system/environment", |
||||
|
}) |
||||
|
}, |
||||
|
}) |
||||
@ -0,0 +1,129 @@ |
|||||
|
export const buildUserEndpoints = API => ({ |
||||
|
/** |
||||
|
* Fetches the currently logged-in user object. |
||||
|
* Used in client apps. |
||||
|
*/ |
||||
|
fetchSelf: async () => { |
||||
|
return await API.get({ |
||||
|
url: "/api/self", |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Fetches the currently logged-in user object. |
||||
|
* Used in the builder. |
||||
|
*/ |
||||
|
fetchBuilderSelf: async () => { |
||||
|
return await API.get({ |
||||
|
url: "/api/global/users/self", |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Gets a list of users in the current tenant. |
||||
|
*/ |
||||
|
getUsers: async () => { |
||||
|
return await API.get({ |
||||
|
url: "/api/global/users", |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Creates a user for an app. |
||||
|
* @param user the user to create |
||||
|
*/ |
||||
|
createAppUser: async user => { |
||||
|
return await API.post({ |
||||
|
url: "/api/users/metadata", |
||||
|
body: user, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Updates the current user metadata. |
||||
|
* @param metadata the metadata to save |
||||
|
*/ |
||||
|
updateOwnMetadata: async metadata => { |
||||
|
return await API.post({ |
||||
|
url: "/api/users/metadata/self", |
||||
|
body: metadata, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Creates an admin user. |
||||
|
* @param adminUser the admin user to create |
||||
|
*/ |
||||
|
createAdminUser: async adminUser => { |
||||
|
return await API.post({ |
||||
|
url: "/api/global/users/init", |
||||
|
body: adminUser, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Updates the current logged-in user. |
||||
|
* @param user the new user object to save |
||||
|
*/ |
||||
|
updateSelf: async user => { |
||||
|
return await API.post({ |
||||
|
url: "/api/global/users/self", |
||||
|
body: user, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Creates or updates a user in the current tenant. |
||||
|
* @param user the new user to create |
||||
|
*/ |
||||
|
saveUser: async user => { |
||||
|
return await API.post({ |
||||
|
url: "/api/global/users", |
||||
|
body: user, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Deletes a user from the curernt tenant. |
||||
|
* @param userId the ID of the user to delete |
||||
|
*/ |
||||
|
deleteUser: async userId => { |
||||
|
return await API.delete({ |
||||
|
url: `/api/global/users/${userId}`, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Invites a user to the current tenant. |
||||
|
* @param email the email address to send the invitation to |
||||
|
* @param builder whether the user should be a global builder |
||||
|
* @param admin whether the user should be a global admin |
||||
|
*/ |
||||
|
inviteUser: async ({ email, builder, admin }) => { |
||||
|
return await API.post({ |
||||
|
url: "/api/global/users/invite", |
||||
|
body: { |
||||
|
email, |
||||
|
userInfo: { |
||||
|
admin: admin ? { global: true } : undefined, |
||||
|
builder: builder ? { global: true } : undefined, |
||||
|
}, |
||||
|
}, |
||||
|
}) |
||||
|
}, |
||||
|
|
||||
|
/** |
||||
|
* Accepts an invitation to join the platform and creates a user. |
||||
|
* @param inviteCode the invite code sent in the email |
||||
|
* @param password the password for the newly created user |
||||
|
*/ |
||||
|
acceptInvitation: async ({ inviteCode, password }) => { |
||||
|
return await API.post({ |
||||
|
url: "/api/global/users/invite/accept", |
||||
|
body: { |
||||
|
inviteCode, |
||||
|
password, |
||||
|
}, |
||||
|
}) |
||||
|
}, |
||||
|
}) |
||||
Loading…
Reference in new issue