diff --git a/src/main/frontend/package-lock.json b/src/main/frontend/package-lock.json index fa834d75..2ea75d7e 100644 --- a/src/main/frontend/package-lock.json +++ b/src/main/frontend/package-lock.json @@ -951,9 +951,9 @@ } }, "@mdi/js": { - "version": "4.4.95", - "resolved": "https://registry.npmjs.org/@mdi/js/-/js-4.4.95.tgz", - "integrity": "sha512-wCrur/ICoHP7/NcNboBCdqR64gQnoUKxSRla4uOsGC61jMUnUeDMNfU7PrA/I0IzvotWc0ws2cCNVL7JsOPh2Q==", + "version": "4.5.95", + "resolved": "https://registry.npmjs.org/@mdi/js/-/js-4.5.95.tgz", + "integrity": "sha512-zQ6LqK/B61/ASwoR26AauCLfNc6u/SyTwsnWF0WLcSIh+oe+A7rQbioYT3eSsQch1gC+1Ejk8YDfD7gDk0FUXg==", "dev": true }, "@mrmlnc/readdir-enhanced": { diff --git a/src/main/frontend/package.json b/src/main/frontend/package.json index f5e59c0b..4d6b573f 100644 --- a/src/main/frontend/package.json +++ b/src/main/frontend/package.json @@ -23,7 +23,7 @@ "devDependencies": { "@babel/plugin-proposal-nullish-coalescing-operator": "^7.4.4", "@babel/plugin-proposal-optional-chaining": "^7.6.0", - "@mdi/js": "^4.4.95", + "@mdi/js": "^4.5.95", "@vue/cli-plugin-babel": "^3.4.0", "@vue/cli-plugin-eslint": "^3.4.0", "@vue/cli-service": "^3.8.0", diff --git a/src/main/frontend/src/api/SchemataRepository.js b/src/main/frontend/src/api/SchemataRepository.js index 57c9c0d4..943d487f 100644 --- a/src/main/frontend/src/api/SchemataRepository.js +++ b/src/main/frontend/src/api/SchemataRepository.js @@ -3,13 +3,20 @@ import Repository from '@/api/Repository' const resources = { organizations: () => '/organizations', - units: (o) => `/organizations/${o}/units`, - contexts: (o, u) => `/organizations/${o}/units/${u}/contexts`, + organization: (o) => `${resources.organizations()}/${o}`, + units: (o) => `${resources.organization(o)}/units`, + unit: (o, u) => `${resources.units(o)}/${u}`, + contexts: (o, u) => `${resources.unit(o, u)}/contexts`, + context: (o, u, c) => `${resources.contexts(o, u)}/${c}`, 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`, - schemaSpecification: (o, u, c, s, v) => `/organizations/${o}/units/${u}/contexts/${c}/schemas/${s}/versions/${v}/specification` + schemata: (o, u, c) => `${resources.context(o, u, c)}/schemas`, + schema: (o, u, c, s) => `${resources.schemata(o, u, c)}/${s}`, + versions: (o, u, c, s) => `${resources.schema(o, u, c, s)}/versions`, + version: (o, u, c, s, v) => `${resources.versions(o, u, c, s)}/${v}`, + versionStatus: (o, u, c, s, v) => `${resources.version(o, u, c, s, v)}/status`, + schemaSpecification: (o, u, c, s, v) => `${resources.version(o, u, c, s, v)}/specification`, + sources: (o, u, c, s, v, lang) => `/code/${o}:${u}:${c}:${s}:${v}/${lang}`, } function ensure(response, status) { @@ -33,18 +40,34 @@ export default { .then(ensureOk) .then(response => response.data) }, + getOrganization(organization) { + return Repository.get(resources.organization(organization)) + .then(ensureOk) + .then(response => response.data) + }, getUnits(organization) { return Repository.get(resources.units(organization)) .then(ensureOk) .then(response => response.data) }, + getUnit(organization, unit) { + return Repository.get(resources.unit(organization, unit)) + .then(ensureOk) + .then(response => response.data) + }, getContexts(organization, unit) { return Repository.get(resources.contexts(organization, unit)) .then(ensureOk) .then(response => response.data) }, + getContext(organization, unit, context) { + return Repository.get(resources.context(organization, unit, context)) + .then(ensureOk) + .then(response => response.data) + }, + getCategories() { return Repository.get(resources.categories()) .then(ensureOk) @@ -60,12 +83,22 @@ export default { .then(ensureOk) .then(response => response.data) }, + getSchema(organization, unit, context, schema) { + return Repository.get(resources.schema(organization, unit, context, schema)) + .then(ensureOk) + .then(response => response.data) + }, getVersions(organization, unit, context, schema) { return Repository.get(resources.versions(organization, unit, context, schema)) .then(ensureOk) .then(response => response.data) }, + getVersion(organization, unit, context, schema, version) { + return Repository.get(resources.version(organization, unit, context, schema, version)) + .then(ensureOk) + .then(response => response.data) + }, createOrganization(name, description) { return Repository.post(resources.organizations(), @@ -115,12 +148,11 @@ export default { }, createSchemaVersion( organization, unit, context, schema, - specification, description, status, previousVersion, currentVersion) { + specification, description, previousVersion, currentVersion) { return Repository.post(resources.versions(organization, unit, context, schema), { schemaVersionId: '', specification: specification, - status: status, previousVersion: previousVersion, currentVersion: currentVersion, description: description @@ -145,4 +177,48 @@ export default { .then(ensureOk) .then(response => response.data) }, + setSchemaVersionStatus( + organization, unit, context, schema, version, status) { + + let config = { + headers: { + 'Content-Type': 'application/json' + }, + responseType: 'text' + }; + return Repository.patch( + resources.versionStatus(organization, unit, context, schema, version), + status, + config + ) + .then(ensureOk) + .then(response => response.data) + }, + loadSources( + organization, unit, context, schema, version, language) { + let config = { + headers: { + 'Content-Type': 'application/json' + }, + responseType: 'text' + }; + return Promise.all([ + this.getOrganization(organization), + this.getUnit(organization, unit), + this.getContext(organization, unit, context), + this.getSchema(organization, unit, context, schema), + this.getVersion(organization, unit, context, schema, version), + ]).then(([org, unit, context, schema, version]) => { + return Repository.get( + resources.sources( + org.name, + unit.name, + context.namespace, + schema.name, + version.currentVersion, + language), config) + }) + .then(ensureOk) + .then(response => response.data) + }, } \ No newline at end of file diff --git a/src/main/frontend/src/components/Properties.vue b/src/main/frontend/src/components/Properties.vue index b6c2db40..069de937 100644 --- a/src/main/frontend/src/components/Properties.vue +++ b/src/main/frontend/src/components/Properties.vue @@ -1,14 +1,17 @@ diff --git a/src/main/frontend/src/components/SchemaVersion.vue b/src/main/frontend/src/components/SchemaVersion.vue index e568002f..3834a2cb 100644 --- a/src/main/frontend/src/components/SchemaVersion.vue +++ b/src/main/frontend/src/components/SchemaVersion.vue @@ -66,7 +66,7 @@ - + - + - - - - @@ -149,10 +140,8 @@ schemaVersionId: '', description: '', specification: '', - status: 'Draft', previousVersion: '', currentVersion: '', - statuses: ['Draft', 'Published', 'Deprecated', 'Removed'], descriptionEditorActive: false, specificationEditorActive: false, @@ -173,7 +162,6 @@ this.schema.schemaId, this.specification, this.description, - this.status, this.previousVersion, this.currentVersion) .then((created) => { @@ -189,6 +177,7 @@ message: `Schema v${vm.currentVersion} created.`, type: 'success' }) + vm.$store.dispatch('loadVersions') } ) .catch(function (err) { diff --git a/src/main/frontend/src/components/Schemata.vue b/src/main/frontend/src/components/Schemata.vue index fec6cbae..dc2bb279 100644 --- a/src/main/frontend/src/components/Schemata.vue +++ b/src/main/frontend/src/components/Schemata.vue @@ -80,7 +80,7 @@ return [this.$store.schema] }, set(value) { - this.$store.commit('selectSchema', value[0]) + this.$store.dispatch('selectSchema', value[0]) } }, @@ -100,6 +100,7 @@ vm.items.push(organization) } }) + .catch((err) => vm.$store.commit('raiseError', {message: err})) }, async loadChildren(item) { diff --git a/src/main/frontend/src/components/Versions.vue b/src/main/frontend/src/components/Versions.vue index 2f70c54a..10983081 100644 --- a/src/main/frontend/src/components/Versions.vue +++ b/src/main/frontend/src/components/Versions.vue @@ -3,7 +3,7 @@ - +