Skip to content

Commit

Permalink
Merge branch 'master' into 7928-collections-overflow-resources-view-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Mutugiii committed Dec 17, 2024
2 parents 210ebc9 + 56d4b39 commit 1a19088
Show file tree
Hide file tree
Showing 21 changed files with 252 additions and 75 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "planet",
"license": "AGPL-3.0",
"version": "0.15.97",
"version": "0.16.5",
"myplanet": {
"latest": "v0.21.34",
"min": "v0.20.34"
"latest": "v0.21.40",
"min": "v0.20.40"
},
"scripts": {
"ng": "ng",
Expand Down
22 changes: 18 additions & 4 deletions src/app/chat/chat-window/chat-window.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Component, OnInit, OnDestroy, ViewChild, ElementRef, ChangeDetectorRef, Input, AfterViewInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { filter, takeUntil } from 'rxjs/operators';

import { CustomValidators } from '../../validators/custom-validators';
import { ConversationForm, AIProvider } from '../chat.model';
Expand All @@ -20,6 +20,7 @@ export class ChatWindowComponent implements OnInit, OnDestroy, AfterViewInit {
spinnerOn = true;
streaming: boolean;
disabled = false;
clearChat = true;
provider: AIProvider;
conversations: any[] = [];
selectedConversationId: any;
Expand Down Expand Up @@ -71,8 +72,7 @@ export class ChatWindowComponent implements OnInit, OnDestroy, AfterViewInit {
this.chatService.newChatSelected$
.pipe(takeUntil(this.onDestroy$))
.subscribe(() => {
this.selectedConversationId = null;
this.conversations = [];
this.resetConversation();
this.focusInput();
}, error => {
console.error('Error subscribing to newChatSelected$', error);
Expand All @@ -81,7 +81,16 @@ export class ChatWindowComponent implements OnInit, OnDestroy, AfterViewInit {

subscribeToSelectedConversation() {
this.chatService.selectedConversationId$
.pipe(takeUntil(this.onDestroy$))
.pipe(
takeUntil(this.onDestroy$),
filter(() => {
if (this.clearChat) {
this.clearChat = false;
return false;
}
return true;
})
)
.subscribe((conversationId) => {
this.selectedConversationId = conversationId;
this.fetchConversation(this.selectedConversationId?._id);
Expand All @@ -102,6 +111,11 @@ export class ChatWindowComponent implements OnInit, OnDestroy, AfterViewInit {
}));
}

resetConversation() {
this.conversations = [];
this.selectedConversationId = null;
}

createForm() {
this.promptForm = this.formBuilder.group({
prompt: [ '', CustomValidators.required ],
Expand Down
5 changes: 3 additions & 2 deletions src/app/courses/courses.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ <h3 class="header">
</ng-container>
<ng-container *ngTemplateOutlet="headerText"></ng-container>
<ng-template #headerText>
<a *ngIf="!isDialog && !isForm; else newTabLink" [routerLink]="['view', element._id]">{{ element.doc.courseTitle.length > 180 ? element.doc.courseTitle.slice(0, 180) + '...' : element.doc.courseTitle }}</a>
<ng-template #newTabLink><a class="cursor-pointer" (click)="openCourseViewDialog(element._id)">{{ element.doc.courseTitle.length > 180 ? element.doc.courseTitle.slice(0, 180) + '...' : element.doc.courseTitle }}</a></ng-template>
<a *ngIf="!isDialog && !isForm; else newTabLink" [routerLink]="['view', element._id]" class="break-word">{{ element.doc.courseTitle.length > 180 ? element.doc.courseTitle.slice(0, 180) + '...' : element.doc.courseTitle }}</a>
<ng-template #newTabLink><a class="cursor-pointer break-word" (click)="openCourseViewDialog(element._id)">{{ element.doc.courseTitle.length > 180 ? element.doc.courseTitle.slice(0, 180) + '...' : element.doc.courseTitle }}</a>
</ng-template>
<span *ngIf="!parent && !isDialog" [ngClass]="{ 'cursor-pointer': !isForm }">
<mat-icon class="margin-lr-3" i18n-matTooltip matTooltip="In myCourses" [inline]="true" *ngIf="element.admission" (click)="courseToggle(element._id, 'resign')">bookmark</mat-icon>
<mat-icon class="margin-lr-3" i18n-matTooltip matTooltip="Not in myCourses" [inline]="true" *ngIf="!element.admission && element.doc.steps.length" (click)="courseToggle(element._id, 'admission')">bookmark_border</mat-icon>
Expand Down
4 changes: 4 additions & 0 deletions src/app/courses/courses.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ $label-height: 1rem;
height: $toolbar-height;
}

.break-word {
word-break: break-word;
}

@media(max-width: $screen-md) {
.mat-column-info {
max-width: 120px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { dedupeObjectArray } from '../../shared/utils';
import { DialogsLoadingService } from '../../shared/dialogs/dialogs-loading.service';
import { findDocuments } from '../../shared/mangoQueries';
import { UserProfileDialogComponent } from '../../users/users-profile/users-profile-dialog.component';
import { StateService } from '../../shared/state.service';
import { DeviceInfoService, DeviceType } from '../../shared/device-info.service';

@Component({
Expand All @@ -31,6 +32,7 @@ export class CoursesProgressLeaderComponent implements OnInit, OnDestroy {
submittedExamSteps: any[] = [];
planetCodes: string[] = [];
selectedPlanetCode: string;
configuration: any = {};
deviceType: DeviceType;
deviceTypes = DeviceType;

Expand All @@ -42,6 +44,7 @@ export class CoursesProgressLeaderComponent implements OnInit, OnDestroy {
private csvService: CsvService,
private dialogsLoadingService: DialogsLoadingService,
private dialog: MatDialog,
private stateService: StateService,
private deviceInfoService: DeviceInfoService
) {
this.dialogsLoadingService.start();
Expand Down Expand Up @@ -221,23 +224,41 @@ export class CoursesProgressLeaderComponent implements OnInit, OnDestroy {
}

structureChartData(data) {
const dataArr = [];
data.forEach(element => {
const dataDict = {};
dataDict['Username'] = element.label;
for (let i = 0; i < element.items.length; i++) {
dataDict[`Step ${(i + 1)}`] = element.items[i].number;
}
return data.map(element => {
let successfulSteps = 0;
let totalSteps = 0;
let totalErrors = 0;
const steps = {};

dataArr.push(dataDict);
element.items.forEach((item, index) => {
const stepErrors = item.number || 0;
totalSteps++;
if (stepErrors === 0) {
successfulSteps++;
}
totalErrors += stepErrors;
steps[`Step ${(index + 1)}`] = stepErrors;
});

return {
'Username': element.label,
'Success Percentage': `${((successfulSteps / totalSteps) * 100).toFixed(2)}%`,
'Total Errors': totalErrors,
...steps
};
});
return dataArr;
}

exportChartData() {
const planetName = this.stateService.configuration.name;
const courseTitle = this.course.courseTitle;
const entityLabel = this.configuration.planetType === 'nation' ? 'Nation' : 'Community';
const title = $localize`${courseTitle} Course Progress for ${entityLabel} ${planetName}`;

const structuredData = this.structureChartData(this.chartData);
this.csvService.exportCSV({
data: this.structureChartData(this.chartData),
title: $localize`Course Progress Data`
data: structuredData,
title: title
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/dashboard/dashboard-tile.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#dashboardTile
>
<p [matBadge]="item.badge" [matBadgeHidden]="item.badge===0" matBadgeOverlap="false">{{item.firstLine}}</p>
<p class="dashboard-text" [ngStyle]="{ '-webkit-line-clamp': tileLines }">{{item.title | slice:0:80}}</p>
<p class="dashboard-text" [ngStyle]="{ '-webkit-line-clamp': tileLines,'word-wrap': 'break-word' }">{{item.title | slice:0:80}}</p>
<button mat-icon-button class="delete-item" (click)="removeFromShelf($event, item)" *ngIf="cardType!=='myLife' && !item?.canRemove">
<mat-icon i18n-matTooltip [matTooltip]="'Remove from ' + cardTitle" [inline]="true">clear</mat-icon>
</button>
Expand Down
2 changes: 0 additions & 2 deletions src/app/home/home-router.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { NotificationsComponent } from '../notifications/notifications.component
import { UpgradeComponent } from '../upgrade/upgrade.component';
import { UsersAchievementsComponent } from '../users/users-achievements/users-achievements.component';
import { UsersAchievementsUpdateComponent } from '../users/users-achievements/users-achievements-update.component';
import { LogsMyPlanetComponent } from '../logs-myplanet/logs-myplanet.component';
import { TeamsViewComponent } from '../teams/teams-view.component';
import { HealthListComponent } from '../health/health-list.component';
import { CommunityComponent } from '../community/community.component';
Expand Down Expand Up @@ -35,7 +34,6 @@ const routes: Routes = [
{ path: 'upgrade/myplanet', component: UpgradeComponent, data: { myPlanet: true } },
{ path: 'teams', loadChildren: () => import('../teams/teams.module').then(m => m.TeamsModule) },
{ path: 'enterprises', loadChildren: () => import('../teams/teams.module').then(m => m.TeamsModule), data: { mode: 'enterprise' } },
{ path: 'logs/myplanet', component: LogsMyPlanetComponent },
{ path: 'health', component: HealthListComponent },
{ path: 'health/profile/:id', loadChildren: () => import('../health/health.module').then(m => m.HealthModule) },
{ path: 'nation', component: TeamsViewComponent, data: { mode: 'services' } },
Expand Down
2 changes: 1 addition & 1 deletion src/app/home/home.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { UpgradeComponent } from '../upgrade/upgrade.component';
import { SharedComponentsModule } from '../shared/shared-components.module';
import { UsersAchievementsModule } from '../users/users-achievements/users-achievements.module';
import { NewsModule } from '../news/news.module';
import { LogsMyPlanetComponent } from '../logs-myplanet/logs-myplanet.component';
import { LogsMyPlanetComponent } from '../manager-dashboard/reports/logs-myplanet.component';
import { TeamsModule } from '../teams/teams.module';
import { CommunityComponent } from '../community/community.component';
import { PlanetCalendarModule } from '../shared/calendar.module';
Expand Down
2 changes: 2 additions & 0 deletions src/app/manager-dashboard/manager-dashboard-router.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ReportsDetailComponent } from './reports/reports-detail.component';
import { ReportsPendingComponent } from './reports/reports-pending.component';
import { ReportsMyPlanetComponent } from './reports/reports-myplanet.component';
import { RequestsComponent } from './requests/requests.component';
import { LogsMyPlanetComponent } from './reports/logs-myplanet.component';

const routes: Routes = [
{ path: '', component: ManagerDashboardComponent },
Expand All @@ -27,6 +28,7 @@ const routes: Routes = [
{ path: 'reports/detail', component: ReportsDetailComponent },
{ path: 'reports/pending', component: ReportsPendingComponent },
{ path: 'reports/myplanet', component: ReportsMyPlanetComponent },
{ path: 'logs/myplanet', component: LogsMyPlanetComponent },
{ path: 'requests', component: RequestsComponent }
];

Expand Down
1 change: 1 addition & 0 deletions src/app/manager-dashboard/manager-dashboard.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</ng-container>
<a *ngIf="planetType !== 'community' || isHub" [routerLink]="['reports', isHub ? { 'hubId': planetConfiguration._id } : {}]" i18n mat-raised-button>Reports</a>
<a [routerLink]="['reports', 'myplanet', isHub ? { 'hubId': planetConfiguration._id } : {}]" i18n mat-raised-button>myPlanet Reports</a>
<a [routerLink]="['logs', 'myplanet', isHub ? { 'hubId': planetConfiguration._id } : {}]" i18n mat-raised-button>myPlanet Logs</a>
<ng-container *planetAuthorizedRoles="'manager'">
<a [routerLink]="['surveys']" mat-raised-button i18n>Surveys</a>
<button *ngIf="planetType !== center && showResendConfiguration"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<mat-toolbar>
<button class="btnBack" mat-icon-button routerLink="/">
<button class="btnBack" mat-icon-button routerLink="/manager">
<mat-icon>arrow_back</mat-icon>
</button>
<span i18n>Logs</span>
Expand All @@ -13,6 +13,10 @@
<mat-toolbar>
<mat-toolbar-row class="primary-color font-size-1">
<span i18n>myPlanet</span>
<span class="toolbar-fill"></span>
<button mat-raised-button color="accent" (click)="exportAll()">
Export All
</button>
</mat-toolbar-row>
</mat-toolbar>
<div class="view-container view-full-height">
Expand All @@ -22,6 +26,9 @@
<mat-panel-title>{{planet.nameDoc?.name || planet.doc?.name}} ({{planet.children.length}})</mat-panel-title>
</mat-expansion-panel-header>
<planet-myplanet-table dataType="logs" [data]="planet.children"></planet-myplanet-table>
<button mat-raised-button color="accent" (click)="exportSingle(planet)" style="margin-right: 2rem;">
Export
</button>
</mat-expansion-panel>
</ng-container>
<ng-container *ngIf="isEmpty">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Component, OnInit } from '@angular/core';
import { CouchService } from '../shared/couchdb.service';
import { CouchService } from '../../shared/couchdb.service';
import { forkJoin } from 'rxjs';
import { StateService } from '../shared/state.service';
import { PlanetMessageService } from '../shared/planet-message.service';
import { ManagerService } from '../manager-dashboard/manager.service';
import { filterSpecificFields } from '../shared/table-helpers';
import { attachNamesToPlanets, areNoChildren } from '../manager-dashboard/reports/reports.utils';

import { StateService } from '../../shared/state.service';
import { PlanetMessageService } from '../../shared/planet-message.service';
import { ManagerService } from '../manager.service';
import { filterSpecificFields } from '../../shared/table-helpers';
import { attachNamesToPlanets, areNoChildren } from './reports.utils';
import { CsvService } from '../../shared/csv.service';

@Component({
templateUrl: './logs-myplanet.component.html'
Expand All @@ -23,6 +23,7 @@ export class LogsMyPlanetComponent implements OnInit {
}

constructor(
private csvService: CsvService,
private couchService: CouchService,
private stateService: StateService,
private planetMessageService: PlanetMessageService,
Expand Down Expand Up @@ -64,4 +65,36 @@ export class LogsMyPlanetComponent implements OnInit {
}, (error) => this.planetMessageService.showAlert($localize`There was a problem getting myPlanet activity.`));
}

private mapToCsvData(children: any[], planetName?: string): any[] {
return children.map((data: any) => ({
...(planetName ? { 'Planet Name': planetName } : {}),
'ID': data.androidId,
'Name': data.deviceName || data.customDeviceName,
'Type': data.type,
'Time': new Date(Number(data.time)),
'Version': data.version,
'Error': data.error || 'N/A',
}));
}

exportAll(): void {
const csvData: any[] = this.apklogs.flatMap((planet: any) => {
return this.mapToCsvData(planet.children, planet.name);
});

this.csvService.exportCSV({
data: csvData,
title: 'myPlanet Logs',
});
}

exportSingle(planet: any): void {
const csvData = this.mapToCsvData(planet.children);

this.csvService.exportCSV({
data: csvData,
title: `myPlanet Logs for ${planet.name}`,
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<mat-toolbar-row class="primary-color font-size-1">
<span i18n>myPlanet on { planetType, select, center {Nations} other {Communities} }</span>
<span class="toolbar-fill"></span>
<button mat-raised-button color="accent" (click)="exportAll()">
Export All
</button>
</mat-toolbar-row>
</mat-toolbar>
<div class="view-container view-full-height">
Expand All @@ -38,6 +41,9 @@
<mat-panel-title>{{planet.nameDoc?.name || planet.doc?.name}} ({{planet.children.length}})</mat-panel-title>
</mat-expansion-panel-header>
<planet-myplanet-table [data]="planet.children"></planet-myplanet-table>
<button mat-raised-button color="accent" (click)="exportSingle(planet)" style="margin-right: 2rem;">
Export
</button>
</mat-expansion-panel>
</ng-container>
<ng-container *ngIf="isEmpty">
Expand Down
Loading

0 comments on commit 1a19088

Please sign in to comment.