diff --git a/.github/workflows/build-dev-push-azure.yml b/.github/workflows/build-dev-push-azure.yml index 57219fc2..22355dfa 100644 --- a/.github/workflows/build-dev-push-azure.yml +++ b/.github/workflows/build-dev-push-azure.yml @@ -5,20 +5,23 @@ on: push: branches: - dev + workflow_dispatch: + env: ACCOUNT_NAME: udirdit SOURCE: dist DESTINATION: frontend-dev + AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }} jobs: build: runs-on: ubuntu-latest steps: - name: Check out repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 20 @@ -29,14 +32,14 @@ jobs: run: yarn buildDev - name: Login to Azure - uses: azure/login@v1 + uses: azure/login@v2 with: creds: ${{ secrets.AZURE_CREDENTIALS }} - name: Upload files to Azure Blob - uses: azure/CLI@v1 + uses: azure/CLI@v2 with: - azcliversion: 2.48.1 + azcliversion: 2.34.1 inlineScript: | az storage blob upload-batch --account-name ${{ env.ACCOUNT_NAME }} \ --auth-mode key -s ${{ env.SOURCE }} -d ${{ env.DESTINATION }} --overwrite diff --git a/.github/workflows/build-master-push-azure.yml b/.github/workflows/build-master-push-azure.yml index 1033497e..55b6e260 100644 --- a/.github/workflows/build-master-push-azure.yml +++ b/.github/workflows/build-master-push-azure.yml @@ -5,20 +5,23 @@ on: push: branches: - master + workflow_dispatch: + env: ACCOUNT_NAME: udirdit SOURCE: dist DESTINATION: frontend-master + AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }} jobs: build: runs-on: ubuntu-latest steps: - name: Check out repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup node - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 20 @@ -29,25 +32,25 @@ jobs: run: yarn buildProduction - name: Login to Azure - uses: azure/login@v1 + uses: azure/login@v2 with: - creds: ${{ secrets.AZURE_CREDENTIALS }} + creds: ${{ secrets.AZURE_CREDENTIALS }} - name: Upload files to Azure Blob - uses: azure/CLI@v1 + uses: azure/CLI@v2 with: - azcliversion: 2.48.1 + azcliversion: 2.34.1 inlineScript: | - az storage blob upload-batch --account-name ${{ env.ACCOUNT_NAME }} \ - --auth-mode key -s ${{ env.SOURCE }} -d ${{ env.DESTINATION }} --overwrite + az storage blob upload-batch --account-name ${{ env.ACCOUNT_NAME }} \ + --auth-mode key -s ${{ env.SOURCE }} -d ${{ env.DESTINATION }} --overwrite - az storage blob list --account-name ${{ env.ACCOUNT_NAME }} --container-name ${{ env.DESTINATION }} --query "[?ends_with(name, '.woff')].{Name:name}" --output tsv | \ - xargs -I {} az storage blob update --account-name ${{ env.ACCOUNT_NAME }} --container-name ${{ env.DESTINATION }} --name {} --content-type "application/font-woff" + az storage blob list --account-name ${{ env.ACCOUNT_NAME }} --container-name ${{ env.DESTINATION }} --query "[?ends_with(name, '.woff')].{Name:name}" --output tsv | \ + xargs -I {} az storage blob update --account-name ${{ env.ACCOUNT_NAME }} --container-name ${{ env.DESTINATION }} --name {} --content-type "application/font-woff" - az storage blob list --account-name ${{ env.ACCOUNT_NAME }} --container-name ${{ env.DESTINATION }} --query "[?ends_with(name, '.woff2')].{Name:name}" --output tsv | \ - xargs -I {} az storage blob update --account-name ${{ env.ACCOUNT_NAME }} --container-name ${{ env.DESTINATION }} --name {} --content-type "font/woff2" + az storage blob list --account-name ${{ env.ACCOUNT_NAME }} --container-name ${{ env.DESTINATION }} --query "[?ends_with(name, '.woff2')].{Name:name}" --output tsv | \ + xargs -I {} az storage blob update --account-name ${{ env.ACCOUNT_NAME }} --container-name ${{ env.DESTINATION }} --name {} --content-type "font/woff2" # Azure logout - Force step to always run with 'always()', ensures no hanging logins - name: logout if: always() run: | - az logout + az logout diff --git a/src/js/account-theme.js b/src/js/account-theme.js new file mode 100644 index 00000000..7af32321 --- /dev/null +++ b/src/js/account-theme.js @@ -0,0 +1,115 @@ +import LoginDirectLink from '../vue/components/login-choice/LoginDirectLink.vue'; +import { createApp } from 'vue'; +import utilRoot from './utilRoot'; + +var udirDesignLoaded; + + +jQuery.extend({ + getScript: function (url, callback) { + var head = document.getElementsByTagName("head")[0]; + var script = document.createElement("script"); + script.src = url; + + // Handle Script loading + { + var done = false; + + // Attach handlers for all browsers + script.onload = script.onreadystatechange = function () { + if ( + !done && + (!this.readyState || + this.readyState == "loaded" || + this.readyState == "complete") + ) { + done = true; + if (callback) callback(); + + // Handle memory leak in IE + script.onload = script.onreadystatechange = null; + } + }; + } + + head.appendChild(script); + + // We handle everything using the script element injection + return undefined; + }, +}); + +jQuery(document).ready(function ($) { + console.log("START."); + + var redirected = false; + + // Redirect if necessary + if (document.location.pathname == "/search/all_courses" && document.location.search.includes('?enroll_code')) { + window.location.href = '/courses' + document.location.search; + redirected = true; + } else if (document.location.pathname == "/login/canvas") { + if (document.referrer.includes("/logout")) { + window.location.href = '/search/all_courses'; + redirected = true; + } else if (!document.referrer.includes("/login/canvas")) { + $(".ic-Login").hide(); + $("#f1_container").hide(); // Small screens + redirected = utilRoot.redirectFeideAuthIfEnrollReferrer(); + if (!redirected) { + if (!document.location.search.includes("normalLogin=1")) { + document.getElementById('wrapper').remove(); + let parent = document.getElementById('application'); + let login = document.createElement('div'); + login.id = 'login-component'; + let customLogin = createApp(LoginDirectLink); + parent.appendChild(login); + customLogin.mount("#login-component"); + } else { + $(".ic-Login").show(); + $("#f1_container").show(); // Small screens + } + } + } + } else if (document.location.pathname == "/courses") { + redirected = utilRoot.redirectToEnrollIfCodeParamPassed(); + } else if (document.location.href.indexOf('?login_success=1') != -1) { + window.location.href = '/search/all_courses'; + } else if (document.location.pathname == "/") { + setTimeout(function () { + if (!$(".ic-DashboardCard__header_hero").length) { + let html = ` +
+

