Start working on adding UI
This commit is contained in:
parent
61cba414bf
commit
66fcbee0df
3 changed files with 292 additions and 244 deletions
|
@ -1111,3 +1111,243 @@ App::post('/v1/functions/:functionId/deployments/:deploymentId/builds/:buildId')
|
|||
|
||||
$response->noContent();
|
||||
});
|
||||
|
||||
// Variables
|
||||
|
||||
App::post('/v1/functions/variables/:functionId')
|
||||
->desc('Create Variable')
|
||||
->groups(['api', 'functions'])
|
||||
->label('scope', 'functions.write')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
|
||||
->label('sdk.namespace', 'functions')
|
||||
->label('sdk.method', 'createVariable')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_CREATED)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_VARIABLE)
|
||||
->param('functionId', null, new UID(), 'Function unique ID.', false)
|
||||
->param('key', null, new Text(255), 'Variable key. Max length: 255 chars.', false)
|
||||
->param('value', null, new Text(16384), 'Variable value. Max length: 16384 chars.', false)
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->inject('dbForProject')
|
||||
->inject('projectId')
|
||||
->action(function (string $functionId, string $key, string $value, Response $response, Database $dbForConsole, Database $dbForProject, string $projectId) {
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception('Project not found', 404, Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
|
||||
if ($function->isEmpty()) {
|
||||
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
$variable = new Document([
|
||||
'$id' => $dbForProject->getId(),
|
||||
'$read' => ['role:all'],
|
||||
'$write' => ['role:all'],
|
||||
'functionInternalId' => $function->getInternalId(),
|
||||
'functionId' => $function->getId(),
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
]);
|
||||
|
||||
try {
|
||||
$variable = $dbForProject->createDocument('variables', $variable);
|
||||
} catch (DuplicateException $th) {
|
||||
throw new Exception('Variable name already used.', 409, Exception::VARIABLE_ALREADY_EXISTS);
|
||||
}
|
||||
|
||||
$dbForProject->deleteCachedDocument('functions', $function->getId());
|
||||
|
||||
$response->setStatusCode(Response::STATUS_CODE_CREATED);
|
||||
$response->dynamic($variable, Response::MODEL_VARIABLE);
|
||||
});
|
||||
|
||||
App::get('/v1/functions/variables/:functionId')
|
||||
->desc('List Variables')
|
||||
->groups(['api', 'functions'])
|
||||
->label('scope', 'functions.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
|
||||
->label('sdk.namespace', 'functions')
|
||||
->label('sdk.method', 'listVariables')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_VARIABLE_LIST)
|
||||
->param('functionId', null, new UID(), 'Function unique ID.', false)
|
||||
// TODO: Pagination
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->inject('dbForProject')
|
||||
->inject('projectId')
|
||||
->action(function (string $functionId, Response $response, Database $dbForConsole, Database $dbForProject, string $projectId) {
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception('Project not found', 404, Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
|
||||
if ($function->isEmpty()) {
|
||||
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
$variables = $dbForProject->find('variables', [
|
||||
new Query('functionInternalId', Query::TYPE_EQUAL, [$function->getInternalId()]),
|
||||
], 5000);
|
||||
|
||||
$response->dynamic(new Document([
|
||||
'variables' => $variables,
|
||||
'total' => count($variables),
|
||||
]), Response::MODEL_VARIABLE_LIST);
|
||||
});
|
||||
|
||||
App::get('/v1/functions/variables/:functionId/:variableId')
|
||||
->desc('Get Variable')
|
||||
->groups(['api', 'functions'])
|
||||
->label('scope', 'functions.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
|
||||
->label('sdk.namespace', 'functions')
|
||||
->label('sdk.method', 'getVariable')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_VARIABLE)
|
||||
->param('functionId', null, new UID(), 'Function unique ID.', false)
|
||||
->param('variableId', null, new UID(), 'Variable unique ID.', false)
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->inject('dbForProject')
|
||||
->inject('projectId')
|
||||
->action(function (string $functionId, string $variableId, Response $response, Database $dbForConsole, Database $dbForProject, string $projectId) {
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception('Project not found', 404, Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
|
||||
if ($function->isEmpty()) {
|
||||
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
$variable = $dbForProject->findOne('variables', [
|
||||
new Query('_uid', Query::TYPE_EQUAL, [$variableId]),
|
||||
new Query('functionInternalId', Query::TYPE_EQUAL, [$function->getInternalId()])
|
||||
]);
|
||||
|
||||
if ($variable === false || $variable->isEmpty()) {
|
||||
throw new Exception('Variable not found', 404, Exception::VARIABLE_NOT_FOUND);
|
||||
}
|
||||
|
||||
$response->dynamic($variable, Response::MODEL_VARIABLE);
|
||||
});
|
||||
|
||||
App::put('/v1/functions/variables/:functionId/:variableId')
|
||||
->desc('Update Variable')
|
||||
->groups(['api', 'functions'])
|
||||
->label('scope', 'functions.write')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
|
||||
->label('sdk.namespace', 'functions')
|
||||
->label('sdk.method', 'updateVariable')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_VARIABLE)
|
||||
->param('functionId', null, new UID(), 'Function unique ID.', false)
|
||||
->param('variableId', null, new UID(), 'Variable unique ID.', false)
|
||||
->param('key', null, new Text(255), 'Variable key. Max length: 255 chars.', true)
|
||||
->param('value', null, new Text(16384), 'Variable value. Max length: 16384 chars.', true)
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->inject('dbForProject')
|
||||
->action(function (string $projectId, string $functionId, string $variableId, ?string $key, ?string $value, Response $response, Database $dbForConsole, Database $dbForProject) {
|
||||
if (empty($key) && empty($value)) {
|
||||
throw new Exception('Missing key or value. Define at least one.', 400, Exception::VARIABLE_MISSING_PAYLOAD);
|
||||
}
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception('Project not found', 404, Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
|
||||
if ($function->isEmpty()) {
|
||||
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
$variable = $dbForProject->findOne('variables', [
|
||||
new Query('_uid', Query::TYPE_EQUAL, [$variableId]),
|
||||
new Query('functionInternalId', Query::TYPE_EQUAL, [$function->getInternalId()])
|
||||
]);
|
||||
|
||||
if ($variable === false || $variable->isEmpty()) {
|
||||
throw new Exception('Variable not found', 404, Exception::VARIABLE_NOT_FOUND);
|
||||
}
|
||||
|
||||
$variable
|
||||
->setAttribute('key', $key ?? $variable->getAttribute('key'))
|
||||
->setAttribute('value', $value ?? $variable->getAttribute('value'))
|
||||
;
|
||||
|
||||
try {
|
||||
$dbForProject->updateDocument('variables', $variable->getId(), $variable);
|
||||
} catch (DuplicateException $th) {
|
||||
throw new Exception('Variable name already used.', 409, Exception::VARIABLE_ALREADY_EXISTS);
|
||||
}
|
||||
|
||||
$dbForProject->deleteCachedDocument('functions', $function->getId());
|
||||
|
||||
$response->dynamic($variable, Response::MODEL_VARIABLE);
|
||||
});
|
||||
|
||||
App::delete('/v1/functions/variables/:functionId/:variableId')
|
||||
->desc('Delete Variable')
|
||||
->groups(['api', 'functions'])
|
||||
->label('scope', 'functions.write')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
|
||||
->label('sdk.namespace', 'functions')
|
||||
->label('sdk.method', 'deleteVariable')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT)
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('functionId', null, new UID(), 'Function unique ID.', false)
|
||||
->param('variableId', null, new UID(), 'Variable unique ID.', false)
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->inject('dbForProject')
|
||||
->action(function (string $projectId, string $functionId, string $variableId, Response $response, Database $dbForConsole, Database $dbForProject) {
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception('Project not found', 404, Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
|
||||
if ($function->isEmpty()) {
|
||||
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
$variable = $dbForProject->findOne('variables', [
|
||||
new Query('_uid', Query::TYPE_EQUAL, [$variableId]),
|
||||
new Query('functionInternalId', Query::TYPE_EQUAL, [$function->getInternalId()])
|
||||
]);
|
||||
|
||||
if ($variable === false || $variable->isEmpty()) {
|
||||
throw new Exception('Variable not found', 404, Exception::VARIABLE_NOT_FOUND);
|
||||
}
|
||||
|
||||
$dbForProject->deleteDocument('variables', $variable->getId());
|
||||
|
||||
$dbForProject->deleteCachedDocument('functions', $function->getId());
|
||||
|
||||
$response->noContent();
|
||||
});
|
||||
|
|
|
@ -1425,247 +1425,4 @@ App::delete('/v1/projects/:projectId/domains/:domainId')
|
|||
->setDocument($domain);
|
||||
|
||||
$response->noContent();
|
||||
});
|
||||
|
||||
|
||||
// Variables
|
||||
|
||||
App::post('/v1/projects/:projectId/variables/:functionId')
|
||||
->desc('Create Variable')
|
||||
->groups(['api', 'projectsScoped'])
|
||||
->label('scope', 'projects.write')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
|
||||
->label('sdk.namespace', 'projects')
|
||||
->label('sdk.method', 'createVariable')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_CREATED)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_VARIABLE)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('functionId', null, new UID(), 'Function unique ID.', true)
|
||||
->param('key', null, new Text(255), 'Variable key. Max length: 255 chars.')
|
||||
->param('value', null, new Text(16384), 'Variable value. Max length: 16384 chars.')
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->inject('dbForProject')
|
||||
->action(function (string $projectId, string $functionId, string $key, string $value, Response $response, Database $dbForConsole, Database $dbForProject) {
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception('Project not found', 404, Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
|
||||
if ($function->isEmpty()) {
|
||||
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
$variable = new Document([
|
||||
'$id' => $dbForProject->getId(),
|
||||
'$read' => ['role:all'],
|
||||
'$write' => ['role:all'],
|
||||
'functionInternalId' => $function->getInternalId(),
|
||||
'functionId' => $function->getId(),
|
||||
'key' => $key,
|
||||
'value' => $value,
|
||||
]);
|
||||
|
||||
try {
|
||||
$variable = $dbForProject->createDocument('variables', $variable);
|
||||
} catch (DuplicateException $th) {
|
||||
throw new Exception('Variable name already used.', 409, Exception::VARIABLE_ALREADY_EXISTS);
|
||||
}
|
||||
|
||||
$dbForProject->deleteCachedDocument('functions', $function->getId());
|
||||
|
||||
$response->setStatusCode(Response::STATUS_CODE_CREATED);
|
||||
$response->dynamic($variable, Response::MODEL_VARIABLE);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/variables/:functionId')
|
||||
->desc('List Variables')
|
||||
->groups(['api', 'projectsScoped'])
|
||||
->label('scope', 'projects.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
|
||||
->label('sdk.namespace', 'projects')
|
||||
->label('sdk.method', 'listVariables')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_VARIABLE_LIST)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('functionId', null, new UID(), 'Function unique ID.', true)
|
||||
// TODO: Pagination
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->inject('dbForProject')
|
||||
->action(function (string $projectId, string $functionId, Response $response, Database $dbForConsole, Database $dbForProject) {
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception('Project not found', 404, Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
|
||||
if ($function->isEmpty()) {
|
||||
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
$variables = $dbForProject->find('variables', [
|
||||
new Query('functionInternalId', Query::TYPE_EQUAL, [$function->getInternalId()]),
|
||||
], 5000);
|
||||
|
||||
$response->dynamic(new Document([
|
||||
'variables' => $variables,
|
||||
'total' => count($variables),
|
||||
]), Response::MODEL_VARIABLE_LIST);
|
||||
});
|
||||
|
||||
App::get('/v1/projects/:projectId/variables/:functionId/:variableId')
|
||||
->desc('Get Variable')
|
||||
->groups(['api', 'projectsScoped'])
|
||||
->label('scope', 'projects.read')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
|
||||
->label('sdk.namespace', 'projects')
|
||||
->label('sdk.method', 'getVariable')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_VARIABLE)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('functionId', null, new UID(), 'Function unique ID.')
|
||||
->param('variableId', null, new UID(), 'Variable unique ID.')
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->inject('dbForProject')
|
||||
->action(function (string $projectId, string $functionId, string $variableId, Response $response, Database $dbForConsole, Database $dbForProject) {
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception('Project not found', 404, Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
|
||||
if ($function->isEmpty()) {
|
||||
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
$variable = $dbForProject->findOne('variables', [
|
||||
new Query('_uid', Query::TYPE_EQUAL, [$variableId]),
|
||||
new Query('functionInternalId', Query::TYPE_EQUAL, [$function->getInternalId()])
|
||||
]);
|
||||
|
||||
if ($variable === false || $variable->isEmpty()) {
|
||||
throw new Exception('Variable not found', 404, Exception::VARIABLE_NOT_FOUND);
|
||||
}
|
||||
|
||||
$response->dynamic($variable, Response::MODEL_VARIABLE);
|
||||
});
|
||||
|
||||
App::put('/v1/projects/:projectId/variables/:functionId/:variableId')
|
||||
->desc('Update Variable')
|
||||
->groups(['api', 'projectsScoped'])
|
||||
->label('scope', 'projects.write')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
|
||||
->label('sdk.namespace', 'projects')
|
||||
->label('sdk.method', 'updateVariable')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_OK)
|
||||
->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
|
||||
->label('sdk.response.model', Response::MODEL_VARIABLE)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('functionId', null, new UID(), 'Function unique ID.')
|
||||
->param('variableId', null, new UID(), 'Variable unique ID.')
|
||||
->param('key', null, new Text(255), 'Variable key. Max length: 255 chars.', true)
|
||||
->param('value', null, new Text(16384), 'Variable value. Max length: 16384 chars.', true)
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->inject('dbForProject')
|
||||
->action(function (string $projectId, string $functionId, string $variableId, ?string $key, ?string $value, Response $response, Database $dbForConsole, Database $dbForProject) {
|
||||
if (empty($key) && empty($value)) {
|
||||
throw new Exception('Missing key or value. Define at least one.', 400, Exception::VARIABLE_MISSING_PAYLOAD);
|
||||
}
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception('Project not found', 404, Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
|
||||
if ($function->isEmpty()) {
|
||||
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
$variable = $dbForProject->findOne('variables', [
|
||||
new Query('_uid', Query::TYPE_EQUAL, [$variableId]),
|
||||
new Query('functionInternalId', Query::TYPE_EQUAL, [$function->getInternalId()])
|
||||
]);
|
||||
|
||||
if ($variable === false || $variable->isEmpty()) {
|
||||
throw new Exception('Variable not found', 404, Exception::VARIABLE_NOT_FOUND);
|
||||
}
|
||||
|
||||
$variable
|
||||
->setAttribute('key', $key ?? $variable->getAttribute('key'))
|
||||
->setAttribute('value', $value ?? $variable->getAttribute('value'))
|
||||
;
|
||||
|
||||
try {
|
||||
$dbForProject->updateDocument('variables', $variable->getId(), $variable);
|
||||
} catch (DuplicateException $th) {
|
||||
throw new Exception('Variable name already used.', 409, Exception::VARIABLE_ALREADY_EXISTS);
|
||||
}
|
||||
|
||||
$dbForProject->deleteCachedDocument('functions', $function->getId());
|
||||
|
||||
$response->dynamic($variable, Response::MODEL_VARIABLE);
|
||||
});
|
||||
|
||||
App::delete('/v1/projects/:projectId/variables/:functionId/:variableId')
|
||||
->desc('Delete Variable')
|
||||
->groups(['api', 'projectsScoped'])
|
||||
->label('scope', 'projects.write')
|
||||
->label('sdk.auth', [APP_AUTH_TYPE_ADMIN])
|
||||
->label('sdk.namespace', 'projects')
|
||||
->label('sdk.method', 'deleteVariable')
|
||||
->label('sdk.response.code', Response::STATUS_CODE_NOCONTENT)
|
||||
->label('sdk.response.model', Response::MODEL_NONE)
|
||||
->param('projectId', null, new UID(), 'Project unique ID.')
|
||||
->param('functionId', null, new UID(), 'Function unique ID.')
|
||||
->param('variableId', null, new UID(), 'Variable unique ID.')
|
||||
->inject('response')
|
||||
->inject('dbForConsole')
|
||||
->inject('dbForProject')
|
||||
->action(function (string $projectId, string $functionId, string $variableId, Response $response, Database $dbForConsole, Database $dbForProject) {
|
||||
|
||||
$project = $dbForConsole->getDocument('projects', $projectId);
|
||||
|
||||
if ($project->isEmpty()) {
|
||||
throw new Exception('Project not found', 404, Exception::PROJECT_NOT_FOUND);
|
||||
}
|
||||
|
||||
$function = $dbForProject->getDocument('functions', $functionId);
|
||||
|
||||
if ($function->isEmpty()) {
|
||||
throw new Exception('Function not found', 404, Exception::FUNCTION_NOT_FOUND);
|
||||
}
|
||||
|
||||
$variable = $dbForProject->findOne('variables', [
|
||||
new Query('_uid', Query::TYPE_EQUAL, [$variableId]),
|
||||
new Query('functionInternalId', Query::TYPE_EQUAL, [$function->getInternalId()])
|
||||
]);
|
||||
|
||||
if ($variable === false || $variable->isEmpty()) {
|
||||
throw new Exception('Variable not found', 404, Exception::VARIABLE_NOT_FOUND);
|
||||
}
|
||||
|
||||
$dbForProject->deleteDocument('variables', $variable->getId());
|
||||
|
||||
$dbForProject->deleteCachedDocument('functions', $function->getId());
|
||||
|
||||
$response->noContent();
|
||||
});
|
||||
});
|
|
@ -686,6 +686,57 @@ sort($patterns);
|
|||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li data-state="/console/functions/function/variables?id={{router.params.id}}&project={{router.params.project}}">
|
||||
<h2>Variables</h2>
|
||||
|
||||
|
||||
<div data-ls-if="(!{{console-project.platforms.length}})" class="box dashboard margin-bottom">
|
||||
<div class="margin-bottom-small margin-top-small margin-end margin-start">
|
||||
<h3 class="margin-bottom-small text-bold">There are currently no variables</h3>
|
||||
|
||||
<p class="margin-bottom-no">Add your first variable to store information securely.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div data-ui-modal class="modal box close" data-button-alias=".variable-new">
|
||||
<button type="button" class="close pull-end" data-ui-modal-close=""><i class="icon-cancel"></i></button>
|
||||
|
||||
<h1>Create a new variable</h1>
|
||||
|
||||
<form
|
||||
data-analytics
|
||||
data-analytics-activity
|
||||
data-analytics-event="submit"
|
||||
data-analytics-category="console"
|
||||
data-analytics-label="Create New Function Variable"
|
||||
data-service="functions.createPlatform"
|
||||
data-scope="console"
|
||||
data-event="submit"
|
||||
data-success="alert,trigger,reset"
|
||||
data-success-param-alert-text="Registered new platform successfully"
|
||||
data-success-param-trigger-events="projects.createPlatform"
|
||||
data-failure="alert"
|
||||
data-failure-param-alert-text="Failed to register platform"
|
||||
data-failure-param-alert-classname="error">
|
||||
|
||||
<input type="hidden" name="projectId" data-ls-bind="{{router.params.project}}" />
|
||||
<input type="hidden" name="type" data-ls-bind="android" />
|
||||
|
||||
<label for="name">Name <span class="tooltip large" data-tooltip="The name of the environment variable you want to set"><i class="icon-question"></i></span></label>
|
||||
<input type="text" class="full-width" name="name" required autocomplete="off" placeholder="APP_ENV" maxlength="128" />
|
||||
|
||||
<label for="key">Value <span class="tooltip large" data-tooltip="The value of your environment variable"><i class="icon-question"></i></span></label>
|
||||
<input type="text" class="full-width" name="key" required autocomplete="off" placeholder="Production" />
|
||||
|
||||
<hr />
|
||||
|
||||
<button type="submit">Create</button> <button data-ui-modal-close="" type="button" class="reverse">Cancel</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="pull-start link variable-new" data-ls-ui-open="" data-button-aria="Add Variable" data-button-text="Add Variable" data-button-class="button" data-blur="1">
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue