Skip to content

Commit

Permalink
feat: added git repo page
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Jun 15, 2024
1 parent ef207d5 commit 1b11554
Show file tree
Hide file tree
Showing 16 changed files with 282 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/i18n/lang/en/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const router: LRouter = {
spiders: 'Spiders',
schedules: 'Schedules',
tasks: 'Tasks',
git: 'Git Repo',
ds: 'Data Sources',
users: 'Users',
tags: 'Tags',
Expand Down
20 changes: 20 additions & 0 deletions src/i18n/lang/en/views/gits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const gits: LViewGits = {
table: {
columns: {
name: 'Name',
}
},
navActions: {
new: {
label: 'New Git Repo',
tooltip: 'Create a new git repo'
},
filter: {
search: {
placeholder: 'Search git repos'
}
}
}
};

export default gits;
2 changes: 2 additions & 0 deletions src/i18n/lang/en/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import projects from './projects';
import spiders from './spiders';
import schedules from './schedules';
import tasks from './tasks';
import gits from './gits';
import ds from './ds';
import users from './users';
import tags from './tags';
Expand All @@ -24,6 +25,7 @@ const views: LViews = {
spiders,
schedules,
tasks,
gits,
ds,
users,
tags,
Expand Down
1 change: 1 addition & 0 deletions src/i18n/lang/zh/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const router: LRouter = {
spiders: '爬虫',
schedules: '定时任务',
tasks: '任务',
git: 'Git 仓库',
ds: '数据源',
users: '用户',
tags: '标签',
Expand Down
20 changes: 20 additions & 0 deletions src/i18n/lang/zh/views/gits.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const gits: LViewGits = {
table: {
columns: {
name: '名称',
}
},
navActions: {
new: {
label: '新建 Git 仓库',
tooltip: '添加一个新 Git 仓库'
},
filter: {
search: {
placeholder: '搜索 Git 仓库'
}
}
}
};

export default gits;
2 changes: 2 additions & 0 deletions src/i18n/lang/zh/views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import projects from './projects';
import spiders from './spiders';
import schedules from './schedules';
import tasks from './tasks';
import gits from './gits';
import ds from './ds';
import users from './users';
import tags from './tags';
Expand All @@ -24,6 +25,7 @@ const views: LViews = {
spiders,
schedules,
tasks,
gits,
ds,
users,
tags,
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/i18n/router.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export declare global {
spiders: string;
schedules: string;
tasks: string;
git: string;
ds: string;
users: string;
tags: string;
Expand Down
8 changes: 8 additions & 0 deletions src/interfaces/i18n/views/gits.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
interface LViewGits {
table: {
columns: {
name: string;
};
};
navActions: LNavActions;
}
1 change: 1 addition & 0 deletions src/interfaces/i18n/views/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export declare global {
notification: LViewsNotification;
plugins: LViewsPlugins;
misc: LViewsMisc;
gits: LViewGits;
ds: LViewsDataSource;
environment: LViewsEnvironments;
system: LViewsSystem;
Expand Down
1 change: 1 addition & 0 deletions src/interfaces/models/git.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export declare global {

interface Git extends BaseModel {
url?: string;
name?: string;
auth_type?: string;
username?: string;
password?: string;
Expand Down
30 changes: 30 additions & 0 deletions src/router/git.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {RouteRecordRaw} from 'vue-router';
import {TAB_NAME_OVERVIEW, TAB_NAME_SPIDERS} from '@/constants/tab';

const endpoint = 'gits';

export default [
{
name: 'GitList',
path: endpoint,
component: () => import('@/views/git/list/GitList.vue'),
},
{
name: 'GitDetail',
path: `${endpoint}/:id`,
redirect: to => {
return {path: to.path + '/overview'};
},
component: () => import('@/views/git/detail/GitDetail.vue'),
children: [
{
path: TAB_NAME_OVERVIEW,
component: () => import('@/views/git/detail/tabs/GitDetailTabOverview.vue'),
},
// {
// path: TAB_NAME_SPIDERS,
// component: () => import('@/views/git/detail/tabs/GitDetailTabSpiders.vue'),
// },
]
},
] as Array<RouteRecordRaw>;
6 changes: 3 additions & 3 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import tag from '@/router/tag';
import token from '@/router/token';
import deps from '@/router/deps';
import notification from '@/router/notification';
import plugin from '@/router/plugin';
import git from '@/router/git';
import ds from '@/router/ds';
import environment from '@/router/environment';
import system from '@/router/system';
Expand Down Expand Up @@ -40,8 +40,8 @@ export function getDefaultRoutes(): Array<RouteRecordRaw> {
...token,
...deps,
...notification,
...plugin,
...misc,
...git,
...ds,
...environment,
...system,
Expand All @@ -58,9 +58,9 @@ export function getDefaultSidebarMenuItems(): MenuItem[] {
{path: '/spiders', title: 'router.menuItems.spiders', icon: ['fa', 'spider']},
{path: '/schedules', title: 'router.menuItems.schedules', icon: ['fa', 'clock']},
{path: '/tasks', title: 'router.menuItems.tasks', icon: ['fa', 'tasks']},
{path: '/gits', title: 'router.menuItems.git', icon: ['fab', 'git']},
{path: '/data-sources', title: 'router.menuItems.ds', icon: ['fa', 'database']},
{path: '/users', title: 'router.menuItems.users', icon: ['fa', 'users']},
// {path: '/tags', title: 'router.menuItems.tags', icon: ['fa', 'tag']},
{path: '/tokens', title: 'router.menuItems.tokens', icon: ['fa', 'key']},
{
path: '/deps',
Expand Down
11 changes: 11 additions & 0 deletions src/views/git/detail/GitDetail.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
</script>

<template>
<cl-detail-layout store-namespace="git"/>
</template>

<style scoped lang="scss">
</style>
13 changes: 13 additions & 0 deletions src/views/git/detail/tabs/GitDetailTabOverview.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script setup lang="ts">
</script>

<template>
<div class="project-detail-tab-overview">
<cl-git-form/>
</div>
</template>

<style scoped lang="scss">
</style>
35 changes: 35 additions & 0 deletions src/views/git/list/GitList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<script setup lang="ts">
import useGitList from "@/views/git/list/useGitList";
const {
actionFunctions,
navActions,
tablePagination,
tableColumns,
tableData,
tableTotal,
} = useGitList();
</script>

<template>
<cl-list-layout
class="node-list"
:action-functions="actionFunctions"
:nav-actions="navActions"
:table-pagination="tablePagination"
:table-columns="tableColumns"
:table-data="tableData"
:table-total="tableTotal"
>
<template #extra>
<!-- Dialogs (handled by store) -->
<cl-create-edit-git-dialog/>
<!-- ./Dialogs -->
</template>
</cl-list-layout>
</template>

<style scoped lang="scss">
</style>
133 changes: 133 additions & 0 deletions src/views/git/list/useGitList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
import {computed, h} from 'vue';
import {useStore} from 'vuex';
import {useRouter} from "vue-router";
import {
ACTION_ADD,
ACTION_DELETE,
ACTION_FILTER,
ACTION_FILTER_SEARCH,
ACTION_VIEW, FILTER_OP_CONTAINS, TAB_NAME_SPIDERS,
TABLE_COLUMN_NAME_ACTIONS
} from "@/constants";
import {sendEvent} from "@/admin/umeng";
import {useList} from "@/layouts/content";
import {onListFilterChangeByKey, translate} from "@/utils";
import NavLink from "@/components/nav/NavLink.vue";

const useGitList = () => {
// router
const router = useRouter();

// store
const ns = 'git';
const store = useStore<RootStoreState>();
const {commit} = store;

// i18n
const t = translate;

// use list
const {
actionFunctions,
} = useList<Git>(ns, store);

// action functions
const {
deleteByIdConfirm,
} = actionFunctions;

// nav actions
const navActions = computed<ListActionGroup[]>(() => [
{
name: 'common',
children: [
{
action: ACTION_ADD,
id: 'add-btn',
className: 'add-btn',
buttonType: 'label',
label: t('views.gits.navActions.new.label'),
tooltip: t('views.gits.navActions.new.tooltip'),
icon: ['fa', 'plus'],
type: 'success',
onClick: () => {
commit(`${ns}/showDialog`, 'create');
}
}
]
},
{
action: ACTION_FILTER,
name: 'filter',
children: [
{
action: ACTION_FILTER_SEARCH,
id: 'filter-search',
className: 'search',
placeholder: t('views.gits.navActions.filter.search.placeholder'),
onChange: onListFilterChangeByKey(store, ns, 'name', FILTER_OP_CONTAINS),
},
]
},
]);

// table columns
const tableColumns = computed<TableColumns<Git>>(() => [
{
className: 'name',
key: 'name',
label: t('views.gits.table.columns.name'),
icon: ['fa', 'font'],
width: '150',
value: (row: Git) => h(NavLink, {
path: `/gits/${row._id}`,
label: row.name,
}),
hasSort: true,
hasFilter: true,
allowFilterSearch: true,
},
{
key: TABLE_COLUMN_NAME_ACTIONS,
label: t('components.table.columns.actions'),
fixed: 'right',
width: '200',
buttons: [
{
className: 'view-btn',
type: 'primary',
icon: ['fa', 'search'],
tooltip: t('common.actions.view'),
onClick: (row: Git) => {
router.push(`/gits/${row._id}`);

sendEvent('click_git_list_actions_view');
},
action: ACTION_VIEW,
},
{
className: 'delete-btn',
type: 'danger',
size: 'small',
icon: ['fa', 'trash-alt'],
tooltip: t('common.actions.delete'),
onClick: deleteByIdConfirm,
action: ACTION_DELETE,
},
],
disableTransfer: true,
}
]);

// options
const opts = {
navActions,
tableColumns,
} as UseListOptions<Git>;

return {
...useList<Git>(ns, store, opts),
};
};

export default useGitList;

0 comments on commit 1b11554

Please sign in to comment.