r45 - in trunk/echobase-ui/src/main: java/fr/ifremer/echobase/ui java/fr/ifremer/echobase/ui/actions java/fr/ifremer/echobase/ui/actions/export java/fr/ifremer/echobase/ui/actions/json resources resources/config resources/i18n webapp/WEB-INF webapp/WEB-INF/includes webapp/WEB-INF/jsp webapp/WEB-INF/jsp/export
Author: tchemit Date: 2011-11-12 21:23:18 +0100 (Sat, 12 Nov 2011) New Revision: 45 Url: http://forge.codelutin.com/repositories/revision/echobase/45 Log: - continue sql export - reformat - continue menus Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/LoadPage.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/LoadSqlGrid.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/SaveExportQuery.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetSqlResult.java trunk/echobase-ui/src/main/resources/config/struts-export.xml trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportGrid.jsp Removed: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportQueryForm.jsp Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsers.java trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties trunk/echobase-ui/src/main/resources/struts.xml trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/export.jsp trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-12 20:22:04 UTC (rev 44) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/EchoBaseApplicationListener.java 2011-11-12 20:23:18 UTC (rev 45) @@ -256,7 +256,7 @@ rootContextSupplier.get(); try { boolean schemaFound = TopiaUtil.isSchemaExist( - tx.getHibernateConfiguration(), + tx, EchoBaseUserImpl.class.getName() ); Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-12 20:22:04 UTC (rev 44) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/EchoBaseActionSupport.java 2011-11-12 20:23:18 UTC (rev 45) @@ -43,7 +43,6 @@ import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Date; -import java.util.Locale; import java.util.Map; /** @@ -192,6 +191,10 @@ return getDecoratorService().sortAndDecorate(getLocale(), beans, context); } + public String decorate(Object o, String context) { + return getDecoratorService().decorate(getLocale(), o, context); + } + protected SimpleDateFormat getDateFormat() { if (dateFormat == null) { dateFormat = new SimpleDateFormat("dd/MM/yyyy"); @@ -207,7 +210,7 @@ } protected DecoratorService getDecoratorService() { - if (decoratorService==null) { + if (decoratorService == null) { decoratorService = newService(DecoratorService.class); } return decoratorService; Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/LoadPage.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/LoadPage.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/LoadPage.java 2011-11-12 20:23:18 UTC (rev 45) @@ -0,0 +1,113 @@ +/* + * #%L + * EchoBase :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.ui.actions.export; + +import fr.ifremer.echobase.entities.ExportQuery; +import fr.ifremer.echobase.entities.ExportQueryImpl; +import fr.ifremer.echobase.services.ExportSqlService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; +import org.apache.commons.lang.StringUtils; + +import java.util.Collection; +import java.util.Map; + +/** + * Load export sql page. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class LoadPage extends EchoBaseActionSupport { + + private static final long serialVersionUID = 1L; + + /** All available queries */ + protected Map<String, String> queries; + + /** Selected query */ + protected ExportQuery query; + + public ExportQuery getQuery() { + if (query == null) { + query = new ExportQueryImpl(); + } + return query; + } + + public Map<String, String> getQueries() { + return queries; + } + + public Map<String, String> getTableNames() { + return queries; + } + + @Override + public String input() throws Exception { + ExportSqlService service = newService(ExportSqlService.class); + + Collection<ExportQuery> sqlQueries = service.getQueries(); + queries = sortAndDecorate(sqlQueries, null); + + if (sqlQueries.isEmpty()) { + // no query saved + addActionMessage(_("echobase.info.no.sqlQuery.saved")); + } + + String selectedQueryId = getQuery().getTopiaId(); + + if (StringUtils.isEmpty(selectedQueryId)) { + + // no query selected + addActionMessage(_("echobase.info.no.sqlQuery.selected")); + } else { + + // load query + query = service.getQuery(selectedQueryId); + } + return INPUT; + } + +// public String getEditType(ColumnMeta meta) { +// Class<?> type = meta.getType(); +// String editType = "text"; +// if (boolean.class.equals(type)) { +// editType = "checkbox"; +// } else if (TopiaEntity.class.isAssignableFrom(type)) { +// editType = "select"; +// } +// return editType; +// } +// +// public String getFormatter(ColumnMeta meta) { +// Class<?> type = meta.getType(); +// String editType = "'string'"; +// if (boolean.class.equals(type)) { +// editType = "'checkbox'"; +// } else if (TopiaEntity.class.isAssignableFrom(type)) { +// editType = "'formatEntityLabel'"; +// } +// return editType; +// } +} Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/LoadPage.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/LoadSqlGrid.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/LoadSqlGrid.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/LoadSqlGrid.java 2011-11-12 20:23:18 UTC (rev 45) @@ -0,0 +1,66 @@ +/* + * #%L + * EchoBase :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.ui.actions.export; + +import fr.ifremer.echobase.services.ExportSqlService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; + +/** + * Load export sql grid page. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class LoadSqlGrid extends EchoBaseActionSupport { + + private static final long serialVersionUID = 1L; + + /** Sql request to execute. */ + protected String sql; + + /** names of columns from the executed sql request. */ + protected String[] columnNames; + + public String getSql() { + return sql; + } + + public String[] getColumnNames() { + return columnNames; + } + + public void setSql(String sql) { + this.sql = sql; + } + + @Override + public String input() throws Exception { + + // obtain columNames from the request + ExportSqlService service = newService(ExportSqlService.class); + columnNames = service.getColumnNames(sql); + + return INPUT; + } +} Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/LoadSqlGrid.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/SaveExportQuery.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/SaveExportQuery.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/SaveExportQuery.java 2011-11-12 20:23:18 UTC (rev 45) @@ -0,0 +1,62 @@ +/* + * #%L + * EchoBase :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.ui.actions.export; + +import fr.ifremer.echobase.entities.ExportQuery; +import fr.ifremer.echobase.entities.ExportQueryImpl; +import fr.ifremer.echobase.services.ExportSqlService; +import fr.ifremer.echobase.ui.actions.EchoBaseActionSupport; + +/** + * To save a given export query. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class SaveExportQuery extends EchoBaseActionSupport { + + private static final long serialVersionUID = 1L; + + /** Selected query */ + protected ExportQuery query; + + public ExportQuery getQuery() { + if (query == null) { + query = new ExportQueryImpl(); + } + return query; + } + + @Override + public String execute() throws Exception { + + //TODO : do validation + ExportSqlService service = newService(ExportSqlService.class); + + service.createOrUpdate(getQuery(), + getEchoBaseSession().getEchoBaseUser() + ); + return SUCCESS; + } +} Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/export/SaveExportQuery.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Added: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetSqlResult.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetSqlResult.java (rev 0) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetSqlResult.java 2011-11-12 20:23:18 UTC (rev 45) @@ -0,0 +1,92 @@ +/* + * #%L + * EchoBase :: UI + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2011 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +package fr.ifremer.echobase.ui.actions.json; + +import fr.ifremer.echobase.services.ExportSqlService; + +import java.util.Map; + +/** + * To get a export sql DTO. + * + * @author tchemit <chemit@codelutin.com> + * @since 0.1 + */ +public class GetSqlResult extends AbstractJSONPaginedAction { + + private static final long serialVersionUID = 1L; + + /** Sql request to execute. */ + protected String sql; + +// /** names of columns from the executed sql request. */ +// protected String[] columnNames; + + /** Datas of the given table. */ + protected Map<?, ?>[] datas; + + public GetSqlResult() { + super("datas_"); + } + + public void setSql(String sql) { + this.sql = sql; + } + +// public String[] getColumnNames() { +// return columnNames; +// } + + public Map<?, ?>[] getDatas() { + return datas; + } + + @Override + public Integer getRows() { + return pager.getPageSize(); + } + + @Override + public Integer getPage() { + return pager.getPageNumber(); + } + + @Override + public Integer getTotal() { + return pager.getPageCount(); + } + + @Override + public Integer getRecords() { + return pager.getRecords(); + } + + @Override + public String execute() throws Exception { + + ExportSqlService service = newService(ExportSqlService.class); + datas = service.executeSql(sql, pager); + return SUCCESS; + } +} Property changes on: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetSqlResult.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsers.java =================================================================== --- trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsers.java 2011-11-12 20:22:04 UTC (rev 44) +++ trunk/echobase-ui/src/main/java/fr/ifremer/echobase/ui/actions/json/GetUsers.java 2011-11-12 20:23:18 UTC (rev 45) @@ -23,11 +23,11 @@ */ package fr.ifremer.echobase.ui.actions.json; +import com.google.common.collect.Lists; import fr.ifremer.echobase.entities.EchoBaseUser; import fr.ifremer.echobase.entities.EchoBaseUserDTO; import fr.ifremer.echobase.services.UserService; -import java.util.ArrayList; import java.util.List; /** @@ -76,7 +76,7 @@ List<EchoBaseUser> allUsers = newService(UserService.class).getUsers(pager); - users = new ArrayList<EchoBaseUserDTO>(allUsers.size()); + users = Lists.newArrayList(); for (EchoBaseUser user : allUsers) { users.add(user.toDTO()); } Added: trunk/echobase-ui/src/main/resources/config/struts-export.xml =================================================================== --- trunk/echobase-ui/src/main/resources/config/struts-export.xml (rev 0) +++ trunk/echobase-ui/src/main/resources/config/struts-export.xml 2011-11-12 20:23:18 UTC (rev 45) @@ -0,0 +1,65 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<!-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --> + +<!DOCTYPE struts PUBLIC + "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" + "http://struts.apache.org/dtds/struts-2.1.7.dtd"> + +<struts> + + <package name="export" extends="loggued" namespace="/export"> + + <action name="exportSql" method="input" + class="fr.ifremer.echobase.ui.actions.export.LoadPage"> + <interceptor-ref name="basicStackLoggued"/> + <result name="input">/WEB-INF/jsp/export/export.jsp</result> + </action> + + <action name="loadResult" method="input" + class="fr.ifremer.echobase.ui.actions.export.LoadSqlGrid"> + <interceptor-ref name="basicStackLoggued"/> + <result name="input">/WEB-INF/jsp/export/exportGrid.jsp</result> + </action> + + <action name="saveQuery" + class="fr.ifremer.echobase.ui.actions.export.SaveExportQuery"> + <interceptor-ref name="basicStackLoggued"/> + <result type="redirectAction"> + <param name="actionName">exportSql</param> + <param name="namespace">export</param> + <param name="query.topiaId">${query.topiaId}</param> + </result> + </action> + + <action name="getSqlResult" method="execute" + class="fr.ifremer.echobase.ui.actions.json.GetSqlResult"> + <interceptor-ref name="basicStackLoggued"/> + <result type="json"/> + </action> + + </package> + +</struts> + Property changes on: trunk/echobase-ui/src/main/resources/config/struts-export.xml ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties =================================================================== --- trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-12 20:22:04 UTC (rev 44) +++ trunk/echobase-ui/src/main/resources/i18n/echobase-ui_fr_FR.properties 2011-11-12 20:23:18 UTC (rev 45) @@ -1,3 +1,4 @@ +echobase.action.applySqlQuery=Appliquer la requête echobase.action.create=Créer echobase.action.delete=Suppression echobase.action.import=Importer @@ -6,11 +7,16 @@ echobase.action.login=Connection echobase.action.logout=Déconnexion echobase.action.save=Sauvegarder +echobase.action.saveSqlQuery=Enregistrer la requête echobase.common.admin=Administrateur echobase.common.comment=Commentaire echobase.common.email=Email echobase.common.import=Import configuration echobase.common.password=Mot de passe +echobase.common.query.description=Description +echobase.common.query.name=Nom +echobase.common.request.result=Résultat de la requête sql +echobase.common.sqlQueries=Requêtes enregistrées echobase.common.tableName=Nom de la table echobase.common.user=Utilisateur echobase.common.voyage=Campagne @@ -29,6 +35,8 @@ echobase.importFile.lectureAgeGen=Fichier lecture age echobase.importFile.pecherie=Fichier pecherie echobase.importFile.typeEchoSpecies=Fichier espèces +echobase.info.no.sqlQuery.saved=Aucune requête d'export sql enregistré +echobase.info.no.sqlQuery.selected=Aucune requête d'export sql sélectionnée echobase.info.no.table.selected=Aucune table sélectionnée echobase.label.admin.user.create=Création d'un utilisateur echobase.label.admin.user.delete=Suppression d'un utilisateur @@ -40,12 +48,14 @@ echobase.label.login=Connexion echobase.label.user.login=Utilisateur \: %s echobase.label.welcome=Bienvenue -echobase.menu.export=Exports +echobase.menu.dbeditor=Modification du référentiel +echobase.menu.export=Export sql echobase.menu.import=Imports echobase.menu.logs=Logs echobase.menu.users=Utilisateurs echobase.message.modified.property= -echobase.msg.warnImportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir acceder au résultats de l'import. +echobase.msg.warnImportInProgress=Merci de ne pas fermer la fenêtre pour pouvoir accéder aux résultats de l'import. +echobase.sqlQuery.configuration=Configuration de la requête echobase.title.dbEditor=Modification de la base echobase.title.export=Export echobase.title.import=Imports Modified: trunk/echobase-ui/src/main/resources/struts.xml =================================================================== --- trunk/echobase-ui/src/main/resources/struts.xml 2011-11-12 20:22:04 UTC (rev 44) +++ trunk/echobase-ui/src/main/resources/struts.xml 2011-11-12 20:23:18 UTC (rev 45) @@ -128,6 +128,7 @@ <include file="config/struts-json.xml"/> <include file="config/struts-user.xml"/> <include file="config/struts-import.xml"/> + <include file="config/struts-export.xml"/> </struts> Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2011-11-12 20:22:04 UTC (rev 44) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/decorators.xml 2011-11-12 20:23:18 UTC (rev 45) @@ -30,6 +30,8 @@ <pattern>/user/login*</pattern> <pattern>/index*</pattern> <pattern>/dbeditor/getForeignEntities*</pattern> + <pattern>/export/loadResult*</pattern> + <pattern>/export/getSqlResult*</pattern> </excludes> <decorator name="layout-default" page="layout-default.jsp"> Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp 2011-11-12 20:22:04 UTC (rev 44) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/includes/menu.jsp 2011-11-12 20:23:18 UTC (rev 45) @@ -28,11 +28,14 @@ <s:a action="import" namespace="/import"><s:text name="echobase.menu.import"/></s:a> </li> <li> - <s:a action="export"><s:text name="echobase.menu.export"/></s:a> + <s:a action="exportSql" namespace="/export"><s:text name="echobase.menu.export"/></s:a> </li> <li> <s:a action="logs"><s:text name="echobase.menu.logs"/></s:a> </li> + <li> + <s:a action="dbeditor" namespace="/dbeditor"><s:text name="echobase.menu.dbeditor"/></s:a> + </li> <s:if test="%{userIsAdmin}"> <li> Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/export.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/export.jsp 2011-11-12 20:22:04 UTC (rev 44) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/export.jsp 2011-11-12 20:23:18 UTC (rev 45) @@ -25,29 +25,70 @@ <%@ taglib prefix="s" uri="/struts-tags" %> <%@ taglib prefix="sj" uri="/struts-jquery-tags" %> +<s:url id="loadUrl" action='exportSql' namespace='/export'/> +<s:url id="loadGridUrl" action="loadResult" namespace="/export"/> +<script type="text/javascript"> + + jQuery(document).ready(function () { + + $('[name="query.topiaId"]').change(function(event) { + var url = "${loadUrl}?" + $.param({ 'query.topiaId':this.value}); + console.info("Reload url " + url); + window.location = url; + }); + }); + + function loadGridData() { + // get sql query + var sqlQuery = "${loadGridUrl}?" + $.param({ sql :$('[name="query.sqlQuery"]').val()}); + + $.ajax(sqlQuery, { + success: function(data, textStatus, jqXHR) { + $('#resultGrid').html(data); + console.info("Return " + data); + } + }); + return false; + } +</script> + <title><s:text name="echobase.title.export"/></title> -<s:url id="savedExportQueries" action="savedExportQueries" namespace="/ajax"/> -<sj:select id="lastQueriesSelect" - href="%{savedExportQueries}" - name="selectedQuery" - listKey="topiaId" - listValue="name" - list="savedExportQueries" - emptyOption="true" - listenTopics="updateSavedExportQueries" - onChangeTopics="updateExportQueryForm"/> +<s:form id="exportQueryForm" namespace="/export"> -<s:url id="exportQueryFormUrl" action="exportQueryFormForm" namespace="/fragment"/> -<sj:div id="exportQueryForm" - href="%{exportQueryFormUrl}" - listenTopics="updateExportQueryForm" - onSuccessTopics="updateExportGrid" - indicator="indicator-searchPanel"> - <img id="indicator-searchPanel" src="/img/indicator.gif" alt="Loading..." style="display:none"/> -</sj:div> + <s:select key="query.topiaId" label="%{getText('echobase.common.sqlQueries')}" + list="queries" headerKey="" headerValue=""/> -<%-- TODO sletellier : add result grid listen event updateExportGrid named exportGrid --%> + <br/> -</sjg:grid> \ No newline at end of file + <fieldset> + <legend><s:text name="echobase.sqlQuery.configuration"/></legend> + + <s:textfield key="query.name" required="true" + label="%{getText('echobase.common.query.name')}" size="40"/> + + <s:textarea key="query.description" required="true" cols="160" rows="6" + label="%{getText('echobase.common.query.description')}"/> + + <s:textarea key="query.sqlQuery" required="true" cols="160" rows="6" + label="%{getText('echobase.common.sqlQuery')}"/> + + <s:label value="%{query.lastModifiedDate}" readonly="true" + label="%{getText('echobase.common.lastModifiedDate')}"/> + + <s:label value="%{decorate(query.lastModifiedUser, null)}" readonly="true" + label="%{getText('echobase.common.lastModifiedUser')}"/> + </fieldset> + <br/> + + <s:submit action="saveQuery" key="echobase.action.saveSqlQuery" + align="right"/> + + <s:submit key="echobase.action.applySqlQuery" align="right" onclick="return loadGridData();"/> +</s:form> + +<br/> +<div id="resultGrid"></div> + + Added: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportGrid.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportGrid.jsp (rev 0) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportGrid.jsp 2011-11-12 20:23:18 UTC (rev 45) @@ -0,0 +1,51 @@ +<%-- + #%L + EchoBase :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2011 Ifremer, Codelutin + %% + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + #L% + --%> +<%@page contentType="text/html" pageEncoding="UTF-8" %> +<%@ taglib prefix="s" uri="/struts-tags" %> +<%@ taglib prefix="sj" uri="/struts-jquery-tags" %> +<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %> + +<s:url id="loadUrl" action="getSqlResult" namespace="/export" + escapeAmp="false"> + <s:param name="sql" value="%{sql}"/> +</s:url> + +<sjg:grid id="rows" caption="%{getText('echobase.common.request.result')}" + dataType="json" href="%{loadUrl}" gridModel="datas" + pager="true" pagerButtons="true" pagerInput="true" + navigator="true" autowidth="true" rownumbers="false" + navigatorEdit="false" navigatorDelete="false" + navigatorSearch="false" navigatorRefresh="true" + navigatorAdd="false" + rowList="10,15,20,50" rowNum="10" + viewrecords="true" resizable="true" editinline="false"> + + <s:iterator value="columnNames" var="name" status="status"> + + <sjg:gridColumn name="%{#name}" title="%{#name}" sortable="false"/> + + </s:iterator> + +</sjg:grid> + Property changes on: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportGrid.jsp ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Deleted: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportQueryForm.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportQueryForm.jsp 2011-11-12 20:22:04 UTC (rev 44) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/export/exportQueryForm.jsp 2011-11-12 20:23:18 UTC (rev 45) @@ -1,67 +0,0 @@ -<%-- - #%L - EchoBase :: UI - - $Id$ - $HeadURL$ - %% - Copyright (C) 2011 Ifremer, Codelutin - %% - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - #L% - --%> -<%@page contentType="text/html" pageEncoding="UTF-8"%> -<%@taglib prefix="s" uri="/struts-tags"%> -<%@taglib prefix="sj" uri="/struts-jquery-tags" %> - -<s:form id="exportQueryForm" action="executeExportQuery" namespace="/export"> - - <s:text name="echobase.export.queryName"/> - <s:textfield id="queryName" - cssClass="right" - theme="simple" - name="queryName" - size="40"/> - - <s:text name="echobase.export.querySql"/> - <s:textarea id="querySql" - name="querySql" - cols="160" - rows="6"/> - - <s:text name="echobase.export.queryDescription"/> - <s:textarea id="querySql" - name="querySql" - cols="160" - rows="6"/> - - <s:url id="saveExportQueryUrl" action="saveExportQuery" namespace="export"/> - - <s:set id="saveExportQueryText"> - <s:text name="echobase.action.save"/> - </s:set> - - <sj:submit id="saveQuery" - href="%{saveExportQueryUrl}" - value="%{saveExportQueryText}" - onSuccessTopics="updateExportQueries" - button="true"/> - - <sj:submit id="search" - value="%{searchText}" - indicator="indicator-exportGrid" - targets="exportGrid" - button="true"/> - -</s:form> \ No newline at end of file Modified: trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp =================================================================== --- trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2011-11-12 20:22:04 UTC (rev 44) +++ trunk/echobase-ui/src/main/webapp/WEB-INF/jsp/home.jsp 2011-11-12 20:23:18 UTC (rev 45) @@ -28,5 +28,4 @@ <h2><s:text name="echobase.label.welcome"/></h2> -<s:a action="dbeditor" namespace="/dbeditor">Modification du référentiel</s:a> <hr/> \ No newline at end of file
participants (1)
-
tchemit@users.forge.codelutin.com