From 8bb068499b8d978f77f9406988eb84c68f67e8d2 Mon Sep 17 00:00:00 2001 From: Andre Henriques Date: Sun, 29 Sep 2024 11:45:53 +0100 Subject: [PATCH] chore: update to ext and cv page --- extensions/background-script.js | 36 ++++++++-- extensions/definitions.js | 17 +++-- site/src/routes/cv/+page.svelte | 88 +++++++++++++---------- site/src/routes/work-area/WorkArea.svelte | 40 ++++++++++- 4 files changed, 132 insertions(+), 49 deletions(-) diff --git a/extensions/background-script.js b/extensions/background-script.js index bd780cd..3376100 100644 --- a/extensions/background-script.js +++ b/extensions/background-script.js @@ -3,6 +3,33 @@ });*/ browser.runtime.onMessage.addListener(async (message, sender, sendResponse) => { + if (message.type === "REGISTER_INTEREST") { + let interestList = + (await browser.storage.local.get("interesetWindows")) + .interesetWindows ?? []; + // Already has interest! + if (interestList.includes(sender.tab.id)) { + return; + } + interestList.push(sender.tab.id); + + await browser.storage.local.set({ + interesetWindows: interestList, + }); + + return; + } + if (message.type === "GOT_INFO_R") { + // TODO then send this information back to that page + let interestList = + (await browser.storage.local.get("interesetWindows")) + .interesetWindows ?? []; + + interestList.forEach((a) => { + browser.tabs.sendMessage(a, message); + }); + return; + } if (message.type !== "MY_GET_URL") return; let windowList = (await browser.storage.local.get("windows")).windows ?? []; @@ -28,11 +55,10 @@ browser.runtime.onMessage.addListener(async (message, sender, sendResponse) => { }); }); -browser.runtime.onInstalled.addListener(async () => { - console.log(browser); - +async function startup() { await browser.storage.local.set({ windows: [], + interesetWindows: [], }); // Clear the menus from the prev install @@ -70,4 +96,6 @@ browser.runtime.onInstalled.addListener(async () => { windows: windowList, }); }); -}); +} + +browser.runtime.onInstalled.addListener(startup); diff --git a/extensions/definitions.js b/extensions/definitions.js index f2b1d04..adb5589 100644 --- a/extensions/definitions.js +++ b/extensions/definitions.js @@ -1,6 +1,16 @@ browser.runtime.onMessage.addListener(function (message) { if (message.type === "MY_GET_URL_R") { window.postMessage(message); + } else if (message.type === "GET_DATA_FROM_PAGE") { + let company = document + .querySelector('header[data-test="job-details-header"]') + .children[0].children[0].querySelector("h4").innerHTML; + let jobTitle = document + .querySelector('header[data-test="job-details-header"]') + .querySelector("h1").innerHTML; + browser.runtime.sendMessage({ type: "GOT_INFO_R", company, jobTitle }); + } else if (message.type === "GOT_INFO_R") { + window.postMessage(message); } }); @@ -10,10 +20,7 @@ window.addEventListener("message", function (e) { } else if (e.data.type === "HAS_EXTENSION_Q") { console.log("Got request for ext"); window.postMessage({ type: "HAS_EXTENSION" }); - } else if (e.data.type === "GET_DATA_FROM_PAGE") { - console.log( - document.querySelector('header[data-test="job-details-header"]'), - ); + } else if (e.data.type === "REGISTER_INTEREST") { + browser.runtime.sendMessage({ type: "REGISTER_INTEREST" }); } - //console.log("here2", e); }); diff --git a/site/src/routes/cv/+page.svelte b/site/src/routes/cv/+page.svelte index f2fb31a..75e50f6 100644 --- a/site/src/routes/cv/+page.svelte +++ b/site/src/routes/cv/+page.svelte @@ -22,30 +22,38 @@
-
-

Andre Henriques

-
-
- +
+
+

Andre Henriques

+
+
-
-
-
-
- I am a dedicated and versatile programmer with for year of professional experience.
- During those years mainly worked with Typescript, JavaScript, React, Svelte.
- I thrive in high paced new environments, and I am always striving to learn new skills and technologies. -
- I also am knowable in various other technologies and am always learning new ones.
+
+
+
+ I am a dedicated and versatile programmer with four years of professional + experience.
+ During those years mainly worked with Typescript, JavaScript, React, Svelte. +
+ I thrive in high paced new environments, and I am always striving to learn new skills + and technologies. +
+ I also am knowable in various other technologies and am always learning new ones. +
+
{#if application} @@ -53,11 +61,11 @@
TODO: Application Information
{/if}
-
-

Work Expericence

+
+

Work Expericence

-

Planum Solucoes, Lda

+

Senior Software Developer @ Planum Solucoes

4 year - May 2020 - Present

Working with:

@@ -72,19 +80,20 @@
  • Developed web-based tools for the DevOps team to use
  • - Updated Jenkins pipelines that the team uses to manage one of the most important - pipelines that the team manages. + Updated Jenkins pipelines that the team uses to manage one of the + most important pipelines that the team manages.
  • - Created new scripts that were used to clean up multiple terabytes of unused data - that led to improvements in the performance of the other scripts running on the same - server as well as the performance of the backup system + Created new scripts that were used to clean up multiple terabytes of + unused data that led to improvements in the performance of the other + scripts running on the same server as well as the performance of the + backup system
-

Sky UK

+

Associate Devops Engineer @ Sky UK

1 year - July 2022 - June 2023

Working with:

@@ -99,13 +108,14 @@
  • Developed web-based tools for the DevOps team to use
  • - Updated Jenkins pipelines that the team uses to manage one of the most important - pipelines that the team manages. + Updated Jenkins pipelines that the team uses to manage one of the + most important pipelines that the team manages.
  • - Created new scripts that were used to clean up multiple terabytes of unused data - that led to improvements in the performance of the other scripts running on the same - server as well as the performance of the backup system + Created new scripts that were used to clean up multiple terabytes of + unused data that led to improvements in the performance of the other + scripts running on the same server as well as the performance of the + backup system
@@ -113,8 +123,8 @@
-
-

Education

+
+

Education

University of Surrey

diff --git a/site/src/routes/work-area/WorkArea.svelte b/site/src/routes/work-area/WorkArea.svelte index 835d5d9..e021006 100644 --- a/site/src/routes/work-area/WorkArea.svelte +++ b/site/src/routes/work-area/WorkArea.svelte @@ -20,6 +20,8 @@ let preparingToDrop = $state(false); + let lastExtData: any = $state(undefined); + async function activate(item?: Application) { if (!item) { return; @@ -58,6 +60,8 @@ console.log('info data', e); } applicationStore.loadApplications(true); + + lastExtData = undefined; } function openWindow(url: string) { @@ -84,6 +88,32 @@ } } + // Load Ext + $effect(() => { + function onMessage(e: MessageEvent) { + if (e.data.type === 'GOT_INFO_R') { + lastExtData = e.data; + } + } + + console.log('setting up interest'); + + window.addEventListener('message', onMessage); + window.postMessage({ type: 'REGISTER_INTEREST' }); + return () => { + window.removeEventListener('message', onMessage); + }; + }); + + function setExtData() { + if (!lastExtData || !activeItem) return; + activeItem.title = `${lastExtData.company} - ${lastExtData.jobTitle}`; + window.requestAnimationFrame(() => { + save(); + lastExtData = undefined; + }); + } + onMount(() => { userStore.checkLogin(); loadActive(); @@ -103,6 +133,7 @@ return; } applicationStore.loadApplications(true); + applicationStore.loadAplyed(true); activeItem = undefined; //openedWindow?.close(); //openedWindow = undefined; @@ -240,6 +271,9 @@ + {#if lastExtData !== undefined} + + {/if} {#if activeItem.original_url == null} {/if} @@ -275,7 +309,11 @@ ondragover={preventDefault(() => {})} ondragenter={preventDefault(() => {})} ondrop={() => { - moveStatus(ApplicationStatus.Expired); + if (activeItem && activeItem.status === ApplicationStatus.Expired) { + moveStatus(ApplicationStatus.ToApply); + } else { + moveStatus(ApplicationStatus.Expired); + } }} >