Answer requests for user data with EcompUser items supplied by Portal.
Drop the DashboardUser model and mock data.
Revise front-end to use new data type and show loginId in table.
Move creation of user mgr bean to new standalone admin config classes.
Change-Id: I4e4cf76296724456540db9c627ed1c37721dca75
Signed-off-by: Lott, Christopher (cl778h) <cl778h@att.com>
RIC Dashboard Release Notes
===========================
-Version 1.2.4, 10 Oct 2019
+Version 1.2.4, 18 Oct 2019
--------------------------
* Revise a1-med-client to use API spec in new submodule ric-plt/a1;
removed cached copy
removed cached copy
* Add Platform page showing Kubernetes pods in aux and platform obtained from CAAS-Ingress
* Update Angular libraries to recent stable versions
+* Revise user controller to answer data sent by portal, drop the mock implementation
Version 1.2.3, 4 Oct 2019
-------------------------
* limitations under the License.
* ========================LICENSE_END===================================
*/
-package org.oransc.ric.portal.dashboard.portalapi;
+package org.oransc.ric.portal.dashboard;
import java.io.File;
import java.io.IOException;
import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
import org.onap.portalsdk.core.restful.domain.EcompRole;
import org.onap.portalsdk.core.restful.domain.EcompUser;
-import org.oransc.ric.portal.dashboard.DashboardConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
/**
- * Provides user-management services.
+ * Provides simple user-management services.
*
* This first implementation serializes user details to a file.
*
}
}
+ /**
+ * Gets the current users.
+ *
+ * @return List of EcompUser objects, possibly empty
+ */
+ public List<EcompUser> getUsers() {
+ return this.users;
+ }
+
/**
* Gets the user with the specified login Id
*
--- /dev/null
+/*-
+ * ========================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===================================
+ */
+package org.oransc.ric.portal.dashboard.config;
+
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+
+import org.oransc.ric.portal.dashboard.DashboardUserManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+/**
+ * Creates an instance of the user manager.
+ */
+@Configuration
+@Profile("!test")
+public class AdminConfiguration {
+
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ // Populated by the autowired constructor
+ private final String userfile;
+
+ @Autowired
+ public AdminConfiguration(@Value("${userfile}") final String userfile) {
+ logger.debug("ctor userfile '{}'", userfile);
+ this.userfile = userfile;
+ }
+
+ @Bean
+ // The bean (method) name must be globally unique
+ public DashboardUserManager userManager() throws IOException {
+ return new DashboardUserManager(userfile);
+ }
+
+}
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.web.util.DefaultUriBuilderFactory;
/**
* Creates instances of CAAS-Ingres clients.
*/
-@org.springframework.context.annotation.Configuration
+@Configuration
@Profile("!test")
public class CaasIngressConfiguration {
import java.lang.reflect.InvocationTargetException;
import org.onap.portalsdk.core.onboarding.util.PortalApiConstants;
+import org.oransc.ric.portal.dashboard.DashboardUserManager;
import org.oransc.ric.portal.dashboard.controller.A1MediatorController;
import org.oransc.ric.portal.dashboard.controller.AdminController;
import org.oransc.ric.portal.dashboard.controller.AnrXappController;
import org.oransc.ric.portal.dashboard.controller.AppManagerController;
import org.oransc.ric.portal.dashboard.controller.E2ManagerController;
import org.oransc.ric.portal.dashboard.controller.SimpleErrorController;
-import org.oransc.ric.portal.dashboard.portalapi.DashboardUserManager;
import org.oransc.ric.portal.dashboard.portalapi.PortalAuthManager;
import org.oransc.ric.portal.dashboard.portalapi.PortalAuthenticationFilter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
private String decryptor;
@Value("${portalapi.usercookie}")
private String userCookie;
- @Value("${userfile}")
- private String userFilePath;
+
+ @Autowired
+ DashboardUserManager userManager;
protected void configure(HttpSecurity http) throws Exception {
logger.debug("configure: portalapi.username {}", userName);
return new PortalAuthManager(appName, userName, password, decryptor, userCookie);
}
- @Bean
- public DashboardUserManager dashboardUserManagerBean() throws IOException {
- return new DashboardUserManager(userFilePath);
- }
-
/*
* If this is annotated with @Bean, it is created automatically AND REGISTERED,
* and Spring processes annotations in the source of the class. However, the
throws ClassNotFoundException, InstantiationException, IllegalAccessException, IOException,
IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
PortalAuthenticationFilter portalAuthenticationFilter = new PortalAuthenticationFilter(portalapiSecurity,
- portalAuthManagerBean(), dashboardUserManagerBean());
+ portalAuthManagerBean(), this.userManager);
return portalAuthenticationFilter;
}
package org.oransc.ric.portal.dashboard.controller;
import java.lang.invoke.MethodHandles;
+import java.util.List;
import javax.servlet.http.HttpServletResponse;
+import org.onap.portalsdk.core.restful.domain.EcompUser;
import org.oransc.ric.portal.dashboard.DashboardApplication;
import org.oransc.ric.portal.dashboard.DashboardConstants;
-import org.oransc.ric.portal.dashboard.model.DashboardUser;
+import org.oransc.ric.portal.dashboard.DashboardUserManager;
import org.oransc.ric.portal.dashboard.model.ErrorTransport;
import org.oransc.ric.portal.dashboard.model.IDashboardResponse;
import org.oransc.ric.portal.dashboard.model.SuccessTransport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
public static final String VERSION_METHOD = DashboardConstants.VERSION_METHOD;
public static final String XAPPMETRICS_METHOD = "metrics";
- private final DashboardUser[] users;
-
- private static final String ACTIVE = "Active";
- private static final String INACTIVE = "Inactive";
-
@Value("${metrics.url.ac}")
private String acAppMetricsUrl;
@Value("${metrics.url.mc}")
private String mcAppMetricsUrl;
+ @Autowired
+ private DashboardUserManager dashboardUserManager;
+
public AdminController() {
- // Mock data
- users = new DashboardUser[] { //
- new DashboardUser(1, "John", "Doe", ACTIVE), //
- new DashboardUser(2, "Alice", "Nolan", ACTIVE), //
- new DashboardUser(3, "Pierce", "King", INACTIVE), //
- new DashboardUser(4, "Paul", "Smith", INACTIVE), //
- new DashboardUser(5, "Jack", "Reacher", ACTIVE) };
}
@ApiOperation(value = "Gets the Dashboard MANIFEST.MF property Implementation-Version.", response = SuccessTransport.class)
return new SuccessTransport(200, "Dashboard is healthy!");
}
- @ApiOperation(value = "Gets the list of application users.", response = DashboardUser.class, responseContainer = "List")
+ @ApiOperation(value = "Gets the list of application users.", response = EcompUser.class, responseContainer = "List")
@GetMapping(USER_METHOD)
- @Secured({ DashboardConstants.ROLE_ADMIN })
- public DashboardUser[] getUsers() {
+ @Secured({ DashboardConstants.ROLE_ADMIN }) // regular users should not see this
+ public List<EcompUser> getUsers() {
logger.debug("getUsers");
- return users;
+ return dashboardUserManager.getUsers();
}
@ApiOperation(value = "Gets the kibana metrics URL for the specified app.", response = SuccessTransport.class)
@GetMapping(XAPPMETRICS_METHOD)
+ // No role required
public IDashboardResponse getAppMetricsUrl(@RequestParam String app, HttpServletResponse response) {
String metricsUrl = null;
if (DashboardConstants.APP_NAME_AC.equals(app))
return new ErrorTransport(400, "Client provided app name is invalid as: " + app);
}
}
+
}
+++ /dev/null
-/*-
- * ========================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===================================
- */
-
-/*
- * TODO: this mocks user properties until integration with ONAP Portal is done.
- */
-package org.oransc.ric.portal.dashboard.model;
-
-public class DashboardUser {
-
- private long id;
- private String firstName;
- private String lastName;
- private String status;
-
- public DashboardUser() {
- }
-
- public DashboardUser(long id, String firstName, String lastName, String status) {
- this.id = id;
- this.firstName = firstName;
- this.lastName = lastName;
- this.status = status;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getFirstName() {
- return firstName;
- }
-
- public void setFirstName(String firstName) {
- this.firstName = firstName;
- }
-
- public String getLastName() {
- return lastName;
- }
-
- public void setLastName(String lastName) {
- this.lastName = lastName;
- }
-
- public String getStatus() {
- return status;
- }
-
- public void setStatus(String status) {
- this.status = status;
- }
-
-}
import org.onap.portalsdk.core.restful.domain.EcompRole;
import org.onap.portalsdk.core.restful.domain.EcompUser;
import org.oransc.ric.portal.dashboard.DashboardConstants;
+import org.oransc.ric.portal.dashboard.DashboardUserManager;
import org.oransc.ric.portal.dashboard.model.EcompUserDetails;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.onap.portalsdk.core.onboarding.crossapi.IPortalRestCentralService;
import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
import org.onap.portalsdk.core.restful.domain.EcompUser;
+import org.oransc.ric.portal.dashboard.DashboardUserManager;
import org.oransc.ric.portal.dashboard.config.SpringContextCache;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Creates a mock implementation of the A1 mediator client API.
*/
-@Profile("test")
@Configuration
+@Profile("test")
public class A1MediatorMockConfiguration {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
--- /dev/null
+/*-
+ * ========================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===================================
+ */
+package org.oransc.ric.portal.dashboard.config;
+
+import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
+import org.onap.portalsdk.core.restful.domain.EcompRole;
+import org.onap.portalsdk.core.restful.domain.EcompUser;
+import org.oransc.ric.portal.dashboard.DashboardUserManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Profile;
+
+/**
+ * Creates a user manager with mock data.
+ */
+@Configuration
+@Profile("test")
+public class AdminMockConfiguration {
+
+ private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ @Autowired
+ public AdminMockConfiguration() {
+ }
+
+ @Bean
+ // The bean (method) name must be globally unique
+ public DashboardUserManager userManager() throws IOException, PortalAPIException {
+ logger.debug("userManager: adding mock data");
+ DashboardUserManager mgr = new DashboardUserManager(true);
+ String[] firsts = { "John", "Alice", "Pierce", "Paul", "Jack" };
+ String[] lasts = { "Doe", "Nolan", "King", "Smith", "Reacher" };
+ String[] logins = { "jdoe", "anolan", "pking", "psmith", "jreacher" };
+ boolean[] actives = { true, true, false, false, true };
+ EcompRole role = new EcompRole();
+ role.setName("view");
+ Set<EcompRole> roles = new HashSet<>();
+ roles.add(role);
+ for (int i = 0; i < firsts.length; ++i) {
+ EcompUser eu = new EcompUser();
+ eu.setFirstName(firsts[i]);
+ eu.setLastName(lasts[i]);
+ eu.setLoginId(logins[i]);
+ eu.setActive(actives[i]);
+ eu.setRoles(roles);
+ mgr.createUser(eu);
+ }
+ return mgr;
+ }
+
+}
/**
* Creates a mock implementation of the ANR xApp client APIs.
*/
-@Profile("test")
@Configuration
+@Profile("test")
public class AnrXappMockConfiguration {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
* Creates an implementation of the xApp manager client that answers requests
* with mock data.
*/
-@Profile("test")
@Configuration
+@Profile("test")
public class AppManagerMockConfiguration {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
* Creates mock implementations of Kubernetes clients that answer requests with
* sample data read from the filesystem.
*/
-@Profile("test")
@Configuration
+@Profile("test")
public class CaasIngressMockConfiguration {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
/**
* Creates a mock implementation of the E2 Manager client API.
*/
-@Profile("test")
@Configuration
+@Profile("test")
public class E2ManagerMockConfiguration {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
*/
package org.oransc.ric.portal.dashboard.config;
-import java.io.IOException;
import java.lang.invoke.MethodHandles;
-import java.util.HashSet;
-import java.util.Set;
-import org.onap.portalsdk.core.onboarding.exception.PortalAPIException;
-import org.onap.portalsdk.core.restful.domain.EcompRole;
-import org.onap.portalsdk.core.restful.domain.EcompUser;
import org.oransc.ric.portal.dashboard.DashboardConstants;
-import org.oransc.ric.portal.dashboard.portalapi.DashboardUserManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
web.ignoring().antMatchers("/", "/csrf"); // allow swagger-ui to load
}
- // This implementation is so light it can be used during tests.
- @Bean
- public DashboardUserManager dashboardUserManager() throws IOException, PortalAPIException {
- DashboardUserManager dum = new DashboardUserManager(true);
- // Mock user for convenience in testing
- EcompUser demo = new EcompUser();
- demo.setLoginId("demo");
- demo.setFirstName("Demo");
- demo.setLastName("User");
- demo.setActive(true);
- EcompRole role = new EcompRole();
- role.setName("view");
- Set<EcompRole> roles = new HashSet<>();
- roles.add(role);
- demo.setRoles(roles);
- dum.createUser(demo);
- return dum;
- }
-
}
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
+import org.onap.portalsdk.core.restful.domain.EcompUser;
import org.oransc.ric.portal.dashboard.DashboardConstants;
-import org.oransc.ric.portal.dashboard.model.DashboardUser;
import org.oransc.ric.portal.dashboard.model.ErrorTransport;
import org.oransc.ric.portal.dashboard.model.SuccessTransport;
import org.slf4j.Logger;
public void getUsersTest() {
URI uri = buildUri(null, AdminController.CONTROLLER_PATH, AdminController.USER_METHOD);
logger.info("Invoking {}", uri);
- ResponseEntity<List<DashboardUser>> response = testRestTemplateAdminRole().exchange(uri, HttpMethod.GET, null,
- new ParameterizedTypeReference<List<DashboardUser>>() {
+ ResponseEntity<List<EcompUser>> response = testRestTemplateAdminRole().exchange(uri, HttpMethod.GET, null,
+ new ParameterizedTypeReference<List<EcompUser>>() {
});
Assertions.assertFalse(response.getBody().isEmpty());
}
public void auxTest() {
final String nsAux = "ricaux";
URI uri = buildUri(null, CaasIngressController.CONTROLLER_PATH, CaasIngressController.PODS_METHOD,
- CaasIngressController.PP_CLUSTER, CaasIngressController.CLUSTER_AUX, CaasIngressController.PP_NAMESPACE, nsAux);
+ CaasIngressController.PP_CLUSTER, CaasIngressController.CLUSTER_AUX, CaasIngressController.PP_NAMESPACE,
+ nsAux);
logger.info("Invoking {}", uri);
String s = testRestTemplateStandardRole().getForObject(uri, String.class);
Assertions.assertFalse(s.isEmpty());
public void pltTest() {
final String nsPlt = "ricplt";
URI uri = buildUri(null, CaasIngressController.CONTROLLER_PATH, CaasIngressController.PODS_METHOD,
- CaasIngressController.PP_CLUSTER, CaasIngressController.CLUSTER_PLT, CaasIngressController.PP_NAMESPACE, nsPlt);
+ CaasIngressController.PP_CLUSTER, CaasIngressController.CLUSTER_PLT, CaasIngressController.PP_NAMESPACE,
+ nsPlt);
logger.info("Invoking {}", uri);
String s = testRestTemplateStandardRole().getForObject(uri, String.class);
Assertions.assertFalse(s.isEmpty());
* 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.
data: string;
}
-export interface DashboardUser {
+export interface EcompRoleFunction {
+ name: string;
+ code: string;
+ type: string;
+ action: string;
+}
+
+export interface EcompRole {
id: number;
- firstName: string;
- lastName: string;
- status: string;
+ name: string;
+ [position: number]: EcompRoleFunction;
+}
+
+export interface EcompUser {
+ orgId?: number;
+ managerId?: string;
+ firstName?: string;
+ middleInitial?: string;
+ lastName?: string;
+ phone?: string;
+ email?: string;
+ hrid?: string;
+ orgUserId?: string;
+ orgCode?: string;
+ orgManagerUserId?: string;
+ jobTitle?: string;
+ loginId: string;
+ active: boolean;
+ [position: number]: EcompRole;
}
* 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.
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
-import { DashboardSuccessTransport, DashboardUser } from '../../interfaces/dashboard.types';
+import { DashboardSuccessTransport, EcompUser } from '../../interfaces/dashboard.types';
@Injectable({
providedIn: 'root'
/**
* Gets Dashboard users
- * @returns Observable that should yield a DashboardUser array
+ * @returns Observable that should yield a EcompUser array
*/
- getUsers(): Observable<DashboardUser[]> {
- return this.httpClient.get<DashboardUser[]>(this.basePath + 'user');
+ getUsers(): Observable<EcompUser[]> {
+ return this.httpClient.get<EcompUser[]>(this.basePath + 'user');
}
}
</div>
<table mat-table [dataSource]="dataSource" matSort class="user-table mat-elevation-z8">
- <ng-container matColumnDef="id">
- <mat-header-cell *matHeaderCellDef mat-sort-header> ID </mat-header-cell>
- <mat-cell *matCellDef="let element"> {{element.id}} </mat-cell>
+ <ng-container matColumnDef="loginId">
+ <mat-header-cell *matHeaderCellDef mat-sort-header> Login ID </mat-header-cell>
+ <mat-cell *matCellDef="let element"> {{element.loginId}} </mat-cell>
</ng-container>
<ng-container matColumnDef="firstName">
<mat-cell *matCellDef="let element"> {{element.lastName}} </mat-cell>
</ng-container>
- <ng-container matColumnDef="status">
- <mat-header-cell *matHeaderCellDef mat-sort-header> Status </mat-header-cell>
- <mat-cell *matCellDef="let element"> {{element.status}} </mat-cell>
+ <ng-container matColumnDef="active">
+ <mat-header-cell *matHeaderCellDef mat-sort-header> Active? </mat-header-cell>
+ <mat-cell *matCellDef="let element"> {{element.active}} </mat-cell>
</ng-container>
<ng-container matColumnDef="action">
* 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.
import { MatSort } from '@angular/material/sort';
import { DashboardService } from '../services/dashboard/dashboard.service';
import { ErrorDialogService } from '../services/ui/error-dialog.service';
-import { DashboardUser } from './../interfaces/dashboard.types';
+import { EcompUser } from './../interfaces/dashboard.types';
import { NotificationService } from './../services/ui/notification.service';
import { UserDataSource } from './user.datasource';
import { AddDashboardUserDialogComponent } from './add-dashboard-user-dialog/add-dashboard-user-dialog.component';
export class UserComponent implements OnInit {
- displayedColumns: string[] = ['id', 'firstName', 'lastName', 'status', 'action'];
+ displayedColumns: string[] = ['loginId', 'firstName', 'lastName', 'active', 'action'];
dataSource: UserDataSource;
@ViewChild(MatSort, {static: true}) sort: MatSort;
this.dataSource.loadTable();
}
- editUser(user: DashboardUser) {
+ editUser(user: EcompUser) {
const dialogRef = this.dialog.open(EditDashboardUserDialogComponent, {
width: '450px',
data: user
* 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.
import { merge } from 'rxjs';
import { of } from 'rxjs/observable/of';
import { catchError, finalize, map } from 'rxjs/operators';
-import { DashboardUser } from '../interfaces/dashboard.types';
+import { EcompUser } from '../interfaces/dashboard.types';
import { DashboardService } from '../services/dashboard/dashboard.service';
import { NotificationService } from '../services/ui/notification.service';
-export class UserDataSource extends DataSource<DashboardUser> {
+export class UserDataSource extends DataSource<EcompUser> {
- private userSubject = new BehaviorSubject<DashboardUser[]>([]);
+ private userSubject = new BehaviorSubject<EcompUser[]>([]);
private loadingSubject = new BehaviorSubject<boolean>(false);
}),
finalize(() => this.loadingSubject.next(false))
)
- .subscribe( (users: DashboardUser[]) => {
+ .subscribe( (users: EcompUser[]) => {
this.rowCount = users.length;
this.userSubject.next(users);
});
}
- connect(collectionViewer: CollectionViewer): Observable<DashboardUser[]> {
+ connect(collectionViewer: CollectionViewer): Observable<EcompUser[]> {
const dataMutations = [
this.userSubject.asObservable(),
this.sort.sortChange
this.loadingSubject.complete();
}
- private getSortedData(data: DashboardUser[]) {
+ private getSortedData(data: EcompUser[]) {
if (!this.sort.active || this.sort.direction === '') {
return data;
}
- return data.sort((a: DashboardUser, b: DashboardUser) => {
+ return data.sort((a: EcompUser, b: EcompUser) => {
const isAsc = this.sort.direction === 'asc';
switch (this.sort.active) {
- case 'id': return this.compare(a.id, b.id, isAsc);
+ case 'loginId': return this.compare(a.loginId, b.loginId, isAsc);
case 'firstName': return this.compare(a.firstName, b.firstName, isAsc);
case 'lastName': return this.compare(a.lastName, b.lastName, isAsc);
- case 'status': return this.compare(a.status, b.status, isAsc);
+ case 'active': return this.compare(a.active, b.active, isAsc);
default: return 0;
}
});