Skip to content

Commit

Permalink
Merge pull request #1725 from aziontech/dev
Browse files Browse the repository at this point in the history
DEPLOY 2024-09-18
  • Loading branch information
HerbertJulio authored Sep 19, 2024
2 parents 513b8f5 + 8f05cf7 commit 3e71176
Show file tree
Hide file tree
Showing 58 changed files with 1,281 additions and 133 deletions.
10 changes: 10 additions & 0 deletions azion/production/azion.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@
"origin-id": 153663,
"origin-key": "6ec17c87-d2fb-4c28-a3b7-588b1ae61bf2",
"name": "origin-github-allowed-accounts"
},
{
"origin-id": 154233,
"origin-key": "8c16e835-20af-41d5-a688-cac8e6aefa94",
"name": "origin-console-feedback"
}
],
"rules-engine": {
Expand Down Expand Up @@ -152,6 +157,11 @@
"id": 296352,
"name": "Route List Client Ids to Github",
"phase": "request"
},
{
"id": 297983,
"name": "Route Send Feedback",
"phase": "request"
}
]
},
Expand Down
2 changes: 2 additions & 0 deletions cypress/e2e/edge-application/add-error-response.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ describe('Edge Application', { tags: ['@dev4'] }, () => {
fixtures.edgeApplicationName = generateUniqueName('EdgeApp')
// Login
cy.login()
cy.intercept('GET', '/api/v3/edge_applications/*/origins*').as('getOriginsApi')

fixtures = {
functionName: generateUniqueName('EdgeFunction'),
Expand Down Expand Up @@ -66,6 +67,7 @@ describe('Edge Application', { tags: ['@dev4'] }, () => {

//select origin
cy.get(selectors.edgeApplication.errorResponses.origin).click()
cy.wait('@getOriginsApi')
cy.get(selectors.edgeApplication.errorResponses.origin).find('li').eq(0).click()

//assert
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"primeflex": "^3.3.1",
"primeicons": "^7.0.0",
"primevue": "^3.35.0",
"primevue-sass-theme": "git+https://github.com/primefaces/primevue-sass-theme.git#3.39.0",
"qrcode.vue": "^3.4.1",
"recaptcha-v3": "^1.10.0",
"vee-validate": "^4.11.1",
Expand Down
26 changes: 23 additions & 3 deletions src/modules/real-time-metrics/chart/format-c3-graph-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,11 @@ function generateMeanLineValues(resultChart, mean) {
* @returns {string} - The title case string
*/
export function camelToTitle(text) {
const title = text.replace(/([A-Z])/g, ' $1').replace(/([a-zA-Z])(\d+)/g, '$1 $2')
return title.charAt(0).toUpperCase() + title.slice(1)
return text
.replace(/([a-z])([A-Z0-9])/g, '$1 $2')
.replace(/\s+/g, ' ')
.trim()
.replace(/\b\w/g, (char) => char.toUpperCase())
}

/**
Expand Down Expand Up @@ -527,6 +530,16 @@ export function FormatC3GraphProps({
tooltip: {
show: window.innerWidth > CHART_RULES.SCREEN_XSMALL_BREAKPOINT,
contents(d, defaultTitleFormat, defaultValueFormat, color) {
if (chartData.type === 'ordered-bar') {
const { index } = d[0]
return this.getTooltipContent(
resetTooltipLabel(d),
defaultTitleFormat,
defaultValueFormat,
() => CHART_RULES.BASE_COLOR_PATTERNS[index]
)
}

return this.getTooltipContent(
resetTooltipLabel(d),
defaultTitleFormat,
Expand All @@ -540,10 +553,17 @@ export function FormatC3GraphProps({
return new Date(d).toLocaleString('en-US')
}
if (typeof d === 'number') {
return ''
return null
}
return d
},
name: (name, _, __, idx) => {
if (chartData.type === 'ordered-bar') {
return resultChart[0][idx + 1]
}

return name
},
value: function (value) {
return formatYAxisLabels(value, chartData)
}
Expand Down
4 changes: 2 additions & 2 deletions src/modules/real-time-metrics/chart/format-graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export function formatDataUnit(data, chartData) {

if (chartData.dataUnit === 'count') {
return {
value: value,
unit: ''
value: Intl.NumberFormat('en', { notation: 'compact' }).format(value),
unit: chartData?.aggregations?.[0]?.variable || ''
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/modules/real-time-metrics/constants/dashboards.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ const PAGES_DASHBOARDS = {
},
{
id: 9,
label: 'Bot Manager',
path: 'bot-manager',
label: 'Bot Manager Advanced',
path: 'bot-manager-advanced',
groupId: 2,
dashboards: [
{
id: '371360344901061482',
label: 'Bot Manager Summary',
path: 'bot-manager-summary',
label: 'Overview',
path: 'overview',
dataset: 'botManagerMetrics'
}
]
Expand Down
18 changes: 9 additions & 9 deletions src/modules/real-time-metrics/constants/reports-texts.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,32 +177,32 @@ const REPORTS_TEXTS = {
botManager: {
botManagerSummary: {
badBotHits: {
description: 'Number of requests identified as bad bot'
description: 'Number of requests identified as bad bots.'
},
goodBotHits: {
description: 'Number of requests identified as good bot'
description: 'Number of requests identified as good bots.'
},
botHits: {
description: 'Number of requests identified as bot'
description: 'Number of requests identified as bots.'
},
transactions: {
description: 'Number of requests evaluated by the Azion Bot Manager'
description: 'Number of requests evaluated by Azion Bot Manager.'
},
botTraffic: {
description: 'Sum of requests grouped by classification'
description: 'Sum of requests grouped by classification.'
},
botCaptcha: {
description: 'Sum of CAPTCHA challenge results returned for requests classified as bots'
description: 'Sum of CAPTCHA challenge results returned for requests classified as bots.'
},
botAction: {
description:
'Action taken by the Azion Bot Manager for requests identified as bots, displayed in both absolute values and percentages'
'Actions taken by Azion Bot Manager for requests identified as bots, displayed in both absolute values and percentages.'
},
botClassification: {
description: 'Number of requests by bot category'
description: 'Number of requests by bot categories.'
},
botActivityMap: {
description: 'Sum of requests identified as bots, presented by the country of origin'
description: 'Sum of requests identified as bots, presented by the country of origin.'
}
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/modules/real-time-metrics/constants/reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ const REPORTS = [
fields: [],
orderDirection: 'DESC',
dashboardId: '371360344901061482',
variationType: 'regular',
variationType: 'inverse',
helpCenterPath: ''
},
{
Expand Down Expand Up @@ -891,7 +891,7 @@ const REPORTS = [
fields: [],
orderDirection: 'DESC',
dashboardId: '371360344901061482',
variationType: 'regular',
variationType: 'neutral',
helpCenterPath: ''
},
{
Expand Down Expand Up @@ -921,7 +921,7 @@ const REPORTS = [
fields: [],
orderDirection: 'DESC',
dashboardId: '371360344901061482',
variationType: 'regular',
variationType: 'inverse',
helpCenterPath: ''
},
{
Expand All @@ -948,7 +948,7 @@ const REPORTS = [
fields: [],
orderDirection: 'DESC',
dashboardId: '371360344901061482',
variationType: 'regular',
variationType: 'neutral',
helpCenterPath: ''
},
{
Expand All @@ -970,7 +970,7 @@ const REPORTS = [
variable: 'requests'
}
],
limit: 5000,
limit: 10000,
groupBy: ['classified'],
orderDirection: 'ASC',
dashboardId: '371360344901061482',
Expand Down Expand Up @@ -1106,7 +1106,7 @@ const REPORTS = [
label: 'Bot Activity Map',
description: REPORTS_TEXTS.botManager.botManagerSummary.botActivityMap.description,
aggregationType: 'sum',
columns: 12,
columns: 6,
type: 'map',
xAxis: 'cat',
isTopX: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,18 @@ export default function ExtractFiltersAndVariables(pFilters) {
Object.assign(variables, dataset.variables)
}

const genericFilter = extractGeneric(pFilters)
if (genericFilter) {
Object.assign(filters, genericFilter.filters)
}

const andFilter = extractAnd(pFilters)
if (andFilter) {
Object.assign(filters, andFilter.filters)
params.push(...andFilter.params)
Object.assign(variables, andFilter.variables)
}

const genericFilter = extractGeneric(pFilters)
if (genericFilter) {
Object.assign(filters, genericFilter.filters)
}

return {
filters,
params,
Expand Down
12 changes: 10 additions & 2 deletions src/modules/real-time-metrics/reports/convert-beholder-to-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,19 @@ const formatMapChartData = ({ report, data }) => {
const geolocCountryName = report.groupBy[0]
const fieldName = report.aggregations[0].aggregation || report.fields[0]

const exhibitionValueFormatter = (value) => {
const variableType = report.aggregations[0].variable
return `${camelToTitle(variableType)}: ${Intl.NumberFormat('en', {
notation: 'compact'
}).format(value)}`
}

const heatmap = data[dataset].map((datasetMapData) => {
const value = datasetMapData[fieldName]
const result = {
countryName: datasetMapData[geolocCountryName],
value: datasetMapData[fieldName],
exhibitionValue: formatYAxisLabels(datasetMapData[fieldName], report),
value,
exhibitionValue: exhibitionValueFormatter(value),
rangeVariation: report.variationType
}

Expand Down
20 changes: 6 additions & 14 deletions src/modules/real-time-metrics/reports/fill-result-query.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,14 @@ function generateDefaultGroupedResults(intervalDefaults, data, groupBy, aggregat
const groupedValues = [...new Set(data.map((item) => item[groupBy]))]

for (let idx = 1; idx <= numberOfResults; idx++) {
const newTimestamp = new Date(intervalToBeAdded * idx + begin).toISOString()
const newTimestamp = new Date(intervalToBeAdded * idx + begin).fromLocaletoBeholderFormat()

groupedValues.forEach((groupItem) => {
const existingItem = data.find(
(item) => item.ts === newTimestamp && item.classified === groupItem
)

if (existingItem) {
defaultResults.push(existingItem)
} else {
defaultResults.push({
[aggregationType]: 0,
[groupBy]: groupItem,
ts: newTimestamp
})
}
defaultResults.push({
[aggregationType]: 0,
[groupBy]: groupItem,
ts: `${newTimestamp}Z`
})
})
}

Expand Down
38 changes: 30 additions & 8 deletions src/router/hooks/redirectToManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import { useAccountStore } from '@/stores/account'
import { listClientIdsReleasedForConsoleService } from '@/services/account-services'

/** @type {import('vue-router').NavigationGuardWithThis} */
export default async function redirectToManager(to, __, next) {
export default async function redirectToManager(to, from, next) {
const accountStore = useAccountStore()
const isPrivateRoute = !to.meta.isPublic
const accountData = accountStore.accountData

if (accountStore.shouldAvoidCalculateServicePlan) {
return next()
if (accountStore.shouldAvoidCalculateServicePlan || accountStore.hasAccessConsole) {
return forceRedirectViewAccess(to, next, from, accountStore)
}

try {
Expand All @@ -29,14 +29,19 @@ export default async function redirectToManager(to, __, next) {
}

// account that are kind client, can access with developer service plan
const [{ isDeveloperSupportPlan }, clientIdsReleadesForConsole] = await Promise.all([
const [{ isDeveloperSupportPlan }, consoleReleasedClient] = await Promise.all([
loadContractServicePlan({ clientId: accountData.client_id }),
listClientIdsReleasedForConsoleService()
listClientIdsReleasedForConsoleService(accountData.client_id)
])
accountStore.setAccountData({ isDeveloperSupportPlan: isDeveloperSupportPlan })

accountStore.setAccountData({
isDeveloperSupportPlan: isDeveloperSupportPlan,
consoleReleasedClient
})

if (!isDeveloperSupportPlan) {
if (clientIdsReleadesForConsole.includes(accountData.client_id)) {
return next()
if (accountStore.hasAccessConsole) {
return forceRedirectViewAccess(to, next, from, accountStore)
}
permanentRedirectToManager()
}
Expand All @@ -54,3 +59,20 @@ function permanentRedirectToManager() {
window.location.replace(managerUrl)
}
}

function forceRedirectViewAccess(to, next, from, accountStore) {
const viewsAccessRestriction = accountStore.viewsAccessRestriction
const isPrivateRoute = !to.meta.isPublic

if (isPrivateRoute && viewsAccessRestriction?.length) {
if (!viewsAccessRestriction.includes(to.name)) {
if (viewsAccessRestriction.includes(from.name)) {
return next(false)
} else {
return next({ name: viewsAccessRestriction[0] })
}
}
}

return next()
}
5 changes: 4 additions & 1 deletion src/router/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { accountRoutes } from '@routes/account-routes'
import { activityHistoryRoutes } from '@routes/activity-history-routes'
import { azionAiRoutes } from '@routes/azion-ai-routes'

import { cliCallbackRoutes } from '@routes/cli-callback-routes'
import { createNewRoutes } from '@routes/create-new-routes'
import { compareWithAzionRoutes } from '@routes/compare-with-azion'
import { dataStreamRoutes } from '@/router/routes/data-stream-routes'
import { digitalCertificatesRoutes } from '@routes/digital-certificates-routes'
import { domainsRoutes } from '@routes/domains-routes'
Expand Down Expand Up @@ -78,7 +80,8 @@ const router = createRouter({
githubRoutes,
billingRoutes,
importGithubRoutes,
azionAiRoutes
azionAiRoutes,
compareWithAzionRoutes
].concat(errorRoutes)
})

Expand Down
Loading

0 comments on commit 3e71176

Please sign in to comment.