From 5d7de18e40bb0da67d375d9461f9106ec3ea8e51 Mon Sep 17 00:00:00 2001 From: elinuxhenrik Date: Mon, 8 Feb 2021 15:40:38 +0100 Subject: [PATCH] Rename controlpanel.component to app.component To follow Angular naming conventions. Change-Id: I5208bfab7e025a5dd53e96080aa25b1a1397f724 Signed-off-by: elinuxhenrik Issue-ID: NONRTRIC-432 --- ...nel-routing.module.ts => app-routing.module.ts} | 2 +- webapp-frontend/src/app/app.component.html | 125 +++++++++++++++++++-- webapp-frontend/src/app/app.component.sass | 0 ...trolpanel.component.scss => app.component.scss} | 0 webapp-frontend/src/app/app.component.spec.ts | 49 +++++--- webapp-frontend/src/app/app.component.ts | 59 +++++++++- .../app/{controlpanel.module.ts => app.module.ts} | 12 +- .../src/app/controlpanel.component.html | 117 ------------------- .../src/app/controlpanel.component.spec.ts | 54 --------- webapp-frontend/src/app/controlpanel.component.ts | 57 ---------- webapp-frontend/src/main.ts | 4 +- 11 files changed, 215 insertions(+), 264 deletions(-) rename webapp-frontend/src/app/{controlpanel-routing.module.ts => app-routing.module.ts} (97%) delete mode 100644 webapp-frontend/src/app/app.component.sass rename webapp-frontend/src/app/{controlpanel.component.scss => app.component.scss} (100%) rename webapp-frontend/src/app/{controlpanel.module.ts => app.module.ts} (95%) delete mode 100644 webapp-frontend/src/app/controlpanel.component.html delete mode 100644 webapp-frontend/src/app/controlpanel.component.spec.ts delete mode 100644 webapp-frontend/src/app/controlpanel.component.ts diff --git a/webapp-frontend/src/app/controlpanel-routing.module.ts b/webapp-frontend/src/app/app-routing.module.ts similarity index 97% rename from webapp-frontend/src/app/controlpanel-routing.module.ts rename to webapp-frontend/src/app/app-routing.module.ts index 366ef9f..f94d4e4 100644 --- a/webapp-frontend/src/app/controlpanel-routing.module.ts +++ b/webapp-frontend/src/app/app-routing.module.ts @@ -42,4 +42,4 @@ const routes: Routes = [ declarations: [] }) -export class ControlpanelRoutingModule { } +export class AppRoutingModule { } diff --git a/webapp-frontend/src/app/app.component.html b/webapp-frontend/src/app/app.component.html index 838606d..494477e 100644 --- a/webapp-frontend/src/app/app.component.html +++ b/webapp-frontend/src/app/app.component.html @@ -1,8 +1,117 @@ -
-

- Welcome to {{title}}! -

- -
- - \ No newline at end of file + + + + + + + + + + +
+ +
+ +
+ + + + + + + + + Non-RT RIC Control Panel + + + +
+ +

