Quellcode durchsuchen

看板logo支持手动上传/数据源现在也可以增删改了

zhuth vor 7 Jahren
Ursprung
Commit
c5009a7df3

+ 118 - 0
kanban-console/src/main/java/com/uas/kanban/controller/LogoController.java

@@ -0,0 +1,118 @@
+package com.uas.kanban.controller;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+
+import com.uas.kanban.base.BaseController;
+import com.uas.kanban.dao.LogoDao;
+import com.uas.kanban.model.Logo;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * 文件上传
+ *
+ * @author sunyj
+ * @since 2017年9月1日 下午4:42:45
+ */
+@Controller
+@RequestMapping("/logo")
+public class LogoController extends BaseController<Logo> {
+
+    private static final String UPLOAD_DIR = System.getProperty("java.io.tmpdir");
+    private static final String NO_LOGO_PATH = System.getProperty("user.dir") + "/src/main/webapp/resources/images/nologo.png";
+
+    private Logger logger = LoggerFactory.getLogger(LogoController.class);
+
+    @Autowired
+    private LogoDao logoDao;
+    
+    @RequestMapping(value = "/upload")
+    @ResponseBody
+    public Map<String, Object> upload(MultipartFile file) {
+    	Map<String, Object> message = new HashMap<String, Object>();
+
+        if (file == null || file.isEmpty()) {
+            message.put("message", "文件为空,无法进行上传!");
+            message.put("success", false);
+            logger.error((String) message.get("message"));
+            return message;
+        }
+
+        String fileName = file.getOriginalFilename();
+        String targetFilePath = (UPLOAD_DIR.endsWith(File.separator) ? UPLOAD_DIR : UPLOAD_DIR + "/") + "kanbanlogo/" + fileName;
+        File targetFile = new File(targetFilePath);
+        if (!targetFile.getParentFile().exists()) {
+            targetFile.getParentFile().mkdirs();
+        }
+        try {
+            file.transferTo(targetFile);
+            Logo logo = new Logo();
+            logo.setName(fileName);
+            logo.setPath(targetFile.getAbsolutePath());
+            Logo saveLogo = logoDao.save(logo);
+            message.put("success", true);
+            message.put("message", "成功上传文件至 :" + targetFile.getCanonicalPath());
+            message.put("logoCode", saveLogo.getCode());
+            message.put("logoName", saveLogo.getName());
+            logger.info((String) message.get("message"));
+            return message;
+        } catch (IllegalStateException | IOException e) {
+            logger.error("", e);
+        }
+        
+        message.put("success", false);
+        message.put("message", "上传文件失败: " + fileName);
+        logger.error((String) message.get("message"));
+        return message;
+    }
+    
+    @RequestMapping(value = "/getLogo", method = RequestMethod.GET)
+    @ResponseBody
+	public String getLogo(String logoCode, HttpServletRequest request, HttpServletResponse response)
+			throws IOException {
+		Logo logo = logoDao.getLogoByCode(logoCode);
+		ServletOutputStream out = null;
+		FileInputStream ips = null;
+		try {
+			// 获取图片存放路径
+			String imgPath = logo.getPath();
+			File logoFile = new File(imgPath);
+			
+			// 图片缺失时使用缺省图片
+			if (!logoFile.exists()) {
+				logoFile = new File(NO_LOGO_PATH);
+	        }
+			ips = new FileInputStream(logoFile);
+			response.setContentType("multipart/form-data");
+			out = response.getOutputStream();
+			// 读取文件流
+			int len = 0;
+			byte[] buffer = new byte[1024 * 10];
+			while ((len = ips.read(buffer)) != -1) {
+				out.write(buffer, 0, len);
+			}
+			out.flush();
+		} catch (Exception e) {
+
+			e.printStackTrace();
+		} finally {
+			out.close();
+			ips.close();
+		}
+		return null;
+	}
+}

+ 0 - 57
kanban-console/src/main/java/com/uas/kanban/controller/UploadController.java

