mirror of
https://github.com/appwrite/appwrite
synced 2026-05-22 16:38:32 +00:00
Merge pull request #9532 from appwrite/feat-site-deployment-details
Feat: Add screenshots to site
This commit is contained in:
commit
20d90e06f2
6 changed files with 47 additions and 2 deletions
|
|
@ -1003,6 +1003,29 @@ return [
|
|||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
|
||||
[
|
||||
'$id' => ID::custom('deploymentScreenshotLight'), // File ID from 'screenshots' Console bucket
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => 32,
|
||||
'signed' => false,
|
||||
'required' => false,
|
||||
'default' => null,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('deploymentScreenshotDark'), // File ID from 'screenshots' Console bucket
|
||||
'type' => Database::VAR_STRING,
|
||||
'format' => '',
|
||||
'size' => 32,
|
||||
'signed' => false,
|
||||
'required' => false,
|
||||
'default' => null,
|
||||
'array' => false,
|
||||
'filters' => [],
|
||||
],
|
||||
[
|
||||
'$id' => ID::custom('vars'),
|
||||
'type' => Database::VAR_STRING,
|
||||
|
|
|
|||
|
|
@ -788,7 +788,7 @@ class Builds extends Action
|
|||
]);
|
||||
|
||||
$config['sleep'] = 3000;
|
||||
|
||||
|
||||
$frameworks = Config::getParam('frameworks', []);
|
||||
$framework = $frameworks[$resource->getAttribute('framework', '')] ?? null;
|
||||
if (!is_null($framework)) {
|
||||
|
|
@ -898,6 +898,8 @@ class Builds extends Action
|
|||
|
||||
$resource->setAttribute('deploymentId', $deployment->getId());
|
||||
$resource->setAttribute('deploymentInternalId', $deployment->getInternalId());
|
||||
$resource->setAttribute('deploymentScreenshotDark', $deployment->getAttribute('screenshotDark', ''));
|
||||
$resource->setAttribute('deploymentScreenshotLight', $deployment->getAttribute('screenshotLight', ''));
|
||||
$resource = $dbForProject->updateDocument('sites', $resource->getId(), $resource);
|
||||
$queries = [
|
||||
Query::equal("projectInternalId", [$project->getInternalId()]),
|
||||
|
|
|
|||
|
|
@ -100,6 +100,8 @@ class Delete extends Action
|
|||
$site = $dbForProject->updateDocument('sites', $site->getId(), new Document(array_merge($site->getArrayCopy(), [
|
||||
'deploymentId' => '',
|
||||
'deploymentInternalId' => '',
|
||||
'deploymentScreenshotDark' => '',
|
||||
'deploymentScreenshotLight' => '',
|
||||
])));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -90,6 +90,8 @@ class Update extends Base
|
|||
$site = $dbForProject->updateDocument('sites', $site->getId(), new Document(array_merge($site->getArrayCopy(), [
|
||||
'deploymentInternalId' => $deployment->getInternalId(),
|
||||
'deploymentId' => $deployment->getId(),
|
||||
'deploymentScreenshotDark' => $deployment->getAttribute('screenshotDark', ''),
|
||||
'deploymentScreenshotLight' => $deployment->getAttribute('screenshotLight', ''),
|
||||
])));
|
||||
|
||||
$queries = [
|
||||
|
|
|
|||
|
|
@ -58,6 +58,18 @@ class Site extends Model
|
|||
'default' => '',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('deploymentScreenshotLight', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Screenshot of active deployment with light theme preference file ID.',
|
||||
'default' => '',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('deploymentScreenshotDark', [
|
||||
'type' => self::TYPE_STRING,
|
||||
'description' => 'Screenshot of active deployment with dark theme preference file ID.',
|
||||
'default' => '',
|
||||
'example' => '5e5ea5c16897e',
|
||||
])
|
||||
->addRule('vars', [
|
||||
'type' => Response::MODEL_VARIABLE,
|
||||
'description' => 'Site variables.',
|
||||
|
|
|
|||
|
|
@ -1816,11 +1816,15 @@ class SitesCustomServerTest extends Scope
|
|||
$this->assertStringContainsString("@media (prefers-color-scheme: dark)", $response['body']);
|
||||
|
||||
$deployment = $this->getDeployment($siteId, $deploymentId);
|
||||
|
||||
$this->assertEquals(200, $deployment['headers']['status-code']);
|
||||
$this->assertNotEmpty($deployment['body']['screenshotLight']);
|
||||
$this->assertNotEmpty($deployment['body']['screenshotDark']);
|
||||
|
||||
$site = $this->getSite($siteId);
|
||||
$this->assertEquals(200, $site['headers']['status-code']);
|
||||
$this->assertEquals($deployment['body']['screenshotLight'], $site['body']['deploymentScreenshotLight']);
|
||||
$this->assertEquals($deployment['body']['screenshotDark'], $site['body']['deploymentScreenshotDark']);
|
||||
|
||||
$screenshotId = $deployment['body']['screenshotLight'];
|
||||
$file = $this->client->call(Client::METHOD_GET, "/storage/buckets/screenshots/files/$screenshotId/view?project=console", array_merge([
|
||||
], $this->getHeaders()));
|
||||
|
|
|
|||
Loading…
Reference in a new issue