Skip to content

Commit

Permalink
Merge branch 'master' into 8062-achievements-printing-spelling-error
Browse files Browse the repository at this point in the history
  • Loading branch information
dogi authored Jan 9, 2025
2 parents 307d05f + eb56a01 commit 9d6216c
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 31 deletions.
4 changes: 4 additions & 0 deletions src/app/exams/exams-add.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class ExamsAddComponent implements OnInit {
pageType: 'Add' | 'Update' | 'Copy' = 'Add';
courseName = '';
examType: 'exam' | 'survey' = <'exam' | 'survey'>this.route.snapshot.paramMap.get('type') || 'exam';
teamId = this.route.parent?.snapshot.paramMap.get('teamId') || null;
successMessage = this.examType === 'survey' ? $localize`New survey added` : $localize`New test added`;
steps = [];
showFormError = false;
Expand Down Expand Up @@ -120,6 +121,9 @@ export class ExamsAddComponent implements OnInit {

onSubmit(reRoute = false) {
if (this.examForm.valid) {
if (this.teamId) {
this.examForm.value.teamId = this.teamId;
}
this.showFormError = false;
this.addExam(Object.assign({}, this.examForm.value, this.documentInfo), reRoute);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/app/health/health.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ <h4 class="primary-text-color" i18n>Notes</h4>
</div>
</div>
<ng-container *ngIf="events.length > 0">
<h4 class="full-width" i18n>Examinations</h4>
<h3 class="full-width examinations-header" i18n>Examinations</h3>
<div class="full-width table-container" #examsTable>
<mat-table [dataSource]="eventTable" *ngIf="events.length > 0">
<ng-container *ngFor="let column of displayedColumns" [matColumnDef]="column" [sticky]="column === 'label'">
Expand Down
6 changes: 5 additions & 1 deletion src/app/health/health.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ mat-table {
}
}

.examinations-header {
text-align: center;
}

mat-header-cell div .header-date {
min-height: 1.7rem;
}
}
4 changes: 2 additions & 2 deletions src/app/home/home-router.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ const routes: Routes = [
}
]
},
{ path: 'landing', component: LandingComponent },
{ path: 'landing', loadChildren: () => import('../landing/landing.module').then(m => m.LandingModule) }
{ path: 'landing', component: LandingComponent, data: { requiresAuth: false } },
{ path: 'landing', loadChildren: () => import('../landing/landing.module').then(m => m.LandingModule), data: { requiresAuth: false } }
];