@@ -1,57 +0,0 @@
-package com.uas.kanban.controller;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.multipart.MultipartFile;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * 文件上传
- *
- * @author sunyj
- * @since 2017年9月1日 下午4:42:45
- */
-@Controller
-@RequestMapping("/upload")
-public class UploadController {
-
-    private static final String UPLOAD_DIR = System.getProperty("java.io.tmpdir");
-
-    private Logger logger = LoggerFactory.getLogger(UploadController.class);
-
-    @RequestMapping
-    @ResponseBody
-    public String upload(MultipartFile file) {
-        String message;
-
-        if (file == null || file.isEmpty()) {
-            message = "文件为空,无法进行上传!";
-            logger.error(message);
-            return message;
-        }
-
-        String fileName = file.getOriginalFilename();
-        String targetFilePath = (UPLOAD_DIR.endsWith(File.separator) ? UPLOAD_DIR : UPLOAD_DIR + "/") + fileName;
-        File targetFile = new File(targetFilePath);
-        if (!targetFile.getParentFile().exists()) {
-            targetFile.getParentFile().mkdirs();
-        }
-        try {
-            file.transferTo(targetFile);
-            message = "成功上传文件至 :" + targetFile.getCanonicalPath();
-            logger.info(message);
-            return message;
-        } catch (IllegalStateException | IOException e) {
-            logger.error("", e);
-        }
-
-        message = "上传文件失败: " + fileName;
-        logger.error(message);
-        return message;
-    }
-}

+ 29 - 0
kanban-console/src/main/java/com/uas/kanban/dao/LogoDao.java

@@ -0,0 +1,29 @@
+/**
+ * 
+ */
+package com.uas.kanban.dao;
+
+import org.springframework.stereotype.Component;
+
+import com.uas.kanban.annotation.NotEmpty;
+import com.uas.kanban.base.BaseDao;
+import com.uas.kanban.model.Logo;
+
+/**
+ * 
+ * @author zhuth
+ * @since 2018/5/15/ 10:50
+ */
+@Component
+public class LogoDao extends BaseDao<Logo> {
+    
+    /**
+     * 获取指定logo
+     *
+     * @param logoCode 所指定的logo code
+     * @return Logo
+     */
+    public Logo getLogoByCode(@NotEmpty("logoCode") String logoCode) {
+    	return findOne(logoCode);
+    }
+}

+ 53 - 0
kanban-console/src/main/java/com/uas/kanban/model/Logo.java

@@ -0,0 +1,53 @@
+package com.uas.kanban.model;
+
+import org.mongodb.morphia.annotations.Entity;
+import com.uas.kanban.annotation.CollectionProperty;
+import com.uas.kanban.annotation.FieldProperty;
+import com.uas.kanban.base.BaseEntity;
+
+/**
+ * logo图片
+ * 
+ * @author zhuth
+ * @since 2018/5/15 10:40
+ */
+@Entity
+@CollectionProperty(simpleName = "Logo")
+public class Logo extends BaseEntity {
+	
+	private static final long serialVersionUID = 1L;
+	 
+    /**
+     * 名称
+     */
+    private String name;
+    
+    /**
+     * 路径
+     */
+    private String path;
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public String getPath() {
+		return path;
+	}
+
+	public void setPath(String path) {
+		this.path = path;
+	}
+	
+	@Override
+    public String toString() {
+    	return "Logo{"
+    			+ "name='" + name + "',"
+    			+ "path='" + path + "'"
+    			+ "} " + super.toString();
+    }
+}

+ 19 - 0
kanban-console/src/main/java/com/uas/kanban/service/LogoService.java

@@ -0,0 +1,19 @@
+/**
+ * 
+ */
+package com.uas.kanban.service;
+
+import java.util.List;
+
+import com.uas.kanban.annotation.NotEmpty;
+import com.uas.kanban.exception.OperationException;
+import com.uas.kanban.model.Logo;
+
+/**
+ * 
+ * @author zhuth
+ * @since 2018年5月15日 上午10:59:03
+ */
+public interface LogoService {
+	
+}