+ +
+ Light + + Dark +
+ +
+ + +
+
+
+ +
+
+ + +
+ +
+ +
+
+
\ No newline at end of file diff --git a/webapp-frontend/src/app/app.component.sass b/webapp-frontend/src/app/app.component.sass deleted file mode 100644 index e69de29..0000000 diff --git a/webapp-frontend/src/app/controlpanel.component.scss b/webapp-frontend/src/app/app.component.scss similarity index 100% rename from webapp-frontend/src/app/controlpanel.component.scss rename to webapp-frontend/src/app/app.component.scss diff --git a/webapp-frontend/src/app/app.component.spec.ts b/webapp-frontend/src/app/app.component.spec.ts index 3e707be..24a2d6f 100644 --- a/webapp-frontend/src/app/app.component.spec.ts +++ b/webapp-frontend/src/app/app.component.spec.ts @@ -1,29 +1,52 @@ +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2019 AT&T Intellectual Property + * %% + * 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. + * ========================LICENSE_END=================================== + */ +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { TestBed, async } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; +import { CookieService } from 'ngx-cookie'; import { AppComponent } from './app.component'; +import { UiService } from './services/ui/ui.service'; describe('AppComponent', () => { beforeEach(async(() => { + const cookieSpy = jasmine.createSpyObj('CookieService', [ 'get' ]); TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], imports: [ RouterTestingModule ], - providers: [] + schemas: [ + CUSTOM_ELEMENTS_SCHEMA + ], + declarations: [ + AppComponent + ], + providers: [ + { provide: CookieService, useValue: cookieSpy }, + UiService + ] }).compileComponents(); })); - it('should create the app', async(() => { + it('should create the app', () => { const fixture = TestBed.createComponent(AppComponent); const app = fixture.debugElement.componentInstance; expect(app).toBeTruthy(); - })); - - it(`should have as title 'controlpanelApp'`, async(() => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app.title).toEqual('controlpanelApp'); - })); -}); \ No newline at end of file + }); +}); diff --git a/webapp-frontend/src/app/app.component.ts b/webapp-frontend/src/app/app.component.ts index 7115687..544f0c4 100644 --- a/webapp-frontend/src/app/app.component.ts +++ b/webapp-frontend/src/app/app.component.ts @@ -1,10 +1,57 @@ -import { Component } from '@angular/core'; +/*- + * ========================LICENSE_START================================= + * O-RAN-SC + * %% + * Copyright (C) 2019 AT&T Intellectual Property + * %% + * 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. + * ========================LICENSE_END=================================== + */ +import { Component, OnInit } from '@angular/core'; +import { UiService } from './services/ui/ui.service'; +import { CookieService } from 'ngx-cookie'; @Component({ - selector: 'app-root', + selector: 'nrcp-root', templateUrl: './app.component.html', - styleUrls: ['./app.component.sass'] + styleUrls: ['./app.component.scss'] }) -export class AppComponent { - title = 'controlpanelApp'; -} \ No newline at end of file +export class AppComponent implements OnInit { + private showMenu = false; + darkMode: boolean; + private 'DARK_MODE_COOKIE' = 'darkMode'; + + constructor(private cookieService: CookieService, private ui: UiService) { + } + + ngOnInit() { + const dark = this.cookieService.get(this.DARK_MODE_COOKIE); + if (dark) { + this.ui.darkModeState.next(dark === 'yes'); + } + + this.ui.darkModeState.subscribe((value) => { + this.darkMode = value; + }); + } + + toggleMenu() { + this.showMenu = !this.showMenu; + } + + modeToggleSwitch() { + this.ui.darkModeState.next(!this.darkMode); + this.cookieService.put(this.DARK_MODE_COOKIE, this.darkMode ? 'yes' : 'no'); + } + +} diff --git a/webapp-frontend/src/app/controlpanel.module.ts b/webapp-frontend/src/app/app.module.ts similarity index 95% rename from webapp-frontend/src/app/controlpanel.module.ts rename to webapp-frontend/src/app/app.module.ts index ea14a5d..6cfabc8 100644 --- a/webapp-frontend/src/app/controlpanel.module.ts +++ b/webapp-frontend/src/app/app.module.ts @@ -50,8 +50,8 @@ import { PolicyCardComponent } from './ui/policy-card/policy-card.component'; import { PolicyControlComponent } from './policy-control/policy-control.component'; import { PolicyInstanceComponent } from './policy-control/policy-instance.component'; import { PolicyInstanceDialogComponent } from './policy-control/policy-instance-dialog.component'; -import { ControlpanelComponent } from './controlpanel.component'; -import { ControlpanelRoutingModule } from './controlpanel-routing.module'; +import { AppComponent } from './app.component'; +import { AppRoutingModule } from './app-routing.module'; import { SidenavListComponent } from './navigation/sidenav-list/sidenav-list.component'; import { UiService } from './services/ui/ui.service'; import { CookieModule } from 'ngx-cookie'; @@ -66,8 +66,8 @@ export const isMock = environment.mock; @NgModule({ declarations: [ + AppComponent, ConfirmDialogComponent, - ControlpanelComponent, EICardComponent, EICoordinatorComponent, ErrorDialogComponent, @@ -82,10 +82,10 @@ export const isMock = environment.mock; SidenavListComponent, ], imports: [ + AppRoutingModule, BrowserModule, BrowserAnimationsModule, ChartsModule, - ControlpanelRoutingModule, CookieModule.forRoot(), FlexLayoutModule, FormsModule, @@ -153,6 +153,6 @@ export const isMock = environment.mock; multi: true } ], - bootstrap: [ControlpanelComponent] + bootstrap: [AppComponent] }) -export class ControlpanelModule { } +export class AppModule { } diff --git a/webapp-frontend/src/app/controlpanel.component.html b/webapp-frontend/src/app/controlpanel.component.html deleted file mode 100644 index 494477e..0000000 --- a/webapp-frontend/src/app/controlpanel.component.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - - - -
- -
- -
- - - - - - - - - Non-RT RIC Control Panel - - - -
- -

