Skip to content

Commit

Permalink
Correction check url (#90)
Browse files Browse the repository at this point in the history
* Show simulation in table

* Change message no token

* Update DataCarbon

* WIP: check all servers

* Revert "WIP: check all servers"

This reverts commit 286654c.

* Integrate optional Call ApiCo2Signal (#82)

* Show simulation in table (#77)

* Change message token Co2Signal (#78)

* Show simulation in table

* Change message no token

* Integrate optional Call ApiCo2Signal

* Add cache for intensity and location

* Feature #80 results per servers localisation (#83)

* Data reception and sorting ok

* WIP insert new card

* WIP insert new card

* WIP insert new card

* WIP insert new card

* Style

* Messages

* #80 : review html markup, only show resources names

* Change bottom message for show/hide urls

* Move buttom

---------

Co-authored-by: OlivierCamon <[email protected]>

* Css Change

* nitpick : removed duplicated code (#84)

* Feature #79 compute average carbon intensity of server requests by location (#85)

* Change model of calcul

* Change model of calcul

* #86 new cards summarize data (#87)

* Update next version

* Reorganisation .svelte

* Add summary cards

* Clean old code

Co-authored-by: OlivierCamon <[email protected]>

* Clean old code

Co-authored-by: OlivierCamon <[email protected]>

---------

Co-authored-by: OlivierCamon <[email protected]>

* Change summary title

* Add runner idea

* Refresh icon received action

* Correction for site without www

* Update version

---------

Co-authored-by: boukhalfa.zahout <[email protected]>
Co-authored-by: OlivierCamon <[email protected]>
Co-authored-by: OlivierCamon <[email protected]>
  • Loading branch information
4 people authored Jul 15, 2024
1 parent af7918b commit d02c03b
Show file tree
Hide file tree
Showing 8 changed files with 187 additions and 14 deletions.
41 changes: 41 additions & 0 deletions .run/build.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="build" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="build" />
</scripts>
<node-interpreter value="project" />
<envs />
<EXTENSION ID="NodeDockerRunConfigurationExtension">
<option name="envVars">
<list />
</option>
<option name="extraHosts">
<list />
</option>
<option name="links">
<list />
</option>
<option name="networkDisabled" value="false" />
<option name="networkMode" value="bridge" />
<option name="portBindings">
<list />
</option>
<option name="publishAllPorts" value="false" />
<option name="runCliOptions" value="--entrypoint= --rm --user=1000" />
<option name="version" value="2" />
<option name="volumeBindings">
<list>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/opt/project" />
<option name="editable" value="true" />
<option name="hostPath" value="$PROJECT_DIR$" />
<option name="readOnly" value="false" />
</DockerVolumeBindingImpl>
</list>
</option>
</EXTENSION>
<method v="2" />
</configuration>
</component>
41 changes: 41 additions & 0 deletions .run/check.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="check" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="check" />
</scripts>
<node-interpreter value="project" />
<envs />
<EXTENSION ID="NodeDockerRunConfigurationExtension">
<option name="envVars">
<list />
</option>
<option name="extraHosts">
<list />
</option>
<option name="links">
<list />
</option>
<option name="networkDisabled" value="false" />
<option name="networkMode" value="bridge" />
<option name="portBindings">
<list />
</option>
<option name="publishAllPorts" value="false" />
<option name="runCliOptions" value="--entrypoint= --rm --user=1000" />
<option name="version" value="2" />
<option name="volumeBindings">
<list>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/opt/project" />
<option name="editable" value="true" />
<option name="hostPath" value="$PROJECT_DIR$" />
<option name="readOnly" value="false" />
</DockerVolumeBindingImpl>
</list>
</option>
</EXTENSION>
<method v="2" />
</configuration>
</component>
48 changes: 48 additions & 0 deletions .run/dev.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="dev" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="dev" />
</scripts>
<node-interpreter value="project" />
<envs />
<EXTENSION ID="NodeDockerRunConfigurationExtension">
<option name="envVars">
<list />
</option>
<option name="extraHosts">
<list />
</option>
<option name="links">
<list />
</option>
<option name="networkDisabled" value="false" />
<option name="networkMode" value="bridge" />
<option name="portBindings">
<list>
<DockerPortBindingImpl>
<option name="containerPort" value="5173" />
<option name="hostIp" value="0.0.0.0" />
<option name="hostPort" value="5173" />
<option name="protocol" value="tcp" />
</DockerPortBindingImpl>
</list>
</option>
<option name="publishAllPorts" value="false" />
<option name="runCliOptions" value="--entrypoint= --rm --user=1000" />
<option name="version" value="2" />
<option name="volumeBindings">
<list>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/opt/project" />
<option name="editable" value="true" />
<option name="hostPath" value="$PROJECT_DIR$" />
<option name="readOnly" value="false" />
</DockerVolumeBindingImpl>
</list>
</option>
</EXTENSION>
<method v="2" />
</configuration>
</component>
38 changes: 38 additions & 0 deletions .run/install.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="install" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="install" />
<node-interpreter value="project" />
<envs />
<EXTENSION ID="NodeDockerRunConfigurationExtension">
<option name="envVars">
<list />
</option>
<option name="extraHosts">
<list />
</option>
<option name="links">
<list />
</option>
<option name="networkDisabled" value="false" />
<option name="networkMode" value="bridge" />
<option name="portBindings">
<list />
</option>
<option name="publishAllPorts" value="false" />
<option name="runCliOptions" value="--entrypoint= --rm --user=1000" />
<option name="version" value="2" />
<option name="volumeBindings">
<list>
<DockerVolumeBindingImpl>
<option name="containerPath" value="/opt/project" />
<option name="editable" value="true" />
<option name="hostPath" value="$PROJECT_DIR$" />
<option name="readOnly" value="false" />
</DockerVolumeBindingImpl>
</list>
</option>
</EXTENSION>
<method v="2" />
</configuration>
</component>
4 changes: 2 additions & 2 deletions extension/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "GreenTrackR",
"description": "__MSG_extDesc__",
"version": "2.2.0",
"version": "2.2.1",
"icons": {
"64": "images/logo.png"
},
Expand Down Expand Up @@ -33,7 +33,7 @@
"devtools_page": "extension/devtools-page.html",
"action": {
"default_icon": "images/logo.png",
"default_title": "GreenTrackr",
"default_title": "GreenTrackR",
"default_popup": "extension/menu.html"
},
"content_security_policy": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "greenTrackR",
"private": true,
"version": "2.2.0",
"version": "2.2.1",
"type": "module",
"scripts": {
"dev": "vite --host=0.0.0.0",
Expand Down
11 changes: 6 additions & 5 deletions src/api/zones.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ const getIpAddress = async (): Promise<string | undefined> => {
return ip ? ip : undefined;
};

export const getCurrentZone = async (url?: string): Promise<DetailedGeoLoc | undefined> => {
export const getCurrentZone = async (url?: URL | string): Promise<DetailedGeoLoc | undefined> => {
logDebug(`Url ${url}`);
const origin = url ? url : await getIpAddress();
const origin: string | URL | undefined = url ? url : await getIpAddress();
logDebug(`Origin ${origin}`);
if (!origin) {
return undefined;
}
const { lat, lon, countryCode, country, city } = await fetch(
IP_API + origin)
const apiCall = IP_API + (origin instanceof URL ? origin.host : origin);
logDebug('Call URL for location: ' + apiCall);
const { lat, lon, countryCode, country, city } = await fetch(apiCall)
.then((res) => res.json())
.catch(reason => logErr('Error getting current zone: ' + reason));
return city ? { cityName: city, countryCode, countryName: country, lat, lon } : undefined;
};

export const getServerZone = (urlHost?: URL): Promise<DetailedGeoLoc | undefined> => {
return getCurrentZone(urlHost ? urlHost.host.replace(/^www\./, '') : urlHost); // Remove www.
return getCurrentZone(urlHost);
};
16 changes: 10 additions & 6 deletions src/pages/Parcours.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
};
const onActionSave = async (component?: string) => {
document.getElementsByClassName("received")[0].style = '';
logDebug('Save ' + component);
await measureAcquisition.getNetworkMeasure(false);
const measure = await measureAcquisition.getGESMeasure(serverSearch, userSearch);
Expand All @@ -65,6 +66,7 @@
if (measure) {
results = [...results, measure];
}
document.getElementsByClassName("received")[0].style = 'display: block';
measureAcquisition.applyLatest();
};
Expand Down Expand Up @@ -101,18 +103,20 @@
<LoadingWheel />
<p class="in-progress-text">{translate('analysisInProgress')}</p>

{#if results.length}
<div class="flex-center">
<CheckIcon />
<p>{translate('receivedResults')}</p>
</div>
{/if}
<div class="flex-center received">
<CheckIcon />
<p>{translate('receivedResults')}</p>
</div>
{/if}
{#if results.length && !onGoingAnalysis}
<JourneyResults measures={results} />
{/if}

<style lang="scss">
div.received {
display: none;
}
.in-progress-text {
text-align: center;
}
Expand Down

0 comments on commit d02c03b

Please sign in to comment.