+ 39 - 0
kanban-console/src/main/java/com/uas/kanban/service/impl/LogoServiceImpl.java

@@ -0,0 +1,39 @@
+/**
+ * 
+ */
+package com.uas.kanban.service.impl;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.uas.kanban.annotation.NotEmpty;
+import com.uas.kanban.base.BaseService;
+import com.uas.kanban.dao.LogoDao;
+import com.uas.kanban.exception.OperationException;
+import com.uas.kanban.model.Kanban;
+import com.uas.kanban.model.Logo;
+import com.uas.kanban.service.LogoService;
+
+/**
+ * 
+ * @author zhuth
+ * @since 2018/5/15/ 11:20
+ */
+@Service
+public class LogoServiceImpl extends BaseService<Logo> implements LogoService {
+
+	@Autowired
+	private LogoDao logoDao;
+	
+	
+	
+	@Override
+	public Logo save(@NotEmpty("json") String json) {
+		Logo logo = logoDao.parse(json);
+		logoDao.save(logo);
+		return logo;
+	}
+	
+}

+ 2 - 1
kanban-console/src/main/webapp/resources/app/controller/board.js

@@ -7,7 +7,8 @@ Ext.define('erp.controller.board', {
 	'component.gridcomponent','component.barcomponent','component.linecomponent','component.piecomponent','component.mixchartcomponent',
 	'core.trigger.TextTrigger', 'core.trigger.StyleTrigger', 'core.trigger.GridRenderTrigger', 'core.trigger.FormRenderTrigger',
 	'boardmodel.modelbackupgrid', 'core.trigger.LegendTrigger', 'core.trigger.PieTrigger', 'core.trigger.ColorPoolTrigger', 'core.trigger.ColorPicker',
-	'core.trigger.BarTrigger', 'core.trigger.LineTrigger', 'core.trigger.ChartAreaTrigger', 'core.trigger.XAxisTrigger', 'core.trigger.YAxisTrigger'
+	'core.trigger.BarTrigger', 'core.trigger.LineTrigger', 'core.trigger.ChartAreaTrigger', 'core.trigger.XAxisTrigger', 'core.trigger.YAxisTrigger',
+	'core.field.FileField', 'boardmodel.LogoWin'
     ],
     stores:['component'],
     init:function(){

+ 1 - 1
kanban-console/src/main/webapp/resources/app/controller/desktop.js

@@ -2,7 +2,7 @@ Ext.QuickTips.init();
 Ext.define('erp.controller.desktop', {
     extend: 'Ext.app.Controller',
     views:['desktop.Desktop', 'desktop.BoardManageLeftPanel', 'desktop.BoardManageMainPanel', 'desktop.BoardManageRightPanel','user.UserSetting',
-    'core.trigger.TextTrigger'],
+    'core.trigger.TextTrigger', 'desktop.DataSourceWin'],
     stores:['desktopboard','user'],
     init:function(){
     	var me = this;

+ 118 - 0
kanban-console/src/main/webapp/resources/app/view/boardmodel/LogoWin.js

@@ -0,0 +1,118 @@
+Ext.define('erp.view.boardmodel.LogoWin', {
+	extend: 'Ext.window.Window',
+	alias: 'widget.logowin',
+	id: 'logowin',
+	title: 'LOGO管理',
+	width: 350,
+	height: 500,
+	resizable: false,
+	layout: 'fit',
+	modal: true,
+	initComponent: function() {
+		var me = this;
+		var view = new Ext.DataView({
+			store : Ext.create('Ext.data.Store', {
+				fields: ['code', 'name'],
+				data:[]
+			}),
+			tpl : new Ext.XTemplate(
+				'<div class="x-logo-wrap">',
+					'<tpl for=".">',
+					'<div class="x-logo-item">',
+						'<span class="x-loge-text">{name}</span></br>',
+						'<img src="' + basePath + 'logo/getLogo?logoCode={code}" class="x-logo-img" />',
+					'</div>',
+			    	'</tpl>',
+				'</div>'
+			),
+			trackOver: true,
+			overItemCls : 'x-logo-over',
+			selectedClass : 'selected',
+			singleSelect : true,
+			itemSelector : '.x-logo-item',
+			listeners:{
+				itemclick:function(view,record){
+					me.selectedLogo = record;
+				}
+			}
+		});
+		
+		view.on('refresh', function() {
+			var centerPanel = Ext.getCmp('dataviewpanel');
+			me.resetViewSize(centerPanel.getWidth(), centerPanel.getHeight());
+		});
+		
+		Ext.apply(me,{
+			items:[{
+				xtype: 'panel',
+				anchor: '100% 100%',
+				id: 'dataviewpanel',
+				items: [view]
+			}],
+			tbar: [{
+				xtype: 'mfilefield',
+				fieldLabel: '添加Logo',
+				callback: function(result) {
+					if(result.success) {
+						Ext.MessageBox.alert("成功","上传成功");
+						var store = me.view.store;
+						store.add({
+							code: result['logoCode'],
+							name: result['logoName'] || '未命名'
+						});
+					}else {
+						Ext.MessageBox.alert("失败","上传失败");
+					}
+				}
+			}, {
+				xtype: 'button',
+				text: '确定',
+				handler: function() {
+					me.titleWin.insertValue('logo/getLogo?logoCode=' + me.selectedLogo.get('code'));
+					me.close();
+				}
+			}]
+		});
+		me.view = view;
+		me.callParent(arguments); 
+	},
+	listeners: {
+		beforerender: function(th) {
+			th.loadAllLogo();
+		},
+		resize: function(th) {
+			th.view.fireEvent('refresh');
+		}
+	},
+	resetViewSize: function(width, height) {
+		var me = this,
+			parentDiv = document.getElementsByClassName('x-logo-wrap')[0];
+		if(!parentDiv) {
+			return;
+		}
+		parentDiv.style.width = width + 'px';
+		parentDiv.style.height = height + 'px';
+		if(parentDiv.offsetHeight < parentDiv.scrollHeight) {
+			parentDiv.style['overflow-y'] = 'scroll';
+			parentDiv.scrollTop = me.view.scrollTop;
+		}else {
+			parentDiv.style['overflow-y'] = 'hidden';
+		}
+	},
+	loadAllLogo: function() {
+		var me = this;
+		Ext.Ajax.request({
+			url:'logo/get/all',
+			method:'POST',
+			callback:function(options,success,response){
+				if(response.responseText == '') return;
+				var data = JSON.parse(response.responseText);
+				if(success) {
+					me.view.store.add(data);
+				}else {
+					showErrorMsg('失败', res.message);
+				}
+			}
+		});
+	}
+});

+ 36 - 3
kanban-console/src/main/webapp/resources/app/view/boardmodel/modeleditpanel.js

@@ -225,6 +225,7 @@ Ext.define('erp.view.boardmodel.modeleditpanel',{
 		}).show();
 	},
 	setModelConfig:function(){
+		var me = this;
 		var modelbuilderpanel = Ext.getCmp('modelbuilderpanel');
 		var record = modelbuilderpanel.modelRecord;
 		var me = Ext.getCmp('modeleditpanel');
@@ -244,6 +245,7 @@ Ext.define('erp.view.boardmodel.modeleditpanel',{
 					id:'tplSetForm',
 					items:[{
 						xtype:'textarea',
+						id: 'tplsettitle',
 						grow: true,
 						columnWidth:1,
 						height:200,
@@ -251,10 +253,11 @@ Ext.define('erp.view.boardmodel.modeleditpanel',{
 						value:record.get('title'),
 						listeners:{
 							afterrender:function(cmp){
+								win.textareaid = cmp.id;
 		        				cmp.getEl().set({
 					                'spellcheck': 'false'
 					            });
-		        			}						
+		        			}
 						}
 					}],
 					buttons:[{
@@ -278,7 +281,31 @@ Ext.define('erp.view.boardmodel.modeleditpanel',{
 							win.close();
 						}
 					}]
-				}]
+				}],
+				tbar: [{
+					xtype: 'button',
+					text: '插入LOGO',
+					handler: function() {
+						me.showLogoWin(win);
+					}
+				},"将光标置于img标签的src属性值位置"],
+				insertValue: function(value) {
+					var el = this.down('form').getForm().findField('tplsettitle');
+			        if (el.inputEl.dom.setSelectionRange) {  
+			            var withIns = el.inputEl.dom.value.substring(0,  
+			                el.inputEl.dom.selectionStart)  
+			                + value;// 获取光标前的文本+value  
+			            var pos = withIns.length;// 获取光标前文本的长度  
+			            el.inputEl.dom.value = withIns  
+			                + el.inputEl.dom.value.substring(  
+			                    el.inputEl.dom.selectionEnd,  
+			                    el.inputEl.dom.value.length);// 光标前文本+获取光标后文本  
+			            el.focus(); // 重新选中输入框
+			            el.inputEl.dom.setSelectionRange(pos, pos);// 设定光标位置  
+			        } else if (document.selection) {  
+			            document.selection.createRange().text = value;// 获取激活文本块  
+			        }  
+			    }
 			});
 			record.win = win;
 		}
@@ -431,5 +458,11 @@ Ext.define('erp.view.boardmodel.modeleditpanel',{
 	    });
 	
 	    return formatted;
-	}
+	},
+    showLogoWin: function(titleWin) {
+    	var logoWin = Ext.getCmp('logowin') || Ext.create('erp.view.boardmodel.LogoWin', {
+    		titleWin: titleWin
+    	});
+    	logoWin.show();
+    }
 });

