Skip to content

Commit

Permalink
Fix dashboard URLs direct accessing issue and Modified URL patterns (#…
Browse files Browse the repository at this point in the history
…732)

* Add required APIs to fix dashboard URLs direct accessing issue

In order to fix direct accessing issue, it is required to have these APIs. Since we are changing the URL patterns, changed web context root path parameter as well.

* Fix URLs direct accessing issue and Modify URL patterns

Modified URLs of the TESTGRID dashboard pages and fixed the direct accessing issue of those pages. Further added bootstrap styling for pages and fixed issues which are related to displaying info on infra combination page. Further fixed formatting issues as well.

* Fix minor issues

Added requested changes from PR review and fixed some minor issues

* Add a new line at the end of file

Some js files has missed new line at the end of the file. Hence added it for missed js files

* Modify response error messages and logging messages

* Add correct Jenkins URLs

* Use two spaces for indentation in all javascript files
  • Loading branch information
lasanthaDLPDS authored and kasunbg committed May 4, 2018
1 parent 784969b commit 3ad18fb
Show file tree
Hide file tree
Showing 25 changed files with 1,501 additions and 1,392 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TestGrid strengthens the positioning of WSO2 products and adds major value to th
Currently, we only have a crude list that simply detail names and descriptions though. [3]

------------------------
Current TestGrid-Live dashboard can be found here - https://testgrid-live.private.wso2.com/testgrid/dashboard/
Current TestGrid-Live dashboard can be found here - https://testgrid-live.private.wso2.com/

