diff --git a/repl/appengine/web/src/app/reference_panel/reference-panel-component.spec.ts b/repl/appengine/web/src/app/reference_panel/reference-panel-component.spec.ts index a8e3677a..3289a51c 100644 --- a/repl/appengine/web/src/app/reference_panel/reference-panel-component.spec.ts +++ b/repl/appengine/web/src/app/reference_panel/reference-panel-component.spec.ts @@ -15,7 +15,11 @@ */ import { ComponentFixture, TestBed } from '@angular/core/testing'; - +import { MatButtonModule } from '@angular/material/button'; +import { MatExpansionModule } from '@angular/material/expansion'; +import { MatFormFieldModule } from '@angular/material/form-field'; +import { MatListModule } from '@angular/material/list'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { ReferencePanelComponent } from './reference-panel-component'; describe('ReferencePanelComponent', () => { @@ -24,7 +28,11 @@ describe('ReferencePanelComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ ReferencePanelComponent ] + declarations: [ ReferencePanelComponent ], + imports: [ + MatButtonModule, MatExpansionModule, MatListModule, MatFormFieldModule, + NoopAnimationsModule + ] }) .compileComponents(); diff --git a/repl/appengine/web/src/app/reference_panel/reference-panel-component.ts b/repl/appengine/web/src/app/reference_panel/reference-panel-component.ts index b1b4f977..14458ecf 100644 --- a/repl/appengine/web/src/app/reference_panel/reference-panel-component.ts +++ b/repl/appengine/web/src/app/reference_panel/reference-panel-component.ts @@ -20,8 +20,6 @@ import { ReplExampleService, Example } from '../shared/repl-example-service'; const examples = new Map([ ["hello-world", { - "description": - ``, "request": { commands: [ `"hello world!"` @@ -29,8 +27,6 @@ const examples = new Map([ } }], ["variables", { - "description": - ``, "request": { commands: [ `%let x = 10`, @@ -39,8 +35,6 @@ const examples = new Map([ } }], ["errors", { - "description": - ``, "request": { commands: [ `%let x = 0`, @@ -52,30 +46,26 @@ const examples = new Map([ } }], ["extension-functions", { - "description": - ``, "request": { commands: [ `%let string.prepend(prefix: string) : string -> prefix + this`, `"def".prepend("abc")`, - `%let exp(base: double, exponent: int) : double -> + `%let exp(base: double, exponent: int) : double -> {-2: 1.0 / base / base, -1: 1.0 / base, 0: 1.0, 1: base, - 2: base * base + 2: base * base }[exponent]`, `exp(2.0, -2) == 0.25`, ] } }], ["json", { - "description": - ``, "request": { commands: [ `%let now = timestamp("2001-01-01T00:00:01Z")`, - `%let sa_user = ""`, + `%let sa_user = "example-service"`, `{'aud': 'my-project', 'exp': now + duration('300s'), 'extra_claims': { @@ -90,8 +80,6 @@ const examples = new Map([ } }], ["macros", { - "description": - ``, "request": { commands: [ `[1, 2, 3, 4].exists(x, x > 3)`, @@ -105,7 +93,6 @@ const examples = new Map([ }], ["optionals", { - description: ``, request: { commands: [ `%option --extension "optional"`, @@ -124,7 +111,6 @@ const examples = new Map([ [ "strings", { - description: ``, request: { commands: [ `%option --extension "strings"`, @@ -138,7 +124,6 @@ const examples = new Map([ [ "math", { - description: ``, request: { commands: [ `%option --extension "math"`, @@ -151,7 +136,6 @@ const examples = new Map([ [ "bind", { - description: ``, request: { commands: [ `%option --extension "bindings"`, diff --git a/repl/appengine/web/src/app/repl_console/repl-console-component.ts b/repl/appengine/web/src/app/repl_console/repl-console-component.ts index caa18d29..d60b6048 100644 --- a/repl/appengine/web/src/app/repl_console/repl-console-component.ts +++ b/repl/appengine/web/src/app/repl_console/repl-console-component.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; import { ReplApiService, EvaluateResponse, EvaluateRequest, CommandResponse } from '../shared/repl-api-service'; import { Example, ReplExampleService } from '../shared/repl-example-service'; @@ -27,12 +27,16 @@ import { Example, ReplExampleService } from '../shared/repl-example-service'; templateUrl: './repl-console-component.html', styleUrls: ['./repl-console-component.scss'] }) -export class ReplConsoleComponent { +export class ReplConsoleComponent implements OnInit { lastEvaluate: EvaluateResponse = {responses: [], evalTime: 0}; lastRequest: EvaluateRequest = {commands: []}; - constructor (private readonly replService: ReplApiService, private readonly exampleService: ReplExampleService) { - exampleService.examplePosted$.subscribe({ + constructor ( + private readonly replService: ReplApiService, + private readonly exampleService: ReplExampleService) {} + + ngOnInit() { + this.exampleService.examplePosted$.subscribe({ next: (ex: Example) => { this.lastRequest = ex.request; this.lastEvaluate = {responses: [], evalTime: 0}; diff --git a/repl/appengine/web/src/app/shared/repl-example-service.spec.ts b/repl/appengine/web/src/app/shared/repl-example-service.spec.ts index 88054243..ced14fec 100644 --- a/repl/appengine/web/src/app/shared/repl-example-service.spec.ts +++ b/repl/appengine/web/src/app/shared/repl-example-service.spec.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 Google LLC + * + * 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 { TestBed } from '@angular/core/testing'; import { Example, ReplExampleService } from './repl-example-service'; @@ -16,7 +32,7 @@ describe('ReplExampleService', () => { it('should publish examples', () => { - let recorded_example: Example = {description: "", request: {commands: []}}; + let recorded_example: Example = {request: {commands: []}}; service.examplePosted$.subscribe({ next: (example: Example) => { @@ -24,12 +40,12 @@ describe('ReplExampleService', () => { } }); - service.postExample({description: "description", request: { + service.postExample({request: { commands: [ "%status" ] }}); - expect(recorded_example.description).toBe("description"); + expect(recorded_example.request.commands).toHaveSize(1); }); }); diff --git a/repl/appengine/web/src/app/shared/repl-example-service.ts b/repl/appengine/web/src/app/shared/repl-example-service.ts index c7c7a17b..a40b4cf2 100644 --- a/repl/appengine/web/src/app/shared/repl-example-service.ts +++ b/repl/appengine/web/src/app/shared/repl-example-service.ts @@ -1,3 +1,19 @@ +/** + * Copyright 2023 Google LLC + * + * 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 { Injectable } from '@angular/core'; import { Subject } from 'rxjs'; import { EvaluateRequest } from './repl-api-service'; @@ -6,7 +22,6 @@ import { EvaluateRequest } from './repl-api-service'; * Representation of an example REPL session. */ export declare interface Example { - description: string; request: EvaluateRequest; } diff --git a/repl/appengine/web/src/main.ts b/repl/appengine/web/src/main.ts index e04d313d..43269b49 100644 --- a/repl/appengine/web/src/main.ts +++ b/repl/appengine/web/src/main.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; +import { platformBrowser } from '@angular/platform-browser'; import { AppModule } from './app/app-module'; -platformBrowserDynamic().bootstrapModule(AppModule) +platformBrowser().bootstrapModule(AppModule) .catch(err => {console.error(err);});