This is an automated email from the ASF dual-hosted git repository.

ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git


The following commit(s) were added to refs/heads/master by this push:
     new 962a65d766 TP Allow Change Logs to be "expanded" to see the whole 
message. (#7087)
962a65d766 is described below

commit 962a65d7669b58da68361b19fc3f747667c260df
Author: Steve Hamrick <[email protected]>
AuthorDate: Tue Oct 11 16:14:40 2022 -0600

    TP Allow Change Logs to be "expanded" to see the whole message. (#7087)
    
    * Allow expanding of change log
    
    * Add changelog
    
    * Fix lint & license
    
    * Fix license
    
    * Remove un-needed method
---
 CHANGELOG.md                                       |  1 +
 .../core/change-logs/change-logs.component.html    |  2 ++
 .../app/core/change-logs/change-logs.component.ts  | 35 +++++++++++++++++-
 .../dialogs/text-dialog/text-dialog.component.html | 19 ++++++++++
 .../dialogs/text-dialog/text-dialog.component.scss | 13 +++++++
 .../text-dialog/text-dialog.component.spec.ts      | 40 +++++++++++++++++++++
 .../dialogs/text-dialog/text-dialog.component.ts   | 42 ++++++++++++++++++++++
 .../traffic-portal/src/app/shared/shared.module.ts |  4 ++-
 .../table/changeLogs/TableChangeLogsController.js  | 38 +++++++++++++++++++-
 .../table/changeLogs/table.changeLogs.tpl.html     |  2 +-
 10 files changed, 192 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index cddf67f49f..48dfa74cd7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -12,6 +12,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
 - [#7063](https://github.com/apache/trafficcontrol/pull/7063) *Traffic Ops* 
Added API version 5.0 (IN DEVELOPMENT)
 - [#7023](https://github.com/apache/trafficcontrol/pull/7023) *Traffic Ops* 
Added the `ASN` field in TO Server struct, which provides the ability to query 
servers by `ASN`.
 - [#2101](https://github.com/apache/trafficcontrol/issues/2101) *Traffic 
Portal* Added the ability to tell if a Delivery Service is the target of 
another steering DS.
+- [#6021](https://github.com/apache/trafficcontrol/issues/6021) *Traffic 
Portal* Added the ability to view a change logs message in it's entirety by 
clicking on it.
 - [#6033](https://github.com/apache/trafficcontrol/issues/6033) *Traffic Ops, 
Traffic Portal* Added ability to assign multiple server capabilities to a 
server.
 - [#7032](https://github.com/apache/trafficcontrol/issues/7032) *Cache Config* 
Add t3c-apply flag to use local ATS version for config generation rather than 
Server package Parameter, to allow managing the ATS OS package via external 
tools. See 'man t3c-apply' and 'man t3c-generate' for details.
 - [#7097](https://github.com/apache/trafficcontrol/issues/7097) *Traffic Ops, 
Traffic Portal* Added the `regional` field to Delivery Services, which 
indicates whether `maxOriginConnections` should be per Cache Group
diff --git 
a/experimental/traffic-portal/src/app/core/change-logs/change-logs.component.html
 
b/experimental/traffic-portal/src/app/core/change-logs/change-logs.component.html
index f5be561e04..e9bd224cff 100644
--- 
a/experimental/traffic-portal/src/app/core/change-logs/change-logs.component.html
+++ 
b/experimental/traffic-portal/src/app/core/change-logs/change-logs.component.html
@@ -19,9 +19,11 @@ limitations under the License.
        <tp-generic-table
                [data]="changeLogs | async"
                [cols]="columnDefs"
+               [contextMenuItems]="contextMenuOptions"
                [fuzzySearch]="fuzzySubj"
                [tableTitleButtons]="titleBtns"
                (tableTitleButtonAction)="handleTitleButton($event)"
+               (contextMenuAction)="handleContextMenu($event)"
                context="change-logs">
        </tp-generic-table>
 
diff --git 
a/experimental/traffic-portal/src/app/core/change-logs/change-logs.component.ts 
b/experimental/traffic-portal/src/app/core/change-logs/change-logs.component.ts
index 0595bd9480..939bb2738a 100644
--- 
a/experimental/traffic-portal/src/app/core/change-logs/change-logs.component.ts
+++ 
b/experimental/traffic-portal/src/app/core/change-logs/change-logs.component.ts
@@ -21,7 +21,12 @@ import { Log } from "trafficops-types";
 
 import { ChangeLogsService } from "src/app/api/change-logs.service";
 import { LastDaysComponent } from 
"src/app/core/change-logs/last-days/last-days.component";
-import { TableTitleButton } from 
"src/app/shared/generic-table/generic-table.component";
+import { TextDialogComponent } from 
"src/app/shared/dialogs/text-dialog/text-dialog.component";
+import {
+       ContextMenuActionEvent,
+       ContextMenuItem,
+       TableTitleButton
+} from "src/app/shared/generic-table/generic-table.component";
 import { TpHeaderService } from "src/app/shared/tp-header/tp-header.service";
 import { relativeTimeString } from "src/app/utils";
 
@@ -73,6 +78,13 @@ export class ChangeLogsComponent implements OnInit {
                }
        ];
 
+       public contextMenuOptions: Array<ContextMenuItem<AugmentedChangeLog>> = 
[
+               {
+                       action: "viewChangeLog",
+                       name: "Expand Log"
+               }
+       ];
+
        public columnDefs: Array<ColDef> = [
                {
                        field: "relativeTime",
@@ -134,6 +146,27 @@ export class ChangeLogsComponent implements OnInit {
                await this.loadData();
        }
 
+       /**
+        * handles when a context menu event is emitted
+        *
+        * @param action which button was pressed
+        */
+       public async handleContextMenu(action: 
ContextMenuActionEvent<AugmentedChangeLog>): Promise<void> {
+               switch (action.action) {
+                       case "viewChangeLog":
+                               let changeLog: AugmentedChangeLog;
+                               if (Array.isArray(action.data)) {
+                                       changeLog = action.data[0];
+                               } else {
+                                       changeLog = action.data;
+                               }
+                               this.dialog.open(TextDialogComponent, {
+                                       data: {message: changeLog.message, 
title: `Change Log for ${changeLog.user}`}
+                               });
+                               break;
+               }
+       }
+
        /**
         * handles when a title button is event is emitted
         *
diff --git 
a/experimental/traffic-portal/src/app/shared/dialogs/text-dialog/text-dialog.component.html
 
b/experimental/traffic-portal/src/app/shared/dialogs/text-dialog/text-dialog.component.html
new file mode 100644
index 0000000000..3cbb124de0
--- /dev/null
+++ 
b/experimental/traffic-portal/src/app/shared/dialogs/text-dialog/text-dialog.component.html
@@ -0,0 +1,19 @@
+<!--
+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.
+-->
+
+<h2 mat-dialog-title>{{dialogData.title}}</h2>
+<mat-dialog-content>{{dialogData.message}}</mat-dialog-content>
+<mat-dialog-actions>
+       <button mat-button mat-dialog-close>Ok</button>
+</mat-dialog-actions>
diff --git 
a/experimental/traffic-portal/src/app/shared/dialogs/text-dialog/text-dialog.component.scss
 
b/experimental/traffic-portal/src/app/shared/dialogs/text-dialog/text-dialog.component.scss
new file mode 100644
index 0000000000..ebe77042d3
--- /dev/null
+++ 
b/experimental/traffic-portal/src/app/shared/dialogs/text-dialog/text-dialog.component.scss
@@ -0,0 +1,13 @@
+/*
+* 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.
+*/
diff --git 
a/experimental/traffic-portal/src/app/shared/dialogs/text-dialog/text-dialog.component.spec.ts
 
b/experimental/traffic-portal/src/app/shared/dialogs/text-dialog/text-dialog.component.spec.ts
new file mode 100644
index 0000000000..64988602cc
--- /dev/null
+++ 
b/experimental/traffic-portal/src/app/shared/dialogs/text-dialog/text-dialog.component.spec.ts
@@ -0,0 +1,40 @@
+/*
+* 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.
+*/
+
+import { ComponentFixture, TestBed } from "@angular/core/testing";
+import { MAT_DIALOG_DATA } from "@angular/material/dialog";
+
+import { TextDialogComponent } from "./text-dialog.component";
+
+describe("TextDialogComponent", () => {
+       let component: TextDialogComponent;
+       let fixture: ComponentFixture<TextDialogComponent>;
+
+       beforeEach(async () => {
+               await TestBed.configureTestingModule({
+                       declarations: [TextDialogComponent],
+                       providers: [
+                               {provide: MAT_DIALOG_DATA, useValue: {message: 
"", title: ""}}]
+               })
+                       .compileComponents();
+
+               fixture = TestBed.createComponent(TextDialogComponent);
+               component = fixture.componentInstance;
+               fixture.detectChanges();
+       });
+
+       it("should create", () => {
+               expect(component).toBeTruthy();
+       });
+});
diff --git 
a/experimental/traffic-portal/src/app/shared/dialogs/text-dialog/text-dialog.component.ts
 
b/experimental/traffic-portal/src/app/shared/dialogs/text-dialog/text-dialog.component.ts
new file mode 100644
index 0000000000..1ebdd84376
--- /dev/null
+++ 
b/experimental/traffic-portal/src/app/shared/dialogs/text-dialog/text-dialog.component.ts
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+import { Component, Inject } from "@angular/core";
+import { MAT_DIALOG_DATA } from "@angular/material/dialog";
+
+/**
+ * Contains the structure of the data the TextDialogComponent expects
+ */
+export interface TextDialogData {
+       title: string;
+       message: string;
+}
+
+/**
+ * TextDialogComponent contains code for displaying a simple text mat-dialog.
+ */
+@Component({
+       selector: "tp-text-dialog",
+       styleUrls: ["./text-dialog.component.scss"],
+       templateUrl: "./text-dialog.component.html"
+})
+export class TextDialogComponent {
+
+       constructor(@Inject(MAT_DIALOG_DATA) public readonly dialogData: 
TextDialogData) {
+       }
+}
diff --git a/experimental/traffic-portal/src/app/shared/shared.module.ts 
b/experimental/traffic-portal/src/app/shared/shared.module.ts
index 518c1c2628..649bd4e441 100644
--- a/experimental/traffic-portal/src/app/shared/shared.module.ts
+++ b/experimental/traffic-portal/src/app/shared/shared.module.ts
@@ -23,6 +23,7 @@ import { AlertComponent } from "./alert/alert.component";
 import { AlertService } from "./alert/alert.service";
 import { LinechartDirective } from "./charts/linechart.directive";
 import { CurrentUserService } from "./currentUser/current-user.service";
+import { TextDialogComponent } from 
"./dialogs/text-dialog/text-dialog.component";
 import { GenericTableComponent } from 
"./generic-table/generic-table.component";
 import { AlertInterceptor } from "./interceptor/alerts.interceptor";
 import { ErrorInterceptor } from "./interceptor/error.interceptor";
@@ -54,7 +55,8 @@ import { CustomvalidityDirective } from 
"./validation/customvalidity.directive";
                EmailCellRendererComponent,
                TelephoneCellRendererComponent,
                ObscuredTextInputComponent,
-               TreeSelectComponent
+               TreeSelectComponent,
+               TextDialogComponent
        ],
        exports: [
                AlertComponent,
diff --git 
a/traffic_portal/app/src/common/modules/table/changeLogs/TableChangeLogsController.js
 
b/traffic_portal/app/src/common/modules/table/changeLogs/TableChangeLogsController.js
index 21a5d79c23..f709d66bcd 100644
--- 
a/traffic_portal/app/src/common/modules/table/changeLogs/TableChangeLogsController.js
+++ 
b/traffic_portal/app/src/common/modules/table/changeLogs/TableChangeLogsController.js
@@ -29,6 +29,17 @@ var TableChangeLogsController = function(tableName, 
changeLogs, $scope, $state,
                }
        };
 
+       /** @type CGC.ContextMenuOption */
+       $scope.contextMenuOptions = [
+               {
+                       text: "Expand Log",
+                       onClick: function(row) {
+                               showDialog(row);
+                       },
+                       type: 1
+               }
+       ]
+
        /** @type CGC.ColumnDefinition */
        $scope.columns = [
                {
@@ -71,7 +82,32 @@ var TableChangeLogsController = function(tableName, 
changeLogs, $scope, $state,
                });
 
        /** @type CGC.GridSettings */
-       $scope.gridOptions = {};
+       $scope.gridOptions = {
+               onRowClick(event) {
+                       showDialog(event.data);
+               }
+       };
+
+       const showDialog = (row) => {
+               const params = {
+                       title: "Change Log for " + row.user,
+                       message: row.message
+               };
+               $uibModal.open({
+                       templateUrl: 
"common/modules/dialog/text/dialog.text.tpl.html",
+                       controller: "DialogTextController",
+                       size: "md",
+                       resolve: {
+                               params: function() {
+                                       return params;
+                               },
+                               text: function() {
+                                       return null;
+                               }
+                       }
+               });
+
+       }
 
        /** Allows the user to change the number of days queried for change 
logs. */
        $scope.changeDays = function() {
diff --git 
a/traffic_portal/app/src/common/modules/table/changeLogs/table.changeLogs.tpl.html
 
b/traffic_portal/app/src/common/modules/table/changeLogs/table.changeLogs.tpl.html
index 08756edfa0..ca14d07a50 100644
--- 
a/traffic_portal/app/src/common/modules/table/changeLogs/table.changeLogs.tpl.html
+++ 
b/traffic_portal/app/src/common/modules/table/changeLogs/table.changeLogs.tpl.html
@@ -19,5 +19,5 @@ under the License.
 
 <div class="x_panel">
     <common-grid-controller table-title="Change Logs" table-name="changeLogs" 
options="gridOptions" data="changeLogs"
-                            columns="columns" 
title-button="titleButton"></common-grid-controller>
+                            columns="columns" 
context-menu-options="contextMenuOptions" 
title-button="titleButton"></common-grid-controller>
 </div>

Reply via email to