Skip to content

Commit

Permalink
refactor: 拆分插件状态列表
Browse files Browse the repository at this point in the history
  • Loading branch information
rehiy committed Apr 6, 2024
1 parent c5a9fd6 commit 53cff34
Show file tree
Hide file tree
Showing 7 changed files with 135 additions and 109 deletions.
25 changes: 14 additions & 11 deletions webview/src/apps/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { CronjobListComponent } from './cronjob/list';
import { CronjobCreateComponent } from './cronjob/create';
import { CronjobUpdateComponent } from './cronjob/update';

import { HandlerListComponent } from './handler/list';

import { LLModelCreateComponent } from './llmodel/create';
import { LLModelListComponent } from './llmodel/list';
import { LLModelUpdateComponent } from './llmodel/update';
Expand All @@ -19,7 +21,8 @@ import { KeywordListComponent } from './keyword/list';
import { KeywordCreateComponent } from './keyword/create';
import { KeywordUpdateComponent } from "./keyword/update";

import { PluginListComponent } from './plugin/list';
import { PluginCronjobComponent } from './plugin/cronjob';
import { PluginKeywordComponent } from './plugin/keyword';

import { ProfileListComponent } from './profile/list';
import { ProfileCreateComponent } from './profile/create';
Expand All @@ -29,15 +32,13 @@ import { SettingListComponent } from './setting/list';
import { SettingCreateComponent } from './setting/create';
import { SettingUpdateComponent } from './setting/update';

import { HandlerListComponent } from './handler/list';

import { WcferryChatroomComponent } from './wcferry/chatroom';
import { WcferryContactComponent } from './wcferry/contact';
import { WcferryDbqueryComponent } from './wcferry/dbquery';
import { WcferryReceiverComponent } from './wcferry/receiver';

import { WebhookCreateComponent } from './webhook/create'
import { WebhookListComponent} from "./webhook/list";
import { WebhookCreateComponent } from './webhook/create';
import { WebhookListComponent } from "./webhook/list";


