Skip to content

Commit

Permalink
FEAT: manage site name (#34)
Browse files Browse the repository at this point in the history
RECONSTRUCTURE: domain => host
  • Loading branch information
sheepzh committed Dec 5, 2021
1 parent cf58447 commit 4ec8d1b
Show file tree
Hide file tree
Showing 93 changed files with 810 additions and 551 deletions.
6 changes: 3 additions & 3 deletions global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @since 0.3.0
*/
declare namespace Timer {
type SiteItem = 'total' | 'focus' | 'time'
type DataDimension = 'total' | 'focus' | 'time'
/**
* Options used for the popup page
*/
Expand All @@ -17,9 +17,9 @@ declare namespace Timer {
/**
* The default to display
*/
defaultType: SiteItem
defaultType: DataDimension
/**
* Replace the domain name with site name which is detected automatically from the title of site homepages,
* Replace the host name with site name which is detected automatically from the title of site homepages,
* or modified manually by the user
*
* @since 0.4.1
Expand Down
2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Config } from '@jest/types'
import type { Config } from "@jest/types"

const config: Config.InitialOptions = {
roots: [
Expand Down
8 changes: 4 additions & 4 deletions public/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
</div>
</div>
</div>
<!-- merge domain -->
<!-- merge host -->
<div
id="merge-domain-switch"
id="merge-host-switch"
class="el-switch option-right"
role="switch"
style="margin-left: 10px"
Expand Down Expand Up @@ -169,7 +169,7 @@
</div>
<!-- Switch popup -->
<div
id="merge-domain-popup-container"
id="merge-host-popup-container"
class="el-popper is-dark"
style="
z-index: 2012;
Expand All @@ -180,7 +180,7 @@
display: none;
"
>
<a id="merge-domain-popup-info">
<a id="merge-host-popup-info">
<!-- 合并子域名 -->
</a>
<div
Expand Down
4 changes: 2 additions & 2 deletions src/api/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* https://opensource.org/licenses/MIT
*/

import axios, { AxiosResponse } from 'axios'
import { IS_CHROME, IS_EDGE, IS_FIREFOX } from '../util/constant/environment'
import axios, { AxiosResponse } from "axios"
import { IS_CHROME, IS_EDGE, IS_FIREFOX } from "../util/constant/environment"

async function getFirefoxVersion(): Promise<string | null> {
const response: AxiosResponse<any> = await axios.get('https://addons.mozilla.org/api/v3/addons/addon/2690100')
Expand Down
8 changes: 1 addition & 7 deletions src/app/components/common/editable-tag.sass
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,12 @@
margin-bottom: 9px
line-height: 32px !important

.origin-domain-input
.origin-host-input
.el-input__inner
border-bottom-right-radius: 0
border-top-right-radius: 0
border-right: 0

.merged-domain-input
margin-right: 5px
.el-input__inner
border-bottom-left-radius: 0
border-top-left-radius: 0

.el-alert
margin-bottom: 20px

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { ElPagination } from "element-plus"
import { h, UnwrapRef } from "vue"
import { PaginationInfo, QueryData } from "../common/constants"
import { PaginationInfo, QueryData } from "./constants"

export type PaginationProps = {
queryData: QueryData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { ElButton, ElMessage, ElMessageBox, ElTooltip } from "element-plus"
import { Ref, h } from "vue"
import TimerDatabase, { TimerCondition } from "../../../../../database/timer-database"
import SiteInfo from "../../../../../entity/dto/site-info"
import DataItem from "../../../../../entity/dto/data-item"
import { ItemMessage } from "../../../../../util/i18n/components/item"
import { t } from "../../../../locale"
import { DataManageMessage } from "../../../../locale/components/data-manage"
Expand All @@ -30,7 +30,7 @@ type _Props = BaseFilterProps & {

confirm: {
message: keyof DataManageMessage
operation: (result: SiteInfo[]) => Promise<any>
operation: (result: DataItem[]) => Promise<any>
resultMessage: keyof DataManageMessage
}

Expand Down Expand Up @@ -103,7 +103,7 @@ const generateParamAndSelect = (props: _Props) => {
}

const handleClick = async (props: _Props) => {
const result: SiteInfo[] = await generateParamAndSelect(props)
const result: DataItem[] = await generateParamAndSelect(props)

const count = result.length
ElMessageBox.confirm(t(msg => msg.dataManage[props.confirm.message], { count }))
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/data-manage/clear/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ElAlert, ElCard } from "element-plus"
import { h } from "vue"
import { t } from "../../../locale"
import { alertProps, bodyStyle } from "../common"
import Filter from './filter'
import Filter from "./filter"

type _Props = {
queryData: () => Promise<void> | void
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/data-manage/memory-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { ElAlert, ElCard, ElProgress } from "element-plus"
import { h, Ref } from 'vue'
import { h, Ref } from "vue"
import { t } from "../../locale"
import { alertProps, bodyStyle } from "./common"

Expand Down
6 changes: 3 additions & 3 deletions src/app/components/habit/chart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* https://opensource.org/licenses/MIT
*/

import { ElCard } from 'element-plus'
import { h, Ref } from 'vue'
import { contentContainerCardStyle } from '../../common/content-container'
import { ElCard } from "element-plus"
import { h, Ref } from "vue"
import { contentContainerCardStyle } from "../../common/content-container"

export type ChartProps = {
chartRef: Ref<HTMLDivElement>
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/habit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { daysAgo, isSameDay } from "../../../util/time"
import { renderContentContainer } from "../common/content-container"
import chart, { ChartProps } from "./chart"
import generateOptions from "./chart/option"
import filter from './filter'
import filter from "./filter"

const periodSizeRef: Ref<string> = ref('1')
//@ts-ignore ts(2322)
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/limit/add-dialog/form/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { computed, ComputedRef, defineComponent, h, ref, Ref, SetupContext } fro
import '../style/el-input'
import pathEdit from "./path-edit"
import timeFormItem from "./time-limit"
import urlFormItem, { FormUrlProps, Protocol } from './url'
import urlFormItem, { FormUrlProps, Protocol } from "./url"
import UrlPathItem from "./url-path-item"

// Limited time
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/limit/add-dialog/form/url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { h, Ref } from "vue"
import clipboardy from 'clipboardy'
import clipboardy from "clipboardy"
import { t } from "../../../../locale"
import { ElButton, ElFormItem, ElInput, ElOption, ElSelect } from "element-plus"
import UrlPathItem from "./url-path-item"
Expand Down
4 changes: 2 additions & 2 deletions src/app/components/limit/add-dialog/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import { ElDialog, ElMessage } from "element-plus"
import { defineComponent, h, ref, Ref, SetupContext } from "vue"
import { t } from "../../../locale"
import Form, { FormData } from './form'
import Footer from './footer'
import Form, { FormData } from "./form"
import Footer from "./footer"
import LimitDatabase from "../../../../database/limit-database"
import { TimeLimit } from "../../../../entity/dao/time-limit"

Expand Down
2 changes: 1 addition & 1 deletion src/app/components/limit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { defineComponent, h, ref, Ref, watch } from "vue"
import { renderContentContainer, contentContainerCardStyle } from "../common/content-container"
import filter, { FilterProps } from "./filter"
import table from "./table"
import AddDialog from './add-dialog'
import AddDialog from "./add-dialog"
import TimeLimitItem from "../../../entity/dto/time-limit-item"
import limitService from "../../../service/limit-service"
import { useRoute, useRouter } from "vue-router"
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/limit/table/column/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import cond from "./cond"
import waste from "./waste"
import time from "./time"
import enabled from "./enabled"
import delay from './delay'
import delay from "./delay"
import operations from "./operation"
import { QueryData } from "../../../common/constants"

Expand Down
2 changes: 1 addition & 1 deletion src/app/components/limit/table/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { ElTable } from "element-plus"
import { h, Ref } from 'vue'
import { h, Ref } from "vue"
import TimeLimitItem from "../../../../entity/dto/time-limit-item"
import { QueryData } from "../../common/constants"
import columns from "./column"
Expand Down
6 changes: 3 additions & 3 deletions src/app/components/option/components/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ElCard, ElDivider, ElInputNumber, ElOption, ElSelect, ElSwitch } from "
import { t } from "../../../locale"
import { defineComponent, h, Ref, ref } from "vue"
import optionService from "../../../../service/option-service"
import { ALL_SITE_ITEMS } from "../../../../entity/dto/site-info"
import { ALL_DATA_ITEMS } from "../../../../entity/dto/data-item"
import { renderOptionItem, renderHeader, tagText } from "../common"
import { defaultPopup } from "../../../../util/constant/option"

Expand All @@ -27,12 +27,12 @@ const popupMaxInput = () => h(ElInputNumber, {
}
})

const typeOptions = () => ALL_SITE_ITEMS.map(item => h(ElOption, { value: item, label: t(msg => msg.item[item]) }))
const typeOptions = () => ALL_DATA_ITEMS.map(item => h(ElOption, { value: item, label: t(msg => msg.item[item]) }))
const typeSelect = () => h(ElSelect, {
modelValue: optionRef.value.defaultType,
size: 'mini',
style: { width: '140px' },
onChange: (val: Timer.SiteItem) => {
onChange: (val: Timer.DataDimension) => {
optionRef.value.defaultType = val
optionService.setPopupOption(optionRef.value)
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/components/option/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* https://opensource.org/licenses/MIT
*/

import { defineComponent, h } from 'vue'
import Popup from './components/popup'
import Appearance from './components/appearance'
import Statistics from './components/statistics'
import { defineComponent, h } from "vue"
import Popup from "./components/popup"
import Appearance from "./components/appearance"
import Statistics from "./components/statistics"
import './style'

export default defineComponent(() => {
Expand Down
10 changes: 5 additions & 5 deletions src/app/components/report/filter/download-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { Download } from "@element-plus/icons"
import { ElButton, ElDropdown, ElDropdownItem, ElDropdownMenu, ElIcon } from "element-plus"
import { Ref, h } from "vue"
import SiteInfo from "../../../../entity/dto/site-info"
import DataItem from "../../../../entity/dto/data-item"
import { exportCsv, exportJson } from "../../../../util/file"
import { t } from "../../../locale"
import { dateFormatter, periodFormatter } from "../formatter"
Expand All @@ -25,7 +25,7 @@ type ExportInfo = {

type _Props = {
mergeDateRef: Ref<boolean>
dataRef: Ref<SiteInfo[]>
dataRef: Ref<DataItem[]>
exportFileName: Ref<string>
}

Expand All @@ -35,7 +35,7 @@ export type DownloadFileProps = _Props
* @param rows row data
* @returns data with json format
*/
const generateJsonData = (rows: SiteInfo[]) => {
const generateJsonData = (rows: DataItem[]) => {
return rows.map(row => {
const data: ExportInfo = { host: row.host }
// Always display by seconds
Expand All @@ -50,8 +50,8 @@ const generateJsonData = (rows: SiteInfo[]) => {
* @param rows row data
* @returns data with csv format
*/
const generateCsvData = (rows: SiteInfo[], mergeDate: boolean) => {
let columnName: Array<keyof SiteInfo> = []
const generateCsvData = (rows: DataItem[], mergeDate: boolean) => {
let columnName: Array<keyof DataItem> = []
!mergeDate && columnName.push('date')
columnName = [...columnName, 'host', 'total', 'focus', 'time']
const data = [columnName.map(c => t(msg => msg.item[c]))]
Expand Down
8 changes: 4 additions & 4 deletions src/app/components/report/filter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import dateRange, { DateRangeFilterItemProps } from "./date-range-filter-item"
import displayBySecond, { DisplayBySecondFilterItemProps } from "./display-by-second-filter-item"
import downloadFile, { DownloadFileProps } from "./download-file"
import host, { HostFilterItemProps } from "./host-filter-item"
import mergeDate, { MergeDateFilterItemProps } from './merge-date-filter-item'
import mergeDomain, { MergeDomainFilterItemProps } from "./merge-domain-filter-item"
import mergeDate, { MergeDateFilterItemProps } from "./merge-date-filter-item"
import mergeHost, { MergeHostFilterItemProps } from "./merge-host-filter-item"

export type FilterProps = HostFilterItemProps
& DateRangeFilterItemProps
& MergeDateFilterItemProps
& MergeDomainFilterItemProps
& MergeHostFilterItemProps
& DisplayBySecondFilterItemProps
& DownloadFileProps

Expand All @@ -25,7 +25,7 @@ const childNodes = (props: FilterProps) =>
host(props),
dateRange(props),
...mergeDate(props),
...mergeDomain(props),
...mergeHost(props),
...displayBySecond(props),
downloadFile(props)
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { Ref } from "vue"
import { QueryData } from "../../common/constants"
import { switchFilterItem } from "../../common/filter"

export type MergeDomainFilterItemProps = {
mergeDomainRef: Ref<boolean>
export type MergeHostFilterItemProps = {
mergeHostRef: Ref<boolean>
queryData: QueryData
}

export default ({ mergeDomainRef, queryData }: MergeDomainFilterItemProps) => switchFilterItem(
mergeDomainRef, msg => msg.report.mergeDomain, queryData
export default ({ mergeHostRef, queryData }: MergeHostFilterItemProps) => switchFilterItem(
mergeHostRef, msg => msg.report.mergeDomain, queryData
)
Loading

0 comments on commit 4ec8d1b

Please sign in to comment.