Er det tomt her?

+

Dersom du har valgt å logge inn med Feide og ikke finner innholdet ditt kan det hende det er fordi du + vanligvis har logget på med en annen bruker ved å bruke epost og passord. Logg ut og inn igjen ved å benytte "Ikke Feide" - knappen. +

+ Ny innloggingsskjerm +
+ `; + document.getElementById('dashboard-activity').insertAdjacentHTML('beforebegin', html); + } + }, 1000) + } + + if (!redirected) { + if (window.udirDesignLoaded === undefined) { + window.udirDesignLoaded = true; + console.log("Loading udir design."); + + var filename = SERVER + DESIGNCSS; + + var fileref = document.createElement("link") + fileref.setAttribute("rel", "stylesheet") + fileref.setAttribute("type", "text/css") + fileref.setAttribute("href", filename) + fileref.onload = (_) => { + $.getScript(SERVER + DESIGNJS); + } + document.getElementsByTagName("head")[0].appendChild(fileref) + } else { + console.log("Udir design already loaded."); + } + } + +}); diff --git a/src/js/main.js b/src/js/main.js index ecbecb42..d3f1d4ae 100755 --- a/src/js/main.js +++ b/src/js/main.js @@ -52,7 +52,7 @@ jQuery(function($) { if (document.location.search === '?mmpf') { mmooc.powerFunctions.show(parentId); } else { - window.location.href = '/courses?design=udir'; + window.location.href = '/courses'; } }); diff --git a/src/js/modules/courselist.js b/src/js/modules/courselist.js index 9811358e..e28cbcde 100755 --- a/src/js/modules/courselist.js +++ b/src/js/modules/courselist.js @@ -23,7 +23,7 @@ export default (function () { var myCoursesWithSettings = util.mapCourseSettings(courses, allCoursesSettings.result); if (courses.length == 0) { - window.location.href = "/search/all_courses?design=udir"; + window.location.href = "/search/all_courses"; } else { diff --git a/src/js/modules/coursepage.js b/src/js/modules/coursepage.js index da13188d..0a76d9d9 100755 --- a/src/js/modules/coursepage.js +++ b/src/js/modules/coursepage.js @@ -19,14 +19,12 @@ export default (function() { showCourseInvitation: function () { if (!util.isAuthenticated()) { var enrollButton = $(".course_enrollment_link"); - var linkToSelectedCourse = window.location.href.split('/'); - var selectedCourseId = linkToSelectedCourse[linkToSelectedCourse.length - 1]; if (enrollButton) { enrollButton.text('Enroll this course'); enrollButton.click(function (e) { e.preventDefault(); - window.location.href = '/search/all_courses' + '?design=udir' + '#' + selectedCourseId; + window.location.href = '/search/all_courses'; }) } } diff --git a/src/js/modules/enroll.js b/src/js/modules/enroll.js index 8c10d94e..286c2a52 100755 --- a/src/js/modules/enroll.js +++ b/src/js/modules/enroll.js @@ -4,7 +4,6 @@ import LoggedInLandingPage from "../../vue/pages/LoggedInLandingPage.vue"; import NotLoggedInPage from "../../vue/pages/NotLoggedInPage.vue"; import api from "../api/api"; import { createApp } from "vue/dist/vue.runtime.esm-bundler.js"; -import { hrefQueryString } from "../settingsRoot"; import kpasApi from "../api/kpas-api"; import settings from "../settings"; import util from "./util"; @@ -60,7 +59,7 @@ export default (function () { if ($this.hasClass('btn-primary')){ var _href = $this.attr("href"); }else { - var _href = $this.attr("href") + hrefQueryString; + var _href = $this.attr("href"); } const urlParamsObj = utilRoot.urlParamsToObject(); diff --git a/src/js/modules/util.js b/src/js/modules/util.js index 1aed9ee2..b9c05390 100755 --- a/src/js/modules/util.js +++ b/src/js/modules/util.js @@ -1,5 +1,3 @@ -import { hrefAmpQueryString, hrefQueryString } from "../settingsRoot"; - import api from '../api/api.js' import settings from "../settings"; @@ -477,7 +475,7 @@ export default (function () { $this.remove(); } else{ - $this.attr("href", _href + hrefAmpQueryString); + $this.attr("href", _href); } }); }, @@ -488,7 +486,7 @@ export default (function () { }); }, getLinkToAvailableCourses: function () { - var linkToAvailableCourses = "/search/all_courses" + hrefQueryString; + var linkToAvailableCourses = "/search/all_courses"; //ETH20190409 By making sure the root account loads our design, we do not need a front page. /* if (allCoursesFrontpageCourseID > 0) { diff --git a/src/js/rootaccount.js b/src/js/rootaccount.js deleted file mode 100644 index 73e3cb5f..00000000 --- a/src/js/rootaccount.js +++ /dev/null @@ -1,123 +0,0 @@ -import LoginDirectLink from '../vue/components/login-choice/LoginDirectLink.vue'; -import { createApp } from 'vue'; -import { hrefQueryString } from './settingsRoot'; -import utilRoot from './utilRoot'; - -// Replace the normal jQuery getScript function with one that supports -// debugging and which references the script files as external resources -// rather than inline. -var self = this; -var udirDesignLoaded; -function getScript(url, callback) { - var head = document.getElementsByTagName('head')[0]; - var script = document.createElement('script'); - script.src = url; - - // Handle Script loading - { - var done = false; - - // Attach handlers for all browsers - script.onload = script.onreadystatechange = function() { - if ( - !done && - (!this.readyState || - this.readyState == 'loaded' || - this.readyState == 'complete') - ) { - done = true; - if (callback) callback(); - - // Handle memory leak in IE - script.onload = script.onreadystatechange = null; - } - }; - } - - head.appendChild(script); - - // We handle everything using the script element injection - return undefined; -} - -//Redirect if necessary -var redirected = false; -//If this is a Feide self enrollment link, forward to a page that requires authentication. It will redirect to the Canvas login page -//which will pick up that there is an enrollment code in the link and forward to Feide. -if(document.location.pathname == "/search/all_courses" && document.location.search.includes('?enroll_code')) { - window.location.href = '/courses' + document.location.search; - redirected = true; -} else if(document.location.pathname == "/login/canvas") { - if (document.referrer.endsWith("/logout" + hrefQueryString)) { - window.location.href = '/search/all_courses' + hrefQueryString; - redirected = true; - } else if(!document.referrer.includes("/login/canvas")) { - $(".ic-Login").hide(); - $("#f1_container").hide(); //Small screens - redirected = utilRoot.redirectFeideAuthIfEnrollReferrer(); - if(!redirected) { - if(!document.location.search.includes("normalLogin=1")) { - document.getElementById('wrapper').remove(); - let parent = document.getElementById('application'); - let login = document.createElement('div'); - login.id = 'login-component'; - let customLogin = createApp(LoginDirectLink); - parent.appendChild(login); - customLogin.mount("#login-component"); - - } - else { - $(".ic-Login").show(); - $("#f1_container").show(); //Small screens - } - } - } -} else if (document.location.pathname == "/courses") { - redirected = utilRoot.redirectToEnrollIfCodeParamPassed(); -} else if (document.location.href.indexOf('?login_success=1') != -1 ){ - window.location.href = '/search/all_courses?design=udir'; -} else if (document.location.pathname == "/") { - setTimeout(function() { - if(!$(".ic-DashboardCard__header_hero").length) { - let html = ` -
-