export const AppComponents = [
Expand All @@ -52,6 +53,8 @@ export const AppComponents = [
CronjobCreateComponent,
CronjobUpdateComponent,

HandlerListComponent,

LLModelCreateComponent,
LLModelListComponent,
LLModelUpdateComponent,
Expand All @@ -60,7 +63,8 @@ export const AppComponents = [
KeywordCreateComponent,
KeywordUpdateComponent,

PluginListComponent,
PluginCronjobComponent,
PluginKeywordComponent,

ProfileListComponent,
ProfileCreateComponent,
Expand All @@ -70,8 +74,6 @@ export const AppComponents = [
SettingCreateComponent,
SettingUpdateComponent,

HandlerListComponent,

WcferryChatroomComponent,
WcferryContactComponent,
WcferryDbqueryComponent,
Expand All @@ -96,6 +98,8 @@ export const AppRoutes: Routes = [
{ path: 'cronjob/create', component: CronjobCreateComponent, canActivate: [LoginGuard] },
{ path: 'cronjob/update/:rd', component: CronjobUpdateComponent, canActivate: [LoginGuard] },

{ path: 'handler/list', component: HandlerListComponent, canActivate: [LoginGuard] },

{ path: 'llmodel/create', component: LLModelCreateComponent, canActivate: [LoginGuard] },
{ path: 'llmodel/list', component: LLModelListComponent, canActivate: [LoginGuard] },
{ path: 'llmodel/update/:rd', component: LLModelUpdateComponent, canActivate: [LoginGuard] },
Expand All @@ -104,7 +108,8 @@ export const AppRoutes: Routes = [
{ path: 'keyword/create', component: KeywordCreateComponent, canActivate: [LoginGuard] },
{ path: 'keyword/update/:rd', component: KeywordUpdateComponent, canActivate: [LoginGuard] },

{ path: 'plugin/list', component: PluginListComponent, canActivate: [LoginGuard] },
{ path: 'plugin/cronjob', component: PluginCronjobComponent, canActivate: [LoginGuard] },
{ path: 'plugin/keyword', component: PluginKeywordComponent, canActivate: [LoginGuard] },

{ path: 'profile/list', component: ProfileListComponent, canActivate: [LoginGuard] },
{ path: 'profile/create', component: ProfileCreateComponent, canActivate: [LoginGuard] },
Expand All @@ -114,8 +119,6 @@ export const AppRoutes: Routes = [
{ path: 'setting/create', component: SettingCreateComponent, canActivate: [LoginGuard] },
{ path: 'setting/update/:rd', component: SettingUpdateComponent, canActivate: [LoginGuard] },

{ path: 'handler/list', component: HandlerListComponent, canActivate: [LoginGuard] },

{ path: 'wcferry/chatroom', component: WcferryChatroomComponent, canActivate: [LoginGuard] },
{ path: 'wcferry/contact', component: WcferryContactComponent, canActivate: [LoginGuard] },
{ path: 'wcferry/dbquery', component: WcferryDbqueryComponent, canActivate: [LoginGuard] },
Expand Down
38 changes: 38 additions & 0 deletions webview/src/apps/plugin/cronjob.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<layout-header></layout-header>

<nav class="container-xl mb-3">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a routerLink="/welcome">首页</a></li>
<li class="breadcrumb-item active">插件</li>
<li class="breadcrumb-item active">计划任务</li>
</ol>
</nav>

<div class="container-xl mb-3">
<table class="table table-hover align-middle">
<thead class="table-light">
<tr>
<th scope="col">文件</th>
<th scope="col">名称</th>
<th scope="col" class="d-none d-sm-table-cell">计划</th>
<th scope="col">状态</th>
</tr>
</thead>
<tbody>
@for (item of cronjobPlugins; track item.file) {
<tr>
<th scope="row">{{item.file}}</th>
@if (item.config) {
<td>{{item.config.name}}</td>
<td class="d-none d-sm-table-cell">
{{item.config.second}} {{item.config.minute}} {{item.config.hour}} {{item.config.day_of_month}} {{item.config.month}} {{item.config.day_of_week}}
</td>
<td>{{item.config.rd > 0 ? '已激活': '未激活'}}</td>
} @else {
<td colspan="3" class="text-body-tertiary">{{item.error}}</td>
}
</tr>
}
</tbody>
</table>
</div>
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
import { Component } from '@angular/core';

import { UserLevels, SpecialRooms } from '../../openapi/const';
import { SundryApi, CronjobPlugin, KeywordPlugin } from '../../openapi/sundry';
import { SundryApi, CronjobPlugin } from '../../openapi/sundry';
import { WrestApi, WcfrestContactPayload } from '../../openapi/wcfrest';


@Component({
selector: 'page-plugin-list',
templateUrl: 'list.html'
selector: 'page-plugin-cronjob',
templateUrl: 'cronjob.html'
})
export class PluginListComponent {
export class PluginCronjobComponent {

public userLevels = UserLevels;
public specialRooms = SpecialRooms;

public type = 'cronjob';
public cronjobPlugins: Array<CronjobPlugin> = [];
public keywordPlugins: Array<KeywordPlugin> = [];

public wcfChatrooms: Record<string, WcfrestContactPayload> = {};

constructor() {
this.getWcfChatrooms();
this.getCronjobPlugins();
this.getKeywordPlugins();
}

public getCronjobPlugins() {
Expand All @@ -32,12 +29,6 @@ export class PluginListComponent {
});
}

public getKeywordPlugins() {
return SundryApi.pluginKeywords({}).then((data) => {
this.keywordPlugins = data || [];
});
}

public getWcfChatrooms() {
return WrestApi.chatrooms().then((data) => {
data.forEach((item) => this.wcfChatrooms[item.wxid] = item);
Expand Down
38 changes: 38 additions & 0 deletions webview/src/apps/plugin/keyword.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<layout-header></layout-header>

<nav class="container-xl mb-3">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a routerLink="/welcome">首页</a></li>
<li class="breadcrumb-item active">插件</li>
<li class="breadcrumb-item active">关键词</li>
</ol>
</nav>

<div class="container-xl mb-3">
<table class="table table-hover align-middle">
<thead class="table-light">
<tr>
<th scope="col">文件</th>
<th scope="col">指令</th>
<th scope="col" class="d-none d-sm-table-cell">描述</th>
<th scope="col">状态</th>
</tr>
</thead>
<tbody>
@for (item of keywordPlugins; track item.file) {
<tr>
<th scope="row">{{item.file}}</th>
@if (item.config) {
<td>{{item.config.phrase}}</td>
<td class="d-none d-sm-table-cell">
{{item.config.remark}}
</td>
<td>{{item.config.rd > 0 ? '已激活': '未激活'}}</td>
}@else {
<td colspan="3" class="text-body-tertiary">{{item.error}}</td>
}
</tr>
}
</tbody>
</table>
</div>
38 changes: 38 additions & 0 deletions webview/src/apps/plugin/keyword.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Component } from '@angular/core';

import { UserLevels, SpecialRooms } from '../../openapi/const';
import { SundryApi, KeywordPlugin } from '../../openapi/sundry';
import { WrestApi, WcfrestContactPayload } from '../../openapi/wcfrest';


@Component({
selector: 'page-plugin-keyword',
templateUrl: 'keyword.html'
})
export class PluginKeywordComponent {

public userLevels = UserLevels;
public specialRooms = SpecialRooms;

public keywordPlugins: Array<KeywordPlugin> = [];

public wcfChatrooms: Record<string, WcfrestContactPayload> = {};

constructor() {
this.getWcfChatrooms();
this.getKeywordPlugins();
}

public getKeywordPlugins() {
return SundryApi.pluginKeywords({}).then((data) => {
this.keywordPlugins = data || [];
});
}

public getWcfChatrooms() {
return WrestApi.chatrooms().then((data) => {
data.forEach((item) => this.wcfChatrooms[item.wxid] = item);
});
}

}
84 changes: 0 additions & 84 deletions webview/src/apps/plugin/list.html

This file was deleted.

4 changes: 3 additions & 1 deletion webview/src/layouts/header/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@
</a>
<div class="dropdown-menu" ngbDropdownMenu>
<a ngbDropdownItem routerLink="/handler/list" routerLinkActive="active">可用指令</a>
<a ngbDropdownItem routerLink="/plugin/list" routerLinkActive="active">插件状态</a>
<a ngbDropdownItem [disabled]="true">插件状态</a>
<a ngbDropdownItem routerLink="/plugin/keyword" routerLinkActive="active">&nbsp; 关键词</a>
<a ngbDropdownItem routerLink="/plugin/cronjob" routerLinkActive="active">&nbsp; 计划任务</a>
</div>
</li>
</ul>
Expand Down

0 comments on commit 53cff34

Please sign in to comment.