+ 96 - 0
kanban-console/src/main/webapp/resources/app/view/core/field/FileField.js

@@ -0,0 +1,96 @@
+/**
+ * 多文件上传下载
+ */
+Ext.define('erp.view.core.field.FileField', {
+	extend: 'Ext.form.Panel',
+	alias: 'widget.mfilefield',
+	columnWidth: 1,
+	frame: false,
+	border: false,
+	minHeight: 22,
+	layout: 'hbox',
+	initComponent: function() {
+		var me = this;
+		Ext.apply(me, {
+			items: [{
+				xtype: 'filefield',
+				name: 'file',
+				buttonText: me.fieldLabel || '浏览<font color=blue size=1>(≤100M)</font>...',
+				buttonOnly: true,
+				hideLabel: true,
+				createFileInput : function() {
+		            var me = this;
+		            me.fileInputEl = me.button.el.createChild({
+		            name: me.getName(),
+		            cls: Ext.baseCSSPrefix + 'form-file-input',
+		            tag: 'input',
+		            type: 'file',
+		            multiple:'multiple',
+		            size: 1
+		           });
+		        },
+				listeners: {
+					change: function(field){
+						if(field.value != null){
+							me.upload(field, me.callback);
+						}
+					}
+				}
+			}]
+		});
+		me.callParent(arguments);
+	},
+	/**
+	 * 上传附件
+	 */
+	upload: function(field, callback){
+		var me = form = this;
+		//检查文件总量大小是否过量
+		if(!me.checkUploadAmount(form)){
+			return;
+		}
+		var files = form.getEl().down('input[type=file]').dom.files;
+		// 检查文件类型是否收到限制
+		if(!me.checkFileType(files[0].name, me.types)) {
+			Ext.MessageBox.alert("错误","文件类型不符合要求("+type.join(',')+")");
+			return;
+		}
+    	form.getForm().submit({
+    		url:basePath + 'logo/upload',
+    		waitMsg: "正在上传",
+    		method:'POST',
+    		success: function(form, action) {
+				if(callback && typeof callback == "function" ) {
+					callback(action.result);
+				}
+			},
+			failure: function(form, action) {
+				if(callback && typeof callback == "function" ) {
+					callback(action.result);
+				}
+			}
+    	});
+	},
+	
+	checkUploadAmount:function(form){
+		var files = form.getEl().down('input[type=file]').dom.files;
+		var amounts = 0;
+		for (var i = 0; i < files.length; i++) {
+			amounts = amounts + files[i].size
+		}
+		if (amounts>104857600) {
+			Ext.MessageBox.alert("警告","对不起,上传文件总大小超过100m");
+			return false
+		}
+		return true;
+	},
+	checkFileType:function(fileName, types){
+		fileName += fileName;
+		if(!types || !(types instanceof Array)) {
+			return true;
+		}
+		//var arr=['php','php2','php3', 'php5', 'phtml', 'asp', 'aspx', 'ascx', 'jsp', 'cfm', 'cfc', 'pl','pl','bat',  'dll', 'reg', 'cgi','war'];
+	    var suffix=fileName.substring(fileName.lastIndexOf(".")+1);
+	    return Ext.Array.contains(types,suffix);
+	}
+});

