1
0
Fork 0
mirror of synced 2024-06-16 09:44:50 +12:00

Updated timeout range

This commit is contained in:
Eldad Fux 2020-05-13 23:59:02 +03:00
parent 8674eb97f2
commit 8e4dd5583a
4 changed files with 22 additions and 45 deletions

View file

@ -26,7 +26,7 @@ $utopia->post('/v1/functions')
->param('vars', [], function () { return new Assoc();}, 'Key-value JSON object.', true)
->param('events', [], function () { return new ArrayList(new Text(256)); }, 'Events list.', true)
->param('schedule', '', function () { return new Cron(); }, 'Schedule CRON syntax.', true)
->param('timeout', 15, function () { return new Range(0, 60); }, 'Function maximum execution time in seconds.', true)
->param('timeout', 15, function () { return new Range(1, 900); }, 'Function maximum execution time in seconds.', true)
->action(
function ($name, $vars, $events, $schedule, $timeout) use ($response, $projectDB) {
$function = $projectDB->createDocument([
@ -120,7 +120,7 @@ $utopia->put('/v1/functions/:functionId')
->param('vars', [], function () { return new Assoc();}, 'Key-value JSON object.', true)
->param('events', [], function () { return new ArrayList(new Text(256)); }, 'Events list.', true)
->param('schedule', '', function () { return new Cron(); }, 'Schedule CRON syntax.', true)
->param('timeout', 15, function () { return new Range(0, 60); }, 'Function maximum execution time in seconds.', true)
->param('timeout', 15, function () { return new Range(1, 900); }, 'Function maximum execution time in seconds.', true)
->action(
function ($functionId, $name, $vars, $events, $schedule, $timeout) use ($response, $projectDB) {
$function = $projectDB->getDocument($functionId);

View file

@ -3,7 +3,6 @@
$events = array_keys($this->getParam('events', []));
?>
<div
data-service="functions.get"
data-name="project-function"
@ -80,20 +79,20 @@ $events = array_keys($this->getParam('events', []));
data-service="functions.listTags"
data-scope="sdk"
data-event="load,functions.createTag,functions.deleteTag"
data-name="project-functions"
data-name="project-function-tags"
data-param-project-id="{{router.params.project}}"
data-success="trigger"
data-success-param-trigger-events="functions.list">
data-success-param-trigger-events="functions.listTags">
<div data-ls-if="0 == {{project-functions.functions.length}} || undefined == {{project-functions.functions.length}}" class="box margin-top margin-bottom">
<div data-ls-if="0 == {{project-function-tags.tags.length}} || undefined == {{project-function-tags.tags.length}}" class="box margin-top margin-bottom">
<h3 class="margin-bottom-small text-bold">No Tags Found</h3>
<p class="margin-bottom-no">You haven't uploaded any tags for your function yet.</p>
<p class="margin-bottom-no">You haven't deployed any tags for your function yet.</p>
</div>
<div data-ls-if="0 != {{project-functions.functions.length}}">
<div data-ls-if="(0 != {{project-function-tags.tags.length}}) && (undefined !== {{project-function-tags.tags.length}})">
<div class="box margin-bottom">
<ul data-ls-loop="project-functions.functions" data-ls-as="function" class="list">
<ul data-ls-loop="project-function-tags.tags" data-ls-as="tag" class="list">
<li class="clear">
<a data-ls-attrs="href=/console/functions/function?id={{function.$id}}&project={{router.params.project}}" class="button pull-end">Set Default</a>
@ -106,32 +105,14 @@ $events = array_keys($this->getParam('events', []));
</div>
<div class="pull-start">
<div data-ui-modal class="modal close box sticky-footer" data-button-text="Add Tag">
<div data-ui-modal class="modal close box sticky-footer" data-button-text="Deploy Tag">
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
<h1>Add Function</h1>
<h1>Deploy a New Tag</h1>
<form
data-analytics-event="submit"
data-analytics-category="console"
data-analytics-label="Create Project Function"
data-service="functions.create"
data-scope="sdk"
data-event="submit"
data-success="alert,trigger,reset"
data-success-param-alert-text="Created function successfully"
data-success-param-trigger-events="functions.create"
data-failure="alert"
data-failure-param-alert-text="Failed to create function"
data-failure-param-alert-classname="error">
<label for="name">Name</label>
<input type="text" id="name" name="name" required autocomplete="off" class="margin-bottom-xl" />
<footer>
<button type="submit">Create</button> &nbsp; <button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
</footer>
</form>
<footer>
<button type="submit">Create</button> &nbsp; <button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
</footer>
</div>
</div>
@ -224,15 +205,9 @@ $events = array_keys($this->getParam('events', []));
<label for="name">Name</label>
<input name="name" id="function-name" type="text" autocomplete="off" data-ls-bind="{{project-function.name}}" data-forms-text-direction required placeholder="Function Name" />
<label for="timeout">Timeout <span class="tooltip small" data-tooltip="Limit the execution time of your function."><i class="icon-info-circled"></i></span></label>
<select name="timeout" data-ls-bind="{{project-function.timeout}}" required>
<option value="5">5 seconds</option>
<option value="15">15 seconds</option>
<option value="30">30 seconds</option>
<option value="60">1 minute</option>
<!-- <option value="300" disabled>5 minutes</option> -->
<!-- <option value="900" disabled>15 minutes</option> -->
</select>
<label for="timeout">Timeout (seconds) <span class="tooltip small" data-tooltip="Limit the execution time of your function."><i class="icon-info-circled"></i></span></label>
<input name="timeout" id="function-timeout" type="number" autocomplete="off" data-ls-bind="{{project-function.timeout}}" min="1" max="900" />
<div class="text-size-small text-fade margin-bottom margin-top-negative-small">Max value is 900 seconds (15 minutes)</div>
<label for="events">Events <span class="tooltip small" data-tooltip="Choose which events should trigger this function."><i class="icon-info-circled"></i></span></label>
<div class="row responsive thin">
@ -258,7 +233,7 @@ $events = array_keys($this->getParam('events', []));
<hr class="margin-bottom margin-top-no" />
<fieldset name="vars" data-cast-to="object">
<div data-ls-loop="project-function.vars" data-ls-as="var" style="overflow: hidden">
<div data-ls-loop="project-function.vars" data-ls-as="var" style="overflow: hidden" id="project-vars">
<div class="margin-bottom-small">
<div data-forms-remove class="row thin">
<div class="col span-10">
@ -271,7 +246,7 @@ $events = array_keys($this->getParam('events', []));
</div>
</div>
<div data-forms-clone="" data-label="Add Variable" data-first="0">
<div data-forms-clone="" data-target="project-vars" data-label="Add Variable" data-first="0">
<div class="margin-bottom-small">
<div data-forms-remove class="row thin margin-bottom-small">
<div class="col span-10">

View file

@ -2363,7 +2363,8 @@ object=object[path.shift()];}
let shift=path.shift();if(value!==null&&value!==undefined&&object&&shift&&(object[shift]!==undefined||object[shift]!==null)){switch(type){case'append':if(!Array.isArray(object[shift])){object[shift]=[];}
object[shift].push(value);break;case'prepend':if(!Array.isArray(object[shift])){object[shift]=[];}
object[shift].unshift(value);break;case'splice':if(!Array.isArray(object[shift])){object[shift]=[];}
object[shift].splice(value,1);break;default:object[shift]=value;}
object[shift].splice(value,1);break;case'merge':if(!typeof object[shift]!=='object'){object[shift]={};}
console.log('object[shift]',object[shift]);console.log('object',object);console.log('shift',shift);console.log('value',value);console.log('result',{...object[shift],...value});object[shift]={...object[shift],...value};break;default:object[shift]=value;}
return true;}
if(!object){return null;}
if(!shift){result=object;}else{return object[shift];}

View file

@ -22,7 +22,8 @@ object=object[path.shift()];}
let shift=path.shift();if(value!==null&&value!==undefined&&object&&shift&&(object[shift]!==undefined||object[shift]!==null)){switch(type){case'append':if(!Array.isArray(object[shift])){object[shift]=[];}
object[shift].push(value);break;case'prepend':if(!Array.isArray(object[shift])){object[shift]=[];}
object[shift].unshift(value);break;case'splice':if(!Array.isArray(object[shift])){object[shift]=[];}
object[shift].splice(value,1);break;default:object[shift]=value;}
object[shift].splice(value,1);break;case'merge':if(!typeof object[shift]!=='object'){object[shift]={};}
console.log('object[shift]',object[shift]);console.log('object',object);console.log('shift',shift);console.log('value',value);console.log('result',{...object[shift],...value});object[shift]={...object[shift],...value};break;default:object[shift]=value;}
return true;}
if(!object){return null;}
if(!shift){result=object;}else{return object[shift];}