Changeset 6738cc0 for src/Clients


Ignore:
Timestamp:
01/19/22 19:14:27 (3 years ago)
Author:
Стојков Марко <mst@…>
Branches:
dev
Parents:
f3c4950
Message:

Added notifications

Location:
src/Clients/Angular/finki-chattery
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/Clients/Angular/finki-chattery/package-lock.json

    rf3c4950 r6738cc0  
    78017801      }
    78027802    },
     7803    "ngx-pipes": {
     7804      "version": "2.7.6",
     7805      "resolved": "https://registry.npmjs.org/ngx-pipes/-/ngx-pipes-2.7.6.tgz",
     7806      "integrity": "sha512-FAeMd1mI8jCnnrhUuNLXs+PaVT1ujhA0QD3KRBDuzGFcbnP7NMXR2EJ5KYbV39LDNuRCluhpfwZudQu/NvrVuA==",
     7807      "requires": {
     7808        "tslib": "^2.0.0"
     7809      }
     7810    },
    78037811    "ngx-toastr": {
    78047812      "version": "13.2.1",
  • src/Clients/Angular/finki-chattery/package.json

    rf3c4950 r6738cc0  
    3333    "ng2-file-upload": "^1.4.0",
    3434    "ngx-material-timepicker": "^5.5.3",
     35    "ngx-pipes": "^2.7.6",
    3536    "ngx-toastr": "^13.2.1",
    3637    "oidc-client": "^1.11.5",
  • src/Clients/Angular/finki-chattery/src/app/core/services/auth.service.ts

    rf3c4950 r6738cc0  
    107107    });
    108108  }
     109
     110  public studentCheckedNotifications(): Observable<void> {
     111    return this.baseApi.post('v1/students/checked-notifications');
     112  }
    109113}
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/generic/header/header.component.html

    rf3c4950 r6738cc0  
    1919      'header-student-questions' | translate
    2020    }}</app-button>
     21    <app-button
     22      matBadge="{{ auth.selfUser?.student?.notifications?.length }}"
     23      matBadgeHidden="{{ studentCheckedNotifications || auth.selfUser?.student?.notifications?.length === 0 }}"
     24      [matMenuTriggerFor]="notificationMenu"
     25      class="margin-y-xs"
     26      *ngIf="auth.isStudent()"
     27      (click)="studentCheckedNotificationsClick()"
     28      [buttonType]="ButtonType.Basic"
     29    >
     30      <mat-icon>notifications</mat-icon>
     31    </app-button>
    2132    <app-button class="margin-y-xs" *ngIf="auth.isLoggedIn()" (action)="logout()" [buttonType]="ButtonType.Basic">{{
    2233      'header-logout' | translate
     
    3445  </button>
    3546</mat-menu>
     47
     48<mat-menu #notificationMenu="matMenu">
     49  <div (click)="goToQuestion(q.questionUid)" mat-menu-item *ngFor="let q of auth.selfUser?.student?.notifications">
     50    {{ q?.text }} <span class="time-ago">{{ q?.createdOn | timeAgo }}</span>
     51  </div>
     52</mat-menu>
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/generic/header/header.component.scss

    rf3c4950 r6738cc0  
    1414  }
    1515}
     16
     17::ng-deep.mat-menu-panel {
     18  max-width: none !important;
     19}
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/generic/header/header.component.ts

    rf3c4950 r6738cc0  
    1111export class HeaderComponent implements OnInit {
    1212  ButtonType = ButtonType;
     13
     14  public studentCheckedNotifications = false;
    1315
    1416  constructor(public auth: AuthService, private router: Router) {}
     
    3638    this.router.navigateByUrl(`questioning/${questionUid}`);
    3739  }
     40
     41  studentCheckedNotificationsClick(): void {
     42    if (!this.studentCheckedNotifications) {
     43      this.auth.studentCheckedNotifications().subscribe();
     44    }
     45    this.studentCheckedNotifications = true;
     46  }
    3847}
  • src/Clients/Angular/finki-chattery/src/app/shared-app/models/user.models.ts

    rf3c4950 r6738cc0  
     1import * as moment from 'moment';
     2
    13export class ApplicationUser {
    24  constructor(
     
    3032  public questions!: StudentQuestionResponse[];
    3133  public teams!: StudentTeamResponse[];
     34  public notifications!: StudentNotificationResponse[];
     35}
     36
     37export class StudentNotificationResponse {
     38  public uid!: string;
     39  public createdOn!: moment.Moment;
     40  public questionUid!: string;
     41  public text!: string;
     42
     43  constructor(uid: string, createdOn: moment.Moment, questionUid: string, text: string) {
     44    this.uid = uid;
     45    this.createdOn = createdOn;
     46    this.questionUid = questionUid;
     47    this.text = text;
     48  }
    3249}
    3350
  • src/Clients/Angular/finki-chattery/src/app/shared-app/services/base-api.service.ts

    rf3c4950 r6738cc0  
    44
    55import { environment } from '@env/environment';
    6 import { SelfUserResponse } from '../models';
     6import { SelfUserResponse, StudentNotificationResponse } from '../models';
     7import { map } from 'rxjs/operators';
     8import * as moment from 'moment';
    79
    810@Injectable({
     
    1921
    2022  public getSelfUser(): Observable<SelfUserResponse> {
    21     return this.get<SelfUserResponse>('v1/self');
     23    return this.get<SelfUserResponse>('v1/self').pipe(
     24      map((x) => {
     25        if (x.student) {
     26          x.student.notifications = x.student.notifications.map(
     27            (y) => new StudentNotificationResponse(y.uid, moment(y.createdOn), y.questionUid, y.text)
     28          );
     29        }
     30
     31        return x;
     32      })
     33    );
    2234  }
    2335
  • src/Clients/Angular/finki-chattery/src/app/shared-app/shared-app.module.ts

    rf3c4950 r6738cc0  
    1414import { SERVICES } from './services/services';
    1515import { PIPES } from './pipes/pipes';
     16import { NgPipesModule } from 'ngx-pipes';
    1617
    1718@NgModule({
     
    2728    FileUploadModule,
    2829    NgxMaterialTimepickerModule,
    29     EditorModule
     30    EditorModule,
     31    NgPipesModule
    3032  ],
    3133  exports: [
     
    4143    PIPES,
    4244    SharedMaterialModule,
    43     EditorModule
     45    EditorModule,
     46    NgPipesModule
    4447  ]
    4548})
Note: See TracChangeset for help on using the changeset viewer.