Skip to content
This repository was archived by the owner on Jun 6, 2023. It is now read-only.

feat(environment settings): added possibility to upload custom logo for monitoring environment #471

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions docs/index.html

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/routes/environment/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ interface Request {
interface Response {
environment: Environment;
environmentRights: string[];
userEnvironmentSettings: UserEnvironmentSettings,
userEnvironmentSettings: UserEnvironmentSettings;
environmentLogo: string | null;
Comment on lines 13 to +17
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requested change, I think

I would have imagined that the logo was part of the Environment model as:

// ...
logo?: FileFromServer | null,
// ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't need whole FileFromServer
interface FileFromServer { hashId: string; requestorType: string; requestorHashId: string; url: string; signature: string; name: string | null; mimeType: string | null; bytes: number; md5: string; crc32: string; expiresAt: Date | null; }
Why send it all to UI part if I need only link?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not about needing this info, but how the file is related to the environment, see https://github.com/withthegrid/platform/pull/2011#issuecomment-1453628465

}

const controllerGeneratorOptions: ControllerGeneratorOptionsWithoutClientOrSupplier = {
Expand All @@ -28,6 +29,8 @@ const controllerGeneratorOptions: ControllerGeneratorOptionsWithoutClientOrSuppl
environmentRights: Joi.array().items(Joi.string()).required().example(['STATIC', 'USERS'])
.description('See the getting started section about rights'),
userEnvironmentSettings: userEnvironmentSettingsSchema.required(),
environmentLogo: Joi.string().allow(null).required().description('download link for photo.')
.example('https://api.withthegrid.com/file/yr969d...'),
}).required(),
description: 'Get a specific monitoring environment identified by its hashId',
};
Expand Down
2 changes: 2 additions & 0 deletions src/routes/environment/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ interface Request {
measurementsExpirationDays?: number;
enforceTwoFactorAuthentication?: boolean;
theme: Theme | null;
environmentLogo?: string | null;
};
}

Expand Down Expand Up @@ -58,6 +59,7 @@ const controllerGeneratorOptions: ControllerGeneratorOptionsWithClient = {
enforceTwoFactorAuthentication: Joi.boolean().example(false)
.description('Describes if users need to have two factor authentication enabled in order to access this environment.'),
theme: themeSchema.allow(null),
environmentLogo: Joi.string().allow(null).description('Should be a dataurl. Null clears the photo'),
}).required();
},
right: { environment: 'ENVIRONMENT_ADMIN' },
Expand Down
3 changes: 3 additions & 0 deletions src/routes/settings/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface Response {
environmentRights?: string[];
userEnvironmentSettings?: UserEnvironmentSettings,
user: User;
environmentLogo?: string | null;
}

const controllerGeneratorOptions: ControllerGeneratorOptionsWithoutClientOrSupplier = {
Expand All @@ -25,6 +26,8 @@ const controllerGeneratorOptions: ControllerGeneratorOptionsWithoutClientOrSuppl
.description('See the getting started section about rights'),
userEnvironmentSettings: userEnvironmentSettingsSchema,
user: userSchema.required(),
environmentLogo: Joi.string().allow(null).description('download link for photo.')
.example('https://api.withthegrid.com/file/yr969d...'),
}).required(),
description: 'Get information about the logged in user',
};
Expand Down
3 changes: 3 additions & 0 deletions src/routes/supplier/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface Request {
interface Response {
supplier: Supplier;
supplierRights: string[];
environmentLogo: string | null;
}

const controllerGeneratorOptions: ControllerGeneratorOptionsWithoutClientOrSupplier = {
Expand All @@ -25,6 +26,8 @@ const controllerGeneratorOptions: ControllerGeneratorOptionsWithoutClientOrSuppl
supplier: supplierSchema.required(),
supplierRights: Joi.array().items(Joi.string()).required().example(['STATIC', 'USERS'])
.description('See the getting started section about rights'),
environmentLogo: Joi.string().allow(null).required().description('download link for photo.')
.example('https://api.withthegrid.com/file/yr969d...'),
}).required(),
description: 'Get a specific connectivity environment identified by its hashId',
};
Expand Down
2 changes: 2 additions & 0 deletions src/routes/supplier/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface Request {
name?: string;
enforceTwoFactorAuthentication?: boolean;
theme: Theme | null;
environmentLogo?: string | null;
};
}

Expand All @@ -20,6 +21,7 @@ const controllerGeneratorOptions: ControllerGeneratorOptionsWithSupplier = {
enforceTwoFactorAuthentication: Joi.boolean().example(false)
.description('Describes if users need to have two factor authentication enabled in order to access this environment.'),
theme: themeSchema.allow(null),
environmentLogo: Joi.string().allow(null).description('Should be a dataurl. Null clears the photo'),
}).required(),
right: { supplier: 'ENVIRONMENT_ADMIN' },
};
Expand Down