Skip to content

Commit a04c2d7

Browse files
committed
add clear all pins button in the pinned view container
1 parent 57c6a47 commit a04c2d7

File tree

3 files changed

+55
-16
lines changed

3 files changed

+55
-16
lines changed

Diff for: tensorboard/webapp/metrics/views/main_view/pinned_view_component.scss

+19
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,25 @@ mat-icon {
2626
margin-right: 5px;
2727
}
2828

29+
.group-toolbar {
30+
justify-content: space-between;
31+
}
32+
33+
.left-items {
34+
display: flex;
35+
align-items: center;
36+
}
37+
38+
.right-items {
39+
button {
40+
$_height: 25px;
41+
font-size: 12px;
42+
font-weight: normal;
43+
height: $_height;
44+
line-height: $_height;
45+
}
46+
}
47+
2948
.group-text {
3049
display: flex;
3150
align-items: baseline;

Diff for: tensorboard/webapp/metrics/views/main_view/pinned_view_component.ts

+30-16
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,44 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
import {ChangeDetectionStrategy, Component, Input} from '@angular/core';
15+
import {
16+
ChangeDetectionStrategy,
17+
Component,
18+
EventEmitter,
19+
Input,
20+
Output,
21+
} from '@angular/core';
1622
import {CardObserver} from '../card_renderer/card_lazy_loader';
1723
import {CardIdWithMetadata} from '../metrics_view_types';
1824

1925
@Component({
2026
selector: 'metrics-pinned-view-component',
2127
template: `
2228
<div class="group-toolbar">
23-
<mat-icon svgIcon="keep_24px"></mat-icon>
24-
<span class="group-text">
25-
<span class="group-title" aria-role="heading" aria-level="3"
26-
>Pinned</span
27-
>
28-
<span *ngIf="cardIdsWithMetadata.length > 1" class="group-card-count"
29-
>{{ cardIdsWithMetadata.length }} cards</span
30-
>
31-
<span *ngIf="lastPinnedCardTime">
32-
<span
33-
*ngFor="let id of [lastPinnedCardTime]"
34-
[attr.data-id]="id"
35-
class="new-card-pinned"
36-
>New card pinned</span
29+
<div class="left-items">
30+
<mat-icon svgIcon="keep_24px"></mat-icon>
31+
<span class="group-text">
32+
<span class="group-title" aria-role="heading" aria-level="3"
33+
>Pinned</span
3734
>
35+
<span *ngIf="cardIdsWithMetadata.length > 1" class="group-card-count"
36+
>{{ cardIdsWithMetadata.length }} cards</span
37+
>
38+
<span *ngIf="lastPinnedCardTime">
39+
<span
40+
*ngFor="let id of [lastPinnedCardTime]"
41+
[attr.data-id]="id"
42+
class="new-card-pinned"
43+
>New card pinned</span
44+
>
45+
</span>
3846
</span>
39-
</span>
47+
</div>
48+
<div class="right-items" *ngIf="cardIdsWithMetadata.length > 0">
49+
<button mat-stroked-button (click)="onClearAllPinsClicked.emit()">
50+
Clear all pins
51+
</button>
52+
</div>
4053
</div>
4154
<metrics-card-grid
4255
*ngIf="cardIdsWithMetadata.length; else emptyPinnedView"
@@ -54,4 +67,5 @@ export class PinnedViewComponent {
5467
@Input() cardObserver!: CardObserver;
5568
@Input() cardIdsWithMetadata!: CardIdWithMetadata[];
5669
@Input() lastPinnedCardTime!: number;
70+
@Output() onClearAllPinsClicked = new EventEmitter<void>();
5771
}

Diff for: tensorboard/webapp/metrics/views/main_view/pinned_view_container.ts

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {DeepReadonly} from '../../../util/types';
2121
import {getLastPinnedCardTime, getPinnedCardsWithMetadata} from '../../store';
2222
import {CardObserver} from '../card_renderer/card_lazy_loader';
2323
import {CardIdWithMetadata} from '../metrics_view_types';
24+
import {metricsClearAllPinnedCards} from '../../actions';
2425

2526
@Component({
2627
selector: 'metrics-pinned-view',
@@ -29,6 +30,7 @@ import {CardIdWithMetadata} from '../metrics_view_types';
2930
[cardIdsWithMetadata]="cardIdsWithMetadata$ | async"
3031
[lastPinnedCardTime]="lastPinnedCardTime$ | async"
3132
[cardObserver]="cardObserver"
33+
(onClearAllPinsClicked)="onClearAllPinsClicked()"
3234
></metrics-pinned-view-component>
3335
`,
3436
changeDetection: ChangeDetectionStrategy.OnPush,
@@ -47,4 +49,8 @@ export class PinnedViewContainer {
4749
// pins after page load.
4850
skip(1)
4951
);
52+
53+
onClearAllPinsClicked() {
54+
this.store.dispatch(metricsClearAllPinnedCards());
55+
}
5056
}

0 commit comments

Comments
 (0)