Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stage #551

Merged
merged 20 commits into from
Sep 4, 2024
Merged

Stage #551

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
22810fe
DIT-267: Bugfix modules not showing for featured course preview & Dua…
ajxudir Jul 2, 2024
f11dcb6
DIT-226: Add .svg files that are download from repo but not save in g…
ajxudir Jul 2, 2024
2206622
DIT-226: Remove storybook as it is not in active use during development
ajxudir Jul 3, 2024
b1effa0
DIT-226: Remove unused github templates
ajxudir Jul 3, 2024
3f44b31
DIT-226: Swapped out dev branch with stage
ajxudir Jul 3, 2024
2527b3f
Merge pull request #542 from matematikk-mooc/aj/DIT-267
madsenandreas Jul 4, 2024
b67cda7
DIT-226: Updated packages and webpack development server
ajxudir Jul 4, 2024
c550fd5
Merge remote-tracking branch 'origin/dev' into aj/DIT-226
ajxudir Jul 4, 2024
f4bb9bb
DIT-155: Updated NPM packages and added hook to remember close quiz w…
ajxudir Jul 8, 2024
c1cd47a
DIT-226: Updated yarn lock file
ajxudir Jul 8, 2024
bf5831f
DIT-267: Fix width issue for featured enroll popup
ajxudir Jul 8, 2024
9467411
DIT-226: Swap out node-sass with sass for better compatibility
ajxudir Jul 11, 2024
314a3c7
DIT-226: Updated yarn lock file
ajxudir Jul 11, 2024
4d61e11
DIT-226: Fix SCSS {} order to remove sass warning
ajxudir Jul 11, 2024
5392b98
Merge pull request #545 from matematikk-mooc/aj/DIT-267-002
madsenandreas Jul 15, 2024
d989f3e
Merge remote-tracking branch 'origin/dev' into aj/DIT-226
ajxudir Jul 17, 2024
d48f4d2
DIT-226: Updated readme
ajxudir Jul 18, 2024
8604735
Merge pull request #547 from matematikk-mooc/aj/DIT-226
madsenandreas Jul 18, 2024
0729662
DIT-226: Added logging for LTI message exchange and updated NodeJS ve…
AjXUthaya Aug 28, 2024
0d72722
Merge pull request #550 from matematikk-mooc/aj/DIT-226
ajxudir Aug 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions .github/ISSUE_TEMPLATE/bug_report.md

This file was deleted.

20 changes: 0 additions & 20 deletions .github/ISSUE_TEMPLATE/feature_request.md

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build-master-push-azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: yarn install

- name: Run build script
run: yarn buildProduction
run: yarn production

- name: Login to Azure
uses: azure/login@v2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
name: CICD Frontend Dev
name: CICD Frontend Stage
run-name: ${{ github.actor }} Committed code for azure blob storage

on:
push:
branches:
- dev
- stage
workflow_dispatch:

env:
ACCOUNT_NAME: udirdit
SOURCE: dist
DESTINATION: frontend-dev
DESTINATION: frontend-stage
AZURE_STORAGE_KEY: ${{ secrets.AZURE_STORAGE_KEY }}

jobs:
Expand All @@ -29,7 +29,7 @@ jobs:
run: yarn install

- name: Run build script
run: yarn buildDev
run: yarn stage

