From 6286edb0fe9be8966e6f298f7073516c0c2eb981 Mon Sep 17 00:00:00 2001 From: Adrian Pavel Date: Thu, 28 Jul 2022 21:29:33 +0200 Subject: [PATCH] removed useless tests_qa --- .gitignore | 2 + backend/srcs/server.py | 3 + extension/OLDindex.js | 378 --------------------- extension/index.js | 8 +- extension/manifest-firefox.json | 21 ++ extension/tests_qa/.white_nova.feature.swp | Bin 12288 -> 0 bytes extension/tests_qa/white_nova.feature | 15 - 7 files changed, 30 insertions(+), 397 deletions(-) delete mode 100644 extension/OLDindex.js create mode 100644 extension/manifest-firefox.json delete mode 100644 extension/tests_qa/.white_nova.feature.swp delete mode 100644 extension/tests_qa/white_nova.feature diff --git a/.gitignore b/.gitignore index 1e22fc7..59a96ba 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ config.yml venv __pycache__ +white-nova-chrome* +white-nova-firefox diff --git a/backend/srcs/server.py b/backend/srcs/server.py index 6c8df73..f8e580f 100644 --- a/backend/srcs/server.py +++ b/backend/srcs/server.py @@ -49,6 +49,9 @@ def index(): except: return jsonify({"ok": 0, "message": "Error"}) + print(date_range['end'].timestamp()) + print(pendulum.now().timestamp()) + payload = { "hours": time['hours'], "minutes": time['minutes'], diff --git a/extension/OLDindex.js b/extension/OLDindex.js deleted file mode 100644 index 584e2e2..0000000 --- a/extension/OLDindex.js +++ /dev/null @@ -1,378 +0,0 @@ - -function get_user_login() { - return document.getElementsByClassName("login")[0].dataset.login; -} - -function remove_element_content(element) { - element.innerHTML = " "; -} - -function create_title_element(days) { - let title_element = document.createElement("div"); - title_element.style.fontSize = "31px"; - title_element.style.textAlign = "center"; - title_element.style.marginBottom = "11px" - title_element.innerHTML = days + " days until next cycle"; - - return title_element; -} - -function create_hours_element(hours, minutes, real_percent) { - let hours_element = document.createElement("div"); - hours_element.innerHTML = hours + " hrs " + minutes + " mins - " + real_percent + "%"; - hours_element.style.position = "absolute"; - hours_element.style.width = "100%"; - hours_element.style.height = "100%"; - hours_element.style.textAlign = "center"; - hours_element.style.lineHeight = 2; - - return hours_element; -} - -function create_progress_bar_container_element() { - let progress_bar_container = document.createElement('div'); - progress_bar_container.style.width = "100%"; - progress_bar_container.style.height = "35px"; - progress_bar_container.style.backgroundColor = "black"; - progress_bar_container.style.borderRadius = "5px"; - progress_bar_container.style.position = "relative"; - progress_bar_container.style.display = "none"; - - return progress_bar_container; -} - -function create_progress_bar_element(percent, coalition_color) { - let progress_bar = document.createElement('div'); - progress_bar.style.width = percent + "%"; - progress_bar.style.height = "35px"; - progress_bar.style.backgroundColor = coalition_color; - progress_bar.style.borderRadius = "5px 0 0 5px"; - - return progress_bar; -} - -function get_coalition_color() { - return document.getElementsByClassName("progress-bar")[0].style.backgroundColor; -} - -function create_clock_icon() { - let clock_icon = document.createElement('div'); - clock_icon.style.cursor = "pointer"; - - clock_icon.innerHTML = ' '; - - return clock_icon; -} - -function create_evaluations_icon() { - let evaluations_icon = document.createElement('div'); - evaluations_icon.style.cursor = "pointer"; - - evaluations_icon.innerHTML = ''; - - return evaluations_icon; -} - -function create_events_icon() { - let events_icon = document.createElement('div'); - events_icon.style.cursor = "pointer"; - - events_icon.innerHTML = ''; - - return events_icon; -} - -function create_icons_container() { - let icons_container = document.createElement('div'); - icons_container.style.display = "flex"; - icons_container.style.justifyContent = "space-between"; - icons_container.style.width = "50%"; - icons_container.style.margin = "0 auto 11px auto"; - - - return icons_container; -} - -function create_blackhole_switch_icon() { - let switch_icon = document.createElement('div'); - switch_icon.style.position = "absolute"; - switch_icon.style.top = "10px"; - switch_icon.style.left = "10px"; - switch_icon.style.cursor = "pointer"; - - //switch_icon.innerHTML = ''; - switch_icon.innerHTML = ''; - return switch_icon; -} - -function create_white_nova_switch_icon() { - let switch_icon = document.createElement('div'); - switch_icon.style.position = "absolute"; - switch_icon.style.top = "10px"; - switch_icon.style.left = "10px"; - switch_icon.style.cursor = "pointer"; - - switch_icon.innerHTML = ''; - return switch_icon; -} - -function create_evaluations_element(evaluations, total) { - let element = document.createElement('div'); - - element.innerHTML = evaluations + "/"+ total + " evaluations"; - element.style.position = "absolute"; - element.style.width = "100%"; - element.style.height = "100%"; - element.style.textAlign = "center"; - element.style.lineHeight = 2; - return element; -} - -let layer = 0; - -function create_events_element(events, total) { - let element = document.createElement('div'); - - element.innerHTML = events + "/"+ total + " events"; - element.style.position = "absolute"; - element.style.width = "100%"; - element.style.height = "100%"; - element.style.textAlign = "center"; - element.style.lineHeight = 2; - return element; -} - -async function main() { - - let blackhole_container = document.getElementById("goals_container"); - blackhole_container.style.position = "relative"; - - let blackhole_date = document.getElementById("blackhole-date"); - blackhole_date.style.display = "none"; - - let loading_text = document.createElement("div"); - loading_text.innerHTML = "loading white nova..."; - - blackhole_container.append(loading_text); - - let user_login = get_user_login(); - - let response = await fetch("https://intranet-white-nova-kesbd7iw5q-ew.a.run.app?login=" + user_login, { - method: "GET", - }); - - let payload = await response.json(); - if (payload.ok == 0) - return; - - let percent = payload.raw_hours * 100 / 12; - let evaluations_icon = create_evaluations_icon(); - let events_icon = create_events_icon(); - let clock_icon = create_clock_icon(); - - clock_icon.style.margin = "0 4px"; - events_icon.style.margin = "0 4px"; - evaluations_icon.style.margin = "0 4px"; - - clock_icon.style.opacity = "0.4"; - events_icon.style.opacity = "0.4"; - evaluations_icon.style.opacity = "0.4"; - - loading_text.style.display = "none"; - - title_element = create_title_element(payload.next_cycle); - - icons_container = create_icons_container(); - - - icons_container.append(clock_icon); - icons_container.append(evaluations_icon); - icons_container.append(events_icon); - - let switch_icon = document.createElement('div'); - - let blackhole_switch_icon = create_blackhole_switch_icon(); - let white_nova_switch_icon = create_white_nova_switch_icon(); - - blackhole_switch_icon.style.display = "none"; - - switch_icon.append(blackhole_switch_icon); - switch_icon.append(white_nova_switch_icon); - - let white_nova_container = document.createElement("div"); - white_nova_container.style.width = "80%"; - - blackhole_container.append(switch_icon); - white_nova_container.append(title_element); - white_nova_container.append(icons_container); - - blackhole_container.append(white_nova_container); - - let real_percent = Math.floor(percent); - - if (percent >= 100) - percent = 100; - - let hours_element = create_hours_element(payload.hours, payload.minutes, real_percent); - let evaluations_element = create_evaluations_element(payload.evaluations, 2); - let events_element = create_events_element(payload.events, 2); - let coalition_color = get_coalition_color(); - - let white_nova_progress_bar_container = create_progress_bar_container_element(); - white_nova_progress_bar_container.style.display = "block"; - white_nova_progress_bar_container.style.textAlign = "center"; - white_nova_progress_bar_container.innerHTML = "White Nova"; - - let hours_progress_bar_container = create_progress_bar_container_element(); - - let evaluations_progress_bar_container = create_progress_bar_container_element(); - - let events_progress_bar_container = create_progress_bar_container_element(); - - let active_bar = 0; - - let hours_progress_bar = create_progress_bar_element(percent, coalition_color); - hours_progress_bar_container.append(hours_element); - hours_progress_bar_container.append(hours_progress_bar); - - let evaluation_percent = payload.evaluations / 2 * 100; - if (evaluation_percent > 100) - evaluation_percent = 100; - let evaluations_progress_bar = create_progress_bar_element(evaluation_percent, coalition_color); - evaluations_progress_bar_container.append(evaluations_element); - evaluations_progress_bar_container.append(evaluations_progress_bar); - - - let events_percent = payload.events / 2 * 100; - if (events_percent > 100) - events_percent = 100; - let events_progress_bar = create_progress_bar_element(events_percent, coalition_color); - events_progress_bar_container.append(events_element); - events_progress_bar_container.append(events_progress_bar); - - if (events_percent == 100) - events_progress_bar.style.borderRadius = "5px"; - - if (percent == 100) - hours_progress_bar.style.borderRadius = "5px"; - - if (evaluation_percent == 100) - events_progress_bar.style.borderRadius = "5px"; - - if (events_percent == 100 || percent == 100 || evaluation_percent == 100) { - white_nova_progress_bar_container.style.backgroundColor = coalition_color; - white_nova_progress_bar_container.innerHTML = "White Nova "; - } - - white_nova_container.append(white_nova_progress_bar_container); - white_nova_container.append(hours_progress_bar_container); - white_nova_container.append(evaluations_progress_bar_container); - white_nova_container.append(events_progress_bar_container); - - if (percent == 100) - clock_icon.style.opacity = "1"; - - if (events_percent == 100) - events_icon.style.opacity = "1"; - - if (evaluation_percent == 100) - evaluations_icon.style.opacity = "1"; - - - - function disable_highlight() { - clock_icon.style.margin = "0 4px"; - if (percent < 100) - clock_icon.style.opacity = "0.4"; - - if (evaluation_percent < 100) - evaluations_icon.style.opacity = "0.4"; - - if (events_percent < 100) - events_icon.style.opacity = "0.4"; - - events_icon.style.color = "white"; - evaluations_icon.style.color = "white"; - clock_icon.style.color = "white"; - } - - clock_button = 0; - evaluations_button = 0; - events_button = 0; - - function nisu() { - disable_highlight(); - hours_progress_bar_container.style.display = "none"; - white_nova_progress_bar_container.style.display = "block"; - evaluations_progress_bar_container.style.display = "none"; - events_progress_bar_container.style.display = "none"; - - clock_button = 0; - evaluations_button = 0; - events_button = 0; - } - - clock_icon.addEventListener("click", function() { - disable_highlight(); - clock_icon.style.opacity = "1"; - clock_icon.style.color = coalition_color; - hours_progress_bar_container.style.display = "block"; - white_nova_progress_bar_container.style.display = "none"; - evaluations_progress_bar_container.style.display = "none"; - events_progress_bar_container.style.display = "none"; - - if (clock_button == 1) - return nisu(); - - clock_button = 1; - }); - - evaluations_icon.addEventListener("click", function() { - disable_highlight(); - evaluations_icon.style.opacity = "1"; - evaluations_icon.style.color = coalition_color; - hours_progress_bar_container.style.display = "none"; - white_nova_progress_bar_container.style.display = "none"; - evaluations_progress_bar_container.style.display = "block"; - events_progress_bar_container.style.display = "none"; - - if (evaluations_button == 1) - return nisu(); - - evaluations_button = 1; - }); - - events_icon.addEventListener("click", function() { - disable_highlight(); - events_icon.style.opacity = "1"; - events_icon.style.color = coalition_color; - hours_progress_bar_container.style.display = "none"; - white_nova_progress_bar_container.style.display = "none"; - evaluations_progress_bar_container.style.display = "none"; - events_progress_bar_container.style.display = "block"; - - if (events_button == 1) - return nisu(); - - events_button = 1; - }); - - switch_icon.addEventListener("click", function() { - if (layer == 0) { - layer = 1; - white_nova_container.style.display = "none"; - blackhole_date.style.display = "block"; - white_nova_switch_icon.style.display = "none"; - blackhole_switch_icon.style.display = "block"; - } else { - layer = 0; - white_nova_container.style.display = "block"; - blackhole_date.style.display = "none"; - white_nova_switch_icon.style.display = "block"; - blackhole_switch_icon.style.display = "none"; - } - }); -} - -main(); - diff --git a/extension/index.js b/extension/index.js index fddadf0..83f2724 100644 --- a/extension/index.js +++ b/extension/index.js @@ -55,7 +55,7 @@ class ProgressBar { set text(value) { this.text_ = value; - this.progress_bar_text_.innerHTML = this.text_; + this.progress_bar_text_.setHTML(this.text_); } } @@ -77,7 +77,7 @@ class Application { } async init() { - const HTML_file = await fetch(chrome.runtime.getURL("layout.html")); + const HTML_file = await fetch(browser.runtime.getURL("layout.html")); const HTML_text = await HTML_file.text(); const goals_container = document.getElementById("goals_container"); @@ -85,7 +85,7 @@ class Application { this.getCoalitionColor(); await this.getLoginData(); - goals_container.innerHTML = goals_container.innerHTML + HTML_text; + goals_container.setHTML(goals_container.innerHTML + HTML_text); goals_container.style.position = "relative"; //switch button @@ -105,7 +105,7 @@ class Application { this.progress_bar = new ProgressBar(progress_bar_container, 50, "White Nova", this.coalition_color); const contdown_text = document.getElementById('countdown-text'); - contdown_text.innerHTML = this.days_left + " days left until next cycle"; + contdown_text.setHTML(this.days_left + " days left until next cycle"); this.getPanelButtons(); this.addButtonsEvents(); diff --git a/extension/manifest-firefox.json b/extension/manifest-firefox.json new file mode 100644 index 0000000..d83aaac --- /dev/null +++ b/extension/manifest-firefox.json @@ -0,0 +1,21 @@ +{ + "name": "Intra42Nova", + "description": "", + "author": "apavel ycarro alvrodri", + "version": "1.0", + "manifest_version": 2, + "web_accessible_resources":[ + "layout.html" + ], + "permissions": [ + "*://intranet-white-nova-kesbd7iw5q-ew.a.run.app/*" + ], + "content_scripts": [{ + "run_at": "document_end", + "js": ["index.js"], + "matches": [ + "https://profile.intra.42.fr/*" + ], + "css" : ["style.css"] + }] +} diff --git a/extension/tests_qa/.white_nova.feature.swp b/extension/tests_qa/.white_nova.feature.swp deleted file mode 100644 index 633a65bd4d0f183decd25ccff0be2b937c6012c0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 12288 zcmeI&L5mYH6ae7VTVYp4|G+ce+uAOR^rkB-dr%kFbwLj$&AfJEXOfy^y68a<{sRAo z;8jrngMYxAAovqJ`evrpvW|l6sqhBg%(Q(;UcO8Zr5X1g9o&PPot~iMvJmfD@5lM~ z$Kvw~A=F$gFe^X!_n`-V5OzB|{ahv9BpvPY#s)9z4!d_S%%YojBZe48&s6s`H4#VF zEmUWMDi$6a+w+?&zyjwH*cOBSjq0m@U0#E$SB}rq8MkEt7GMDuU;!3j0Ty5Z7T7R> zIB$tpRP%*p-Itcv)|u<_C0|&81z3OuSbzmsfCX591z3OuSbzmKP(UR@eBBaaxJ|{= z|NpDs|KI551H~H(r07xnxG2OYijNdeD0V5fD85kJw-m1_s(v=mflFoq7GMDuU;!3j z0Ty5Z7GQy9fp&E~OwocoDK{_Qr@hO2E}v%@F&Q0tH}x38ZRI6khB?{@sS2P#jx(ia z62^3%dRN#)wA;6A0>=S8=*;L@07u>K^!ExMia@DFjLuTpNjcuxygKWMM$yqYD+&F`2suV?bbyKTAX7&}$@K;%fU#AgJTyTYi>qqpYKoM3*DO}WEGM?i zlc2Pwc}3Aa(rA@8ZV3D3D8CX4nrir8xXNvvjf$uifKD(mK17h^4)O=%r=`RKB}6p_ zshy3)FM+0%m@v=Ob4*};u1oZCMN0Wn=db-Ww4)}9dY(+sm&@Ex1T|_}I(iuXESPfF zXxEk@SH>RL=#_+e34ZI=kA$+IQ)Q=E&7gh?Xr_c9_UldcL#UorC`X0dB}InfCnb9y A?EnA( diff --git a/extension/tests_qa/white_nova.feature b/extension/tests_qa/white_nova.feature deleted file mode 100644 index 9cc11ee..0000000 --- a/extension/tests_qa/white_nova.feature +++ /dev/null @@ -1,15 +0,0 @@ -Feature: White nova module - Scenario: User can change the selected tab - Given User is in the "mainIntra" page - When User clicks on a "novaObjective" tab - And User clicks on a different "novaObjective" tab - And User clicks back on the first "novaObjective" tab - Then The first "novaObjective" tab "content" is displayed - - Scenario: For "Piscine" users "WhiteNovaCompleted_ProgressBar" element has a black background - Given User has a "Piscine" account - And User is in the "PiscineCursus" page - And User has completed the metrics for "hours" - When User clicks on "CursusSelection" selector - And User clicks on "42Cursus" button - Then "WhiteNovaCompleted_ProgressBar" element has a "black" background