Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add creation dialogs for schema and schema version #37

Merged
merged 6 commits into from
Sep 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
{route: '/organization', title: 'New Organization', icon: mdiFactory},
{route: '/unit', title: 'New Unit', icon: mdiStore},
{route: '/context', title: 'New Context', icon: mdiEllipseOutline},
{route: '/404', title: 'New Schema', icon: mdiFileDocument},
{route: '/404', title: 'New Schema Version', icon: mdiTag},
{route: '/schema', title: 'New Schema', icon: mdiFileDocument},
{route: '/schemaVersion', title: 'New Schema Version', icon: mdiTag},
],
icons: {
sync: mdiSync,
Expand Down
36 changes: 35 additions & 1 deletion src/main/frontend/src/api/SchemataRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const resources = {
units: (o) => `/organizations/${o}/units`,
contexts: (o, u) => `/organizations/${o}/units/${u}/contexts`,
categories: () => '/schema/categories',
scopes: () => '/schema/scopes',
schemata: (o, u, c) => `/organizations/${o}/units/${u}/contexts/${c}/schemas`,
versions: (o, u, c, s) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions`
}
Expand Down Expand Up @@ -48,7 +49,11 @@ export default {
.then(ensureOk)
.then(response => response.data)
},

getScopes() {
return Repository.get(resources.scopes())
.then(ensureOk)
.then(response => response.data)
},
getSchemata(organization, unit, context) {
return Repository.get(resources.schemata(organization, unit, context))
.then(ensureOk)
Expand Down Expand Up @@ -94,4 +99,33 @@ export default {
.then(ensureCreated)
.then(response => response.data)
},
createSchema(organization, unit, context, name, scope, category, description) {
return Repository.post(resources.schemata(organization, unit, context),
{
contextId: '',
name: name,
scope: scope,
category: category,
description: description
}
)
.then(ensureCreated)
.then(response => response.data)
},
createSchemaVersion(
organization, unit, context, schema,
specification, description, status, previousVersion, currentVersion) {
return Repository.post(resources.versions(organization, unit, context, schema),
{
schemaVersionId: '',
specification: specification,
status: status,
previousVersion: previousVersion,
currentVersion: currentVersion,
description: description
}
)
.then(ensureCreated)
.then(response => response.data)
},
}
3 changes: 3 additions & 0 deletions src/main/frontend/src/components/Context.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
:disabled="!namespace || !description || !organization||!unit"
@click="createUnit">Create
</v-btn>
<v-btn color="secondary" to="/schema"
:disabled="!contextId">Create Schema
</v-btn>
</v-card-actions>
</v-card>
</template>
Expand Down
212 changes: 212 additions & 0 deletions src/main/frontend/src/components/Schema.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
<template>
<v-card class="xs12" height="95vh" width="100%">
<v-card-title>Schema</v-card-title>
<v-card-text>
<v-form
ref="form"
lazy-validation
>
<v-row>
<v-col class="d-flex" cols="12">
<v-text-field
v-model="schemaId"
label="SchemaID"
disabled
></v-text-field>
</v-col>
<v-col class="d-flex" cols="12" sm="6">
<v-select
:items="organizations"
label="Organization"
:loading="loading.organizations"
return-object
item-value="organizationId"
item-text="name"
v-model="organization"

></v-select>
</v-col>
<v-col class="d-flex" cols="12" sm="6">
<v-select
:items="units"
label="Unit"
:loading="loading.units"
return-object
item-value="unitId"
item-text="name"
v-model="unit"

></v-select>
</v-col>
<v-col class="d-flex" cols="12" sm="6">
<v-select
:items="contexts"
label="Context"
:loading="loading.contexts"
return-object
item-value="contextId"
item-text="namespace"
v-model="context"
></v-select>
</v-col>
<v-col class="d-flex" cols="12">
<v-text-field
v-model="name"
label="Name"
required
></v-text-field>
</v-col>
<v-col class="d-flex" cols="12" sm="6">
<v-select
:items="categories"
label="Category"
:loading="loading.categories"
v-model="category"
></v-select>
</v-col>
<v-col class="d-flex" cols="12" sm="6">
<v-select
:items="scopes"
label="Scope"
:loading="loading.scopes"
v-model="scope"
></v-select>
</v-col>
</v-row>

<v-row>
<v-col class="d-flex" cols="12">
<v-textarea
v-model="description"
label="Description"
required
></v-textarea>
</v-col>
</v-row>
</v-form>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="primary"
:disabled="!name || !description || !organization || !unit || !context"
@click="createSchema">Create
</v-btn>
<v-btn color="secondary" to="/schemaVersion"
:disabled="!schemaId">Create Schema Version
</v-btn>
</v-card-actions>
</v-card>
</template>

<script>
import {mapFields} from 'vuex-map-fields';
import Repository from '@/api/SchemataRepository'

export default {
data: () => {
return {
schemaId: '',
name: '',
description: '',
category: '',
scope: '',
loading: {
organizations: false,
units: false,
contexts: false,
categories: false,
scopes: false
}
}
},
computed: {
...mapFields([
'organization',
'unit',
'context',
'schema'
]),
},
watch: {
name() {
this.schemaId = ''
},
description() {
this.schemaId = ''
},
category() {
this.schemaId = ''
},
scope() {
this.schemaId = ''
}
},

asyncComputed: {
async organizations() {
this.loading.organizations = true
const result = await Repository.getOrganizations()
this.loading.organizations = false
return result
},
async units() {
if (!this.organization) return []

this.loading.organizations = true
const result = await Repository.getUnits(this.organization.organizationId)
this.loading.organizations = false
return result
},
async contexts() {
if (!this.organization || !this.unit) return []

this.loading.contexts = true
const result = await Repository.getContexts(
this.organization.organizationId,
this.unit.unitId
)
this.loading.contexts = false
return result
},
async categories() {
this.loading.categories = true
const result = await Repository.getCategories()
this.loading.categories = false
return result
},
async scopes() {
this.loading.scopes = true
const result = await Repository.getScopes()
this.loading.scopes = false
return result
},
},

methods: {
createSchema() {
let vm = this
Repository.createSchema(
this.organization.organizationId,
this.unit.unitId,
this.context.contextId,
this.name,
this.scope,
this.category,
this.description)
.then((created) => {
vm.schema = created
vm.schemaId = created.schemaId
vm.name = created.name
vm.scope = created.scope
vm.category = created.category
vm.description = created.description
}
)
.catch(function (err) {
let response = err.response ? err.response.data + ' - ' : ''
vm.$store.commit('raiseError', {message: response + err})
})
}
}
}
</script>
Loading