Er det tomt her?

-

Dersom du har valgt å logge inn med Feide og ikke finner innholdet ditt kan det hende det er fordi du - vanligvis har logget på med en annen bruker ved å bruke epost og passord. Logg ut og inn igjen ved å benytte "Ikke Feide" - knappen. -

- Ny innloggingsskjerm -
- `; - document.getElementById('dashboard-activity').insertAdjacentHTML('beforebegin', html); - } - }, 1000) -} - - - -if(!redirected) { - const urlParamsObj = utilRoot.urlParamsToObject(); - const design = urlParamsObj && urlParamsObj['design']; - if (design !== undefined && design=="udir") { - if(window.udirDesignLoaded === undefined) - { - window.udirDesignLoaded = true; - console.log("Root account:Loading udir design."); - - var filename = SERVER + DESIGNCSS; - - var fileref=document.createElement("link") - fileref.setAttribute("rel", "stylesheet") - fileref.setAttribute("type", "text/css") - fileref.setAttribute("href", filename) - fileref.onload = (_) => { - $.getScript(SERVER + DESIGNJS); - } - document.getElementsByTagName("head")[0].appendChild(fileref) - } else { - console.log("Root account:Udir design already loaded."); - } - } else { - console.log("Root account:Not loading any special design."); - } -} diff --git a/src/js/rootaccountfwd-dev.js b/src/js/rootaccountfwd-dev.js deleted file mode 100644 index 8151eadf..00000000 --- a/src/js/rootaccountfwd-dev.js +++ /dev/null @@ -1,49 +0,0 @@ -// Replace the normal jQuery getScript function with one that supports -// debugging and which references the script files as external resources -// rather than inline. -jQuery.extend({ - getScript: function(url, callback) { - var head = document.getElementsByTagName('head')[0]; - var script = document.createElement('script'); - script.src = url; - - // Handle Script loading - { - var done = false; - - // Attach handlers for all browsers - script.onload = script.onreadystatechange = function() { - if ( - !done && - (!this.readyState || - this.readyState == 'loaded' || - this.readyState == 'complete') - ) { - done = true; - if (callback) callback(); - - // Handle memory leak in IE - script.onload = script.onreadystatechange = null; - } - }; - } - - head.appendChild(script); - - // We handle everything using the script element injection - return undefined; - } -}); - -jQuery(document).ready(function($) { - var filename = SERVER + DESIGNCSS; - - var fileref=document.createElement("link") - fileref.setAttribute("rel", "stylesheet") - fileref.setAttribute("type", "text/css") - fileref.setAttribute("href", filename) - fileref.onload = (_) => { - $.getScript(SERVER + DESIGNJS); - } - document.getElementsByTagName("head")[0].appendChild(fileref) -}); diff --git a/src/js/settingsRoot.js b/src/js/settingsRoot.js index b3f49e76..66336886 100644 --- a/src/js/settingsRoot.js +++ b/src/js/settingsRoot.js @@ -1,10 +1,6 @@ var settingsRoot = { - - hrefQueryString: "?design=udir", - hrefAmpQueryString: "&design=udir", feideEnrollRefferers: [ - "design=udir", "enroll_code", "kslaring.no" ], diff --git a/src/js/subaccount.js b/src/js/subaccount.js deleted file mode 100644 index 280dc0c9..00000000 --- a/src/js/subaccount.js +++ /dev/null @@ -1,75 +0,0 @@ -import utilRoot from "./utilRoot"; -// Replace the normal jQuery getScript function with one that supports -// debugging and which references the script files as external resources -// rather than inline. -var udirDesignLoaded; - -jQuery.extend({ - getScript: function (url, callback) { - var head = document.getElementsByTagName("head")[0]; - var script = document.createElement("script"); - script.src = url; - - // Handle Script loading - { - var done = false; - - // Attach handlers for all browsers - script.onload = script.onreadystatechange = function () { - if ( - !done && - (!this.readyState || - this.readyState == "loaded" || - this.readyState == "complete") - ) { - done = true; - if (callback) callback(); - - // Handle memory leak in IE - script.onload = script.onreadystatechange = null; - } - }; - } - - head.appendChild(script); - - // We handle everything using the script element injection - return undefined; - }, -}); - -jQuery(document).ready(function ($) { - console.log("Subaccount: START."); - const urlParamsObj = utilRoot.urlParamsToObject(); - var enrollCode = utilRoot.isEnrollCodeParamPassed(urlParamsObj); - if (enrollCode) { - console.log("Subaccount: ENROLLCODE DEFINED."); - return null; - } - if (utilRoot.isLoginParamPassed(urlParamsObj)) { - console.log("Subaccount: LOGINPARAM PASSED."); - return null; - } - - if (window.udirDesignLoaded == undefined && udirDesignLoaded === undefined) { - window.udirDesignLoaded = true; - udirDesignLoaded = true; - console.log("Subaccount: loading design."); - console.log("before filename"); - var filename = SERVER + DESIGNCSS; - console.log(filename); - var fileref = document.createElement("link"); - fileref.setAttribute("rel", "stylesheet"); - fileref.setAttribute("type", "text/css"); - fileref.setAttribute("href", filename); - fileref.onload = (_) => { - $.getScript(SERVER + DESIGNJS); - }; - console.log("SA: after get script"); - document.getElementsByTagName("head")[0].appendChild(fileref); - } else { - console.log("Subaccount: design already loaded."); - } - - console.log("Subaccount: EOF."); -}); diff --git a/src/js/subaccountfwd-dev.js b/src/js/subaccountfwd-dev.js deleted file mode 100644 index bc9723ca..00000000 --- a/src/js/subaccountfwd-dev.js +++ /dev/null @@ -1,40 +0,0 @@ -// Replace the normal jQuery getScript function with one that supports -// debugging and which references the script files as external resources -// rather than inline. -jQuery.extend({ - getScript: function(url, callback) { - var head = document.getElementsByTagName('head')[0]; - var script = document.createElement('script'); - script.src = url; - - // Handle Script loading - { - var done = false; - - // Attach handlers for all browsers - script.onload = script.onreadystatechange = function() { - if ( - !done && - (!this.readyState || - this.readyState == 'loaded' || - this.readyState == 'complete') - ) { - done = true; - if (callback) callback(); - - // Handle memory leak in IE - script.onload = script.onreadystatechange = null; - } - }; - } - - head.appendChild(script); - - // We handle everything using the script element injection - return undefined; - } -}); - -jQuery(document).ready(function($) { - $.getScript(SERVER + DESIGNJS); -}); diff --git a/src/js/utilRoot.js b/src/js/utilRoot.js index 2533670e..41d5f4b2 100644 --- a/src/js/utilRoot.js +++ b/src/js/utilRoot.js @@ -1,4 +1,3 @@ -import { hrefQueryString } from "./settingsRoot"; import settingsRoot from "./settingsRoot"; export default (function() { @@ -11,7 +10,7 @@ export default (function() { return this.getRoles() !== null; }, getLinkToMyCourses: function () { - var linkToMyCourses = "/courses" + hrefQueryString; + var linkToMyCourses = "/courses"; return linkToMyCourses; }, @@ -103,10 +102,7 @@ export default (function() { var enrollCode = this.isEnrollCodeParamPassed(urlParamsObj); if (enrollCode) { - newHref = "/enroll/" + enrollCode; // + hrefQueryString; - if(design) { - newHref += "?design=" + design; - } + newHref = "/enroll/" + enrollCode; } var forwardTo = urlParamsObj && urlParamsObj['forwardTo']; diff --git a/src/vue/components/course-modules/CourseModule.vue b/src/vue/components/course-modules/CourseModule.vue index d99858c7..05e7bffe 100644 --- a/src/vue/components/course-modules/CourseModule.vue +++ b/src/vue/components/course-modules/CourseModule.vue @@ -45,7 +45,7 @@ diff --git a/src/vue/components/course-modules/CourseModules.vue b/src/vue/components/course-modules/CourseModules.vue index 70f0c419..5debed63 100644 --- a/src/vue/components/course-modules/CourseModules.vue +++ b/src/vue/components/course-modules/CourseModules.vue @@ -30,7 +30,7 @@ - - diff --git a/src/vue/components/login-choice/LoginChoice.vue b/src/vue/components/login-choice/LoginChoice.vue index 97f77e9d..762f5465 100644 --- a/src/vue/components/login-choice/LoginChoice.vue +++ b/src/vue/components/login-choice/LoginChoice.vue @@ -43,10 +43,10 @@ export default { this.modalOpen = false }, goToFeide() { - window.location.href = window.location.origin + "/courses?login=1&design=udir" + window.location.href = window.location.origin + "/login/saml/2" }, goToCanvas() { - window.location.href = window.location.origin + "/login/canvas?normalLogin=1&design=udir" + window.location.href = window.location.origin + "/login/canvas?normalLogin=1" } } } diff --git a/src/vue/components/login-choice/LoginDirectLink.vue b/src/vue/components/login-choice/LoginDirectLink.vue index 7aa6a914..f5f34bbf 100644 --- a/src/vue/components/login-choice/LoginDirectLink.vue +++ b/src/vue/components/login-choice/LoginDirectLink.vue @@ -77,6 +77,7 @@ export default { align-items: center; justify-content: center; margin-bottom: 2rem; + text-align: center; } .login-options { display: flex; diff --git a/src/vue/components/modal/Modal.vue b/src/vue/components/modal/Modal.vue index 25b18ef5..028ff40c 100644 --- a/src/vue/components/modal/Modal.vue +++ b/src/vue/components/modal/Modal.vue @@ -28,7 +28,6 @@