Fix bugs with check plugins

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl 2019-10-10 15:32:55 +02:00 committed by Arthur Schiwon
parent 6878d36e50
commit e72f58b000
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
4 changed files with 48 additions and 17 deletions

View File

@ -32,17 +32,20 @@
:tagging="false"
@input="setValue">
<template slot="singleLabel" slot-scope="props">
<span class="option__icon" :class="props.option.icon" />
<span v-if="props.option.icon" class="option__icon" :class="props.option.icon" />
<img v-else :src="props.option.iconUrl" />
<span class="option__title option__title_single">{{ props.option.label }}</span>
</template>
<template slot="option" slot-scope="props">
<span class="option__icon" :class="props.option.icon" />
<span v-if="props.option.icon" class="option__icon" :class="props.option.icon" />
<img v-else :src="props.option.iconUrl" />
<span class="option__title">{{ props.option.label }}</span>
</template>
</Multiselect>
<input v-if="!isPredefined"
type="text"
:value="currentValue.pattern"
:placeholder="t('workflowengine', 'e.g. httpd/unix-directory')"
@input="updateCustom">
</div>
</template>
@ -68,12 +71,12 @@ export default {
pattern: '/image\\/.*/'
},
{
icon: 'icon-category-office',
iconUrl: OC.imagePath('core', 'filetypes/x-office-document'),
label: t('workflowengine', 'Office documents'),
pattern: '/(vnd\\.(ms-|openxmlformats-).*))$/'
},
{
icon: 'icon-filetype-file',
iconUrl: OC.imagePath('core', 'filetypes/application-pdf'),
label: t('workflowengine', 'PDF documents'),
pattern: 'application/pdf'
}
@ -130,3 +133,15 @@ export default {
}
}
</script>
<style scoped>
.multiselect, input[type='text'] {
width: 100%;
}
.multiselect >>> .multiselect__content-wrapper li>span,
.multiselect >>> .multiselect__single {
display: flex;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>

View File

@ -4,12 +4,13 @@
<input v-model="newValue.startTime"
type="text"
class="timeslot--start"
placeholder="08:00"
placeholder="e.g. 08:00"
@input="update">
<input v-model="newValue.endTime"
type="text"
placeholder="18:00"
placeholder="e.g. 18:00"
@input="update">
<p v-if="!valid" class="invalid-hint">{{ t('workflowengine', 'Please enter a valid time span')}}</p>
</div>
</template>
@ -30,7 +31,7 @@ export default {
props: {
value: {
type: String,
default: '1 MB'
default: ''
}
},
data() {
@ -46,15 +47,16 @@ export default {
},
methods: {
updateInternalValue(value) {
var data = JSON.parse(value)
var startTime = data[0].split(' ', 2)[0]
var endTime = data[1].split(' ', 2)[0]
var timezone = data[0].split(' ', 2)[1]
this.newValue = {
startTime: startTime,
endTime: endTime,
timezone: timezone
}
try {
const data = JSON.parse(value)
if (data.length === 2) {
this.newValue = {
startTime: data[0].split(' ', 2)[0],
endTime: data[1].split(' ', 2)[0],
timezone: data[0].split(' ', 2)[1]
}
}
} catch (e) {}
},
validate() {
return this.newValue.startTime && this.newValue.startTime.match(/^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]$/i) !== null
@ -90,10 +92,15 @@ export default {
width: 50%;
margin: 0;
margin-bottom: 5px;
&.timeslot--start {
margin-right: 5px;
width: calc(50% - 5px);
}
}
.invalid-hint {
color: var(--color-text-maxcontrast);
}
}
</style>

View File

@ -65,7 +65,7 @@ const FileChecks = [
{ operator: 'greater', name: t('workflowengine', 'greater') }
],
placeholder: (check) => '5 MB',
validate: (check) => check.value.match(/^[0-9]+[ ]?[kmgt]?b$/i) !== null
validate: (check) => check.value ? check.value.match(/^[0-9]+[ ]?[kmgt]?b$/i) !== null : false
},
{

View File

@ -24,16 +24,25 @@ const regexIPv4 = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]
const regexIPv6 = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(1([01][0-9]|2[0-8])|[1-9][0-9]|[0-9])$/
const validateRegex = function(string) {
if (!string) {
return false
}
const result = regexRegex.exec(string)
return result !== null
}
const validateIPv4 = function(string) {
if (!string) {
return false
}
const result = regexIPv4.exec(string)
return result !== null
}
const validateIPv6 = function(string) {
if (!string) {
return false
}
const result = regexIPv6.exec(string)
return result !== null
}