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

Feature: Online Survey with Auth and Case components; Case and Online Survey APIs; "Locked" Online Surveys with Links from Case Event Forms #3710

Closed
Closed
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
1630bae
Add components for auth in online-survey-app
May 16, 2024
8971b53
Add online survey get and save form response from case event form id
May 23, 2024
d4a713c
Working version of online-survey login routing
May 29, 2024
bc72f19
Fix release online survey script copying of form directory
May 30, 2024
aaf3809
Add server-side APIs to create Case, Event and Form
May 30, 2024
9752ad5
Fix unfinished case-api function
May 31, 2024
a92d271
Fix bugs in case-api and add user-profile create api
May 31, 2024
69fce19
Add app config 'requireAccessCode' for users to lock access to online…
May 31, 2024
d852178
Reorder span items in release online survey component
Jun 3, 2024
1ef7c00
Include custom-scripts in online-survey releases
Jun 3, 2024
c4b6c68
Online Survey - save case variables to local storage
Jun 3, 2024
4d8c5b6
Add case module to online-survey-app
Jun 4, 2024
69a5108
Allow online survey link for case event form; online-survey custom-lo…
Jun 4, 2024
0b075e2
Ensure auth works for case in online surveys
Jun 4, 2024
c565cec
Editor event form list items get a copy link button
Jun 4, 2024
0360347
Add menu to event form list for survey link copy, qr, and open
Jun 5, 2024
1e0077c
Add getOnlineSurvey and getCaseEventFormSurveyLinks APIs
Jun 7, 2024
5837be6
Fix up case create api
Jun 8, 2024
1853c34
Update /case/createParticipant API
Jun 8, 2024
901ea4c
Add case service set context and caseSErvice window var for online su…
Jun 8, 2024
3640ef6
Fix bugs in case-api and case class
Jun 8, 2024
78c20ac
Add eventFormRedirect to online surveys
Jun 8, 2024
992c76f
case api getEventFormSurveyLinks outputs a JSON object with list of l…
Jun 10, 2024
dca0786
Fix setting event id in case creation api
Jun 11, 2024
eaa0bbb
Fix typo in content-set.md
Jun 11, 2024
26e197f
Event form link copy not allowed with http
Jun 11, 2024
e65a88d
Add case, event and form info to response
Jun 11, 2024
9f40001
Build custom-scripts when releasing online app
Jun 11, 2024
eaebe51
use surveyLinkUrl in event form list item
Jun 12, 2024
ac3d58b
Create participant event forms when adding participant through api
Jun 12, 2024
697a9f1
Set event and form name from definition in creation api
Jun 12, 2024
45ed8ee
Add helpLink config for online-survey to enable a custom link from an…
Jun 12, 2024
ed615fc
Fix creation of event forms for participant role in case api
Jun 12, 2024
175787e
Revert addition of all client/app-config.json; only set helpLink
Jun 12, 2024
8c2dbc6
Fix GROUP_ID in release online survey app
Jun 15, 2024
981d49b
Add timeout and logout to online survey
Jun 15, 2024
526f837
Add logout to editor app after warning
Jun 15, 2024
88071e5
Add process monitor dialogs to publish/unpublish online survey
Jun 15, 2024
59d05b7
Add expiry logout in online survey after warning
Jun 15, 2024
3eaa97a
Save-as-you-go in online surveys with case
Jun 15, 2024
a0011c2
Remove online survey getResponse API
Jun 15, 2024
21f922e
Add online-survey-app logout button and return to case url
Jun 25, 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
Prev Previous commit
Next Next commit
Working version of online-survey login routing
  • Loading branch information
esurface committed May 29, 2024
commit d4a713cf556142bc145fedb8941edfa0799433e4
7 changes: 4 additions & 3 deletions develop.sh
Original file line number Diff line number Diff line change
@@ -77,11 +77,12 @@ if echo "$T_MODULES" | grep mysql; then
./mysql-create-dirs.sh
fi

if echo "$T_USE_MYSQL_CONTAINER" | grep "true"; then
if echo "$T_USE_MYSQL_CONTAINER" | grep "true"; then
./mysql-start-container.sh
echo "Waiting 60 seconds for mysql container to start..."
sleep 60
./mysql-setup.sh
sleep 60
./mysql-setup.sh
fi
fi

if echo "$T_MYSQL_PHPMYADMIN" | grep "TRUE"; then
2 changes: 2 additions & 0 deletions online-survey-app/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -4,8 +4,10 @@ import { FormSubmittedSuccessComponent } from './form-submitted-success/form-sub
import { FormsListComponent } from './forms-list/forms-list.component';
import { TangyFormsPlayerComponent } from './tangy-forms-player/tangy-forms-player.component';
import { LoginGuard } from './core/auth/_guards/login-guard.service';
import { SurveyLoginComponent } from './core/auth/_components/survey-login/survey-login.component';

