forked from directus/v8-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add interface debugger (directus#61)
* Add /interfaces overview route * Update route to be plural * Add interface debugger route * Render interface to screen * Add form for interface settings * Add misc section to settings * Add some styling to show width * Add output preview * Add options form * Add missing global for readonly interface * Add readonly to interface debugger page
- Loading branch information
1 parent
7c2e7b0
commit 0e718b6
Showing
6 changed files
with
259 additions
and
4 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
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,198 @@ | ||
<template> | ||
<div class="interface-debugger"> | ||
<portal to="header-title"> | ||
<breadcrumb :links="links" /> | ||
</portal> | ||
|
||
<div | ||
:style="{ width: width + 'px' }" | ||
class="box"> | ||
<interface-extension | ||
v-model="value" | ||
:id="id" | ||
:name="id" | ||
:type="type" | ||
:length="length" | ||
:readonly="readonly" | ||
:required="required" | ||
:loading="loading" | ||
:options="options" /> | ||
</div> | ||
|
||
<output>{{ value }}</output> | ||
|
||
<div | ||
:style="{ width: width + 'px' }" | ||
class="box"> | ||
<readonly-extension | ||
v-model="value" | ||
:id="id" | ||
:name="id" | ||
:type="type" | ||
:length="length" | ||
:readonly="readonly" | ||
:required="required" | ||
:loading="loading" | ||
:options="options" /> | ||
</div> | ||
|
||
<form @submit.prevent> | ||
<fieldset> | ||
<legend>Settings</legend> | ||
|
||
<label for="type">Type</label> | ||
<select | ||
id="type" | ||
v-model="type"> | ||
<option | ||
v-for="(length, type) in extension.dataTypes" | ||
:key="type" | ||
:value="type" | ||
>{{ type }}</option> | ||
</select> | ||
|
||
<label for="length">Length</label> | ||
<input | ||
id="length" | ||
v-model="length" | ||
type="number" | ||
min="0"> | ||
|
||
<label for="readonly">Read only</label> | ||
<input | ||
id="readonly" | ||
v-model="readonly" | ||
type="checkbox"> | ||
|
||
|
||
<label for="required">Required</label> | ||
<input | ||
id="required" | ||
v-model="required" | ||
type="checkbox"> | ||
|
||
<label for="loading">Loading</label> | ||
<input | ||
id="loading" | ||
v-model="loading" | ||
type="checkbox"> | ||
</fieldset> | ||
<fieldset> | ||
<legend>Options</legend> | ||
<div | ||
v-for="(option, optionID) in extension.options" | ||
:key="optionID"> | ||
<label :for="optionID">{{ option.name }}</label> | ||
<p>{{ option.comment }}</p> | ||
<interface-extension | ||
v-model="options[optionID]" | ||
:id="optionID" | ||
:name="optionID" | ||
:type="option.type" | ||
:length="option.length" | ||
:readonly="option.readonly" | ||
:required="option.required" | ||
:loading="option.loading" | ||
:options="option.options" /> | ||
</div> | ||
</fieldset> | ||
<fieldset> | ||
<legend>Misc.</legend> | ||
<label for="width">Responsiveness tester</label> | ||
<input | ||
id="width" | ||
v-model="width" | ||
min="50" | ||
max="1000" | ||
step="1" | ||
type="range"> | ||
<span>{{ width }}px</span> | ||
</fieldset> | ||
</form> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'interface-debugger', | ||
props: { | ||
id: { | ||
type: String, | ||
required: true, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
type: null, | ||
length: null, | ||
value: null, | ||
readonly: false, | ||
required: false, | ||
loading: false, | ||
options: {}, | ||
width: 200, | ||
}; | ||
}, | ||
computed: { | ||
links() { | ||
return [ | ||
{ | ||
name: 'Interfaces', | ||
path: '/interfaces', | ||
}, | ||
{ | ||
name: this.extension.name, | ||
path: `/interfaces/${this.id}`, | ||
}, | ||
]; | ||
}, | ||
extension() { | ||
return this.$store.state.extensions.interfaces.data[this.id]; | ||
}, | ||
}, | ||
watch: { | ||
id() { | ||
this.hydrate(); | ||
}, | ||
type() { | ||
this.length = this.extension.dataTypes[this.type]; | ||
}, | ||
}, | ||
created() { | ||
this.hydrate(); | ||
}, | ||
methods: { | ||
hydrate() { | ||
// Set type to the first datatype available in the meta info | ||
this.type = Object.keys(this.extension.dataTypes)[0]; | ||
// Populate the options with the default values | ||
const defaults = this.$lodash.mapValues( | ||
this.extension.options, | ||
settings => settings.default || null, | ||
); | ||
this.options = defaults; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style scoped> | ||
.interface-debugger { | ||
padding: 10px; | ||
} | ||
.box { | ||
border: 1px solid var(--lighter-gray); | ||
padding: 10px; | ||
margin-bottom: 20px; | ||
} | ||
output { | ||
background-color: white; | ||
padding: 10px; | ||
margin: 10px 0; | ||
font-family: monospace; | ||
display: block; | ||
} | ||
</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,36 @@ | ||
<template> | ||
<v-table | ||
:columns="columns" | ||
:items="items" | ||
link="__link" | ||
primary-key-field="id" /> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
computed: { | ||
items() { | ||
return Object.keys(this.$store.state.extensions.interfaces.data).map(id => ({ | ||
...this.$store.state.extensions.interfaces.data[id], | ||
__link: `/interfaces/${id}`, | ||
})); | ||
}, | ||
columns() { | ||
return [ | ||
{ | ||
field: 'name', | ||
name: 'Name', | ||
}, | ||
{ | ||
field: 'id', | ||
name: 'id', | ||
}, | ||
{ | ||
field: 'version', | ||
name: 'Version', | ||
}, | ||
]; | ||
}, | ||
}, | ||
}; | ||
</script> |
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