Skip to content

Commit

Permalink
merget dev-0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardShan committed Nov 26, 2018
2 parents 626a4e1 + 1d3cc3e commit 7c40ac1
Show file tree
Hide file tree
Showing 30 changed files with 1,208 additions and 139 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added davinci-ui/3a2ba31570920eeb9b1d217cabe58315.ttf
Binary file not shown.
Binary file not shown.
Binary file added davinci-ui/5711de027db30bc0faf2fbe31f11a3a5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file added davinci-ui/9ec5e40edddff9ff300e6791941fe869.eot
Binary file not shown.

Large diffs are not rendered by default.

927 changes: 927 additions & 0 deletions davinci-ui/ca5d4588dad9c32f49e895e7f19479df.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added davinci-ui/de3f28fdd0af647ec0d2b1c22d845064.woff
Binary file not shown.

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,45 @@
<version>1.3.0</version>
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>


<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>2.12.0</version>
<exclusions>
<exclusion>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>
<version>2.12.0</version>
<exclusions>
<exclusion>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>

<!--oracle-->
<!--<dependency>-->
<!--<groupId>com.oracle</groupId>-->
Expand Down
3 changes: 3 additions & 0 deletions server/src/main/java/edp/DavinciServerApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@
package edp;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@EnableAutoConfiguration(exclude = {org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration.class})
public class DavinciServerApplication {

public static void main(String[] args) {
SpringApplication.run(DavinciServerApplication.class, args);
}

}