+ 47 - 25
kanban-console/src/main/webapp/resources/app/view/desktop/BoardManageMainPanel.js

@@ -80,33 +80,51 @@ Ext.define('erp.view.desktop.BoardManageMainPanel', {
                 columns: 2,
                 allowBlank: false,
                 items: [
-                    { boxLabel: '自动切换', name: 'display', inputValue: 'AutoSwitch'},
+                    { boxLabel: '自动切换', name: 'display', inputValue: 'AutoSwitch'}
                     // { boxLabel: '分屏展示', name: 'display', inputValue: 'SplitScreen' }
                 ]
             }, {
-                xtype:'combo',
-                columnWidth:0.75,
-                fieldLabel:'数据源',
-                name:'dataSourceCode',
-                id:'dataSourceCode',
-                //value:'UAS',
-                editable:false,
-                allowBlank: false,
-                store:Ext.create('Ext.data.Store',{
-                    fields:['username','code','name'],
-                    proxy:{
-                        type:'ajax',
-                        url:'datasource/get',
-                        reader: {
-                            type: 'json',
-                            root: 'content'
-                        }
-                    },
-                    autoLoad: true
-                }),
-                queryMode: 'local',
-                displayField: 'name',
-                valueField: 'code'
+            	xtype: 'container',
+            	columnWidth: 1,
+            	width: '100%',
+            	layout: 'hbox',
+            	items: [{
+            		labelWidth: 80,
+            		width: 300,
+	                xtype:'combo',
+	                fieldLabel:'数据源',
+	                name:'dataSourceCode',
+	                id:'dataSourceCode',
+	                //value:'UAS',
+	                editable:false,
+	                allowBlank: false,
+	                store:Ext.create('Ext.data.Store',{
+	                    fields:['username','code','name'],
+	                    proxy:{
+	                        type:'ajax',
+	                        url:'datasource/get',
+	                        reader: {
+	                            type: 'json',
+	                            root: 'content'
+	                        }
+	                    },
+	                    autoLoad: true
+	                }),
+	                queryMode: 'local',
+	                displayField: 'name',
+	                valueField: 'code'
+	            }, {
+	            	xtype: 'button',
+	            	iconCls: 'datasource',
+	            	margin: '0 0 0 10',
+	            	style: {
+	            		"background": "none"
+	            	},
+	            	tooltip: '数据源管理',
+	            	handler: function() {
+	            		me.dataSourceManage();
+	            	}
+	            }]
             }],
             bbar: ['->', {
                 xtype: 'button',
@@ -275,7 +293,7 @@ Ext.define('erp.view.desktop.BoardManageMainPanel', {
                             paramRecord: record
                         }).show();
                     }
-                },
+                }
             },
             loadGridData: function() {
                 var grid = this;
@@ -442,4 +460,8 @@ Ext.define('erp.view.desktop.BoardManageMainPanel', {
             }
         });
     },
