Skip to content

Commit d0a6f94

Browse files
Merge pull request #7 from tensorflow/backendselector
[debugger] Add backend and version selector
2 parents c771e61 + b25fc47 commit d0a6f94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1463
-64
lines changed

toolings/tfjs-debugger/package.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,23 @@
1414
"@angular/platform-browser": "~13.0.0",
1515
"@angular/platform-browser-dynamic": "~13.0.0",
1616
"@angular/router": "~13.0.0",
17-
"@ngrx/store": "~12.5.1",
18-
"@ngrx/router-store": "~12.5.1",
19-
"@ngrx/store-devtools": "~12.5.1",
17+
"@ngrx/effects": "~13.0.2",
18+
"@ngrx/store": "~13.0.2",
19+
"@ngrx/router-store": "~13.0.2",
20+
"@ngrx/store-devtools": "~13.0.2",
21+
"dateformat": "~5.0.2",
2022
"rxjs": "~7.4.0",
2123
"tslib": "^2.3.0",
2224
"zone.js": "~0.11.4"
2325
},
2426
"peerDependencies": {},
2527
"devDependencies": {
2628
"@angular-devkit/build-angular": "~13.0.1",
29+
"@angular/animation": "~4.0.0-beta.8",
2730
"@angular/cli": "~13.0.1",
2831
"@angular/compiler-cli": "~13.0.0",
2932
"@types/jasmine": "~3.8.0",
33+
"@types/dateformat": "~5.0.0",
3034
"@types/node": "^12.11.1",
3135
"clang-format": "~1.5.0",
3236
"jasmine-core": "~3.8.0",

toolings/tfjs-debugger/src/app/app/app.component.html

+3
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,7 @@
2929
<!-- The info graph panel at the right -->
3030
<info-panel></info-panel>
3131
</div>
32+
33+
<!-- Error message panel -->
34+
<error-panel></error-panel>
3235
</div>

toolings/tfjs-debugger/src/app/app/app.component.scss

+12
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
* =============================================================================
1616
*/
1717

18+
@use '../../variables.scss' as var;
19+
20+
$error-msg-container-width: 400px;
21+
1822
.container {
23+
position: relative;
1924
display: flex;
2025
flex-direction: column;
2126
height: 100%;
@@ -26,4 +31,11 @@
2631
flex-grow: 1;
2732
overflow: hidden;
2833
}
34+
35+
error-panel {
36+
position: absolute;
37+
bottom: var.$spacing-6x;
38+
left: calc(50% - $error-msg-container-width / 2);
39+
width: $error-msg-container-width;
40+
}
2941
}

toolings/tfjs-debugger/src/app/app/app.component.spec.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
*/
1717

1818
import {TestBed} from '@angular/core/testing';
19+
import {StoreModule} from '@ngrx/store';
20+
21+
import {mainReducer} from '../store/reducers';
1922

2023
import {AppComponent} from './app.component';
2124

@@ -24,6 +27,11 @@ describe('AppComponent', () => {
2427
await TestBed
2528
.configureTestingModule({
2629
declarations: [AppComponent],
30+
imports: [
31+
StoreModule.forRoot({
32+
main: mainReducer,
33+
}),
34+
],
2735
})
2836
.compileComponents();
2937
});
@@ -33,10 +41,4 @@ describe('AppComponent', () => {
3341
const app = fixture.componentInstance;
3442
expect(app).toBeTruthy();
3543
});
36-
37-
it(`should have as title 'tfjs-debugger'`, () => {
38-
const fixture = TestBed.createComponent(AppComponent);
39-
const app = fixture.componentInstance;
40-
expect(app.title).toEqual('tfjs-debugger');
41-
});
4244
});

toolings/tfjs-debugger/src/app/app/app.component.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,25 @@
1515
* =============================================================================
1616
*/
1717

18-
import {ChangeDetectionStrategy, Component} from '@angular/core';
18+
import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
19+
import {Store} from '@ngrx/store';
20+
21+
import {fetchTfjsReleases} from '../store/actions';
22+
import {AppState} from '../store/state';
1923

