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