Once we have the TestGrid beta,
* You will find the TestGrid home page here - https://testgrid.wso2.com
Expand Down
52 changes: 46 additions & 6 deletions web/src/main/java/org/wso2/testgrid/web/api/ProductService.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ public Response getAllProductStatuses() {
try {
for (Product product : productUOW.getProducts()) {
ProductStatus status = new ProductStatus();
status.setId(product.getId());
status.setName(StringUtil.concatStrings(product.getName()));
status.setProductId(product.getId());
status.setProductName(product.getName());
status.setLastfailed(APIUtil.getTestPlanBean(testPlanUOW.getLastFailure(product), false));
status.setLastBuild(APIUtil.getTestPlanBean(testPlanUOW.getLastBuild(product), false));
status.setStatus(testPlanUOW.getCurrentStatus(product).toString());
status.setProductStatus(testPlanUOW.getCurrentStatus(product).toString());
list.add(status);
}
} catch (TestGridDAOException e) {
Expand All @@ -138,6 +138,46 @@ public Response getAllProductStatuses() {
return Response.status(Response.Status.OK).entity(list).build();
}

/**
* This method returns the product if the requested product name exists in the TestGrid.
*
* <p> The product is returned as a json response with the last build information and
* the last failed build information<p/>
*
* @return product
*/
@GET
@Path("/product-status/{productName}")
public Response getProductStatus(
@PathParam("productName") String productName) {
try {
TestPlanUOW testPlanUOW = new TestPlanUOW();
ProductUOW productUOW = new ProductUOW();
ProductStatus productStatus = new ProductStatus();
Optional<Product> productInstance = productUOW.getProduct(productName);
Product product;
if (productInstance.isPresent()) {
product = productInstance.get();
productStatus.setProductId(product.getId());
productStatus.setProductName(product.getName());
productStatus.setLastfailed(APIUtil.getTestPlanBean(testPlanUOW.getLastFailure(product), false));
productStatus.setLastBuild(APIUtil.getTestPlanBean(testPlanUOW.getLastBuild(product), false));
productStatus.setProductStatus(testPlanUOW.getCurrentStatus(product).toString());
} else {
String msg = "Could not found the product:" + productName + " in TestGrid. Please check the "
+ "infrastructure_parameter table";
logger.error(msg);
return Response.status(Response.Status.NOT_FOUND).entity(msg).build();
}
return Response.status(Response.Status.OK).entity(productStatus).build();
} catch (TestGridDAOException e) {
String msg = "Error occurred while fetching the statuses of the product: " + productName + ". Please "
+ "check the database configurations";
logger.error(msg, e);
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(msg).build();
}
}

/**
* This method is able to get the latest report of a given product from the remote storage and return.
* <p>
Expand All @@ -149,9 +189,9 @@ public Response getAllProductStatuses() {
@Path("/reports")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public Response getProductReport(
@QueryParam("product-name") String productName,
@DefaultValue("false") @QueryParam("show-success") Boolean showSuccess,
@DefaultValue("SCENARIO") @QueryParam("group-by") String groupBy) {
@QueryParam("product-name") String productName,
@DefaultValue("false") @QueryParam("show-success") Boolean showSuccess,
@DefaultValue("SCENARIO") @QueryParam("group-by") String groupBy) {
try {
ProductUOW productUOW = new ProductUOW();
Optional<Product> productInstance = productUOW.getProduct(productName);
Expand Down
88 changes: 44 additions & 44 deletions web/src/main/java/org/wso2/testgrid/web/bean/ProductStatus.java
Original file line number Diff line number Diff line change
@@ -1,72 +1,72 @@
/*
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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.
*/
* Copyright (c) 2018, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you 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.
*/
package org.wso2.testgrid.web.bean;

/**
* Bean class for Aggregated product status reponses.
* Bean class for Aggregated product productStatus reponses.
*
* @since 1.0.0
*/
public class ProductStatus {

private String id;
private String name;
private String productId;
private String productName;
private String reportLink;
private String status;
private String productStatus;
private TestPlan lastBuild;
private TestPlan lastfailed;
private String executeLink;
private String configLink;

/**
* Returns the id of the product.
* Returns the productId of the product.
*
* @return id of the product
* @return productId of the product
*/
public String getId() {
return id;
public String getProductId() {
return productId;
}

/**
* Sets the id of the product.
* Sets the productId of the product.
*
* @param id product-id
* @param productId product-productId
*/
public void setId(String id) {
this.id = id;
public void setProductId(String productId) {
this.productId = productId;
}

/**
* Returns the name of product.
* Returns the productName of product.
*
* @return product name
* @return product productName
*/
public String getName() {
return name;
public String getProductName() {
return productName;
}

/**
* Sets the name of product.
* Sets the productName of product.
*
* @param name name to set to product
* @param productName productName to set to product
*/
public void setName(String name) {
this.name = name;
public void setProductName(String productName) {
this.productName = productName;
}

/**
Expand All @@ -90,21 +90,21 @@ public void setReportLink(String reportLink) {

/**
*
* Returns the status of product.
* Returns the productStatus of product.
*
* @return the status of product
* @return the productStatus of product
*/
public String getStatus() {
return status;
public String getProductStatus() {
return productStatus;
}

/**
* Sets the status of the product.
* Sets the productStatus of the product.
*
* @param status the status of product
* @param productStatus the productStatus of product
*/
public void setStatus(String status) {
this.status = status;
public void setProductStatus(String productStatus) {
this.productStatus = productStatus;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void doFilter(ServletRequest servletRequest, ServletResponse servletRespo
} else {
httpResponse.sendRedirect(ssoLoginUrl);
}
return;
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions web/src/main/java/org/wso2/testgrid/web/utils/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Constants extends TestGridConstants {
public static final String JENKINS_CRUMB_ISSUER_URI = "/crumbIssuer/api/json";
public static final String CRUMB = "crumb";
public static final String JENKINS_CRUMB_HEADER_NAME = "Jenkins-Crumb";
public static final String WEBAPP_CONTEXT = "/testgrid/dashboard";
public static final String WEBAPP_CONTEXT = "/";

/* Terms used in Jenkins template job. */
public static final String PRODUCT_NAME = "$productName";
Expand All @@ -44,12 +44,12 @@ public class Constants extends TestGridConstants {
public static final String SCENARIOS_LOCATION = "$scenariosLocation";

/* Constants relates to SSO configurations. */
public static final String LOGIN_URI = WEBAPP_CONTEXT + "/login";
public static final String STATIC_DATA_URI = WEBAPP_CONTEXT + "/static";
public static final String ACS_URI = WEBAPP_CONTEXT + "/api/acs";
public static final String LOGIN_URI = WEBAPP_CONTEXT + "login";
public static final String STATIC_DATA_URI = WEBAPP_CONTEXT + "static";
public static final String ACS_URI = WEBAPP_CONTEXT + "api/acs";
public static final String JKS_FILE_NAME = "wso2carbon.jks";
public static final String SSO_DIRECTORY = "SSO";
public static final String BACKEND_API_URI = WEBAPP_CONTEXT + "/api/";
public static final String BACKEND_API_URI = WEBAPP_CONTEXT + "api/";

public static final String PROPERTYNAME_KEYSTORE_PASSWORD = "KeyStorePassword";
public static final String PROPERTYNAME_PRIVATE_KEY_ALIAS = "PrivateKeyAlias";
Expand Down
2 changes: 1 addition & 1 deletion web/src/main/react-dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "testgrid-dashboard",
"version": "0.1.0",
"private": true,
"homepage": "/testgrid/dashboard",
"homepage": "/",
"dependencies": {
"bootstrap": "^4.1.0",
"downloadjs": "^1.4.7",
Expand Down
54 changes: 32 additions & 22 deletions web/src/main/react-dashboard/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* under the License.
*/

import React, { Component } from 'react';
import React, {Component} from 'react';
import './App.css';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import ProductContainer from './containers/productContainer.js';
Expand All @@ -28,14 +28,14 @@ import testRunContainer from './containers/testRunContainer.js';
import Login from './components/Login.js'
import {
Route,
Switch,
Switch
} from 'react-router-dom';
import AppBar from 'material-ui/AppBar';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import {createStore} from 'redux';
import {Provider} from 'react-redux';
import testGrid from './reducers/testGrid.js';
import { persistStore, persistCombineReducers } from 'redux-persist';
import { PersistGate } from 'redux-persist/es/integration/react';
import {persistStore, persistCombineReducers} from 'redux-persist';
import {PersistGate} from 'redux-persist/es/integration/react';
import storage from 'redux-persist/es/storage';
import Drawer from 'material-ui/Drawer';
import MenuItem from 'material-ui/MenuItem';
Expand All @@ -57,41 +57,52 @@ class App extends Component {
handleClose = () => {
var b = !this.state.open;
var w = b ? 240 : 20;
this.setState({ open: b, navWidth: w });
this.setState({open: b, navWidth: w});
};

constructor(props) {
super(props);
this.baseURL = "/testgrid/dashboard"
this.state = {
open: false,
navWidth: 20
}
}

render() {
const paperStyle = { margin: '80px 20px 50px ' + this.state.navWidth + 'px' };
const paperStyle = {margin: '80px 20px 50px ' + this.state.navWidth + 'px'};
return (
<Provider store={store}>
<PersistGate
persistor={persistor}>
<MuiThemeProvider>
<div style={{ position: 'absolute', top: '0px', right: '0px', bottom: '0px', left: '0px', backgroundColor: '#EEEEEE' }}>
<div style={{
position: 'absolute',
top: '0px',
right: '0px',
bottom: '0px',
left: '0px',
backgroundColor: '#EEEEEE'
}}>
<AppBar title=" WSO2 TestGrid " style={{
backgroundColor: '#424242',position: 'fixed'}}
iconElementLeft={<IconButton onClick={this.handleClose}>{this.state.open ? <NavigationBack /> : <NevigationExpand />}</IconButton>}> </AppBar>
<Drawer open={this.state.open} containerStyle={{ 'top': '64px', backgroundColor:'#BDBDBD'}} width={200} >
<MenuItem><a href="/blue/organizations/jenkins/wso2is5.4.0LTS/activity"> TestGrid AdminPortal</a></MenuItem>
backgroundColor: '#424242', position: 'fixed'
}}
iconElementLeft={<IconButton onClick={this.handleClose}>{this.state.open ? <NavigationBack/> :
<NevigationExpand/>}</IconButton>}> </AppBar>
<Drawer open={this.state.open} containerStyle={{'top': '64px', backgroundColor: '#BDBDBD'}} width={200}>
<MenuItem><a href="/blue/organizations/jenkins/wso2is5.4.0LTS/activity"> TestGrid
AdminPortal</a></MenuItem>
</Drawer>
<Paper style={paperStyle} zDepth={2}>
<Switch>
<Route exact path = {this.baseURL + '/login'} component={Login}/>
<Route exact path = {this.baseURL + '/'} component={ProductContainer}/>
<Route exact path = {this.baseURL + '/deployments/product/:productId/'} component={DeploymentContainer} />
<Route exact path = {this.baseURL + '/testplans/history/:testplanid'} component={InfrastructureContainer} />
<Route exact path = {this.baseURL + '/scenarios/infrastructure/:infraid'} component={ScenarioContainer} />
<Route exact path = {this.baseURL + '/testcases/scenario/:scenarioid'} component={TestCaseContainer} />
<Route exact path = {this.baseURL + '/testplans/:testplanid'} component={testRunContainer}/>
<Route exact path={'/login'} component={Login}/>
<Route exact path={'/'} component={ProductContainer}/>
<Route exact path={'/:productName'} component={DeploymentContainer}/>
<Route exact path={'/:productName/:deploymentPatternName/:testPlanId/infra'}
component={InfrastructureContainer}/>
<Route exact path={'/scenarios/infrastructure/:infraid'} component={ScenarioContainer}/>
<Route exact path={'/testcases/scenario/:scenarioid'} component={TestCaseContainer}/>
<Route exact path={'/:productName/:deploymentPatternName/test-plans/:testPlanId'}
component={testRunContainer}/>
</Switch>
</ Paper>
</div>
Expand All @@ -100,7 +111,6 @@ class App extends Component {
</Provider>
);
}

}

export default App;
Loading

0 comments on commit 3ad18fb

Please sign in to comment.