- -
- Light - - Dark -
- -
- - -
-
-
- -
-
- - - - -
-
-
\ No newline at end of file diff --git a/webapp-frontend/src/app/controlpanel.component.spec.ts b/webapp-frontend/src/app/controlpanel.component.spec.ts deleted file mode 100644 index 4a86e91..0000000 --- a/webapp-frontend/src/app/controlpanel.component.spec.ts +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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. - * ========================LICENSE_END=================================== - */ -import { TestBed, async } from '@angular/core/testing'; -import { RouterTestingModule } from '@angular/router/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async(() => { - TestBed.configureTestingModule({ - imports: [ - RouterTestingModule - ], - declarations: [ - AppComponent - ], - }).compileComponents(); - })); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app).toBeTruthy(); - }); - - it(`should have as title 'controlpanelApp'`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.debugElement.componentInstance; - expect(app.title).toEqual('controlpanelApp'); - }); - - it('should render title in a h1 tag', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.debugElement.nativeElement; - expect(compiled.querySelector('h1').textContent).toContain('Welcome to controlpanelApp!'); - }); -}); diff --git a/webapp-frontend/src/app/controlpanel.component.ts b/webapp-frontend/src/app/controlpanel.component.ts deleted file mode 100644 index b85d524..0000000 --- a/webapp-frontend/src/app/controlpanel.component.ts +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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. - * ========================LICENSE_END=================================== - */ -import { Component, OnInit } from '@angular/core'; -import { UiService } from './services/ui/ui.service'; -import { CookieService } from 'ngx-cookie'; - -@Component({ - selector: 'nrcp-root', - templateUrl: './controlpanel.component.html', - styleUrls: ['./controlpanel.component.scss'] -}) -export class ControlpanelComponent implements OnInit { - private showMenu = false; - private darkMode: boolean; - private 'DARK_MODE_COOKIE' = 'darkMode'; - - constructor(private cookieService: CookieService, private ui: UiService) { - } - - ngOnInit() { - const dark = this.cookieService.get(this.DARK_MODE_COOKIE); - if (dark) { - this.ui.darkModeState.next(dark === 'yes'); - } - - this.ui.darkModeState.subscribe((value) => { - this.darkMode = value; - }); - } - - toggleMenu() { - this.showMenu = !this.showMenu; - } - - modeToggleSwitch() { - this.ui.darkModeState.next(!this.darkMode); - this.cookieService.put(this.DARK_MODE_COOKIE, this.darkMode ? 'yes' : 'no'); - } - -} diff --git a/webapp-frontend/src/main.ts b/webapp-frontend/src/main.ts index 8aaa09a..7b06452 100644 --- a/webapp-frontend/src/main.ts +++ b/webapp-frontend/src/main.ts @@ -21,12 +21,12 @@ import { enableProdMode } from '@angular/core'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; -import { ControlpanelModule } from './app/controlpanel.module'; +import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; if (environment.production) { enableProdMode(); } -platformBrowserDynamic().bootstrapModule(ControlpanelModule) +platformBrowserDynamic().bootstrapModule(AppModule) .catch(err => console.error(err)); -- 2.16.6