From f460a40b1eaf139b20224eb62055f960c05d7554 Mon Sep 17 00:00:00 2001 From: Matthew Griffin Date: Tue, 21 May 2024 12:22:09 +0100 Subject: [PATCH 01/11] Change 'User' to 'Employee' Covers user facing text and code so that it doesn't get confusing in future --- docs/types.md | 6 ++--- .../carbon-estimation.component.spec.ts | 24 +++++++++---------- .../carbon-estimation.component.ts | 10 ++++---- src/app/estimation/device-usage.spec.ts | 8 +++---- .../estimate-direct-emissions.spec.ts | 14 +++++------ .../estimation/estimate-direct-emissions.ts | 2 +- .../estimate-upstream-emissions.spec.ts | 14 +++++------ .../estimation/estimate-upstream-emissions.ts | 2 +- .../carbon-estimation.service.spec.ts | 8 +++---- src/app/services/carbon-estimation.service.ts | 6 ++--- .../tech-carbon-estimator.component.spec.ts | 4 ++-- src/app/types/carbon-estimator.ts | 6 ++--- 12 files changed, 52 insertions(+), 52 deletions(-) diff --git a/docs/types.md b/docs/types.md index 9e404785..4648b718 100644 --- a/docs/types.md +++ b/docs/types.md @@ -98,7 +98,7 @@ This contains the data as entered on the main form, which uses Angular FormGroup classDiagram class DeviceCategory { <> - 'user' + 'employee' 'server' 'network' } @@ -125,7 +125,7 @@ classDiagram class UpstreamEstimation { software: number - user: number + employee: number network: number server: number } @@ -135,7 +135,7 @@ classDiagram managed: number } class DirectEstimation { - user: number + employee: number network: number server: number } diff --git a/src/app/carbon-estimation/carbon-estimation.component.spec.ts b/src/app/carbon-estimation/carbon-estimation.component.spec.ts index e0aa2ab5..608da318 100644 --- a/src/app/carbon-estimation/carbon-estimation.component.spec.ts +++ b/src/app/carbon-estimation/carbon-estimation.component.spec.ts @@ -22,12 +22,12 @@ describe('CarbonEstimationComponent', () => { version: '1.0', upstreamEmissions: { software: 7, - user: 6, + employee: 6, network: 6, server: 6, }, directEmissions: { - user: 9, + employee: 9, network: 8, server: 8, }, @@ -118,7 +118,7 @@ describe('CarbonEstimationComponent', () => { meta: { svg: 'web-logo', parent: 'Upstream Emissions' }, }, { - x: 'User Hardware', + x: 'Employee Hardware', y: 6, meta: { svg: 'devices-logo', parent: 'Upstream Emissions' }, }, @@ -139,7 +139,7 @@ describe('CarbonEstimationComponent', () => { color: '#CB3775', data: [ { - x: 'User Devices', + x: 'Employee Devices', y: 9, meta: { svg: 'devices-logo', parent: 'Direct Emissions' }, }, @@ -206,12 +206,12 @@ describe('CarbonEstimationComponent', () => { version: '1.0', upstreamEmissions: { software: 0.2, - user: 0.1, + employee: 0.1, network: 0.1, server: 0.1, }, directEmissions: { - user: 34.5, + employee: 34.5, network: 8, server: 8, }, @@ -237,12 +237,12 @@ describe('CarbonEstimationComponent', () => { version: '1.0', upstreamEmissions: { software: 25, - user: 0, + employee: 0, network: 0, server: 0, }, directEmissions: { - user: 25, + employee: 25, network: 0, server: 0, }, @@ -277,7 +277,7 @@ describe('CarbonEstimationComponent', () => { color: '#CB3775', data: [ { - x: 'User Devices', + x: 'Employee Devices', y: 25, meta: { svg: 'devices-logo', parent: 'Direct Emissions' }, }, @@ -315,12 +315,12 @@ describe('CarbonEstimationComponent', () => { version: '1.0', upstreamEmissions: { software: 50, - user: 0, + employee: 0, network: 0, server: 0, }, directEmissions: { - user: 50, + employee: 50, network: 0, server: 0, }, @@ -355,7 +355,7 @@ describe('CarbonEstimationComponent', () => { color: '#CB3775', data: [ { - x: 'User Devices', + x: 'Employee Devices', y: 50, meta: { svg: 'devices-logo', parent: 'Direct Emissions' }, }, diff --git a/src/app/carbon-estimation/carbon-estimation.component.ts b/src/app/carbon-estimation/carbon-estimation.component.ts index 5a1aeac7..342c0ac7 100644 --- a/src/app/carbon-estimation/carbon-estimation.component.ts +++ b/src/app/carbon-estimation/carbon-estimation.component.ts @@ -153,8 +153,8 @@ export class CarbonEstimationComponent implements OnInit { return this.getDataItemObject('Software - Off the Shelf', value, SVG.WEB, parent); case 'saas': return this.getDataItemObject('SaaS', value, SVG.WEB, parent); - case 'user': - return this.getDataItemObject(this.getUserLabel(parent), value, SVG.DEVICES, parent); + case 'employee': + return this.getDataItemObject(this.getEmployeeLabel(parent), value, SVG.DEVICES, parent); case 'endUser': return this.getDataItemObject('End-User Devices', value, SVG.DEVICES, parent); case 'network': @@ -183,12 +183,12 @@ export class CarbonEstimationComponent implements OnInit { }; } - private getUserLabel(key: string): string { + private getEmployeeLabel(key: string): string { switch (key) { case 'Upstream Emissions': - return 'User Hardware'; + return 'Employee Hardware'; case 'Direct Emissions': - return 'User Devices'; + return 'Employee Devices'; default: return startCase(key); } diff --git a/src/app/estimation/device-usage.spec.ts b/src/app/estimation/device-usage.spec.ts index de066b4f..11e1ca54 100644 --- a/src/app/estimation/device-usage.spec.ts +++ b/src/app/estimation/device-usage.spec.ts @@ -4,7 +4,7 @@ import { estimateEnergyEmissions } from './estimate-energy-emissions'; describe('createDeviceUsage()', () => { it('should expose device category', () => { - expect(createDeviceUsage(laptop, 'user', 0, 0).category).toBe('user'); + expect(createDeviceUsage(laptop, 'employee', 0, 0).category).toBe('employee'); expect(createDeviceUsage(laptop, 'server', 0, 0).category).toBe('server'); expect(createDeviceUsage(laptop, 'network', 0, 0).category).toBe('network'); }); @@ -12,7 +12,7 @@ describe('createDeviceUsage()', () => { it('should estimate upstream emissions using device type', () => { spyOn(laptop, 'estimateYearlyUpstreamEmissions').and.callFake(() => 42); const deviceCount = 10; - const usage = createDeviceUsage(laptop, 'user', 0, deviceCount); + const usage = createDeviceUsage(laptop, 'employee', 0, deviceCount); expect(usage.estimateUpstreamEmissions()).toBe(42); expect(laptop.estimateYearlyUpstreamEmissions).toHaveBeenCalledOnceWith(deviceCount); @@ -22,7 +22,7 @@ describe('createDeviceUsage()', () => { spyOn(laptop, 'estimateYearlyEnergy').and.callFake(() => 42); const deviceCount = 100; const carbonIntensity = 500; - const usage = createDeviceUsage(laptop, 'user', carbonIntensity, deviceCount); + const usage = createDeviceUsage(laptop, 'employee', carbonIntensity, deviceCount); const expectedEmissions = estimateEnergyEmissions(42, carbonIntensity); expect(usage.estimateDirectEmissions()).toBe(expectedEmissions); @@ -34,7 +34,7 @@ describe('createDeviceUsage()', () => { const deviceCount = 1000; const carbonIntensity = 500; const pue = 2; - const usage = createDeviceUsage(laptop, 'user', carbonIntensity, deviceCount, pue); + const usage = createDeviceUsage(laptop, 'employee', carbonIntensity, deviceCount, pue); const expectedEmissions = estimateEnergyEmissions(84, carbonIntensity); expect(usage.estimateDirectEmissions()).toBe(expectedEmissions); diff --git a/src/app/estimation/estimate-direct-emissions.spec.ts b/src/app/estimation/estimate-direct-emissions.spec.ts index 2c4d8d79..793ea8a4 100644 --- a/src/app/estimation/estimate-direct-emissions.spec.ts +++ b/src/app/estimation/estimate-direct-emissions.spec.ts @@ -14,7 +14,7 @@ describe('estimateDirectEmissions', () => { it('should return no emissions for an empty list', () => { expect(estimateDirectEmissions([])).toEqual({ - user: 0, + employee: 0, server: 0, network: 0, }); @@ -22,13 +22,13 @@ describe('estimateDirectEmissions', () => { it('should allocate emissions to relevant category', () => { const deviceUsage: DeviceUsage[] = [ - createDirectDeviceUsageStub('user', 1), + createDirectDeviceUsageStub('employee', 1), createDirectDeviceUsageStub('server', 2), createDirectDeviceUsageStub('network', 3), ]; expect(estimateDirectEmissions(deviceUsage)).toEqual({ - user: 1, + employee: 1, server: 2, network: 3, }); @@ -36,12 +36,12 @@ describe('estimateDirectEmissions', () => { it('should total multiple emissions in the same category', () => { const deviceUsage: DeviceUsage[] = [ - createDirectDeviceUsageStub('user', 1), - createDirectDeviceUsageStub('user', 2), - createDirectDeviceUsageStub('user', 3), + createDirectDeviceUsageStub('employee', 1), + createDirectDeviceUsageStub('employee', 2), + createDirectDeviceUsageStub('employee', 3), ]; expect(estimateDirectEmissions(deviceUsage)).toEqual({ - user: 6, + employee: 6, server: 0, network: 0, }); diff --git a/src/app/estimation/estimate-direct-emissions.ts b/src/app/estimation/estimate-direct-emissions.ts index 8a8e6c87..773ec100 100644 --- a/src/app/estimation/estimate-direct-emissions.ts +++ b/src/app/estimation/estimate-direct-emissions.ts @@ -3,7 +3,7 @@ import { DeviceUsage } from './device-usage'; export function estimateDirectEmissions(deviceUsage: DeviceUsage[]): DirectEstimation { const result: Record = { - user: 0, + employee: 0, server: 0, network: 0, }; diff --git a/src/app/estimation/estimate-upstream-emissions.spec.ts b/src/app/estimation/estimate-upstream-emissions.spec.ts index 73c79255..e47e2612 100644 --- a/src/app/estimation/estimate-upstream-emissions.spec.ts +++ b/src/app/estimation/estimate-upstream-emissions.spec.ts @@ -15,7 +15,7 @@ describe('estimateUpstreamEmissions', () => { it('should return no emissions for an empty list', () => { expect(estimateUpstreamEmissions([])).toEqual({ software: 0, - user: 0, + employee: 0, server: 0, network: 0, }); @@ -23,14 +23,14 @@ describe('estimateUpstreamEmissions', () => { it('should allocate emissions to relevant category', () => { const deviceUsage: DeviceUsage[] = [ - createUpstreamDeviceUsageStub('user', 1), + createUpstreamDeviceUsageStub('employee', 1), createUpstreamDeviceUsageStub('server', 2), createUpstreamDeviceUsageStub('network', 3), ]; expect(estimateUpstreamEmissions(deviceUsage)).toEqual({ software: 0, - user: 1, + employee: 1, server: 2, network: 3, }); @@ -38,13 +38,13 @@ describe('estimateUpstreamEmissions', () => { it('should total multiple emissions in the same category', () => { const deviceUsage: DeviceUsage[] = [ - createUpstreamDeviceUsageStub('user', 1), - createUpstreamDeviceUsageStub('user', 2), - createUpstreamDeviceUsageStub('user', 3), + createUpstreamDeviceUsageStub('employee', 1), + createUpstreamDeviceUsageStub('employee', 2), + createUpstreamDeviceUsageStub('employee', 3), ]; expect(estimateUpstreamEmissions(deviceUsage)).toEqual({ software: 0, - user: 6, + employee: 6, server: 0, network: 0, }); diff --git a/src/app/estimation/estimate-upstream-emissions.ts b/src/app/estimation/estimate-upstream-emissions.ts index 1fdc56a9..7aeb4e57 100644 --- a/src/app/estimation/estimate-upstream-emissions.ts +++ b/src/app/estimation/estimate-upstream-emissions.ts @@ -3,7 +3,7 @@ import { DeviceUsage } from './device-usage'; export function estimateUpstreamEmissions(deviceUsage: DeviceUsage[]): UpstreamEstimation { const result: Record = { - user: 0, + employee: 0, server: 0, network: 0, }; diff --git a/src/app/services/carbon-estimation.service.spec.ts b/src/app/services/carbon-estimation.service.spec.ts index 74e768d7..83cc09ec 100644 --- a/src/app/services/carbon-estimation.service.spec.ts +++ b/src/app/services/carbon-estimation.service.spec.ts @@ -188,12 +188,12 @@ describe('CarbonEstimationService', () => { const result = service.calculateCarbonEstimation(hardwareInput); expectPartialEstimationCloseTo(result, { upstreamEmissions: { - user: 5.78, + employee: 5.78, server: 7.64, network: 3.43, }, directEmissions: { - user: 2.89, + employee: 2.89, server: 58.37, network: 21.89, }, @@ -217,12 +217,12 @@ describe('CarbonEstimationService', () => { const result = service.calculateCarbonEstimation(hardwareInput); expectPartialEstimationCloseTo(result, { upstreamEmissions: { - user: 6.21, + employee: 6.21, server: 8.21, network: 3.68, }, directEmissions: { - user: 1.55, + employee: 1.55, server: 62.71, network: 17.64, }, diff --git a/src/app/services/carbon-estimation.service.ts b/src/app/services/carbon-estimation.service.ts index b5c4ee1e..0dac4b6c 100644 --- a/src/app/services/carbon-estimation.service.ts +++ b/src/app/services/carbon-estimation.service.ts @@ -73,12 +73,12 @@ export class CarbonEstimationService { const employeeIntensity = this.carbonIntensityService.getCarbonIntensity(formValue.upstream.employeeLocation); const onPremIntensity = this.carbonIntensityService.getCarbonIntensity(formValue.onPremise.serverLocation); return [ - createDeviceUsage(desktop, 'user', employeeIntensity, desktopCount), - createDeviceUsage(laptop, 'user', employeeIntensity, laptopCount), + createDeviceUsage(desktop, 'employee', employeeIntensity, desktopCount), + createDeviceUsage(laptop, 'employee', employeeIntensity, laptopCount), createDeviceUsage(network, 'network', employeeIntensity, employeeNetworkCount, ON_PREMISE_AVERAGE_PUE), createDeviceUsage(server, 'server', onPremIntensity, serverCount, ON_PREMISE_AVERAGE_PUE), createDeviceUsage(network, 'network', onPremIntensity, serverNetworkCount, ON_PREMISE_AVERAGE_PUE), - createDeviceUsage(monitor, 'user', employeeIntensity, monitorCount), + createDeviceUsage(monitor, 'employee', employeeIntensity, monitorCount), ]; } } diff --git a/src/app/tech-carbon-estimator/tech-carbon-estimator.component.spec.ts b/src/app/tech-carbon-estimator/tech-carbon-estimator.component.spec.ts index bfd5d0f4..4537462a 100644 --- a/src/app/tech-carbon-estimator/tech-carbon-estimator.component.spec.ts +++ b/src/app/tech-carbon-estimator/tech-carbon-estimator.component.spec.ts @@ -15,7 +15,7 @@ describe('TechCarbonEstimatorComponent', () => { version: '0.0.0', upstreamEmissions: { software: 0, - user: 10, + employee: 10, network: 10, server: 5, }, @@ -25,7 +25,7 @@ describe('TechCarbonEstimatorComponent', () => { cloud: 25, }, directEmissions: { - user: 10, + employee: 10, network: 10, server: 5, }, diff --git a/src/app/types/carbon-estimator.ts b/src/app/types/carbon-estimator.ts index fd431794..475e9b58 100644 --- a/src/app/types/carbon-estimator.ts +++ b/src/app/types/carbon-estimator.ts @@ -11,7 +11,7 @@ export type CarbonEstimation = { export type UpstreamEstimation = { software: number; - user: number; + employee: number; network: number; server: number; }; @@ -21,7 +21,7 @@ export type IndirectEstimation = { managed: number; }; export type DirectEstimation = { - user: number; + employee: number; network: number; server: number; }; @@ -87,7 +87,7 @@ export type Downstream = { purposeOfSite: PurposeOfSite; }; -export type DeviceCategory = 'user' | 'server' | 'network'; +export type DeviceCategory = 'employee' | 'server' | 'network'; export const locationArray = [ 'WORLD', From dea56c27b55f5938bd95031a268971be781959dc Mon Sep 17 00:00:00 2001 From: Matthew Griffin Date: Thu, 23 May 2024 13:20:15 +0100 Subject: [PATCH 02/11] Change assumptions component to show device information from the available classes --- .../assumptions-and-limitation.component.html | 82 ++++--------------- .../assumptions-and-limitation.component.ts | 31 +++++++ 2 files changed, 49 insertions(+), 64 deletions(-) diff --git a/src/app/assumptions-and-limitation/assumptions-and-limitation.component.html b/src/app/assumptions-and-limitation/assumptions-and-limitation.component.html index 36532f95..55601fcc 100644 --- a/src/app/assumptions-and-limitation/assumptions-and-limitation.component.html +++ b/src/app/assumptions-and-limitation/assumptions-and-limitation.component.html @@ -58,34 +58,12 @@