+    dataSourceManage: function() {
+    	var win = Ext.getCmp('datasourcewin') || Ext.create('erp.view.desktop.DataSourceWin');
+    	win.show();
+    }
 });

+ 182 - 0
kanban-console/src/main/webapp/resources/app/view/desktop/DataSourceWin.js

@@ -0,0 +1,182 @@
+Ext.define('erp.view.desktop.DataSourceWin', {
+	extend: 'Ext.window.Window',
+	alias: 'widget.datasourcewin',
+	id: 'datasourcewin',
+	title: '数据源管理',
+	width: 500,
+	height: 300,
+	modal: true,
+	resizable: false,
+	initComponent: function() {
+		var me = this;
+		Ext.apply(me, {
+			items: [{
+				xtype: 'grid',
+				store: Ext.create('Ext.data.JsonStore',{
+		            fields: ['code', 'name', 'driverClassName', 'url', 'username', 'password'],
+		            proxy:{
+		                type:'ajax',
+		                url:'datasource/get/all',
+		                reader: {
+		                    type: 'json',
+		                    root: 'content'
+		                }
+		            },
+		            autoLoad: true
+		        }),
+		        autoScroll: true,
+		        forceFit: true,
+		        columnLines: true,
+		        columns: [
+		        	{ text: '编号', dataIndex: 'code', hidden: true },
+		        	{ text: '名称', dataIndex: 'name', flex: 1 },
+		        	{ text: '驱动名', dataIndex: 'driverClassName', flex: 2 },
+		        	{ text: '地址', dataIndex: 'url', flex: 2 },
+		        	{ text: '用户名', dataIndex: 'username', flex: 1 },
+		        	{ text: '密码', dataIndex: 'password', flex: 1 }
+		        ],
+		        tbar: [{
+		        	xtype: 'button',
+		        	text: '新增',
+		        	handler: function() {
+		        		me.showDetailWin();
+		        	}
+		        }, {
+		        	xtype: 'button',
+		        	text: '编辑',
+		        	handler: function() {
+		        		var grid = me.down('grid');
+		        		var sm = grid.getSelectionModel();
+		        		if(sm.getCount() > 0) {
+		        			var selected = sm.getSelection()[0];
+		        			me.showDetailWin(selected);
+		        		}
+		        	}
+		        }, {
+		        	xtype: 'button',
+		        	text: '删除',
+		        	handler: function() {
+		        		var grid = me.down('grid');
+		        		var sm = grid.getSelectionModel();
+		        		if(sm.getCount() > 0) {
+		        			var selected = sm.getSelection()[0];
+		        			Ext.Msg.confirm('警告', '是否确认删除该记录', function(yes) {
+		        				if(yes == 'yes') {
+				        			me.deleteDatasource(selected);
+		        				}
+		        			});
+		        		}
+		        	}
+		        }]
+			}]
+		});
+		me.callParent(arguments);
+	},
+	showDetailWin: function(data) {
+		var me = this;
+		var win = Ext.getCmp('adddatasourcewin') || Ext.create('Ext.window.Window', {
+			id: 'adddatasourcewin',
+    		title: '新增数据源',
+    		width: 300,
+    		height: 250,
+    		layout: 'fit',
+    		modal: true,
+    		resizable: false,
+    		items: [{
+    			xtype: 'form',
+    			bodyPadding: 10,
+    			defaults: {
+    				width: 250,
+	                labelWidth: 80,
+	                allowBlank: false
+	            },
+    			items: [{
+    				xtype: 'hidden',
+    				fieldLabel: '编码',
+    				name: 'code',
+    				allowBlank: true,
+    				value: data ? data.get('code') : ''
+    			}, {
+    				xtype: 'textfield',
+    				fieldLabel: '名称',
+    				name: 'name',
+    				value: data ? data.get('name') : ''
+    			}, {
+    				xtype: 'textfield',
+    				fieldLabel: '驱动名',
+    				name: 'driverClassName',
+    				value: data ? data.get('driverClassName') : ''
+    			}, {
+    				xtype: 'textfield',
+    				fieldLabel: '地址',
+    				name: 'url',
+    				value: data ? data.get('url') : ''
+    			}, {
+    				xtype: 'textfield',
+    				fieldLabel: '用户名',
+    				name: 'username',
+    				value: data ? data.get('username') : ''
+    			}, {
+    				xtype: 'textfield',
+    				fieldLabel: '密码',
+    				name: 'password',
+    				value: data ? data.get('password') : ''
+    			}],
+    			buttonAlign: 'center',
+	    		buttons: [{
+	    			xtype: 'button',
+	    			text: '确定',
+	    			formBind: true,
+	    			handler: function() {
+	    				var values = this.up('form').getForm().getValues();
+	    				me.saveDataSource(values);
+	    				win.close();
+	    			}
+	    		}]
+    		}]
+    	});
+    	win.show();
+	},
+	saveDataSource: function(data) {
+		var me = this; 
+		var type = data['code'] ? 'update' : 'save';
+		me.el.mask('保存中...');
+        Ext.Ajax.request({
+            url: 'datasource/' + type,
+            method:'POST',
+            params: {
+				json: Ext.JSON.encode(data)
+			},
+            callback:function(options,success,response){
+                me.el.unmask();
+                var res = Ext.JSON.decode(response.responseText);
+                if(success) {
+                	showErrorMsg('提示','已保存');
+	                me.down('grid').store.reload();
+	               Ext.getCmp('managemain').down('form').down('combo').store.reload();
+                }else {
+                	showErrorMsg('保存失败',res.message);
+                }
+            }
+        });
+	},
+	deleteDatasource: function(record) {
+		var me = this; 
+		me.el.mask('保存中...');
+        Ext.Ajax.request({
+            url: 'datasource/delete/' + record.get('code'),
+            method:'POST',
+            callback:function(options,success,response){
+                me.el.unmask();
+                var res = Ext.JSON.decode(response.responseText);
+                if(success) {
+                	showErrorMsg('提示','已删除');
+                	me.down('grid').store.reload();
+                	Ext.getCmp('managemain').down('form').down('combo').store.reload();
+                }else {
+                	showErrorMsg('删除失败',res.message);
+                }
+            }
+        });
+	}
+});

