Skip to content

Commit

Permalink
Merge pull request #17 from cloudblue/feature/LITE-27142
Browse files Browse the repository at this point in the history
LITE-27142 Administrative UI
  • Loading branch information
AntonHinz authored Apr 6, 2023
2 parents 12e7a4e + 0d735b4 commit d92fdab
Show file tree
Hide file tree
Showing 16 changed files with 395 additions and 17 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
* `ez-` for Connect SPA components replicas
* `ui-` for ones imported from Connect UI Toolkit
* Table columns now may be styled directly with a column descriptor `style` property
* 0.2.3: Better handling of DB and Client Server errors
* 0.2.3: Better handling of DB and Client Server errors
* 0.3.0: Administrative UI
6 changes: 3 additions & 3 deletions dbaas/extension.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "DBaaS",
"description": "On-demand provisioning of cloud-based database storages as a service.",
"version": "0.2.3",
"version": "0.3.0",
"audience": ["reseller", "distributor", "vendor"],
"readme_url": "https://github.com/cloudblue/connect-extension-dbaas/blob/0.2.3/README.md",
"changelog_url": "https://github.com/cloudblue/connect-extension-dbaas/blob/0.2.3/CHANGELOG.md",
"readme_url": "https://github.com/cloudblue/connect-extension-dbaas/blob/0.3.0/README.md",
"changelog_url": "https://github.com/cloudblue/connect-extension-dbaas/blob/0.3.0/CHANGELOG.md",
"icon": "googleExtensionBaseline"
}
2 changes: 0 additions & 2 deletions dbaas/static/528e7daa04dc61e214a6.js

This file was deleted.

2 changes: 2 additions & 0 deletions dbaas/static/6c5bb1bba5eebb952b58.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbaas/static/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<html><head><title>Lorem ipsum</title><link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Mono:400,500|Material+Icons" rel="stylesheet"><link id="mock-favicon" rel="shortcut icon" href="#"><script defer="defer" src="528e7daa04dc61e214a6.js"></script><link href="main.css" rel="stylesheet"></head><body><div id="app"></div></body></html>
<html><head><title>Lorem ipsum</title><link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Roboto+Mono:400,500|Material+Icons" rel="stylesheet"><link id="mock-favicon" rel="shortcut icon" href="#"><script defer="defer" src="6c5bb1bba5eebb952b58.js"></script><link href="main.css" rel="stylesheet"></head><body><div id="app"></div></body></html>
7 changes: 5 additions & 2 deletions dbaas/static/main.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 7 additions & 2 deletions ui/app/api/databases.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ export default rest(URL, {
{ body: data, ...opts },
),

activate: (id, opts = {}) => http.post(
`${URL}/${id}/activate`,
delete: (id, opts = {}) => http.delete(
`${URL}/${id}`,
opts,
),

activate: (id, data, opts = {}) => http.post(
`${URL}/${id}/activate`,
{ body: data, ...opts },
),
});
4 changes: 4 additions & 0 deletions ui/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ createApp({
},
});

connectBus.watch('*', (ctx) => {
store.commit('setInstallationContext', ctx);
}, { immediate: true });

