usage page updates
This commit is contained in:
parent
76e18fb6de
commit
af7c64255b
|
@ -17,14 +17,6 @@ export const DEFINITIONS: MigrationDefinition[] = [
|
|||
type: MigrationType.APP,
|
||||
name: MigrationName.APP_URLS,
|
||||
},
|
||||
{
|
||||
type: MigrationType.GLOBAL,
|
||||
name: MigrationName.DEVELOPER_QUOTA,
|
||||
},
|
||||
{
|
||||
type: MigrationType.GLOBAL,
|
||||
name: MigrationName.PUBLISHED_APP_QUOTA,
|
||||
},
|
||||
{
|
||||
type: MigrationType.APP,
|
||||
name: MigrationName.EVENT_APP_BACKFILL,
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
export let duration = 1000
|
||||
export let width = false
|
||||
export let sideLabel = false
|
||||
export let hidePercentage = true
|
||||
export let color // red, green, default = blue
|
||||
|
||||
export let size = "M"
|
||||
|
||||
|
@ -37,7 +39,7 @@
|
|||
<slot />
|
||||
</div>
|
||||
{/if}
|
||||
{#if value || value === 0}
|
||||
{#if !hidePercentage && (value || value === 0)}
|
||||
<div
|
||||
class="spectrum-FieldLabel spectrum-ProgressBar-percentage spectrum-FieldLabel--size{size}"
|
||||
>
|
||||
|
@ -47,8 +49,19 @@
|
|||
<div class="spectrum-ProgressBar-track">
|
||||
<div
|
||||
class="spectrum-ProgressBar-fill"
|
||||
class:color-green={color === "green"}
|
||||
class:color-red={color === "red"}
|
||||
style={value || value === 0 ? `width: ${$progress}%` : ""}
|
||||
/>
|
||||
</div>
|
||||
<div class="spectrum-ProgressBar-label" hidden="" />
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.color-green {
|
||||
background: #009562;
|
||||
}
|
||||
.color-red {
|
||||
background: #dd2019;
|
||||
}
|
||||
</style>
|
||||
|
|
|
@ -443,7 +443,6 @@ const destroyApp = async (ctx: any) => {
|
|||
const result = await db.destroy()
|
||||
|
||||
if (isUnpublish) {
|
||||
await quotas.removePublishedApp()
|
||||
await events.app.unpublished(app)
|
||||
} else {
|
||||
await quotas.removeApp()
|
||||
|
|
|
@ -188,12 +188,7 @@ const _deployApp = async function (ctx: any) {
|
|||
|
||||
console.log("Deploying app...")
|
||||
|
||||
let app
|
||||
if (await isFirstDeploy()) {
|
||||
app = await quotas.addPublishedApp(() => deployApp(deployment))
|
||||
} else {
|
||||
app = await deployApp(deployment)
|
||||
}
|
||||
let app = await deployApp(deployment)
|
||||
|
||||
await events.app.published(app)
|
||||
ctx.body = deployment
|
||||
|
|
|
@ -35,12 +35,10 @@ const formatUsage = (usage: QuotaUsage) => {
|
|||
let maxAutomations = 0
|
||||
let maxQueries = 0
|
||||
let rows = 0
|
||||
let developers = 0
|
||||
|
||||
if (usage) {
|
||||
if (usage.usageQuota) {
|
||||
rows = usage.usageQuota.rows
|
||||
developers = usage.usageQuota.developers
|
||||
}
|
||||
|
||||
if (usage.monthly) {
|
||||
|
@ -59,7 +57,6 @@ const formatUsage = (usage: QuotaUsage) => {
|
|||
maxAutomations,
|
||||
maxQueries,
|
||||
rows,
|
||||
developers,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
const { createUserBuildersView } = require("@budibase/backend-core/db")
|
||||
import * as syncDevelopers from "./usageQuotas/syncDevelopers"
|
||||
|
||||
/**
|
||||
* Date:
|
||||
* March 2022
|
||||
*
|
||||
* Description:
|
||||
* Create the builder users view and sync the developer count
|
||||
*/
|
||||
|
||||
export const run = async (db: any) => {
|
||||
await createUserBuildersView(db)
|
||||
await syncDevelopers.run()
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
import * as syncPublishedApps from "./usageQuotas/syncPublishedApps"
|
||||
|
||||
/**
|
||||
* Date:
|
||||
* March 2022
|
||||
*
|
||||
* Description:
|
||||
* Sync the published apps count
|
||||
*/
|
||||
|
||||
export const run = async (db: any) => {
|
||||
await syncPublishedApps.run()
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
import { getTenantId } from "@budibase/backend-core/tenancy"
|
||||
import { utils } from "@budibase/backend-core"
|
||||
import { quotas, QuotaUsageType, StaticQuotaName } from "@budibase/pro"
|
||||
|
||||
export const run = async () => {
|
||||
// get developer count
|
||||
const developerCount = await utils.getBuildersCount()
|
||||
|
||||
// sync developer count
|
||||
const tenantId = getTenantId()
|
||||
console.log(
|
||||
`[Tenant: ${tenantId}] Syncing developer count: ${developerCount}`
|
||||
)
|
||||
await quotas.setUsage(
|
||||
developerCount,
|
||||
StaticQuotaName.DEVELOPERS,
|
||||
QuotaUsageType.STATIC
|
||||
)
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
import { getTenantId } from "@budibase/backend-core/tenancy"
|
||||
import { getAllApps } from "@budibase/backend-core/db"
|
||||
import { quotas, QuotaUsageType, StaticQuotaName } from "@budibase/pro"
|
||||
|
||||
export const run = async () => {
|
||||
// get app count
|
||||
const opts: any = { dev: false }
|
||||
const prodApps = await getAllApps(opts)
|
||||
const prodAppCount = prodApps ? prodApps.length : 0
|
||||
|
||||
// sync app count
|
||||
const tenantId = getTenantId()
|
||||
console.log(
|
||||
`[Tenant: ${tenantId}] Syncing published app count: ${prodAppCount}`
|
||||
)
|
||||
await quotas.setUsage(
|
||||
prodAppCount,
|
||||
StaticQuotaName.PUBLISHED_APPS,
|
||||
QuotaUsageType.STATIC
|
||||
)
|
||||
}
|
|
@ -6,8 +6,6 @@ import env from "../environment"
|
|||
import * as userEmailViewCasing from "./functions/userEmailViewCasing"
|
||||
import * as quota1 from "./functions/quotas1"
|
||||
import * as appUrls from "./functions/appUrls"
|
||||
import * as developerQuota from "./functions/developerQuota"
|
||||
import * as publishedAppsQuota from "./functions/publishedAppsQuota"
|
||||
import * as backfill from "./functions/backfill"
|
||||
|
||||
/**
|
||||
|
@ -42,20 +40,6 @@ export const buildMigrations = () => {
|
|||
})
|
||||
break
|
||||
}
|
||||
case MigrationName.DEVELOPER_QUOTA: {
|
||||
serverMigrations.push({
|
||||
...definition,
|
||||
fn: developerQuota.run,
|
||||
})
|
||||
break
|
||||
}
|
||||
case MigrationName.PUBLISHED_APP_QUOTA: {
|
||||
serverMigrations.push({
|
||||
...definition,
|
||||
fn: publishedAppsQuota.run,
|
||||
})
|
||||
break
|
||||
}
|
||||
case MigrationName.EVENT_APP_BACKFILL: {
|
||||
serverMigrations.push({
|
||||
...definition,
|
||||
|
|
|
@ -41,8 +41,6 @@ export enum MigrationName {
|
|||
USER_EMAIL_VIEW_CASING = "user_email_view_casing",
|
||||
QUOTAS_1 = "quotas_1",
|
||||
APP_URLS = "app_urls",
|
||||
DEVELOPER_QUOTA = "developer_quota",
|
||||
PUBLISHED_APP_QUOTA = "published_apps_quota",
|
||||
EVENT_APP_BACKFILL = "event_app_backfill",
|
||||
EVENT_GLOBAL_BACKFILL = "event_global_backfill",
|
||||
EVENT_INSTALLATION_BACKFILL = "event_installation_backfill",
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import env from "../../environment"
|
||||
import { quotas } from "@budibase/pro"
|
||||
import * as apps from "../../utilities/appService"
|
||||
import * as eventHelpers from "./events"
|
||||
import {
|
||||
|
@ -164,15 +163,7 @@ export const save = async (
|
|||
return putOpts
|
||||
}
|
||||
// save the user to db
|
||||
let response
|
||||
const putUserFn = () => {
|
||||
return db.put(user)
|
||||
}
|
||||
if (eventHelpers.isAddingBuilder(user, dbUser)) {
|
||||
response = await quotas.addDeveloper(putUserFn)
|
||||
} else {
|
||||
response = await putUserFn()
|
||||
}
|
||||
let response = await db.put(user)
|
||||
user._rev = response.rev
|
||||
|
||||
await eventHelpers.handleSaveEvents(user, dbUser)
|
||||
|
@ -223,7 +214,6 @@ export const destroy = async (id: string, currentUser: any) => {
|
|||
await deprovisioning.removeUserFromInfoDB(dbUser)
|
||||
await db.remove(dbUser._id, dbUser._rev)
|
||||
await eventHelpers.handleDeleteEvents(dbUser)
|
||||
await quotas.removeUser(dbUser)
|
||||
await cache.user.invalidateUser(dbUser._id)
|
||||
await sessions.invalidateSessions(dbUser._id)
|
||||
// let server know to sync user
|
||||
|
|
Loading…
Reference in New Issue