+ 19 - 0
kanban-console/src/main/webapp/resources/css/boardmodel.css

@@ -81,4 +81,23 @@
     background-position-y: 2px !important;
     background-position-x: 0 !important;
 	background-image: url(../images/icons/yaxis.png) !important;
+}
+.x-logo-item {
+	width:100%;
+	height:80px;
+	padding:0 10px;
+	opacity: .8;
+	border-bottom: 1px solid #949494;
+}
+.x-logo-img {
+	max-width: 100%;
+	max-height: 60px;
+}
+.x-logo-img:HOVER {
+	box-shadow: 0 0 7px 0px;
+}
+.x-logo-wrap .x-item-selected {
+	color: blue;
+	font-weight: bold;
+	opacity: 1;
 }

+ 3 - 0
kanban-console/src/main/webapp/resources/css/desktop.css

@@ -307,6 +307,9 @@ div.ux-taskbar div.x-toolbar {
     background-image:url(../images/icons/separator.png) !important;
     background-repeat: no-repeat;
 }
+.datasource {
+	background-image:url(../images/datasource.png) !important;
+}
 
 /*----------------------------------------------------
     IM window icons

BIN
kanban-console/src/main/webapp/resources/images/datasource.png


BIN
kanban-console/src/main/webapp/resources/images/nologo.png