2024
@Component({
2125
selector: 'app-root',
2226
templateUrl: './app.component.html',
2327
styleUrls: ['./app.component.scss'],
2428
changeDetection: ChangeDetectionStrategy.OnPush,
2529
})
26-
export class AppComponent {
27-
title = 'tfjs-debugger';
30+
export class AppComponent implements OnInit {
31+
constructor(
32+
private readonly store: Store<AppState>,
33+
) {}
34+
35+
ngOnInit() {
36+
// Start fetching TFJS releases.
37+
this.store.dispatch(fetchTfjsReleases());
38+
}
2839
}

toolings/tfjs-debugger/src/app/app/app.module.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,23 @@
1515
* =============================================================================
1616
*/
1717

18+
import {HttpClientModule} from '@angular/common/http';
1819
import {NgModule} from '@angular/core';
1920
import {BrowserModule} from '@angular/platform-browser';
2021
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
2122
import {RouterModule} from '@angular/router';
23+
import {EffectsModule} from '@ngrx/effects';
2224
import {routerReducer, StoreRouterConnectingModule} from '@ngrx/router-store';
2325
import {StoreModule} from '@ngrx/store';
2426
import {StoreDevtoolsModule} from '@ngrx/store-devtools';
2527

2628
import {AppBarModule} from '../components/app_bar/app_bar.module';
2729
import {ConfigsPanelModule} from '../components/configs_panel/configs_panel.module';
30+
import {ErrorPanelModule} from '../components/error_panel/error_panel.module';
2831
import {GraphPaneModule} from '../components/graph_panel/graph_panel.module';
2932
import {InfoPanelModule} from '../components/info_panel/info_panel.module';
30-
import {configsReducer} from '../store/reducers';
33+
import {GithubEffects} from '../store/effects';
34+
import {mainReducer} from '../store/reducers';
3135

3236
import {AppComponent} from './app.component';
3337

@@ -39,11 +43,14 @@ import {AppComponent} from './app.component';
3943
BrowserModule,
4044
BrowserAnimationsModule,
4145
ConfigsPanelModule,
46+
EffectsModule.forRoot([GithubEffects]),
47+
ErrorPanelModule,
48+
HttpClientModule,
4249
InfoPanelModule,
4350
GraphPaneModule,
4451
StoreModule.forRoot({
4552
router: routerReducer,
46-
configs: configsReducer,
53+
main: mainReducer,
4754
}),
4855
RouterModule.forRoot([
4956
{path: '', component: AppComponent},

toolings/tfjs-debugger/src/app/common/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export enum UrlParamKey {
2020
SELECTED_MODEL_TYPE_ID = 'mid',
2121
TFJS_MODEL_URL = 'tfjsmu',
2222
SELECTED_INPUT_TYPE_ID = 'iid',
23+
SELECTED_BACKEND_ID = 'bi',
24+
SELECTED_BACKEND_VERSION = 'bv',
2325
}
2426

2527
/** Valid config index. */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!-- Copyright 2021 Google LLC. All Rights Reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.
14+
==============================================================================
15+
-->
16+
17+
<div class="container">
18+
<!-- Drop down select -->
19+
<mat-form-field appearance="outline" floatLabel="never">
20+
<mat-select
21+
[(value)]="selectedBackendId"
22+
(selectionChange)="handleSelectionChange($event)">
23+
<mat-option *ngFor="let option of backends"
24+
[value]="option.id">
25+
{{option.label}}
26+
</mat-option>
27+
</mat-select>
28+
</mat-form-field>
29+
30+
<!-- Backend version selector -->
31+
<div class="extra-components-container">
32+
<div class="title">Version</div>
33+
<backend-version-selector [configIndex]="configIndex"></backend-version-selector>
34+
</div>
35+
</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC. All Rights Reserved.
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
* =============================================================================
16+
*/
17+
18+
@use '../../../variables' as var;
19+
20+
.container {
21+
mat-form-field {
22+
width: 100%;
23+
}
24+
25+
.title {
26+
margin-top: var.$spacing-1x;
27+
color: var.$grey-600;
28+
font-size: var.$font-size-smaller;
29+
line-height: 11px;
30+
}
31+
}

0 commit comments

Comments
 (0)