Merge pull request #2570 from dataease/pr@dev@fix_panel-mobile

fix: 修复导入有移动端布局的仪表板时,列表中没有及时显示移动端标识
This commit is contained in:
王嘉豪 2022-07-04 17:05:26 +08:00 committed by GitHub
commit 87907beff3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -372,6 +372,7 @@ public class PanelGroupService {
String templateData = null; String templateData = null;
String dynamicData = null; String dynamicData = null;
String staticResource = null; String staticResource = null;
Boolean mobileLayout = false;
if (PanelConstants.NEW_PANEL_FROM.NEW.equals(newFrom)) { if (PanelConstants.NEW_PANEL_FROM.NEW.equals(newFrom)) {
// do nothing // do nothing
} else { } else {
@ -381,11 +382,13 @@ public class PanelGroupService {
templateStyle = panelTemplate.getTemplateStyle(); templateStyle = panelTemplate.getTemplateStyle();
templateData = panelTemplate.getTemplateData(); templateData = panelTemplate.getTemplateData();
dynamicData = panelTemplate.getDynamicData(); dynamicData = panelTemplate.getDynamicData();
mobileLayout = panelViewService.havaMobileLayout(templateData);
} else if (PanelConstants.NEW_PANEL_FROM.NEW_OUTER_TEMPLATE.equals(newFrom)) { } else if (PanelConstants.NEW_PANEL_FROM.NEW_OUTER_TEMPLATE.equals(newFrom)) {
templateStyle = request.getPanelStyle(); templateStyle = request.getPanelStyle();
templateData = request.getPanelData(); templateData = request.getPanelData();
dynamicData = request.getDynamicData(); dynamicData = request.getDynamicData();
staticResource = request.getStaticResource(); staticResource = request.getStaticResource();
mobileLayout = panelViewService.havaMobileLayout(templateData);
} }
Map<String, String> dynamicDataMap = gson.fromJson(dynamicData, Map.class); Map<String, String> dynamicDataMap = gson.fromJson(dynamicData, Map.class);
List<PanelViewInsertDTO> panelViews = new ArrayList<>(); List<PanelViewInsertDTO> panelViews = new ArrayList<>();
@ -418,6 +421,7 @@ public class PanelGroupService {
request.setId(newPanelId); request.setId(newPanelId);
request.setCreateTime(System.currentTimeMillis()); request.setCreateTime(System.currentTimeMillis());
request.setCreateBy(AuthUtils.getUser().getUsername()); request.setCreateBy(AuthUtils.getUser().getUsername());
request.setMobileLayout(mobileLayout);
return newPanelId; return newPanelId;
} }

View File

@ -133,6 +133,21 @@ public class PanelViewService {
return viewIds; return viewIds;
} }
public Boolean havaMobileLayout(String panelData){
Boolean mobileLayout = false;
if (StringUtils.isNotEmpty(panelData)) {
JsonArray dataArray = JsonParser.parseString(panelData).getAsJsonArray();
for (int i = 0; i < dataArray.size(); i++) {
JsonObject jsonObject = dataArray.get(i).getAsJsonObject();
if (jsonObject.get("mobileSelected") != null && jsonObject.get("mobileSelected").getAsBoolean()) {
mobileLayout = true;
}
}
}
return mobileLayout;
}
public List<PanelViewTableDTO> detailList(String panelId) { public List<PanelViewTableDTO> detailList(String panelId) {
return extPanelViewMapper.getPanelViewDetails(panelId); return extPanelViewMapper.getPanelViewDetails(panelId);
} }