Skip to content

Commit

Permalink
Merge pull request #192 from ansibleguy76/release/v5.0.3
Browse files Browse the repository at this point in the history
v5.0.3 into main
  • Loading branch information
ansibleguy76 authored Jun 21, 2024
2 parents 60f8598 + 3bf7c39 commit 337f1ca
Show file tree
Hide file tree
Showing 48 changed files with 1,204 additions and 836 deletions.
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [5.0.3] - 2024-06-21

### Added

- Option to disable/enable schema creation (ALLOW_SCHEMA_CREATION)
- Forms yaml can now be in the database (overriding the local file)
- Database queries are by default no longer logged, use ENABLE_DB_QUERY_LOGGING to enable it again
- Mongodb connection test

### Changed

- Improved schema creation error messages and error handling
- Schema patching is now done at application initialization
- Rewrote database connections with await/async

### Fixed

- Vault credentials, alpine requires decode -d instead --decode
- Type on jobstatus notification template

## [5.0.2] - 2024-06-10

### Adding
Expand Down Expand Up @@ -689,7 +709,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Allow change password for current local user
- Start tracking versions

[Unreleased]: https://github.com/ansibleguy76/ansibleforms/compare/5.0.2...HEAD
[Unreleased]: https://github.com/ansibleguy76/ansibleforms/compare/5.0.3...HEAD

[5.0.3]: https://github.com/ansibleguy76/ansibleforms/compare/5.0.2...5.0.3

[5.0.2]: https://github.com/ansibleguy76/ansibleforms/compare/5.0.1...5.0.2

