1 /*
2 * Copyright 2012-2025 CodeLibs Project and the Others.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
15 */
16 package org.codelibs.fess.app.web.admin.dashboard;
17
18 import org.codelibs.fess.annotation.Secured;
19 import org.codelibs.fess.api.engine.SearchEngineApiManager;
20 import org.codelibs.fess.app.web.base.FessAdminAction;
21 import org.codelibs.fess.util.RenderDataUtil;
22 import org.lastaflute.web.Execute;
23 import org.lastaflute.web.response.HtmlResponse;
24 import org.lastaflute.web.ruts.process.ActionRuntime;
25
26 import jakarta.annotation.Resource;
27
28 /**
29 * Admin action for Dashboard.
30 *
31 */
32 public class AdminDashboardAction extends FessAdminAction {
33
34 /**
35 * Default constructor.
36 */
37 public AdminDashboardAction() {
38 super();
39 }
40
41 /** The role for this action. */
42 public static final String ROLE = "admin-dashboard";
43
44 // ===================================================================================
45 // Attribute
46 // =========
47
48 /** The search engine API manager. */
49 @Resource
50 protected SearchEngineApiManager searchEngineApiManager;
51
52 // ===================================================================================
53 // Hook
54 // ======
55 @Override
56 protected void setupHtmlData(final ActionRuntime runtime) {
57 super.setupHtmlData(runtime);
58 runtime.registerData("helpLink", systemHelper.getHelpLink(fessConfig.getOnlineHelpNameDashboard()));
59 }
60
61 @Override
62 protected String getActionRole() {
63 return ROLE;
64 }
65
66 // ===================================================================================
67 // Index
68 // ==============
69 /**
70 * Show the index page.
71 * @return The HTML response.
72 */
73 @Execute
74 @Secured({ ROLE })
75 public HtmlResponse index() {
76 searchEngineApiManager.saveToken();
77 return asHtml(path_AdminDashboard_AdminDashboardJsp).renderWith(data -> {
78 RenderDataUtil.register(data, "serverPath", searchEngineApiManager.getServerPath());
79 });
80 }
81
82 }