Commit 1134f4d2 authored by mainlove's avatar mainlove

完成插件配置界面基本流程 后台还需要重新想

parent 9f1636d6
......@@ -16,13 +16,17 @@
package org.b3log.solo.processor.console;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.model.Plugin;
import org.b3log.latke.plugin.AbstractPlugin;
import org.b3log.latke.service.LangPropsService;
import org.b3log.latke.servlet.HTTPRequestContext;
import org.b3log.latke.servlet.HTTPRequestMethod;
......@@ -32,6 +36,7 @@ import org.b3log.latke.servlet.annotation.RequestProcessor;
import org.b3log.latke.servlet.renderer.JSONRenderer;
import org.b3log.latke.util.Requests;
import org.b3log.solo.processor.console.common.ProcessAuthAdvice;
import org.b3log.solo.processor.renderer.ConsoleRenderer;
import org.b3log.solo.service.PluginMgmtService;
import org.b3log.solo.service.PluginQueryService;
import org.b3log.solo.util.QueryResults;
......@@ -175,4 +180,42 @@ public final class PluginConsole {
jsonObject.put(Keys.MSG, langPropsService.get("getFailLabel"));
}
}
/**
* get the info of the specified pluginoId,just fot the plugin-setting.
* @param request the specified http servlet request
* @param response the specified http servlet response
* @param context the specified http request context
* @param renderer the specified {@link ConsoleRenderer}
* @throws Exception exception
*/
@RequestProcessing(value = "/console/plugin/toSetting", method = HTTPRequestMethod.POST)
public void toSetting(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context,
final ConsoleRenderer renderer) throws Exception {
context.setRenderer(renderer);
try {
final JSONObject requestJSONObject = Requests.parseRequestJSONObject(request, response);
final String pluginoId = requestJSONObject.getString(Keys.OBJECT_ID);
final AbstractPlugin result = pluginQueryService.getPlugin(pluginoId);
renderer.setTemplateName("admin-plugin-setting.ftl");
final Map<String, Object> dataModel = renderer.getDataModel();
dataModel.put(Plugin.PLUGIN, result);
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
final JSONObject jsonObject = QueryResults.defaultResult();
final JSONRenderer jsonRenderer = new JSONRenderer();
jsonRenderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("getFailLabel"));
}
}
}
......@@ -120,6 +120,31 @@ public final class PluginQueryService {
}
}
/**
* get the {@link AbstractPlugin} by the specified pluginoId.
*
* @param pluginoId the specified pluginId
* @return the {@link AbstractPlugin}
* @throws ServiceException service exception
*/
public AbstractPlugin getPlugin(final String pluginoId) throws ServiceException {
final List<AbstractPlugin> plugins = PluginManager.getInstance().getPlugins();
AbstractPlugin ret = null;
for (final AbstractPlugin plugin : plugins) {
if (plugin.getId().equals(pluginoId)) {
ret = plugin;
}
}
if (ret == null) {
LOGGER.log(Level.SEVERE, "can not find plugin[" + pluginoId + "]");
throw new ServiceException("can not find plugin[" + pluginoId + "]");
}
return ret;
}
/**
* Gets the {@link PluginQueryService} singleton.
*
......
kkkk
\ No newline at end of file
......@@ -3053,7 +3053,7 @@ admin.pluginList = {
}
datas[i].expendRow += "</a> ";
datas[i].expendRow +="<a href='javascript:void(0)'> "+Label.settingLabel+" </a> ";
datas[i].expendRow +="<a href='javascript:void(0)' onclick=\"admin.plugin.toSetting('"+datas[i].oId+"')\"> "+Label.settingLabel+" </a> ";
}
that.tablePagination.updateTablePagination(result.plugins, pageNum, result.pagination);
......@@ -3063,6 +3063,10 @@ admin.pluginList = {
});
},
toSetting:function(pluginId){
},
changeStatus: function (pluginId, status) {
if (status === "ENABLED") {
status = "DISABLED";
......@@ -3092,6 +3096,8 @@ admin.pluginList = {
}
});
}
};
/*
......@@ -3614,6 +3620,32 @@ admin.plugin = {
}
},
toSetting:function(pluginId){
var requestJSONObject = {
"oId": pluginId
};
$.ajax({
url: latkeConfig.servePath + "/console/plugin/toSetting",
type: "POST",
cache: false,
data: JSON.stringify(requestJSONObject),
success: function(result, textStatus){
$("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
//where to put the id?
$("#PluginSetting").dialog("open");
$("#loadMsg").text("");
}
});
},
/*
* 根据当前 hash 初始化或刷新插件
*/
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -39,6 +39,32 @@ admin.plugin = {
}
},
toSetting:function(pluginId){
var requestJSONObject = {
"oId": pluginId
};
$.ajax({
url: latkeConfig.servePath + "/console/plugin/toSetting",
type: "POST",
cache: false,
data: JSON.stringify(requestJSONObject),
success: function(result, textStatus){
$("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
//where to put the id?
$("#PluginSetting").dialog("open");
$("#loadMsg").text("");
}
});
},
/*
* 根据当前 hash 初始化或刷新插件
*/
......
......@@ -92,7 +92,7 @@ admin.pluginList = {
}
datas[i].expendRow += "</a> ";
datas[i].expendRow +="<a href='javascript:void(0)'> "+Label.settingLabel+" </a> ";
datas[i].expendRow +="<a href='javascript:void(0)' onclick=\"admin.plugin.toSetting('"+datas[i].oId+"')\"> "+Label.settingLabel+" </a> ";
}
that.tablePagination.updateTablePagination(result.plugins, pageNum, result.pagination);
......@@ -102,6 +102,10 @@ admin.pluginList = {
});
},
toSetting:function(pluginId){
},
changeStatus: function (pluginId, status) {
if (status === "ENABLED") {
status = "DISABLED";
......@@ -131,6 +135,8 @@ admin.pluginList = {
}
});
}
};
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment