User Tools

Site Tools


sis_developer_manual

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
sis_developer_manual [2024/03/11 01:50] – [Deploying the Frontend] ghacheysis_developer_manual [2025/07/29 05:02] (current) – [Building and Running Backend] ghachey
Line 39: Line 39:
   * [[https://www.npmjs.com/|NPM]] will be installed with NodeJS above. It is the package manager and is used mainly to install dependencies and other tools used by the frontend. You can see the currently used npm packages in ''packages.json''.   * [[https://www.npmjs.com/|NPM]] will be installed with NodeJS above. It is the package manager and is used mainly to install dependencies and other tools used by the frontend. You can see the currently used npm packages in ''packages.json''.
  
-<note warning>The Pacific SIS build tools is easier to setup with the NodeJS LTS version 16The latest LTS 18 at the time of this writing requires handling a SSL obsolete method used by webpack.</note>+<note warning>The Pacific SIS build tools is easier to setup with the NodeJS LTS version 14.21.3. More recent version currently have errors. Use nvm to manage multiple node versions on your system</note>
 ===== Setting Up the Development Environment ===== ===== Setting Up the Development Environment =====
  
Line 47: Line 47:
  
 Most developers currently use Visual Studio, Visual Studio Code, dotnet 6.0, MySQL, NodeJS/NPM. And SourceTree/Git is useful to manage code evolution: Most developers currently use Visual Studio, Visual Studio Code, dotnet 6.0, MySQL, NodeJS/NPM. And SourceTree/Git is useful to manage code evolution:
- 
- 
-<note warning>Regarding step 4. below. The Pacific SIS build tools is easier to setup with the NodeJS LTS version 16. The latest LTS 18 at the time of this writing requires handling a SSL obsolete method used by webpack.</note> 
  
   - Download and install [[https://git-scm.com/|Git]]   - Download and install [[https://git-scm.com/|Git]]
   - Download and install latest [[https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx|Visual Studio]] (developers mostly on 2022).   - Download and install latest [[https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx|Visual Studio]] (developers mostly on 2022).
   - Download and install [[https://dev.mysql.com/downloads/|MySQL Community Version]] (the server and workbench).    - Download and install [[https://dev.mysql.com/downloads/|MySQL Community Version]] (the server and workbench). 
-  - Download and install latest LTS [[https://nodejs.org/en/|NodeJS]].+  - Download and install latest LTS [[https://nodejs.org/en/|NodeJS]]. Use nvm to install multiple versions on your system including the support 14.21.3.
   - [Optional] Download and install [[https://www.sourcetreeapp.com/|SourceTree]] (useful for Git).   - [Optional] Download and install [[https://www.sourcetreeapp.com/|SourceTree]] (useful for Git).
  
Line 139: Line 136:
 ==== Database Upgrades ==== ==== Database Upgrades ====
  
-Database upgrades are done using the .NET EntityFrameworkCore migrations. When a new migration is made available typically in the source code you'll need to apply the migration. This can be done in a number of ways depending on preference and environment (development vs production). One way is to open the Package Manager Console within Visual Studio and run something like the following. +Database upgrades are done using the .NET EntityFrameworkCore migrations. When a new migration is made available typically in the source code you'll need to apply the migration. In production this will usually happen automatically when accessing the application after the successful upgradeIn development, I usually enable (i.e. uncomment) the commented lines below in the file **opensis.data/Models/CRMContextMySQL.cs** and configure it to run the upgrade on the desired tenant (i.e. database).
- +
-<code> +
-PM> Update-Database -Project opensis.data -Context CRMContextMySQL +
-Build started... +
-Build succeeded. +
-Applying migration '20230216092200_AlterStaffSchoolInfoMembershipId'+
-Done. +
-</code> +
- +
-A developer also suggested another by "hitting the API from postman or swagger" the URL https://localhost:port/{databaseName}/Common/getAllLanguageForLogin (replace the {databaseName} with the local databaseName) to automatically trigger the migration.  +
- +
-<note important>At the time of this writing I had to enabled (uncomment) the commented lines below in the file **opensis.data/Models/CRMContextMySQL.cs** to run the upgrade.+
  
 <code csharp> <code csharp>
Line 184: Line 169:
 </code> </code>
  
-</note>+With the above configured the upgrade will run automatically by loading the application. Another way is to open the Package Manager Console within Visual Studio and run something like the following. 
 + 
 +<code> 
 +PM> Update-Database -Project opensis.data -Context CRMContextMySQL 
 +Build started... 
 +Build succeeded. 
 +Applying migration '20230216092200_AlterStaffSchoolInfoMembershipId'
 +Done. 
 +</code> 
 + 
 +A developer also suggested another by "hitting the API from postman or swagger" the URL https://localhost:port/{databaseName}/Common/getAllLanguageForLogin (replace the {databaseName} with the local databaseName) to automatically trigger the migration. 
  
 ==== Building and Running Backend ==== ==== Building and Running Backend ====
Line 192: Line 187:
 {{ :sis-developer-manual:swagger-1.jpg?nolink |}} {{ :sis-developer-manual:swagger-1.jpg?nolink |}}
  
 +==== Initialize First User ====
 +
 +You can use the API endpoint "/{tenant}/User/insertInitialDataAtRegistration" to initialize the first school and user. Use something like the follow payload.
 +
 +<code javascript> 
 +{
 +  "schoolName": "School Template",
 +  "userName": "Username",
 +  "emailAddress": "user@example.com",
 +  "password": "somepassword",
 +  "tenantName": "tenant",
 +  "apiDomain": "https://localhost:44309/",
 +  "schoolBeginDate": "2025-02-01",
 +  "schoolEndDate": "2025-11-30",
 +  "_userName": "string",
 +  "_tenantName": "string",
 +  "_token": "string",
 +  "_tokenExpiry": "2025-07-29T04:52:53.585Z",
 +  "_failure": true,
 +  "_message": "string",
 +  "_academicYear": 0
 +}
 +</code>
 ==== Install Frontend Dependencies ==== ==== Install Frontend Dependencies ====
  
Line 230: Line 248:
 </code> </code>
  
 +Unfortunately, there is another hidden configuration that needs to be checked in ''Pacific-SIS\UI\src\app\common\default-values.service.ts''
 +
 +<code javascript>
 +setDefaultTenant() {
 +    const url = window.location.href;
 +
 +    let tenant = '';
 +    if (url.includes('localhost')) {
 +      // sessionStorage.setItem('tenant', JSON.stringify('opensisv2_ef6'));
 +      //tenant = 'fedsis';
 +      sessionStorage.setItem('tenant', JSON.stringify('fedsis'));
 +      tenant = 'fedsis';
 +    } else {
 +      let startIndex = url.indexOf('//');
 +      let endIndex = url.indexOf('.');
 +      let tenantName = url.substr(startIndex + 2, endIndex - (startIndex + 2));
 +
 +      sessionStorage.setItem('tenant', JSON.stringify(tenantName));
 +      tenant = tenantName;
 +    }
 +    this.commonModel._tenantName = tenant;
 +  }
 +</code>
 ==== Building and Running the Frontend ==== ==== Building and Running the Frontend ====
  
Line 247: Line 288:
 The deployment can be done in a number of ways. You can use the deployment tools in both the backend and frontend to package the files for the production server. Below explains how. The deployment can be done in a number of ways. You can use the deployment tools in both the backend and frontend to package the files for the production server. Below explains how.
  
-==== Deploying the Backend ====+==== Packaging the Backend ====
  
 Simply use the Visual Studio's publish feature. There is a publish "profile" in there that can be use as example. Two  apps need to be deployed on the backend. Simply use the Visual Studio's publish feature. There is a publish "profile" in there that can be use as example. Two  apps need to be deployed on the backend.
Line 270: Line 311:
 This should package all the frontend files in ''Pacific-SIS/UI/dist/vex/'' This should package all the frontend files in ''Pacific-SIS/UI/dist/vex/''
  
 +==== Deploying to Production Server ====
 +
 +Is a matter of preference. You could simply copy the files produced in the two previous steps and configure the Apache Server to server them. The database will need to also be deployed. One of the maintainers of the system uses Ansible to automate all of these final deployment tasks.
sis_developer_manual.1710121800.txt.gz · Last modified: 2024/03/11 01:50 by ghachey