- name: Login to Azure
uses: azure/login@v2
Expand Down
34 changes: 0 additions & 34 deletions .github/workflows/deploy-storybook.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.12.2
v20.17.0
154 changes: 52 additions & 102 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,148 +1,98 @@
# Frontend -
![](https://imgur.com/XWVOBSH.png "")

Custom JS and CSS frontend for inclusion in [Canvas](http://www.instructure.com/).
# Frontend - Kompetanseportalen (KPAS)

# Description
This platform is operated by The Norwegian Directorate of Education's Department for Digital Services, which is responsible for managing a number of national digital solutions that support education and skills development.

The custom JS and CSS frontend is built on top of Canvas using the mechanism in Canvas for including custom .js and .css files.
KPAS provides competency packages across various themes to enhance skills and practices in kindergartens, schools, the Educational Psychological Service (PPT), training companies, and examination boards. The platform is designed to support collaborative and long-term professional development with embedded process and leadership support.

The frontend changes the Canvas graphical design and user interface by using [SCSS](https://sass-lang.com/) and custom HTML injected using JavaScript and [Vue](https://vuejs.org/) components.
The custom JS and CSS frontend is built on top of Canvas using the mechanism in Canvas for including custom .js and .css files. This frontend changes the Canvas graphical design and user interface by utilizing SCSS and custom HTML injected through JavaScript and Vue components. The custom JS and CSS frontend is compiled and concatenated into a single CSS and JavaScript file using Node and Webpack.

The custom JS and CSS frontend is compiled and concatenated into a single CSS and JavaScript file using Node and [Webpack](https://webpack.js.org/)
**Services**

# Getting started
| Service | Environment | URL |
|---------|-------------|-----|
| Frontend | Production | https://bibsys.instructure.com/search/all_courses/ |
| Frontend | Stage | https://bibsys.test.instructure.com/search/all_courses/ |

If you want to to build the frontend on your local machine you need to follow the steps below. Note that some of the commands might require sudo on certain systems.
**Related Codebases**

## Install Node
| Name | Description |
|------|-------------|
| [KPAS API](https://github.com/matematikk-mooc/kpas-api/) | Extends Canvas LMS through LTI tools and REST endpoints |
| [Statistics API](https://github.com/matematikk-mooc/statistics-api/) | Collects and serves statistics data for KPAS |

To build CSS and JavaScript files you need to install [Node JS](http://nodejs.org) or update to the latest version if you are already have it installed.
**Quick links**

## Clone or download frontend project to local machine
- [Dependencies](#dependencies)
- [Configuration](#configuration)
- [Development](#development)
- [Deployment](#deployment)
- [Maintenance](#maintenance)

Clone the frontend from https://github.com/matematikk-mooc/frontend or download using your browser:
## Dependencies

```
git clone https://github.com/matematikk-mooc/frontend.git
```
- [Git](https://git-scm.com/): A free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
- [Visual Studio Code](https://code.visualstudio.com/): A lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux.
- [NVM](https://github.com/nvm-sh/nvm/): A version manager for Node.js that allows you to manage multiple active Node.js versions, simplifying the development and testing process across different versions.

## Install and build dependencies (Node packages)
## Configuration

Switch to the directory where the frontend is located and install the dependencies using [NPM](https://www.npmjs.com/).
### Initialize codebase

1. Install Node.js: `nvm install`
1. Enable corepack for Node.js: `corepack enable`
1. Install NPM packages: `yarn install`

```
npm install
```
### Upload localhost theme to Canvas LMS

1. Build theme: `yarn build`
1. Create a new theme here: https://bibsys.test.instructure.com/accounts/1/brand_configs/
1. Click on create from default template and under the upload tab, select the build files from the first step that are located in the `dist` folder:
- CSS-fil: `theme-localhost.css`
- JavaScript-Fil: `theme-localhost.js`

## Start a web server on your local machine
## Development

If you want to serve the CSS and JS files on your local machine for development, you can do this using Webpack DevServer:
1. Use Node.js: `nvm install`
1. Install NPM packages: `yarn watch`
1. Vist https://bibsys.test.instructure.com/search/all_courses/

```
npm run buildDevelopment
npm run serveDevelopment
```
## Deployment (WIP)

All changes in SCSS, Vue and Javascript will automatically be compiled and are available at [http://localhost:9000](http://localhost:9000/)


## Build JS and CSS files for dev and production environment
Compile JS and CSS for the dev environment using
Compile JS and CSS for the stage environment using

```
npm run buidDev
yarn run stage
```


Compile JS and CSS for the production environment using

```
npm run buildProduction
yarn run production
```


* See scripts section in package.json

The resulting JS and CSS file can be found in the **dist** directory. These commands will get the timestamp of the latest commit to the given branch, and append to the filenames.
To test code locally allways use buildDevelopment and serveDevelopment, as buildDev and buildProduction will use the file already uploaded to Azure, and will not pick up local changes.

# Project structure

## Directories

| Directory | Description |
| ------------- | ----------------------------------------- |
| src | Source code |
| src/js | JavaScript files used to inject custom Vue components and hide unused Canvas elements.
| src/vue | Custom Vue components and scss |
| dist/ | Build output directory |
To test code locally allways use "build" and "watch", as "stage" and "production" will use the file already uploaded to Azure, and will not pick up local changes.

## src/vue

| Directory | Description |
| ------------- | ----------------------------------------- |
| /assets | Font files and svgs |
| /components | Custom Vue componets |
| /pages | Vue views used on urls where replacing the whole page |
| /design | SCSS files for own components and override styling of Canvas elements |
| /utils | util js files used with multilanguage |

## src/js

| File/Directory | Description |
| ----------------- | ------------------------------------------------------------------------ |
| main.js | Calls different JS functions to create custom HTML based on URL (routes) |
| api/ | Call to Canvas REST API and KPAS API |
| modules/ | JavaScripts called from main.js |
| modules/routes.js | Library used to call different JS functions based on URLs using RegExps |

## Webpack config files

| File | Description |
| ------------------------------|---------------------------------------------|
| webpack.development.config.js | Config file for development (running with localhost) |
| webpack.dev.config.js | Config file for dev environment |
| webpack.production.config.js | Config file for production environment |



# Deployment

Copy all files from the dist directory to your web server.
Note that addons generate different files that may be destinated to different directories in your production server.

## Workflow

**.github** containts Github Actions pipelines for building dev and production and pushing **dist** directory to Azure.
### GitHub Actions

# Environment specific variables
### Rollback

## JS variables
Some settings and urls differs between environment, these are replaced at build time using [Webpack DefinePlugin](https://webpack.js.org/plugins/define-plugin/) and can be updated in the following section in webpack.(production|dev|development).config.js
## Maintenance

```
plugins: [
...
new webpack.DefinePlugin({
'DESIGNCSS' : JSON.stringify('subaccount-localhost.css'),
'DESIGNJS' : JSON.stringify('kompetanseportalen-localhost.js'),
'SERVER': JSON.stringify('http://localhost:9000/'),
'KPASAPIURL': JSON.stringify('https://kpas.staging.kompetanse.udir.no/api'),
'ACCOUNTID' : [99, 100, 102, 103, 137, 138, 139, 145],
'KPAS_MERGE_LTI_ID' : 863,
'KPAS_IFRAME_VERSION' : JSON.stringify('localhost'),
})
]
```
Maintaining a frontend project involves regular updates to ensure the application remains secure, performant, and up to date with the latest web standards. Here's how updates are carried out for JavaScript libraries, Vue.js framework components, and other dependencies:

## Storybook
### NPM Packages

Storybook for the custom Vue components. To build the storybook run:
```
npm run storybook
```
Visit storbook:
1. **Update Packages**: Regularly run `yarn update` to fetch the latest versions of dependencies. Use `yarn outdated` to check for available updates.

http://matematikk-mooc.github.io/frontend/
1. **Security Audits**: Perform security audits using `yarn audit` to identify and resolve potential vulnerabilities.
Loading