const app = new Vue({
store,

Expand Down
14 changes: 13 additions & 1 deletion ui/app/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,16 @@ import Vue from 'vue';

Vue.use(Vuex);

export default new Vuex.Store();
export default new Vuex.Store({
state: {
installationContext: {
isAdmin: false,
},
},

mutations: {
setInstallationContext(state, ctx) {
state.installationContext = Object.assign(state.installationContext, ctx);
},
},
});
24 changes: 24 additions & 0 deletions ui/app/styles/materialize.styl
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@ input[type=text][materialize] {
}
}

input[type=password][materialize] {
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;

width: 100%
padding: 12px;
background: $theme-controls-background;
border: 1px solid $theme-border-color;
border-radius: 2px;

color: $base-text-color;
font-family: $theme-font-family;
font-size: $theme-font-size-smaller;
font-style: normal;
font-weight: 400;
line-height: 1.2em;

&:focus-visible {
outline-width: 0;
border-color: $accent;
}
}

textarea[materialize] {
appearance: none;
-webkit-appearance: none;
Expand Down
187 changes: 187 additions & 0 deletions ui/app/views/ActivateDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
<template lang="pug">
ez-dialog(
v-model="dialogOpened",
width="800",
title="Activate database",
)
ui-card(title="Access")
.detail-item._mt_0
.detail-item-head.item-label._mb_8 Username
sup.red._ml_4 *
.detail-item__text
input(required, v-model="form.credentials.username", type="text", materialize)

.detail-item
.detail-item-head.item-label._mb_8 Password
sup.red._ml_4 *
.detail-item__text
input(required, v-model="form.credentials.password", type="password" materialize)

.detail-item
.detail-item-head.item-label._mb_8 Host
sup.red._ml_4 *
.detail-item__text
input(required, v-model="form.credentials.host", type="text", materialize)

.detail-item
.detail-item-head.item-label._mb_8 DB Name
.detail-item__text
input(v-model="form.credentials.name", type="text", materialize)

._mt_24

ui-card(title="General")
.detail-item._mt_0
.detail-item-head.item-label._mb_12 Workload type
.detail-item__text.vertical-middle
input#small(type="radio" v-model="form.workload" value="small", materialize)
label._ml_8(for="small", materialize) Small
._ml_24
input#medium(type="radio" v-model="form.workload" value="medium", materialize)
label._ml_8(for="medium", materialize) Medium
._ml_24
input#large._ml_24(type="radio" v-model="form.workload" value="large", materialize)
label._ml_8(for="large", materialize) Large

template(#actions="")
c-button(
mode="outlined",
label="Cancel",
@click="close",
)

c-button(
:disabled="!allowSaving",
mode="solid",
:loading="saving",
label="Activate",
color="accent",
@click="save",
)
</template>

<script>
import {
clone,
} from 'ramda';
import {
mapActions,
} from 'vuex';
import {
template,
} from '~utils';
import ezDialog from '~components/ezDialog.vue';
import cButton from '~components/cButton.vue';
import databases from '~api/databases';
const initialForm = () => ({
credentials: {
name: '',
host: '',
username: '',
password: '',
},
workload: 'small',
});
const prepareForm = template({
workload: ['workload'],
credentials: ['credentials'],
});
export default {
components: {
ezDialog,
cButton,
},
props: {
value: Boolean,
item: [Object, null],
},
data: () => ({
dialogOpened: false,
saving: false,
form: initialForm(),
}),
computed: {
isEdit: ({ item }) => Boolean(item),
allowSaving: ({ form }) => Boolean((
form.credentials.username
&& form.credentials.password
&& form.credentials.host
)),
},
methods: {
...mapActions('bus', ['emit']),
close() {
this.dialogOpened = false;
this.$emit('closed');
this.form = initialForm();
this.users = [];
this.regions = [];
},
async save() {
this.saving = true;
try {
await databases.activate(this.item.id, prepareForm(this.form));
this.$emit('saved');
this.close();
} catch (e) {
this.emit({ name: 'snackbar:error', value: e });
}
this.saving = false;
},
},
watch: {
value: {
immediate: true,
handler(v) {
const data = clone(this.item);
if (!data?.credentials) data.credentials = initialForm().credentials;
this.form = data;
this.dialogOpened = v;
},
},
dialogOpened(v) {
if (this.value !== v) this.$emit('input', v);
},
},
};
</script>
<style lang="stylus">
@import '~styles/common';
</style>
<style lang="stylus" scoped>
@import '~styles/common';
.red {
color: $nice-red;
}
.vertical-middle {
display: flex;
justify-content: flex-start;
flex-direction: row;
align-items: center;
}
</style>
Loading

0 comments on commit d92fdab

Please sign in to comment.