Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async created () {
this.$emit('started')
try {
this.response = await Minimum(this.request(), 200)
} catch (error) {
this.$emit('failed', error)
}
this.$emit('finished')
},
mounted() {
Minimum(
Nova.request().get(this.src, {
responseType: 'blob',
})
)
.then(({ headers, data }) => {
const blob = new Blob([data], { type: headers['content-type'] })
let newImage = new Image()
newImage.src = window.URL.createObjectURL(blob)
newImage.className = 'block w-full'
newImage.draggable = false
this.$refs.card.$el.appendChild(newImage)
this.loading = false
})
.catch(error => {
this.missing = true
this.$emit('missing', true)
getResource() {
this.resource = null
return Minimum(
Nova.request().get('/nova-api/' + this.resourceName + '/' + this.resourceId)
)
.then(({ data: { panels, resource } }) => {
this.panels = panels
this.resource = resource
this.loading = false
})
.catch(error => {
if (error.response.status >= 500) {
Nova.$emit('error', error.response.data.message)
return
}
if (error.response.status === 404 && this.initialLoading) {
this.$router.push({ name: '404' })
return
fetch() {
this.loading = true
Minimum(Nova.request().get(this.metricEndpoint, this.metricPayload)).then(
({
data: {
value: { labels, trend, value, prefix, suffix, format },
},
}) => {
this.value = value
this.labels = Object.keys(trend)
this.data = {
labels: Object.keys(trend),
series: [
_.map(trend, (value, label) => {
return {
meta: label,
value: value,
}
}),
async fetchResults(search) {
this.results = []
if (search !== '') {
try {
const { data: results } = await Minimum(
Nova.request().get('/nova-api/search', {
params: { search },
})
)
this.results = results
this.loading = false
} catch (e) {
this.loading = false
throw e
}
}
},
fetch() {
this.loading = true
Minimum(Nova.request().get(this.metricEndpoint, this.rangePayload)).then(
({
data: {
value: { value, previous, prefix, suffix, format },
},
}) => {
this.value = value
this.format = format || this.format
this.prefix = prefix || this.prefix
this.suffix = suffix || this.suffix
this.previous = previous
this.loading = false
}
)
},
},
this.$nextTick(() => {
this.clearResourceSelections()
return Minimum(
Nova.request().get('/nova-api/' + this.resourceName + '/lens/' + this.lens, {
params: this.resourceRequestQueryString,
})
).then(({ data }) => {
this.resources = []
this.resourceResponse = data
this.resources = data.resources
this.softDeletes = data.softDeletes
this.hasId = data.hasId
this.loading = false
this.getAllMatchingResourceCount()
if (!this.hasId) {
this.$nextTick(() => {
this.clearResourceSelections()
return Minimum(
Nova.request().get('/nova-api/' + this.resourceName, {
params: this.resourceRequestQueryString,
})
).then(({ data }) => {
this.resources = []
this.resourceResponse = data
this.resources = data.resources
this.softDeletes = data.softDeletes
this.loading = false
this.getAllMatchingResourceCount()
})
})
},
fetch() {
this.loading = true
Minimum(Nova.request(this.cardEndpoint)).then(({ data: { value: { value } } }) => {
this.chartData = value
this.loading = false
})
},
},