forked from github/dataease
commit
a6ca784dfc
@ -24,6 +24,8 @@ import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import static io.dataease.commons.constants.StaticResourceConstants.UPLOAD_URL_PREFIX;
|
||||
|
||||
/**
|
||||
* Author: wangjiahao
|
||||
* Date: 2021-03-05
|
||||
@ -80,6 +82,9 @@ public class PanelTemplateService {
|
||||
}
|
||||
//Store static resource into the server
|
||||
staticResourceService.saveFilesToServe(request.getStaticResource());
|
||||
String snapshotName = "template-" + request.getId() + ".jpeg";
|
||||
staticResourceService.saveSingleFileToServe(snapshotName,request.getSnapshot().replace("data:image/jpeg;base64,","") );
|
||||
request.setSnapshot("/"+UPLOAD_URL_PREFIX+'/'+snapshotName);
|
||||
panelTemplateMapper.insert(request);
|
||||
} else {
|
||||
String nameCheckResult = this.nameCheck(CommonConstants.OPT_TYPE.UPDATE, request.getName(), request.getPid(), request.getId());
|
||||
|
@ -56,21 +56,25 @@ public class StaticResourceService {
|
||||
Map<String,String> resource = gson.fromJson(staticResource,Map.class);
|
||||
for(Map.Entry<String,String> entry:resource.entrySet()){
|
||||
String path = entry.getKey();
|
||||
Path uploadPath = Paths.get(staticDir.toString(), path.substring(path.lastIndexOf("/")+1,path.length()));
|
||||
try{
|
||||
if (uploadPath.toFile().exists()) {
|
||||
LogUtil.info("file exists");
|
||||
}else{
|
||||
String content = entry.getValue();
|
||||
if(StringUtils.isNotEmpty(content)){
|
||||
Files.createFile(uploadPath);
|
||||
FileCopyUtils.copy(Base64Decoder.decode(content),Files.newOutputStream(uploadPath));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
LogUtil.error("template static resource save error"+e.getMessage());
|
||||
String fileName = path.substring(path.lastIndexOf("/")+1,path.length());
|
||||
saveSingleFileToServe(fileName,entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void saveSingleFileToServe(String fileName,String content){
|
||||
Path uploadPath = Paths.get(staticDir.toString(), fileName);
|
||||
try{
|
||||
if (uploadPath.toFile().exists()) {
|
||||
LogUtil.info("file exists");
|
||||
}else{
|
||||
if(StringUtils.isNotEmpty(content)){
|
||||
Files.createFile(uploadPath);
|
||||
FileCopyUtils.copy(Base64Decoder.decode(content),Files.newOutputStream(uploadPath));
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
LogUtil.error("template static resource save error"+e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ export function find(data) {
|
||||
return request({
|
||||
url: '/template/find',
|
||||
data: data,
|
||||
loading: true,
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
@ -55,11 +55,11 @@ export function baseRadarOption(chart_option, chart) {
|
||||
name: y.name,
|
||||
label: y.label
|
||||
}
|
||||
]
|
||||
],
|
||||
selectedMode: true,
|
||||
select: BASE_ECHARTS_SELECT
|
||||
}
|
||||
y.value = JSON.parse(JSON.stringify(y.data))
|
||||
chart_option.series[0].selectedMode = true
|
||||
chart_option.series[0].select = BASE_ECHARTS_SELECT
|
||||
chart_option.series.push(d)
|
||||
|
||||
maxValues.push(Math.max.apply(null, y.value))
|
||||
|
@ -48,6 +48,12 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-button type="text" size="mini" style="float: right;" @click="variableMgm">
|
||||
{{ $t('sql_variable.variable_mgm') }}
|
||||
</el-button>
|
||||
</el-tooltip>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col style="min-width: 200px;">
|
||||
|
@ -26,7 +26,7 @@
|
||||
<el-row v-if="inputType==='new_outer_template'" class="preview" :style="classBackground" />
|
||||
<el-row class="root-class">
|
||||
<el-button size="mini" @click="cancel()">{{ $t('commons.cancel') }}</el-button>
|
||||
<el-button type="primary" size="mini" @click="save()">{{ $t('commons.confirm') }}</el-button>
|
||||
<el-button type="primary" size="mini" :disabled="!saveStatus" @click="save()">{{ $t('commons.confirm') }}</el-button>
|
||||
</el-row>
|
||||
</el-row>
|
||||
</template>
|
||||
@ -57,10 +57,14 @@ export default {
|
||||
importTemplateInfo: {
|
||||
snapshot: ''
|
||||
},
|
||||
editPanel: null
|
||||
editPanel: null,
|
||||
templateSelected: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
saveStatus() {
|
||||
return this.editPanel.panelInfo.name && (this.inputType === 'new' || this.templateSelected)
|
||||
},
|
||||
classBackground() {
|
||||
if (this.importTemplateInfo.snapshot) {
|
||||
return {
|
||||
@ -76,6 +80,7 @@ export default {
|
||||
if (newVal === 'new') {
|
||||
this.editPanel = deepCopy(this.editPanelOut)
|
||||
} else {
|
||||
this.templateSelected = false
|
||||
this.editPanel.panelInfo.name = null
|
||||
this.editPanel.panelInfo.panelStyle = null
|
||||
this.editPanel.panelInfo.panelData = null
|
||||
@ -109,10 +114,15 @@ export default {
|
||||
},
|
||||
showCurrentTemplateInfo(data) {
|
||||
this.editPanel.panelInfo.templateId = data.id
|
||||
this.editPanel.panelInfo.name = data.name
|
||||
// this.editPanel.panelInfo.panelStyle = data.templateStyle
|
||||
// this.editPanel.panelInfo.panelData = data.templateData
|
||||
this.importTemplateInfo.snapshot = data.snapshot
|
||||
if (data.nodeType === 'folder') {
|
||||
this.editPanel.panelInfo.name = null
|
||||
this.importTemplateInfo.snapshot = null
|
||||
this.templateSelected = false
|
||||
} else {
|
||||
this.editPanel.panelInfo.name = data.name
|
||||
this.importTemplateInfo.snapshot = data.snapshot
|
||||
this.templateSelected = true
|
||||
}
|
||||
},
|
||||
getTree() {
|
||||
const request = {
|
||||
@ -177,6 +187,7 @@ export default {
|
||||
const file = e.target.files[0]
|
||||
const reader = new FileReader()
|
||||
reader.onload = (res) => {
|
||||
this.templateSelected = true
|
||||
const result = res.target.result
|
||||
this.importTemplateInfo = JSON.parse(result)
|
||||
this.editPanel.panelInfo.name = this.importTemplateInfo.name
|
||||
|
@ -31,7 +31,7 @@
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</de-aside-container>
|
||||
<de-main-container>
|
||||
<de-main-container v-loading="$store.getters.loadingMap[$store.getters.currentPath]">
|
||||
<template-item
|
||||
v-for="item in currentTemplateShowList"
|
||||
:key="item.id"
|
||||
|
Loading…
Reference in New Issue
Block a user