2023-01-15 13:14:48 +02:00
|
|
|
<!--
|
|
|
|
|
|
2023-02-10 16:17:12 +02:00
|
|
|
Copyright © 2016-2023 The Thingsboard Authors
|
2023-01-15 13:14:48 +02:00
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
|
limitations under the License.
|
|
|
|
|
|
|
|
|
|
-->
|
|
|
|
|
|
2023-02-28 15:04:03 +02:00
|
|
|
<div [formGroup]="alarmCommentFormGroup" class="tb-alarm-comments" fxLayout="column">
|
|
|
|
|
<div class="tb-alarm-comments-header" fxLayout="row" fxLayoutAlign="space-between baseline">
|
|
|
|
|
<span *ngIf="commentsHeaderEnabled" class="tb-alarm-comments-header-title">
|
|
|
|
|
{{ 'alarm-comment.comments' | translate }}
|
|
|
|
|
</span>
|
|
|
|
|
<div style="margin-left: auto">
|
2023-02-10 16:17:12 +02:00
|
|
|
<button mat-icon-button
|
|
|
|
|
type="button"
|
|
|
|
|
(click)="changeSortDirection()"
|
|
|
|
|
matTooltip="{{ 'alarm-comment.sort-direction' | translate }}"
|
|
|
|
|
matTooltipPosition="above">
|
|
|
|
|
<mat-icon class="material-icons">{{ getSortDirectionIcon() }}</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
<button mat-icon-button
|
|
|
|
|
type="button"
|
|
|
|
|
(click)="loadAlarmComments()"
|
|
|
|
|
matTooltip="{{ 'alarm-comment.refresh' | translate }}"
|
|
|
|
|
matTooltipPosition="above">
|
|
|
|
|
<mat-icon class="material-icons">refresh</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2023-01-15 13:14:48 +02:00
|
|
|
</div>
|
|
|
|
|
<div fxLayout="column" fxLayoutGap="32px">
|
2023-02-10 16:17:12 +02:00
|
|
|
<ng-container *ngIf="isDirectionDescending()">
|
|
|
|
|
<ng-container *ngTemplateOutlet="commentInput"></ng-container>
|
|
|
|
|
</ng-container>
|
2023-03-01 17:19:58 +02:00
|
|
|
<div fxFlex *ngFor="let displayDataElement of displayData; index as i">
|
2023-01-15 13:14:48 +02:00
|
|
|
<div style="margin-left: 38px"
|
|
|
|
|
*ngIf="displayDataElement.isSystemComment; else userComment">
|
|
|
|
|
<span class="tb-alarm-comments-system-text"
|
|
|
|
|
style="margin-right: 8px">
|
|
|
|
|
{{ displayDataElement.commentText }}
|
|
|
|
|
</span>
|
|
|
|
|
<span class="tb-alarm-comments-time">
|
|
|
|
|
{{ displayDataElement.createdDateAgo }}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<ng-template #userComment>
|
|
|
|
|
<div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px"
|
|
|
|
|
*ngIf="!displayDataElement.edit; else commentEditing"
|
|
|
|
|
(mouseenter)="onCommentMouseEnter(displayDataElement.commentId, i)"
|
|
|
|
|
(mouseleave)="onCommentMouseLeave(i)">
|
|
|
|
|
<div fxLayout="row" fxLayoutAlign="center center" fxFlexAlign="start"
|
|
|
|
|
class="tb-alarm-comments-user-avatar"
|
|
|
|
|
[style.background-color]="displayDataElement.avatarBgColor">
|
|
|
|
|
{{ getUserInitials(displayDataElement.displayName) }}
|
|
|
|
|
</div>
|
|
|
|
|
<div fxFlex fxLayout="column" fxLayoutGap="5px">
|
|
|
|
|
<div fxLayout="row" fxLayoutGap="8px" fxLayoutAlign="start center">
|
|
|
|
|
<span class="tb-alarm-comments-user-name">{{ displayDataElement.displayName }}</span>
|
|
|
|
|
<span class="tb-alarm-comments-time" *ngIf="displayDataElement.isEdited">
|
|
|
|
|
edited {{ displayDataElement.editedDateAgo }}
|
|
|
|
|
</span>
|
|
|
|
|
<span class="tb-alarm-comments-time" *ngIf="!displayDataElement.isEdited">
|
|
|
|
|
{{ displayDataElement.createdDateAgo }}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="tb-alarm-comments-text">{{ displayDataElement.commentText }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div fxLayout="row" class="tb-alarm-comments-action-buttons"
|
|
|
|
|
[ngClass]="{ 'show-buttons': displayDataElement.showActions }">
|
2023-03-01 17:19:58 +02:00
|
|
|
<button mat-icon-button
|
2023-01-15 13:14:48 +02:00
|
|
|
type="button"
|
|
|
|
|
(click)="editComment(displayDataElement.commentId)">
|
|
|
|
|
<mat-icon class="material-icons">edit</mat-icon>
|
|
|
|
|
</button>
|
2023-03-01 17:19:58 +02:00
|
|
|
<button mat-icon-button
|
2023-01-15 13:14:48 +02:00
|
|
|
type="button"
|
|
|
|
|
(click)="deleteComment(displayDataElement.commentId)">
|
|
|
|
|
<mat-icon class="material-icons">delete</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<ng-template #commentEditing>
|
|
|
|
|
<div fxLayoutAlign="row center" fxLayoutGap="8px">
|
|
|
|
|
<div fxLayout="row" fxLayoutAlign="center center"
|
|
|
|
|
class="tb-alarm-comments-user-avatar"
|
|
|
|
|
[style.background-color]="displayDataElement.avatarBgColor">
|
|
|
|
|
{{ getUserInitials(displayDataElement.displayName) }}
|
|
|
|
|
</div>
|
2023-03-01 17:19:58 +02:00
|
|
|
<mat-form-field fxFlex appearance="fill" class="mat-block">
|
2023-01-15 13:14:48 +02:00
|
|
|
<textarea matInput
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="{{ 'alarm-comment.add' | translate }}"
|
|
|
|
|
cdkTextareaAutosize
|
|
|
|
|
cdkAutosizeMinRows="1"
|
|
|
|
|
cols="1"
|
|
|
|
|
formControlName="alarmCommentEdit"
|
|
|
|
|
(keyup.enter)="saveEditedComment(displayDataElement.commentId)"
|
|
|
|
|
(keydown.enter)="$event.preventDefault()">
|
|
|
|
|
</textarea>
|
|
|
|
|
<div matSuffix fxLayout="row">
|
|
|
|
|
<button mat-icon-button
|
|
|
|
|
(click)="cancelEdit(displayDataElement.commentId)"
|
|
|
|
|
type="button">
|
|
|
|
|
<mat-icon class="material-icons red-button">close</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
<button mat-icon-button
|
|
|
|
|
type="button"
|
|
|
|
|
(click)="saveEditedComment(displayDataElement.commentId)">
|
|
|
|
|
<mat-icon class="material-icons green-button">check</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</div>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</ng-template>
|
|
|
|
|
</div>
|
2023-02-10 16:17:12 +02:00
|
|
|
<ng-container *ngIf="isDirectionAscending()">
|
|
|
|
|
<ng-container *ngTemplateOutlet="commentInput"></ng-container>
|
|
|
|
|
</ng-container>
|
2023-01-15 13:14:48 +02:00
|
|
|
</div>
|
2023-02-10 16:17:12 +02:00
|
|
|
<ng-template #commentInput>
|
|
|
|
|
<div fxLayout="row" fxLayoutAlign="start center" fxLayoutGap="8px" fxFlex>
|
|
|
|
|
<div fxLayout="row" fxLayoutAlign="center center"
|
|
|
|
|
class="tb-alarm-comments-user-avatar"
|
|
|
|
|
*ngIf="userDisplayName$ | async; let userDisplayName"
|
|
|
|
|
[style.background-color]="getCurrentUserBgColor(userDisplayName)">
|
|
|
|
|
{{ getUserInitials(userDisplayName) }}
|
|
|
|
|
</div>
|
2023-03-01 17:19:58 +02:00
|
|
|
<mat-form-field appearance="fill" fxFlex class="mat-block">
|
2023-01-15 13:14:48 +02:00
|
|
|
<textarea matInput
|
|
|
|
|
type="text"
|
|
|
|
|
placeholder="{{ 'alarm-comment.add' | translate }}"
|
|
|
|
|
cdkTextareaAutosize
|
|
|
|
|
cdkAutosizeMinRows="1"
|
|
|
|
|
cols="1"
|
|
|
|
|
formControlName="alarmComment"
|
|
|
|
|
(keyup.enter)="saveComment()"
|
|
|
|
|
(keydown.enter)="$event.preventDefault()">
|
|
|
|
|
</textarea>
|
2023-03-01 17:19:58 +02:00
|
|
|
<button mat-icon-button
|
2023-02-10 16:17:12 +02:00
|
|
|
type="button"
|
|
|
|
|
matSuffix
|
|
|
|
|
*ngIf="getAlarmCommentFormControl().value"
|
|
|
|
|
(click)="saveComment()">
|
|
|
|
|
<mat-icon color="primary">
|
|
|
|
|
send
|
|
|
|
|
</mat-icon>
|
|
|
|
|
</button>
|
|
|
|
|
</mat-form-field>
|
|
|
|
|
</div>
|
|
|
|
|
</ng-template>
|
2023-01-15 13:14:48 +02:00
|
|
|
</div>
|