4 changes: 2 additions & 2 deletions server/src/main/java/edp/core/common/jdbc/JdbcDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ public synchronized DruidDataSource getDataSource(String jdbcUrl, String usernam
instance.setMaxWait(maxWait);
instance.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
instance.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
instance.setTestWhileIdle(testWhileIdle);
instance.setTestWhileIdle(false);
instance.setTestOnBorrow(testOnBorrow);
instance.setTestOnReturn(testOnReturn);
instance.setConnectionErrorRetryAttempts(connectionErrorRetryAttempts);
instance.setBreakAfterAcquireFailure(breakAfterAcquireFailure);

try {
instance.init();
} catch (SQLException e) {
} catch (Exception e) {
log.error("Exception during pool initialization", e);
throw new SourceException(e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public CacheManager cacheManager() {
}


@Bean
@Bean(name = "keyGenerator")
public KeyGenerator keyGenerator() {
return new KeyGenerator() {
@Override
Expand Down
3 changes: 1 addition & 2 deletions server/src/main/java/edp/core/enums/DataTypeEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ public enum DataTypeEnum {

PHOENIX("phoenix", "hbase phoenix", "org.apache.phoenix.jdbc.PhoenixDriver", "", "", "\"", "\""),

//TODO
MONGODB("mongodb", "mongodb", "mongodb.jdbc.MongoDriver", "", "", "'", "'"),
MONGODB("mongo", "mongodb", "mongodb.jdbc.MongoDriver", "`", "`", "\"", "\""),

ELASTICSEARCH("sql4es", "elasticsearch", "nl.anchormen.sql4es.jdbc.ESDriver", "", "", "'", "'"),

Expand Down
2 changes: 1 addition & 1 deletion server/src/main/java/edp/core/utils/FileUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public boolean isImage(File file) {
* @return
*/
public boolean isCsv(MultipartFile file) {
return file.getOriginalFilename().endsWith(".csv");
return file.getOriginalFilename().toLowerCase().endsWith(".csv");
}

/**
Expand Down
5 changes: 4 additions & 1 deletion server/src/main/java/edp/davinci/core/common/ResultMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import edp.core.enums.HttpCodeEnum;
import edp.core.utils.TokenUtils;
import org.springframework.util.StringUtils;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
Expand Down Expand Up @@ -112,7 +113,9 @@ public ResultMap failAndRefreshToken(HttpServletRequest request) {
this.header = new HashMap<>();
this.header.put("code", code);
this.header.put("msg", HttpCodeEnum.FAIL.getMessage());
this.header.put("token", this.tokenUtils.refreshToken(token));
if (!StringUtils.isEmpty(token)) {
this.header.put("token", this.tokenUtils.refreshToken(token));
}
this.put("header", header);
this.put("payload", "");
return this;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* <<
* Davinci
* ==
* Copyright (C) 2016 - 2018 EDP
* ==
* 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.
* >>
*
*/

package edp.davinci.core.config;

import edp.core.utils.TokenUtils;
import edp.davinci.core.common.ResultMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@ControllerAdvice(annotations = RestController.class)
public class RestExceptionHandler {


@Autowired
private TokenUtils tokenUtils;

@ExceptionHandler
@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
private ResultMap runtimeExceptionHandler(HttpServletRequest request, Exception e) {
return new ResultMap(tokenUtils).failAndRefreshToken(request).message(e.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
log.info("{} : Unknown token", request.getServletPath());
response.setStatus(HttpCodeEnum.FORBIDDEN.getCode());
response.getWriter().print("The resource requires authentication, which was not supplied with the request");
new RuntimeException("The resource requires authentication, which was not supplied with the request ");
return false;
}
String username = tokenUtils.getUsername(token);
Expand All @@ -90,15 +89,13 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
log.info("{} : token user not found", request.getServletPath());
response.setStatus(HttpCodeEnum.FORBIDDEN.getCode());
response.getWriter().print("ERROR Permission denied");
new RuntimeException("token user not found ");
return false;

}
if (!tokenUtils.validateToken(token, user)) {
log.info("{} : token validation fails", request.getServletPath());
response.setStatus(HttpCodeEnum.FORBIDDEN.getCode());
response.getWriter().print("Invalid token ");
new RuntimeException("token validation fails ");
return false;
}

Expand All @@ -111,7 +108,6 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
response.setStatus(HttpCodeEnum.FAIL.getCode());
ResultMap resultMap = new ResultMap(tokenUtils);
response.getWriter().print(JSONObject.toJSONString(resultMap.failAndRefreshToken(request).message("Account not active yet. Please check your email to activate your account")));
new RuntimeException("current user is not activated ");
return false;
}
request.setAttribute(Constants.CURRENT_USER, user);
Expand Down
3 changes: 2 additions & 1 deletion webapp/app/containers/Dashboard/components/DashboardItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export class DashboardItem extends React.PureComponent<IDashboardItemProps, IDas
itemId,
widget,
polling,
frequency,
onGetChartData,
rendered,
container
Expand All @@ -158,7 +159,7 @@ export class DashboardItem extends React.PureComponent<IDashboardItemProps, IDas
}
}

if (polling !== this.props.polling) {
if (polling !== this.props.polling || frequency !== this.props.frequency) {
this.setFrequent(nextProps)
}
}
Expand Down
66 changes: 38 additions & 28 deletions webapp/app/containers/Display/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,30 +261,34 @@ export class Editor extends React.Component<IEditorProps, IEditorStates> {

public componentWillReceiveProps (nextProps: IEditorProps) {
const { currentSlide, currentLayers } = nextProps

let { slideParams, currentLocalLayers } = this.state
let init = false
if (currentSlide !== this.props.currentSlide) {
const { slideParams } = JSON.parse(currentSlide.config)
this.setState({
slideParams
}, () => {
this.doScale(1)
})
slideParams = JSON.parse(currentSlide.config).slideParams
init = true
}
if (currentLayers !== this.props.currentLayers) {
const currentLocalLayers = fromJS(currentLayers).toJS()
this.setState({
currentLocalLayers
})
currentLocalLayers = fromJS(currentLayers).toJS()
}
this.getSettingInfo(nextProps)
const settingInfo = this.getSettingInfo(nextProps, slideParams, currentLocalLayers)
this.setState({
slideParams,
currentLocalLayers,
settingInfo
}, () => {
if (init) {
this.doScale(1)
}
})
}

private getSettingInfo = (nextProps: IEditorProps) => {
const { currentSlide, currentSelectedLayers, currentLayers } = nextProps
const { slideParams } = this.state
private getSettingInfo = (nextProps: IEditorProps, slideParams, currentLocalLayers) => {
const { currentSlide, currentSelectedLayers } = nextProps

let settingInfo = null
let settingInfo = this.state.settingInfo
if (currentSelectedLayers.length === 1) {
const selectedLayer = currentLayers.find((layer) => layer.id === currentSelectedLayers[0].id)
const selectedLayer = currentLocalLayers.find((layer) => layer.id === currentSelectedLayers[0].id)
const type = selectedLayer.subType || selectedLayer.type
const param = JSON.parse(selectedLayer['params'])
settingInfo = {
Expand All @@ -301,11 +305,7 @@ export class Editor extends React.Component<IEditorProps, IEditorStates> {
param: slideParams
}
}
if (settingInfo) {
this.setState({
settingInfo
})
}
return settingInfo
}

private containerResize = () => {
Expand Down Expand Up @@ -555,7 +555,7 @@ export class Editor extends React.Component<IEditorProps, IEditorStates> {
}

private formItemChange = (field, val) => {
const { slideParams } = this.state
const { slideParams, currentLocalLayers } = this.state

const {
currentDisplay,
Expand All @@ -565,14 +565,24 @@ export class Editor extends React.Component<IEditorProps, IEditorStates> {

if (currentSelectedLayers.length === 1) {
const selectedLayer = currentSelectedLayers[0]
const layerParams = {
const newParams = JSON.stringify({
...JSON.parse(selectedLayer['params']),
[field]: val
}
this.onEditLayers([{
...selectedLayer,
params: JSON.stringify(layerParams)
}])
})
this.setState({
currentLocalLayers: currentLocalLayers.map((layer) => (
layer.id !== selectedLayer.id ? layer
: {
...layer,
params: newParams
}
))
}, () => {
this.onEditLayers([{
...selectedLayer,
params: newParams
}])
})
} else {
const newSlideParams = {
...slideParams,
Expand Down
2 changes: 1 addition & 1 deletion webapp/app/containers/Display/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ export class Preview extends React.Component<IPreviewProps, IPreviewStates> {
const view = widget && bizlogics.find((b) => b.id === widget.viewId)
const layerId = layer.id

const { polling, frequency } = layer.params
const { polling, frequency } = JSON.parse(layer.params)
const { datasource, loading, interactId, rendered, renderType } = currentLayersInfo[layerId]

return (
Expand Down
6 changes: 4 additions & 2 deletions webapp/app/containers/Display/components/LayerItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,13 @@ export class LayerItem extends React.PureComponent<ILayerItemProps, ILayerItemSt
public componentWillUpdate (nextProps: ILayerItemProps) {
const {
polling,
frequency,
layer
} = nextProps
if (layer.type !== GraphTypes.Chart) {
return
}
if (polling !== this.props.polling) {
if (polling !== this.props.polling || frequency !== this.props.frequency) {
this.setFrequent(nextProps)
}
}
Expand Down Expand Up @@ -287,6 +288,7 @@ export class LayerItem extends React.PureComponent<ILayerItemProps, ILayerItemSt
})

const layerStyle = this.getLayerStyle(layer, layerParams)
const isLoading = !pure && loading

return (
<div
Expand All @@ -305,7 +307,7 @@ export class LayerItem extends React.PureComponent<ILayerItemProps, ILayerItemSt
(<Widget
{...widgetProps}
data={data || []}
loading={loading}
loading={isLoading}
renderType={renderType}
model={model}
/>)
Expand Down
Loading

0 comments on commit 7c40ac1

Please sign in to comment.