-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JS-based validation with results #307
- Loading branch information
Showing
18 changed files
with
424 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,11 +152,6 @@ | |
"boolean" | ||
] | ||
}, | ||
"stacLint": { | ||
"type": [ | ||
"boolean" | ||
] | ||
}, | ||
"geoTiffResolution": { | ||
"type": [ | ||
"integer" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<template> | ||
<div class="valid"> | ||
<b-spinner v-if="working" :label="$t('source.validating')" small /> | ||
<b-button v-else-if="valid === true" variant="success" :size="size" :to="validationLink"><b-icon-check /> {{ $t('checkbox.true') }}</b-button> | ||
<b-button v-else-if="valid === false" variant="danger" :size="size" :to="validationLink"><b-icon-x /> {{ $t('checkbox.false') }}</b-button> | ||
<template v-else>{{ $t('source.validationNA') }}</template> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import STAC from '../models/stac.js'; | ||
import validateSTAC from 'stac-node-validator'; | ||
import { BIconCheck, BIconX } from 'bootstrap-vue'; | ||
import { mapGetters } from 'vuex'; | ||
export default { | ||
name: "Validation", | ||
components: { | ||
BIconCheck, | ||
BIconX | ||
}, | ||
props: { | ||
data: { | ||
type: Object, | ||
default: null | ||
}, | ||
size: { | ||
type: String, | ||
default: "sm" | ||
} | ||
}, | ||
data() { | ||
return { | ||
working: true, | ||
valid: null | ||
}; | ||
}, | ||
computed: { | ||
...mapGetters(['toBrowserPath']), | ||
validationLink() { | ||
if (this.data instanceof STAC) { | ||
return '/validation' + this.toBrowserPath(this.data.getAbsoluteUrl()); | ||
} | ||
else { | ||
return null; | ||
} | ||
} | ||
}, | ||
async created() { | ||
await this.validate(); | ||
}, | ||
methods: { | ||
async validate() { | ||
this.working = true; | ||
this.valid = null; | ||
try { | ||
if (this.data instanceof STAC) { | ||
const report = await validateSTAC(this.data); | ||
this.valid = report.valid; | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
} finally { | ||
this.working = false; | ||
} | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style> | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<template> | ||
<b-card no-body :header="header"> | ||
<b-list-group flush> | ||
<b-list-group-item v-if="errors.length === 0" variant="success"> | ||
{{ $t('source.valid') }} | ||
</b-list-group-item> | ||
<template v-else> | ||
<b-list-group-item v-for="(error, i) in errors" :key="i" variant="danger"> | ||
{{ makeAjvErrorMessage(error) }} | ||
</b-list-group-item> | ||
</template> | ||
</b-list-group> | ||
</b-card> | ||
</template> | ||
|
||
<script> | ||
import { BListGroup, BListGroupItem } from 'bootstrap-vue'; | ||
import URI from 'urijs'; | ||
import Utils from '../utils'; | ||
export default { | ||
name: "ValidationResult", | ||
components: { | ||
BListGroup, | ||
BListGroupItem | ||
}, | ||
props: { | ||
type: { | ||
type: String, | ||
required: true | ||
}, | ||
title: { | ||
type: String, | ||
required: true | ||
}, | ||
errors: { | ||
type: Array, | ||
required: true | ||
} | ||
}, | ||
computed: { | ||
header() { | ||
if (this.title.includes('://')) { | ||
let uri = URI(this.title); | ||
return uri.directory().replace(/\//g, ' ').trim(); | ||
} | ||
return this.title; | ||
} | ||
}, | ||
methods: { | ||
// ToDo: Import from stac-node-validator | ||
makeAjvErrorMessage(error) { | ||
let message = error.message; | ||
if (Utils.isObject(error.params) && Object.keys(error.params).length > 0) { | ||
let params = Object.entries(error.params) | ||
.map(([key, value]) => { | ||
let label = key.replace(/([^A-Z]+)([A-Z])/g, "$1 $2").toLowerCase(); | ||
return `${label}: ${value}`; | ||
}) | ||
.join(', '); | ||
message += ` (${params})`; | ||
} | ||
if (error.instancePath) { | ||
return `${error.instancePath} ${message}`; | ||
} | ||
else if (error.schemaPath) { | ||
return this.$t('messageForSchemaError', {message, schemaPath: error.schemaPath}); | ||
} | ||
else if (message) { | ||
return message; | ||
} | ||
else { | ||
return String(error); | ||
} | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<style lang="scss"> | ||
#stac-browser .validation .results .card-header { | ||
text-transform: capitalize; | ||
} | ||
</style> |
Oops, something went wrong.