@NgModule({
Expand Down
4 changes: 3 additions & 1 deletion src/app/home/home.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { UsersModule } from '../users/users.module';
import { PlanetComponent } from './planet.component';
import { CoursesViewDetailModule } from '../courses/view-courses/courses-view-detail.module';
import { ChatModule } from '../chat/chat.module';
import { SurveysModule } from '../surveys/surveys.module';

@NgModule({
imports: [
Expand All @@ -46,7 +47,8 @@ import { ChatModule } from '../chat/chat.module';
PlanetCalendarModule,
UsersModule,
CoursesViewDetailModule,
ChatModule
ChatModule,
SurveysModule
],
declarations: [
HomeComponent,
Expand Down
9 changes: 9 additions & 0 deletions src/app/shared/auth-guard.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ export class AuthService {
// For main app (which requires login). Uses canActivateChild to check on every route
// change if session has expired
canActivateChild(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
let currentRoute: ActivatedRouteSnapshot | null = route;

while (currentRoute) {
if (currentRoute.data && currentRoute.data.requiresAuth === false) {
return of(true);
}
currentRoute = currentRoute.parent;
}

return this.checkUser(state.url);
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/shared/dialogs/dialogs-announcement.component.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="announcement-container">
<img
src="https://res.cloudinary.com/mutugiii/image/upload/v1733224910/dec_challenge_svcbi3.jpg"
src="assets/challenge/dec challenge.jpeg"
alt="Issues Challenge"
class="announcement-banner"
/>
Expand Down
36 changes: 20 additions & 16 deletions src/app/shared/dialogs/dialogs-announcement.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { MatDialogRef } from '@angular/material/dialog';
import { Router } from '@angular/router';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { Subject, of, Observable } from 'rxjs';
import { takeUntil, catchError, map, switchMap } from 'rxjs/operators';

import { findDocuments } from '../../shared/mangoQueries';
import { CouchService } from '../couchdb.service';
Expand All @@ -11,7 +11,6 @@ import { NewsService } from '../../news/news.service';
import { StateService } from '../state.service';
import { SubmissionsService } from '../../submissions/submissions.service';
import { UserService } from '../user.service';
import { UsersService } from '../../users/users.service';
import { UserChallengeStatusService } from '../user-challenge-status.service';
import { planetAndParentId } from '../../manager-dashboard/reports/reports.utils';

Expand All @@ -24,7 +23,7 @@ export const challengePeriod = (new Date() > new Date(2024, 10, 31)) && (new Dat
template: `
<div class="announcement-container">
<img
src="https://res.cloudinary.com/mutugiii/image/upload/v1733224910/dec_challenge_svcbi3.jpg"
src="assets/challenge/dec challenge.jpeg"
alt="Issues Challenge"
class="announcement-banner"
/>
Expand Down Expand Up @@ -67,7 +66,6 @@ export class DialogsAnnouncementComponent implements OnInit, OnDestroy {
private stateService: StateService,
private submissionsService: SubmissionsService,
private userService: UserService,
private usersService: UsersService,
private userStatusService: UserChallengeStatusService
) {}

Expand All @@ -90,6 +88,7 @@ export class DialogsAnnouncementComponent implements OnInit, OnDestroy {
}

initializeData() {
this.fetchMembers().subscribe(members => { this.members = members; });
this.coursesService.requestCourses();
this.newsService.requestNews({
selectors: {
Expand All @@ -100,7 +99,6 @@ export class DialogsAnnouncementComponent implements OnInit, OnDestroy {
},
viewId: this.teamId
});
this.fetchMembers();
this.fetchCourseAndNews();
this.fetchEnrolledMembers();
}
Expand Down Expand Up @@ -158,16 +156,22 @@ export class DialogsAnnouncementComponent implements OnInit, OnDestroy {
);
}

fetchMembers() {
this.usersService.getAllUsers().subscribe((users: any) => {
this.members = users.map((member: any) => {
const [ , memberName ] = member?._id.split(':');
return {
...member,
name: memberName,
};
});
});
fetchMembers(): Observable<any[]> {
return this.couchService.findAll('login_activities', findDocuments({
type: 'login',
loginTime: { $gte: this.startDate.getTime() }
}, [ 'user' ])).pipe(
catchError(() => of([])),
map((res: any[]) => Array.from(new Set(res.map(doc => doc.user)))),
switchMap(uniqueUsers => {
if (uniqueUsers.length === 0) { return of([]); }
return this.couchService.findAll(
'_users',
findDocuments({ name: { $in: uniqueUsers } }, [ '_id', 'name' ])
);
}),
catchError(() => of([]))
);
}

fetchEnrolledMembers() {
Expand Down
2 changes: 1 addition & 1 deletion src/app/submissions/submissions.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</ng-container>
<ng-container matColumnDef="courseTitle">
<mat-header-cell *matHeaderCellDef mat-sort-header="courseTitle" i18n>Course Name</mat-header-cell>
<mat-cell *matCellDef="let element">{{element.courseTitle}}</mat-cell>
<mat-cell *matCellDef="let element">{{element.courseTitle || element.parent.courseTitle}}</mat-cell>
</ng-container>
<ng-container matColumnDef="stepNum">
<mat-header-cell *matHeaderCellDef mat-sort-header="stepNum" i18n>Course Step</mat-header-cell>
Expand Down
8 changes: 4 additions & 4 deletions src/app/surveys/surveys.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<mat-toolbar>
<mat-toolbar *ngIf="!teamId">
<button mat-icon-button (click)="goBack()">
<mat-icon>arrow_back</mat-icon>
</button>
Expand All @@ -11,7 +11,7 @@
</mat-toolbar>

<div class="space-container primary-link-hover">
<mat-toolbar class="primary-color font-size-1">
<mat-toolbar *ngIf="!teamId" class="primary-color font-size-1">
<button mat-mini-fab (click)="routeToEditSurvey('add')" *ngIf="isAuthorized" >
<mat-icon>add</mat-icon>
</button>
Expand Down Expand Up @@ -61,8 +61,8 @@
<mat-header-cell *matHeaderCellDef i18n>Action</mat-header-cell>
<mat-cell *matCellDef="let element">
<ng-container *ngIf="!element.parent === true">
<button mat-raised-button color="primary" (click)="routeToEditSurvey('update', element._id)" i18n><mat-icon>edit</mat-icon> Edit</button>
<button mat-raised-button color="primary" [disabled]="!element.questions.length" (click)="openSendSurveyDialog(element)" i18n><mat-icon>send</mat-icon> Send</button>
<button mat-raised-button color="primary" *ngIf="!teamId" (click)="routeToEditSurvey('update', element._id)" i18n><mat-icon>edit</mat-icon> Edit</button>
<button mat-raised-button color="primary" *ngIf="!teamId && !routeTeamId" [disabled]="!element.questions.length" (click)="openSendSurveyDialog(element)" i18n><mat-icon>send</mat-icon> Send</button>
<button mat-raised-button color="primary" [disabled]="!element.questions.length" (click)="recordSurvey(element)"
i18n-matTooltip matTooltip="Record survey information from a person who is not a member of {{configuration.name}}" i18n>
<mat-icon>fiber_manual_record</mat-icon> Record
Expand Down
19 changes: 16 additions & 3 deletions src/app/surveys/surveys.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, ViewChild, AfterViewInit, OnDestroy } from '@angular/core';
import { Component, OnInit, ViewChild, AfterViewInit, OnDestroy, Input } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { FormGroup } from '@angular/forms';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
Expand All @@ -25,6 +25,7 @@ import { DialogsFormService } from '../shared/dialogs/dialogs-form.service';
import { DialogsAddTableComponent } from '../shared/dialogs/dialogs-add-table.component';

@Component({
selector: 'planet-surveys',
templateUrl: './surveys.component.html',
styleUrls: [ './surveys.component.scss' ]
})
Expand All @@ -44,6 +45,8 @@ export class SurveysComponent implements OnInit, AfterViewInit, OnDestroy {
message = '';
configuration = this.stateService.configuration;
parentCount = 0;
routeTeamId = this.route.parent?.snapshot.paramMap.get('teamId') || null;
@Input() teamId?: string;

constructor(
private couchService: CouchService,
Expand Down Expand Up @@ -79,7 +82,17 @@ export class SurveysComponent implements OnInit, AfterViewInit, OnDestroy {
}).length
})),
...this.createParentSurveys(submissions)
];
].filter(survey => {
if (this.routeTeamId) {
return survey.teamId === this.routeTeamId;
}

if (this.teamId) {
return survey.teamId === this.teamId;
} else {
return true;
}
});
this.surveys.data = this.surveys.data.map((data: any) => ({ ...data, courseTitle: data.course ? data.course.courseTitle : '' }));
this.dialogsLoadingService.stop();
});
Expand Down Expand Up @@ -245,7 +258,7 @@ export class SurveysComponent implements OnInit, AfterViewInit, OnDestroy {
recordSurvey(survey: any) {
this.submissionsService.createSubmission(survey, 'survey').subscribe((res: any) => {
this.router.navigate([
'dispense',
this.teamId ? 'surveys/dispense' : 'dispense',
{ questionNum: 1, submissionId: res.id, status: 'pending', mode: 'take' }
], { relativeTo: this.route });
});
Expand Down
1 change: 1 addition & 0 deletions src/app/surveys/surveys.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { SharedComponentsModule } from '../shared/shared-components.module';
SurveysRouterModule,
SharedComponentsModule
],
exports: [ SurveysComponent ],
declarations: [
SurveysComponent
]
Expand Down
4 changes: 4 additions & 0 deletions src/app/teams/teams-router.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import { TeamsViewComponent } from './teams-view.component';
const routes: Routes = [
{ path: '', component: TeamsComponent },
{ path: 'view/:teamId', component: TeamsViewComponent },
{
path: 'view/:teamId/surveys',
loadChildren: () => import('../surveys/surveys.module').then(m => m.SurveysModule)
},
{ path: 'users', loadChildren: () => import('../users/users.module').then(m => m.UsersModule) },
];
@NgModule({
Expand Down
6 changes: 5 additions & 1 deletion src/app/teams/teams-view.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ <h3 *ngIf="mode==='services'" class="margin-lr-3 ellipsis-title">{{configuration
<ng-template #actionButtons>
<ng-container [ngSwitch]="userStatus" *ngIf="user.isUserAdmin || user.roles.length">
<ng-container *ngSwitchCase="'member'">
<a class="margin-lr-3" [routerLink]="['surveys']" mat-stroked-button mat-button i18n>Manage Surveys</a>
<button *ngIf="mode!=='services'" mat-stroked-button mat-button class=" toolbar-button margin-lr-3" (click)="openInviteMemberDialog()" i18n [disabled]="disableAddingMembers">
Add Members
</button>
Expand Down Expand Up @@ -184,7 +185,7 @@ <h3 *ngIf="mode==='services'" class="margin-lr-3 ellipsis-title">{{configuration
</div>
</ng-template>
</mat-tab>
<mat-tab label="Courses">
<mat-tab i18n-label label="Courses">
<ng-template mat-tab-label>
<ng-container i18n>Courses</ng-container> ({{team?.courses?.length || 0}})
</ng-template>
Expand All @@ -211,6 +212,9 @@ <h3 *ngIf="mode==='services'" class="margin-lr-3 ellipsis-title">{{configuration
</div>
</ng-template>
</mat-tab>
<mat-tab i18n-label label="Surveys">
<planet-surveys [teamId]="teamId"></planet-surveys>
</mat-tab>
<mat-tab *ngIf="mode!=='services'" #applicantTab>
<ng-template mat-tab-label>
<ng-container i18n>{ mode, select, team {Join Requests} enterprise {Applicants} }</ng-container> ({{requests.length}})
Expand Down
2 changes: 2 additions & 0 deletions src/app/teams/teams.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { TeamsMemberComponent } from './teams-member.component';
import { TeamsReportsComponent } from './teams-reports.component';
import { TeamsReportsDialogComponent } from './teams-reports-dialog.component';
import { TeamsReportsDetailComponent } from './teams-reports-detail.component';
import { SurveysModule } from '../surveys/surveys.module';

@NgModule({
exports: [ TeamsViewComponent, TeamsComponent, TeamsViewFinancesComponent, TeamsMemberComponent, TeamsReportsComponent ],
Expand All @@ -34,6 +35,7 @@ import { TeamsReportsDetailComponent } from './teams-reports-detail.component';
SharedComponentsModule,
PlanetCalendarModule,
FormsModule,
SurveysModule
],
declarations: [
TeamsComponent,
Expand Down
Binary file added src/assets/challenge/dec challenge.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 9d6216c

Please sign in to comment.