Changes in / [2025810:6b0fbbe]


Ignore:
Location:
src/Clients/Angular/finki-chattery/src
Files:
8 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • src/Clients/Angular/finki-chattery/src/app/core/services/auth.service.ts

    r2025810 r6b0fbbe  
    11import { Injectable } from '@angular/core';
    2 import { User, UserManager } from 'oidc-client';
     2import { User, UserManager, WebStorageStateStore } from 'oidc-client';
    33import { Observable, of } from 'rxjs';
    44
     
    1919    post_logout_redirect_uri: window.location.origin,
    2020    filterProtocolClaims: true,
    21     loadUserInfo: true
     21    loadUserInfo: true,
     22    userStore: new WebStorageStateStore({ store: window.localStorage })
    2223  });
    2324
     
    5455
    5556  public isStudent(): boolean {
    56     return this.user !== null && this.user.userType === ApplicationUserType.Student;
     57    return this.user?.userType === ApplicationUserType.Student;
    5758  }
    5859
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.effects.ts

    r2025810 r6b0fbbe  
    3939      switchMap((action) => {
    4040        return this.api.get<QuestionStateResponse>(`v1/questions/${action.questionUid}`).pipe(
    41           switchMap((state) => [
    42             new GetQuestionStateSuccess(QuestionMapper.ToQuestionStateViewModel(state, this.translate)),
    43             new EffectFinishedWorking()
    44           ]),
     41          switchMap((state) => [new GetQuestionStateSuccess(QuestionMapper.ToQuestionStateViewModel(state)), new EffectFinishedWorking()]),
    4542          catchError((err) => [new EffectFinishedWorkingError(err)])
    4643        );
  • src/Clients/Angular/finki-chattery/src/app/core/state/question-state/question.mapper.ts

    r2025810 r6b0fbbe  
    1313} from 'src/app/shared-app/models';
    1414import { TranslateFromJsonService } from 'src/app/shared-app/services';
    15 import { PreviewQuestionResponse, QuestionStateResponse } from './question-state.models';
     15import { PreviewQuestionCategoryResponse, PreviewQuestionResponse, QuestionStateResponse } from './question-state.models';
    1616
    1717export class QuestionMapper {
    18   public static ToQuestionStateViewModel(
    19     questionStateResponse: QuestionStateResponse,
    20     translate: TranslateFromJsonService
    21   ): QuestionStateViewModel {
     18  public static ToQuestionStateViewModel(questionStateResponse: QuestionStateResponse): QuestionStateViewModel {
    2219    let answers: AnswerQuestionStateViewModel[] = [];
    2320
     
    6158
    6259    if (questionStateResponse.categoriesResponse.length > 0) {
    63       categories = questionStateResponse.categoriesResponse.map(
    64         (x) => new QuestionCategoryQuestionStateViewModel(x.uid, x.name, translate.instant(x.name))
    65       );
     60      categories = questionStateResponse.categoriesResponse.map((x) => new QuestionCategoryQuestionStateViewModel(x.uid, x.name));
    6661    }
    6762
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/components.ts

    r2025810 r6b0fbbe  
    33import { FormErrorComponent } from './generic/form-error/form-error.component';
    44import { HeaderComponent } from './generic/header/header.component';
    5 import { TextEditorComponent } from './generic/text-editor/text-editor.component';
    65import { VoteComponent } from './generic/vote/vote.component';
    76import { AskQuestionSharedComponent } from './question/ask-question-shared/ask-question-shared.component';
    87import { PreviewQuestionDisplayComponent } from './question/preview-question-display/preview-question-display.component';
    9 import { PreviewQuestionFullComponent } from './question/preview-question-full/preview-question-full.component';
    108import { QuestionPreviewComponent } from './question/question-preview/question-preview.component';
    119import { SearchQuestionComponent } from './question/search-question/search-question.component';
     
    2220  SearchQuestionComponent,
    2321  PreviewQuestionDisplayComponent,
    24   AskQuestionSharedComponent,
    25   PreviewQuestionFullComponent,
    26   TextEditorComponent
     22  AskQuestionSharedComponent
    2723];
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/ask-question-shared/ask-question-shared.component.html

    r2025810 r6b0fbbe  
    1 <mat-horizontal-stepper linear #stepper>
    2   <mat-step [stepControl]="questionFormGroup">
    3     <ng-template matStepLabel>{{ 'ask-question-stepper-ask' | translate }}</ng-template>
    4     <form [formGroup]="questionFormGroup">
    5       <mat-form-field class="full-width margin-bottom-sm" appearance="fill" appHandleInputFormErrors>
    6         <mat-label>{{ 'ask-question-question-title' | translate }}</mat-label>
    7         <input matInput [formControl]="titleForm" />
    8       </mat-form-field>
     1<form [formGroup]="questionFormGroup">
     2  <mat-form-field class="full-width margin-bottom-sm" appearance="fill" appHandleInputFormErrors>
     3    <mat-label>{{ 'ask-question-question-title' | translate }}</mat-label>
     4    <input matInput [formControl]="titleForm" />
     5  </mat-form-field>
    96
    10       <app-text-editor [textForm]="textForm"></app-text-editor>
     7  <editor
     8    matInput
     9    class="margin-bottom-sm"
     10    [formControl]="textForm"
     11    [init]="{
     12      apiKey: 'fx28x0d64jeufa35u7mcd80fgveayg5c4ap9gnr6posehzny',
     13      menubar: false,
     14      plugins: [
     15        'advlist autolink lists link image charmap print preview anchor',
     16        'searchreplace visualblocks code fullscreen',
     17        'insertdatetime media table paste code help wordcount'
     18      ],
     19      toolbar:
     20        'undo redo | formatselect | bold italic backcolor | code | \
     21        alignleft aligncenter alignright alignjustify | \
     22        bullist numlist outdent indent | removeformat | help'
     23    }"
     24  ></editor>
     25  <mat-error *ngIf="textForm?.touched && textForm?.errors?.required">{{ 'not-found' | translate }}</mat-error>
     26  <mat-error *ngIf="textForm?.touched && textForm?.errors?.maxlength">{{
     27    'error-message-max-length' | translate: { maxlength: textForm?.errors?.maxlength?.requiredLength }
     28  }}</mat-error>
    1129
    12       <mat-form-field class="full-width margin-bottom-sm" appearance="fill" appHandleInputFormErrors>
    13         <mat-label>{{ 'ask-question-categories' | translate }}</mat-label>
    14         <mat-select [formControl]="categoriesForm" multiple>
    15           <mat-option *ngFor="let category of categoriesList$ | async" [value]="category">{{ category.translatedName }}</mat-option>
    16         </mat-select>
    17       </mat-form-field>
     30  <mat-form-field class="full-width margin-bottom-sm" appearance="fill" appHandleInputFormErrors>
     31    <mat-label>{{ 'ask-question-categories' | translate }}</mat-label>
     32    <mat-select [formControl]="categoriesForm" multiple>
     33      <mat-option *ngFor="let category of categoriesList$ | async" [value]="category.uid">{{ category.translatedName }}</mat-option>
     34    </mat-select>
     35  </mat-form-field>
    1836
    19       <button mat-button [disabled]="questionFormGroup.invalid" matStepperNext>
    20         {{ 'ask-question-ask-button-preview' | translate }}
    21       </button>
    22     </form>
    23   </mat-step>
    24   <mat-step>
    25     <ng-template matStepLabel>{{ 'ask-question-stepper-preview' | translate }}</ng-template>
    26     <app-preview-question-full [question]="previewQuestion"></app-preview-question-full>
    27     <div>
    28       <button class="margin-y-xs" mat-button [disabled]="questionFormGroup.invalid" matStepperPrevious>
    29         {{ 'ask-question-ask-button-back' | translate }}
    30       </button>
    31       <app-button
    32         class="margin-y-xs"
    33         [disabled]="questionFormGroup.invalid"
    34         [buttonType]="ButtonType.CallToAction"
    35         (action)="askQuestionEmit()"
    36       >
    37         {{ 'ask-question-ask-button' | translate }}
    38       </app-button>
    39     </div>
    40   </mat-step>
    41 </mat-horizontal-stepper>
     37  <app-button [disabled]="questionFormGroup.invalid" [buttonType]="ButtonType.CallToAction" (action)="askQuestionEmit()">
     38    {{ 'ask-question-ask-button' | translate }}
     39  </app-button>
     40</form>
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/ask-question-shared/ask-question-shared.component.scss

    r2025810 r6b0fbbe  
    1 ::ng-deep .mat-horizontal-content-container {
    2   padding: 0 !important;
    3 }
    4 
    5 ::ng-deep mat-card {
    6   margin: 5px !important;
    7 }
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/ask-question-shared/ask-question-shared.component.ts

    r2025810 r6b0fbbe  
    11import { Component, EventEmitter, OnInit, Output } from '@angular/core';
    22import { FormControl, FormGroup, Validators } from '@angular/forms';
    3 import * as moment from 'moment';
    43
    54import { CategoryFacadeService } from 'src/app/core/state/category-facade.service';
    65import { ButtonType } from 'src/app/shared-app/components/generic/button/button.models';
    7 import {
    8   AskQuestionRequest,
    9   QuestionCategoryQuestionStateViewModel,
    10   QuestionStateViewModel,
    11   StudentQuestionStateViewModel
    12 } from 'src/app/shared-app/models';
     6import { AskQuestionRequest } from 'src/app/shared-app/models';
    137
    148@Component({
     
    1913export class AskQuestionSharedComponent implements OnInit {
    2014  @Output() askQuestion = new EventEmitter<AskQuestionRequest>();
    21 
    22   public previewQuestion?: QuestionStateViewModel;
    2315
    2416  public titleForm = new FormControl('', [Validators.required, Validators.maxLength(500)]);
     
    3729  }
    3830
    39   ngOnInit(): void {
    40     this.questionFormGroup.valueChanges.subscribe((x) => {
    41       const student = new StudentQuestionStateViewModel('', '', '', 0);
    42       const categories = this.categoriesForm.value.map(
    43         (category: any) => new QuestionCategoryQuestionStateViewModel('', category.name, category.translatedName)
    44       );
    45 
    46       this.previewQuestion = new QuestionStateViewModel(
    47         '',
    48         this.titleForm.value,
    49         this.textForm.value,
    50         moment(),
    51         0,
    52         moment(),
    53         student,
    54         [],
    55         categories,
    56         null
    57       );
    58     });
    59   }
     31  ngOnInit(): void {}
    6032
    6133  public askQuestionEmit(): void {
    62     this.askQuestion.emit(
    63       new AskQuestionRequest(
    64         this.titleForm.value,
    65         this.textForm.value,
    66         this.categoriesForm.value.map((x: any) => x.uid)
    67       )
    68     );
     34    this.askQuestion.emit(new AskQuestionRequest(this.titleForm.value, this.textForm.value, this.categoriesForm.value));
    6935  }
    7036}
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/question-preview/question-preview.component.html

    r2025810 r6b0fbbe  
    11<div *ngIf="!working">
    2   <div class="margin-bottom-xl">
    3     <app-preview-question-full [question]="question"></app-preview-question-full>
    4   </div>
     2  <mat-card appHoverElevation class="margin-bottom-xl">
     3    <mat-card-title>{{ question.title }}</mat-card-title>
     4    <mat-card-subtitle
     5      [innerHTML]="
     6        'question-preview-subtitle'
     7          | translate
     8            : {
     9                createdOn: question.createdOn | momentDate: 'LLLL',
     10                lastActive: question.lastActiveOn | momentDate: 'LLLL',
     11                views: question.views
     12              }
     13      "
     14    ></mat-card-subtitle>
     15    <mat-card-content>
     16      <mat-chip-list>
     17        <mat-chip *ngFor="let category of question.categories">
     18          {{ category.name }}
     19        </mat-chip>
     20      </mat-chip-list>
     21
     22      <editor
     23        class="margin-x-sm"
     24        [init]="{
     25          apiKey: 'fx28x0d64jeufa35u7mcd80fgveayg5c4ap9gnr6posehzny',
     26          menubar: false,
     27          plugins: ['autoresize'],
     28          toolbar: ''
     29        }"
     30        [disabled]="true"
     31        [initialValue]="question.text"
     32      ></editor>
     33      <div class="align-right">
     34        <app-student-card
     35          [indexNumber]="question.student.index"
     36          [imageUrl]="question.student.imageUrl"
     37          [uid]="question.student.uid"
     38          [reputation]="question.student.reputation"
     39          [subtitle]="'question-asked-by-subtitle' | translate: { date: question.createdOn | momentDate: 'LL' }"
     40        ></app-student-card>
     41      </div>
     42    </mat-card-content>
     43    <mat-card-actions>
     44      <app-button appShareLink [buttonType]="ButtonType.Basic">{{ 'share-link' | translate }}</app-button>
     45    </mat-card-actions>
     46  </mat-card>
    547
    648  <h1 class="mat-headline">{{ 'question-answers' | translate: { answerCount: question.answers.length } }}</h1>
     
    1658          <app-vote [voteCount]="answer.upvotesCount" [correct]="answer.correctAnswer" fxFlex="6%"></app-vote>
    1759          <div fxFlex="92%">
    18             <app-text-editor
    19               [text]="answer.text"
    20               [configuration]="{
     60            <editor
     61              class="margin-x-sm"
     62              [init]="{
     63                apiKey: 'fx28x0d64jeufa35u7mcd80fgveayg5c4ap9gnr6posehzny',
    2164                menubar: false,
    2265                plugins: ['autoresize'],
    2366                toolbar: ''
    2467              }"
    25               [readonly]="true"
    26             ></app-text-editor>
     68              [disabled]="true"
     69              [initialValue]="answer.text"
     70            ></editor>
    2771            <div class="align-right">
    2872              <app-student-card
  • src/Clients/Angular/finki-chattery/src/app/shared-app/components/question/student-card/student-card.component.ts

    r2025810 r6b0fbbe  
    99  @Input() imageUrl: string | undefined;
    1010  @Input() indexNumber: string | undefined;
    11   @Input() uid?: string;
     11  @Input() uid!: string;
    1212  @Input() reputation: number | undefined;
    1313  @Input() subtitle: string | undefined;
  • src/Clients/Angular/finki-chattery/src/app/shared-app/models/question-state-view-models.models.ts

    r2025810 r6b0fbbe  
    2323
    2424export class QuestionCategoryQuestionStateViewModel {
    25   constructor(public uid: string, public name: string, public translatedName: string) {}
     25  constructor(public uid: string, public name: string) {}
    2626}
    2727
  • src/Clients/Angular/finki-chattery/src/app/shared-material/shared-material.module.ts

    r2025810 r6b0fbbe  
    2424import { MatButtonToggleModule } from '@angular/material/button-toggle';
    2525import { MatBadgeModule } from '@angular/material/badge';
    26 import { MatStepperModule } from '@angular/material/stepper';
    2726
    2827@NgModule({
     
    5049    MatTooltipModule,
    5150    MatButtonToggleModule,
    52     MatBadgeModule,
    53     MatStepperModule
     51    MatBadgeModule
    5452  ],
    5553  exports: [
     
    7573    MatTooltipModule,
    7674    MatButtonToggleModule,
    77     MatBadgeModule,
    78     MatStepperModule
     75    MatBadgeModule
    7976  ]
    8077})
  • src/Clients/Angular/finki-chattery/src/assets/translations/en.json

    r2025810 r6b0fbbe  
    4747  "ask-question-question-title": "Question title",
    4848  "ask-question-categories": "Add categories to question",
    49   "ask-question-ask-button-preview": "Preview question",
     49  "ask-question-ask-button": "Ask question",
    5050  "header-logout": "Logout",
    51   "header-ask-question": "Ask question",
    52   "ask-question-stepper-preview": "Preview question",
    53   "ask-question-stepper-ask": "Ask question",
    54   "ask-question-ask-button-back": "Edit question",
    55   "ask-question-ask-button": "Ask question"
     51  "header-ask-question": "Ask question"
    5652}
Note: See TracChangeset for help on using the changeset viewer.