const routes: Routes = [
{ path: 'survey-login', component: SurveyLoginComponent },
{ path: 'forms-list', component: FormsListComponent, canActivate: [LoginGuard] },
{ path: 'form-submitted-success', component: FormSubmittedSuccessComponent, canActivate: [LoginGuard] },
{ path: 'form/:formId', component: TangyFormsPlayerComponent, canActivate: [LoginGuard] },
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ import { _TRANSLATE } from 'src/app/shared/_services/translation-marker';


@Component({
selector: 'app-login',
selector: 'login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.css']
})
@@ -28,11 +28,7 @@ export class LoginComponent implements OnInit {

if (await this.authenticationService.isLoggedIn()) {
this.router.navigate([this.returnUrl]);
}
// We always want to log in from the "front door". If we log in from path of `/app/<groupId>`, then the global cookie
// will be tied to that pathname and not available at other pathnames such as `/csv/` that is looking for authentication.
if (window.location.pathname !== '/') {
window.location.pathname = '/'
return;
}
this.customLoginMarkup.nativeElement.innerHTML = await this.authenticationService.getCustomLoginMarkup()
this.ready = true
@@ -42,8 +38,8 @@ export class LoginComponent implements OnInit {

if (window.location.origin.startsWith('http://localhost')) {
// If we are running on localhost, we want to use the local server for authentication
localStorage.setItem(this.user.username, this.user.password);
this.router.navigate([this.returnUrl]);

} else if (await this.authenticationService.login(this.user.username, this.user.password)) {
this.router.navigate([this.returnUrl]);
} else {
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
mat-card {
width: 300px;
margin: 30px auto;
}
.mat-title {
color: var(--primary-color);
font-size: 1.5em;
font-weight: 400;
font-family: Roboto, 'Helvetica Nue', sans-serif;
}
#logo {
margin-bottom: 15px;
}
mat-placeholder i {
margin-right: 0.075em;
}

input.mat-input-element {
margin-top: 1em;
}

.mat-placeholder-required.mat-form-field-required-marker.ng-tns-c6-2
.mat-form-field-invalid
.mat-form-field-placeholder.mat-accent,
.mat-form-field-invalid
.mat-form-field-placeholder
.mat-form-field-required-marker {
position: relative;
bottom: 1em !important;
}
.mat-form-field {
width: 100%;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<mat-card *ngIf="!ready">
Loading...
</mat-card>
<mat-card *ngIf="ready">
<form role="form" #login='ngForm' novalidate>
<img id="logo" src="/logo.png" width="100%">
<mat-form-field>
<input matInput type="text" required [(ngModel)]="user.accessCode" id="username" name="username">
<mat-placeholder>
<i class="material-icons app-input-icon">key</i>
<span>{{'Access Code'|translate}}</span>
</mat-placeholder>
</mat-form-field>
<br>
<br>
<button (click)="loginUser()" mat-raised-button color="accent" name="action">{{'LOGIN'|translate}}</button>
<span id="err">
<small>{{errorMessage}}</small>
</span>
</form>
</mat-card>
<span #customLoginMarkup></span>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { AuthenticationService } from '../../_services/authentication.service';
import { _TRANSLATE } from 'src/app/shared/_services/translation-marker';
import { AppConfigService } from 'src/app/shared/_services/app-config.service';


@Component({
selector: 'survey-login',
templateUrl: './survey-login.component.html',
styleUrls: ['./survey-login.component.css']
})
export class SurveyLoginComponent implements OnInit {

errorMessage = '';
returnUrl: string; // stores the value of the url to redirect to after login
user = { accessCode: '' };
@ViewChild('customLoginMarkup', {static: true}) customLoginMarkup: ElementRef;
ready = false

constructor(
private authenticationService: AuthenticationService,
private appConfigService: AppConfigService,
private route: ActivatedRoute,
private router: Router,
) { }

async ngOnInit() {
this.returnUrl = this.route.snapshot.queryParams['returnUrl'] || 'forms-list';

if (await this.authenticationService.isLoggedIn()) {
this.router.navigate([this.returnUrl]);
return;
}
this.customLoginMarkup.nativeElement.innerHTML = await this.authenticationService.getCustomLoginMarkup()
this.ready = true
}
async loginUser() {
try {

const appConfig = await this.appConfigService.getAppConfig();
const groupId = appConfig['groupId'];

if (await this.authenticationService.surveyLogin(groupId, this.user.accessCode)) {
this.router.navigate([this.returnUrl]);
} else {
this.errorMessage = _TRANSLATE('Login Unsuccessful');
}
} catch (error) {
this.errorMessage = _TRANSLATE('Login Unsuccessful');
console.error(error);
}
}

}
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ export class LoginGuard implements CanActivate {
if (await this.authenticationService.isLoggedIn()) {
return true;
}
this.router.navigate([route, 'login'], { queryParams: { returnUrl: state.url } });
this.router.navigate(['survey-login'], { queryParams: { returnUrl: state.url } });
return false;
}
}
Loading