Power consumption

- - Laptop - 17 - - - Desktop - 72 - - - Server - 400 - - - Network - 150 - - - Mobile - 1 - - - Tablet - 3 - - - Monitor - 30 - + @for (device of deviceInfo; track $index) { + + {{ device.name }} + {{ device.info.averagePower }} + + }

@@ -122,7 +100,7 @@

Carbon Intensity

Upstream Emissions

Each class of device is given an average amount of embodied carbon and a lifespan, based on averages taken from - manufacturer provided Product Carbon Footprint documentation. At present these are: + manufacturer provided Product Carbon Footprint documentation*. At present these are:

@@ -135,41 +113,17 @@

Upstream Emissions

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @for (device of deviceInfo; track $index) { + + + + + + }
Laptop2304
Desktop4004
Server14504
Network650 *4
Mobile543
Tablet1343
Monitor3506
{{ device.name }} + {{ device.info.averageEmbodiedCarbon }} + + {{ device.info.averageLifespan }} +

diff --git a/src/app/assumptions-and-limitation/assumptions-and-limitation.component.ts b/src/app/assumptions-and-limitation/assumptions-and-limitation.component.ts index a19a5530..de7cbed2 100644 --- a/src/app/assumptions-and-limitation/assumptions-and-limitation.component.ts +++ b/src/app/assumptions-and-limitation/assumptions-and-limitation.component.ts @@ -4,6 +4,7 @@ import { siteTypeInfo } from '../estimation/estimate-downstream-emissions'; import { PurposeOfSite, WorldLocation, locationArray, purposeOfSiteArray } from '../types/carbon-estimator'; import { DecimalPipe } from '@angular/common'; import { CarbonIntensityService } from '../services/carbon-intensity.service'; +import { desktop, laptop, mobile, monitor, network, server, tablet } from '../estimation/device-type'; const purposeDescriptions: Record = { information: 'Information', @@ -40,6 +41,36 @@ export class AssumptionsAndLimitationComponent implements AfterContentInit { data: siteTypeInfo[purpose].averageMonthlyUserData, })); readonly locationCarbonInfo; + readonly deviceInfo = [ + { + name: 'Laptop', + info: laptop, + }, + { + name: 'Desktop', + info: desktop, + }, + { + name: 'Server', + info: server, + }, + { + name: 'Network', + info: network, + }, + { + name: 'Mobile', + info: mobile, + }, + { + name: 'Tablet', + info: tablet, + }, + { + name: 'Monitor', + info: monitor, + }, + ]; @ViewChild('assumptionsLimitation', { static: true }) public assumptionsLimitation!: ElementRef; From d2d71cdc9a03204117c44805bb7d5d1cbc868bac Mon Sep 17 00:00:00 2001 From: Matthew Griffin Date: Thu, 23 May 2024 13:20:49 +0100 Subject: [PATCH 03/11] Reduce the average power of network devices --- src/app/estimation/device-type.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/estimation/device-type.ts b/src/app/estimation/device-type.ts index b1b08116..a649d2fa 100644 --- a/src/app/estimation/device-type.ts +++ b/src/app/estimation/device-type.ts @@ -55,7 +55,7 @@ export class AverageDeviceType extends DeviceType { export const laptop = new DeviceType(17, 8 * 230, 230, 4); export const desktop = new DeviceType(72, 8 * 230, 400, 4); export const server = new DeviceType(400, 24 * 365, 1450, 4); -export const network = new DeviceType(150, 24 * 365, 650, 4); +export const network = new DeviceType(87, 24 * 365, 650, 4); export const mobile = new DeviceType(1, 24 * 365, 54, 3); export const tablet = new DeviceType(3, 24 * 365, 134, 3); export const monitor = new DeviceType(30, 8 * 230, 350, 6); From f340292d90689e7ba0805141ca84d34841d98dcf Mon Sep 17 00:00:00 2001 From: Matthew Griffin Date: Thu, 23 May 2024 13:26:43 +0100 Subject: [PATCH 04/11] Update Network count calculations Include laptops when calculating employee network device count Remove on-premise PUE factor from employee network device usage Reduce the amount of network devices per device to represent an average amount of connected devices --- src/app/services/carbon-estimation.service.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/services/carbon-estimation.service.ts b/src/app/services/carbon-estimation.service.ts index b5c4ee1e..b68804e8 100644 --- a/src/app/services/carbon-estimation.service.ts +++ b/src/app/services/carbon-estimation.service.ts @@ -62,7 +62,7 @@ export class CarbonEstimationService { const desktopCount = calculateCeilingPercentage(desktopPercent, headCount); const laptopCount = calculateCeilingPercentage(laptopPercent, headCount); const serverCount = this.estimateServerCount(formValue); - const employeeNetworkCount = estimateNetworkDeviceCount(desktopCount); + const employeeNetworkCount = estimateNetworkDeviceCount(desktopCount + laptopCount); const serverNetworkCount = estimateNetworkDeviceCount(serverCount); const monitorCount = headCount; @@ -75,7 +75,7 @@ export class CarbonEstimationService { return [ createDeviceUsage(desktop, 'user', employeeIntensity, desktopCount), createDeviceUsage(laptop, 'user', employeeIntensity, laptopCount), - createDeviceUsage(network, 'network', employeeIntensity, employeeNetworkCount, ON_PREMISE_AVERAGE_PUE), + createDeviceUsage(network, 'network', employeeIntensity, employeeNetworkCount), createDeviceUsage(server, 'server', onPremIntensity, serverCount, ON_PREMISE_AVERAGE_PUE), createDeviceUsage(network, 'network', onPremIntensity, serverNetworkCount, ON_PREMISE_AVERAGE_PUE), createDeviceUsage(monitor, 'user', employeeIntensity, monitorCount), @@ -107,7 +107,7 @@ function calculateCeilingPercentage(percentage: number, value: number) { } function estimateNetworkDeviceCount(deviceCount: number) { - return Math.ceil(deviceCount / 2); + return Math.ceil(deviceCount / 16); } function formatObject(input: unknown): string { From 057e52f401d65f7bb8bd88e7873068355ebf1936 Mon Sep 17 00:00:00 2001 From: jantoun-scottlogic Date: Fri, 24 May 2024 11:09:52 +0100 Subject: [PATCH 05/11] Update test runner section of docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 39d0a61b..467aa4f1 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Run `ng build` to build the project. The build artifacts will be stored in the ` ## Running unit tests -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). +Run `ng test` to execute the unit tests via [Web Test Runner](https://modern-web.dev/docs/test-runner/overview/). ## GitHub Actions From aa9fd1c7cd1b7e0f1a51e03de16bf44dce178bca Mon Sep 17 00:00:00 2001 From: Matthew Griffin Date: Mon, 3 Jun 2024 14:43:38 +0100 Subject: [PATCH 06/11] Add a new configuration for npm-package build and serve, which will be used when preparing or publishing package --- angular.json | 5 +++++ package.json | 2 +- scripts/publish.sh | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/angular.json b/angular.json index 3672b2d0..f0d9b2f2 100644 --- a/angular.json +++ b/angular.json @@ -40,6 +40,8 @@ ], "baseHref": "/sl-tech-carbon-estimator/" }, + "npm-package": { + }, "development": { "optimization": false, "extractLicenses": false, @@ -54,6 +56,9 @@ "production": { "buildTarget": "tech-carbon-estimator:build:production" }, + "npm-package": { + "buildTarget": "tech-carbon-estimator:build:npm-package" + }, "development": { "buildTarget": "tech-carbon-estimator:build:development" } diff --git a/package.json b/package.json index d8db79d5..7deb94e4 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "scripts": { "ng": "ng", "start": "ng serve", - "prepare": "ng build", + "prepare": "ng build --configuration npm-package", "build": "ng build", "watch": "ng build --watch --configuration development", "test": "ng test", diff --git a/scripts/publish.sh b/scripts/publish.sh index 7a953e78..4d51fdee 100644 --- a/scripts/publish.sh +++ b/scripts/publish.sh @@ -34,7 +34,7 @@ fi rm -rf /dist/tech-carbon-estimator # Build and test -npm run build +npm run prepare npm run test From f85a847aadeff303e73ff16dae72353b3b6a43a6 Mon Sep 17 00:00:00 2001 From: Matthew Griffin Date: Mon, 3 Jun 2024 14:50:32 +0100 Subject: [PATCH 07/11] Add a Scott Logic specific style file that isn't applied when building package Add a note class that can be overridden with brand colours --- angular.json | 4 +++- src/app/note/note.component.html | 3 +-- src/sl-styles.css | 20 ++++++++++++++++++++ src/styles.css | 3 +++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 src/sl-styles.css diff --git a/angular.json b/angular.json index f0d9b2f2..1f02cf64 100644 --- a/angular.json +++ b/angular.json @@ -21,7 +21,7 @@ "polyfills": ["zone.js"], "tsConfig": "tsconfig.app.json", "assets": ["src/favicon.ico"], - "styles": ["src/styles.css"], + "styles": ["src/styles.css", "src/sl-styles.css"], "scripts": [] }, "configurations": { @@ -41,6 +41,8 @@ "baseHref": "/sl-tech-carbon-estimator/" }, "npm-package": { + "assets": [], + "styles": ["src/styles.css"] }, "development": { "optimization": false, diff --git a/src/app/note/note.component.html b/src/app/note/note.component.html index 982b0f1f..b0b3d5dd 100644 --- a/src/app/note/note.component.html +++ b/src/app/note/note.component.html @@ -1,5 +1,4 @@ -

+
info
diff --git a/src/sl-styles.css b/src/sl-styles.css new file mode 100644 index 00000000..d619ba08 --- /dev/null +++ b/src/sl-styles.css @@ -0,0 +1,20 @@ +:root { + --primary-charcoal: #252525; + --primary-turquoise: #2bb3bb; + --primary-pink: #c41565; + --primary-orange: #ef8547; + --secondary-yellow: #f8be4f; + --secondary-green: #7fc45f; + --secondary-turquoise: #dff0f3; + --secondary-pink: #f9eaf1; + --secondary-orange: #fdede4; + --secondary-light-yellow: #fef9ef; + --secondary-light-green: #f2faef; + color: var(--primary-charcoal); +} + +.tce-note { + background-color: var(--secondary-turquoise); + border-color: var(--primary-turquoise); + color: var(--primary-charcoal); +} diff --git a/src/styles.css b/src/styles.css index a90f0749..b4ba8147 100644 --- a/src/styles.css +++ b/src/styles.css @@ -2,3 +2,6 @@ @tailwind components; @tailwind utilities; +.tce-note { + @apply tce-bg-sky-200 tce-border-sky-400 tce-text-slate-800 +} From b5c8181585a6c55a654ba2ae43ed261fef34cbac Mon Sep 17 00:00:00 2001 From: Matthew Griffin Date: Mon, 3 Jun 2024 14:56:27 +0100 Subject: [PATCH 08/11] Style input sliders with SL turquoise --- src/sl-styles.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/sl-styles.css b/src/sl-styles.css index d619ba08..bc9b7cba 100644 --- a/src/sl-styles.css +++ b/src/sl-styles.css @@ -18,3 +18,7 @@ border-color: var(--primary-turquoise); color: var(--primary-charcoal); } + +input { + accent-color: var(--primary-turquoise); +} From b9a46d8f0dc47be693bc44a247278510427ea3d4 Mon Sep 17 00:00:00 2001 From: Matthew Griffin Date: Mon, 3 Jun 2024 15:46:59 +0100 Subject: [PATCH 09/11] Add named classes to buttons and style them with SL method --- .../assumptions-and-limitation.component.html | 2 +- .../carbon-estimator-form.component.html | 9 ++------- .../tech-carbon-estimator.component.html | 2 +- src/sl-styles.css | 11 +++++++++++ src/styles.css | 8 ++++++++ 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/app/assumptions-and-limitation/assumptions-and-limitation.component.html b/src/app/assumptions-and-limitation/assumptions-and-limitation.component.html index 36532f95..5c9bdfc4 100644 --- a/src/app/assumptions-and-limitation/assumptions-and-limitation.component.html +++ b/src/app/assumptions-and-limitation/assumptions-and-limitation.component.html @@ -340,7 +340,7 @@
Managed Services
We currently do not make a distinction between on-premises data centers and those ran by a third party.

- +
Technology Carbon Estimator @if (!showAssumptionsAndLimitationView) { diff --git a/src/sl-styles.css b/src/sl-styles.css index bc9b7cba..6fd541f9 100644 --- a/src/sl-styles.css +++ b/src/sl-styles.css @@ -22,3 +22,14 @@ input { accent-color: var(--primary-turquoise); } + +.tce-button-calculate, .tce-button-reset, .tce-button-assumptions, .tce-button-close { + color: var(--primary-charcoal); + border-color: var(--primary-turquoise); + @apply tce-rounded-none tce-border-b-4 tce-bg-transparent +} + +.tce-button-calculate:hover, .tce-button-reset:hover, .tce-button-assumptions:hover, .tce-button-close:hover { + background-color: var(--primary-turquoise); + @apply tce-text-white +} \ No newline at end of file diff --git a/src/styles.css b/src/styles.css index b4ba8147..eacd2545 100644 --- a/src/styles.css +++ b/src/styles.css @@ -5,3 +5,11 @@ .tce-note { @apply tce-bg-sky-200 tce-border-sky-400 tce-text-slate-800 } + +.tce-button-calculate, .tce-button-close { + @apply tce-bg-sky-800 tce-text-white hover:tce-bg-sky-900 tce-rounded +} + +.tce-button-reset, .tce-button-assumptions { + @apply tce-bg-slate-200 tce-text-slate-800 hover:tce-bg-slate-300 tce-rounded +} \ No newline at end of file From e4e28b92669301b6151dbebbeb9d1eb485b470a4 Mon Sep 17 00:00:00 2001 From: Matthew Griffin Date: Mon, 3 Jun 2024 17:03:58 +0100 Subject: [PATCH 10/11] Update unit test expectations --- src/app/estimation/device-type.spec.ts | 6 ++--- .../carbon-estimation.service.spec.ts | 24 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/app/estimation/device-type.spec.ts b/src/app/estimation/device-type.spec.ts index 76b33574..fed875e0 100644 --- a/src/app/estimation/device-type.spec.ts +++ b/src/app/estimation/device-type.spec.ts @@ -44,11 +44,11 @@ describe('Device type of server', () => { describe('Device type of network', () => { it('Estimates kWh of 1 network device', () => { - expect(network.estimateYearlyEnergy(1)).toBeCloseTo(1314); + expect(network.estimateYearlyEnergy(1)).toBeCloseTo(762.12); }); - it('Estimates kWh of 30 desktops', () => { - expect(network.estimateYearlyEnergy(30)).toBeCloseTo(39420); + it('Estimates kWh of 30 network devices', () => { + expect(network.estimateYearlyEnergy(30)).toBeCloseTo(22863.6); }); it('Estimates upstream emissions of 1 network device', () => { diff --git a/src/app/services/carbon-estimation.service.spec.ts b/src/app/services/carbon-estimation.service.spec.ts index 83cc09ec..c34f34e7 100644 --- a/src/app/services/carbon-estimation.service.spec.ts +++ b/src/app/services/carbon-estimation.service.spec.ts @@ -188,14 +188,14 @@ describe('CarbonEstimationService', () => { const result = service.calculateCarbonEstimation(hardwareInput); expectPartialEstimationCloseTo(result, { upstreamEmissions: { - employee: 5.78, - server: 7.64, - network: 3.43, + employee: 6.53, + server: 8.64, + network: 3.87, }, directEmissions: { - employee: 2.89, - server: 58.37, - network: 21.89, + employee: 3.27, + server: 65.97, + network: 11.72, }, }); }); @@ -217,14 +217,14 @@ describe('CarbonEstimationService', () => { const result = service.calculateCarbonEstimation(hardwareInput); expectPartialEstimationCloseTo(result, { upstreamEmissions: { - employee: 6.21, - server: 8.21, - network: 3.68, + employee: 6.8, + server: 8.99, + network: 4.03, }, directEmissions: { - employee: 1.55, - server: 62.71, - network: 17.64, + employee: 1.7, + server: 68.65, + network: 9.83, }, }); }); From 7836762d269c3048c7cc2a4fc91f74b7a9549f0e Mon Sep 17 00:00:00 2001 From: Matthew Griffin Date: Wed, 5 Jun 2024 16:53:16 +0100 Subject: [PATCH 11/11] Tweak button styling to match Scott Logic site --- src/sl-styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sl-styles.css b/src/sl-styles.css index 6fd541f9..ac757069 100644 --- a/src/sl-styles.css +++ b/src/sl-styles.css @@ -26,7 +26,7 @@ input { .tce-button-calculate, .tce-button-reset, .tce-button-assumptions, .tce-button-close { color: var(--primary-charcoal); border-color: var(--primary-turquoise); - @apply tce-rounded-none tce-border-b-4 tce-bg-transparent + @apply tce-rounded-none tce-border-b-[3px] tce-bg-transparent tce-p-0.5 } .tce-button-calculate:hover, .tce-button-reset:hover, .tce-button-assumptions:hover, .tce-button-close:hover {