Expand Down
4 changes: 2 additions & 2 deletions app_versions.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ext.version_code = 50002
ext.version_name = "5.0.2"
ext.version_code = 50003
ext.version_name = "5.0.3"
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ansible_forms_vue",
"version": "5.0.2",
"version": "5.0.3",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand Down
6 changes: 4 additions & 2 deletions client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
</div>
</BulmaModal>
<BulmaNav v-if="version" :isAdmin="isAdmin" @profile="showProfile=true" @about="showAbout=true" :approvals="approvals" :authenticated="authenticated" :profile="profile" @logout="logout()" :version="version" />
<router-view v-if="isLoaded" :isAdmin="isAdmin" :profile="profile" :authenticated="authenticated" :errorMessage="errorMessage" :errorData="errorData" @authenticated="login()" @logout="logout()" @refreshApprovals="loadApprovals()" />
<router-view v-if="isLoaded" :isAdmin="isAdmin" :profile="profile" :authenticated="authenticated" :errorMessage="errorMessage" :errorData="errorData" @recheckSchema="checkDatabase()" @authenticated="login()" @logout="logout()" @refreshApprovals="loadApprovals()" />
</div>
</template>
<script>
Expand Down Expand Up @@ -144,7 +144,9 @@
return; // Skip the database check
}
console.log("Checking database")
axios.get(`${process.env.BASE_URL}api/v1/schema`) // check database
// create timestamp to add to api call to prevent caching
var timestamp = new Date().getTime();
axios.get(`${process.env.BASE_URL}api/v1/schema?${timestamp}`) // check database
.then((result)=>{
if(result.data.status=="error"){
ref.errorMessage=result.data.message;
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/BulmaTextArea.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div class="field">
<label v-if="label!=''" class="label">{{label}} <span v-if="required" class="has-text-danger">*</span></label>
<p class="is-size-7" v-if="help!=''">{{ help }}</p>
<textarea class="textarea is-family-monospace" rows="10" @keyup.enter="$emit('enterClicked')" :readonly="readonly" v-focus="focus" :type="type" :value="value" :class="{'is-danger':hasError}" @input="$emit('input', $event.target.value)" :placeholder="placeholder"></textarea>
<p class="has-text-danger" v-for="e in errors" :key="e.label" :class="{'is-hidden':!e.if}">{{ e.label }}</p>
</div>
Expand Down Expand Up @@ -31,6 +32,7 @@
label:{type:String,default:""},
hasError:{type:Boolean,default:false},
errors:{type:Array},
help:{type:String,default:""}
},data(){
return{
}
Expand Down
4 changes: 2 additions & 2 deletions client/src/views/Credentials.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
<BulmaInput icon="server" v-model="credential.host" label="Host" placeholder="Host" :required="!!credential.is_database" :hasError="$v.credential.host.$invalid" :errors="[]" />
<BulmaInput icon="door-closed" v-model="credential.port" label="Port" placeholder="3306" :required="!!credential.is_database" :hasError="$v.credential.port.$invalid" :errors="[]" />
<BulmaInput icon="info-circle" v-model="credential.description" label="Description" placeholder="Description" />
<BulmaInput v-if="!!credential.is_database" icon="database" v-model="credential.db_name" label="Database" placeholder="Database" />
<BulmaSelect v-if="!!credential.is_database" icon="database" v-model="credential.db_type" label="Database type" :list="['mysql','mssql','postgres','mongodb']" />
<BulmaSelect v-if="!!credential.is_database" icon="database" v-model="credential.db_type" label="Database type" :list="['mysql','mssql','postgres','mongodb','oracle']" />
<BulmaInput v-if="!!credential.is_database" icon="database" v-model="credential.db_name" :label="(credential.db_type=='oracle')?'Service':'Database'" :placeholder="(credential.db_type=='oracle')?'Service Name':'Database Name'" />
<BulmaCheckbox v-if="!!credential.is_database" checktype="checkbox" v-model="credential.secure" label="Secure connection" /><br><br>
<BulmaButton v-if="credentialItem==-1" icon="save" label="Create Credential" @click="newCredential()"></BulmaButton>
<BulmaButton v-if="credentialItem!=-1" icon="save" label="Update Credential" @click="updateCredential()"></BulmaButton>
Expand Down
68 changes: 42 additions & 26 deletions client/src/views/Schema.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
<template>
<section class="hero has-background-light is-fullheight">
<div class="hero-body">
<div class="container">
<div v-if="!loading" class="container">
<div class="columns is-centered">
<div class="column is-6-tablet is-6-desktop is-6-widescreen">
<div class="notification is-danger" v-if="error!=''" v-text="error"></div>
<div class="notification is-success" v-if="success" v-html="success"></div>
<div class="notification is-warning" v-if="failed" v-html="failed"></div>
<form action="" class="box" v-if="error!='FATAL ERROR' && error!=''">
<div v-if="error!='Schema creation is disabled'">
<form action="" class="box" v-if="error!='FATAL ERROR' && error!='' && success==''">
<div class="content">
If this is the first time setup and you don't have your own schema and tables.<br><br>
Would you like me to try and create the schema and tables ?<br>
I would create the following : <br><br>
<table class="table is-bordered is-striped">
<tbody>
<tr><th>Databaseschema</th><td>AnsibleForms</td></tr>
<tr><th>Tables</th><td>All required tables</td></tr>
<tr><th>Users</th><td>admin (pw = AnsibleForms!123)</td></tr>
<tr><th>Groups</th><td>admins</td></tr>

</tbody>
</table>
</div>
<div class="field">
<button class="button is-success" @click="create()">
<span class="icon"><font-awesome-icon icon="magic" /></span><span>Create</span>
</button>
</div>
</form>
<form action="" class="box" v-else>
<div class="content">
It appears that you have an unuseable schema. Part of the database is present, and part is missing.<br>
Please contact your database or application administrator to either restore from a backup, or create the missing tables.
For now there is nothing I can do for you, until the schema and tables are in a consistent state.
</div>
</form>
</div>
<div v-else class="box">
<div class="content">
If this is the first time setup and you don't have your own schema and tables.<br><br>
Would you like me to try and create the schema and tables ?<br>
I would create the following : <br><br>
<table class="table is-bordered is-striped">
<tbody>
<tr><th>Databaseschema</th><td>AnsibleForms</td></tr>
<tr><th>Tables</th><td>All required tables</td></tr>
<tr><th>Users</th><td>admin (pw = AnsibleForms!123)</td></tr>
<tr><th>Groups</th><td>admins</td></tr>

</tbody>
</table>
</div>
<div class="field">
<button class="button is-success" @click="create()">
<span class="icon"><font-awesome-icon icon="magic" /></span><span>Create</span>
</button>
</div>
</form>
Schema creation is disabled by your administrator.<br>
Please contact your database or application administrator to create the schema and tables.
</div>
</div>
<div v-if="error=='FATAL ERROR'" class="box">
<div class="content">
Something went wrong. Most likely the database is simply not reachable.
Expand All @@ -54,7 +69,8 @@
},
data() {
return {
error:(this.errorMessage=="schema and tables are ok")?"":this.errorMessage
error:(this.errorMessage=="schema and tables are ok")?"":this.errorMessage,
loading:false
}
},
computed:{
Expand All @@ -67,7 +83,7 @@
},
failed(){
if(Array.isArray(this.errorData.error)){
return this.errorData.error.map((e)=>{return e.message}).join('<br>')
return this.errorData.error.join('<br>')
}else {
return this.errorData.error
}
Expand All @@ -76,22 +92,22 @@
methods: {
create() {
var ref=this
ref.loading=true
this.$toast.info("Creating... wait a moment")
axios.post(`${process.env.BASE_URL}api/v1/schema`,{})
.then((result)=>{
this.$emit('recheckSchema')
ref.loading=false
if(result.data.status!="error"){
ref.error=""
this.$toast.success(result.data.message)
//setTimeout(()=>{ref.$router.push({name:"Login"})},3000)
}else{
ref.error=result.data.message
}
console.log(result)
}).catch(function (error) {
ref.error=error
})
console.log("creating")
}
}
}
Expand Down
100 changes: 83 additions & 17 deletions client/src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,62 @@
</nav>
<div class="box">
<BulmaInput icon="globe" v-model="settings.url" help="" label="Public Root Url" placeholder="https://ansibleforms:8443" :required="true" :hasError="$v.settings.url.$invalid" :errors="[]" />
</div>
<div class="box" v-if="settings.enableFormsYamlInDatabase">
<p class="mb-2">
In case you want the main forms.yaml file in the database instead of loaded from the filesystem.
<strong class="ml-3">Note that the designer will be disabled.</strong>
</p>
<div class="level">
<div class="level-left">
<p class="level-item has-text-weight-bold">
Forms YAML
</p>
</div>
<div class="level-right">
<p class="level-item"><BulmaButton icon="file-import" label="Import from file" @click="importYamlFile()"></BulmaButton></p>
</div>
</div>

<VueCodeEditor
v-model="settings.forms_yaml"
@init="editorInit"
lang="yaml"
theme="monokai"
width="100%"
height="40vh"
tabindex=0
:lazymodel="true"
@dirty="formDirty=true"
:options="{
enableBasicAutocompletion: true,
enableLiveAutocompletion: false,
fontSize: 14,
highlightActiveLine: true,
enableSnippets: false,
showLineNumbers: true,
tabSize: 2,
wrap:false,
showPrintMargin: false,
showGutter: true
}"
/>
</div>

<table class="table is-bordered is-striped is-fullwidth">
<thead>
<tr>
<th>Environment Variable</th><th>Set</th><th>Value</th>
</tr>
</thead>
<tbody>
<tr v-for="e in env" :key="e.name">
<td>{{ e.name }}</td>
<td><font-awesome-icon :icon="(e.set)?'check':'times'" :class="{'has-text-success':e.set,'has-text-danger':!e.set}" /></td>
<td>{{ e.value }}</td>
</tr>
</tbody>
</table>
<table class="table is-bordered is-striped is-fullwidth">
<thead>
<tr>
<th>Environment Variable</th><th>Set</th><th>Value</th>
</tr>
</thead>
<tbody>
<tr v-for="e in env" :key="e.name">
<td>{{ e.name }}</td>
<td><font-awesome-icon :icon="(e.set)?'check':'times'" :class="{'has-text-success':e.set,'has-text-danger':!e.set}" /></td>
<td>{{ e.value }}</td>
</tr>
</tbody>
</table>

</div>
</div>
Expand All @@ -44,6 +84,7 @@
import Vuelidate from 'vuelidate'
import BulmaButton from './../components/BulmaButton.vue'
import BulmaInput from './../components/BulmaInput.vue'
import VueCodeEditor from './../components/VueCodeEditor';
import BulmaSettingsMenu from '../components/BulmaSettingsMenu.vue'
import TokenStorage from './../lib/TokenStorage'
import { required, email, minValue,maxValue,minLength,maxLength,helpers,requiredIf,sameAs } from 'vuelidate/lib/validators'
Expand All @@ -56,17 +97,34 @@
authenticated:{type:Boolean},
isAdmin:{type:Boolean}
},
components:{BulmaButton,BulmaInput,BulmaSettingsMenu},
components:{BulmaButton,BulmaInput,VueCodeEditor,BulmaSettingsMenu},
data(){
return {
settings:{
url:""
url:"",
forms_yaml:"",
},
env:[]
}
},
computed:{
},
methods:{
importYamlFile(){
var ref= this;
axios.put(`${process.env.BASE_URL}api/v1/settings/importFormsFileFromYaml`,{},TokenStorage.getAuthentication())
.then((result)=>{
if(result.data.status=="error"){
ref.$toast.error(result.data.message + ", " + result.data.data.error);
}else{
ref.$toast.success(result.data.message);
ref.loadSettings();
}
}),function(err){
ref.$toast.error(err.toString());
};
},
loadSettings(){
var ref= this;
axios.get(`${process.env.BASE_URL}api/v1/settings/`,TokenStorage.getAuthentication())
Expand Down Expand Up @@ -98,7 +156,13 @@
}else{
this.$toast.warning("Invalid form data")
}
}
},
editorInit: function () {
// vue2-code-editor/node_modules/
require('brace/ext/language_tools') //language extension prerequsite...
require('brace/mode/yaml')
require('brace/theme/monokai')
}
},
validations: {
settings:{
Expand All @@ -108,6 +172,8 @@
{description: "Must be a valid public url",type:"regex"},
(value) => !helpers.req(value) || (new RegExp("^https?:\/\/[^\/]+$").test(value)) // eslint-disable-line
)
},
forms_yaml:{
}
}
},
Expand Down
1 change: 0 additions & 1 deletion docs/.htaccess

This file was deleted.

Loading

0 comments on commit 337f1ca

Please sign in to comment.