Skip to content

TagSpaces is an offline, open source, document manager with tagging support

added some basic statistics for tag library #865

Ilian Sapundshiev3459af9fa65a
diff --git a/app/components/SidePanels.css.js b/app/components/SidePanels.css.js
index 7e7f7309d..b3e76888f 100644
--- a/app/components/SidePanels.css.js
+++ b/app/components/SidePanels.css.js
@@ -107,5 +107,19 @@ export default (theme) => ({
},
leftIcon: {
marginRight: theme.spacing.unit,
+ },
+ badge: {
+ display: 'inline-block',
+ minWidth: 10,
+ padding: '3px 7px',
+ fontSize: 10,
+ fontWeight: 'normal',
+ color: '#ffffff',
+ lineHeight: 1,
+ verticalAlign: 'middle',
+ whiteSpace: 'nowrap',
+ textAlign: 'center',
+ backgroundColor: '#bbbbbb',
+ borderRadius: 10
}
});
diff --git a/app/components/TagLibrary.js b/app/components/TagLibrary.js
index 733c1541b..d691b56f2 100644
--- a/app/components/TagLibrary.js
+++ b/app/components/TagLibrary.js
@@ -58,6 +58,7 @@ import {
type TagGroup,
type Tag,
actions as TagLibraryActions,
+ getAllTags,
getTagGroups
} from '../reducers/taglibrary';
import TaggingActions from '../reducers/tagging-actions';
@@ -70,6 +71,7 @@ type Props = {
tagTextColor: string,
tagBackgroundColor: string,
tagGroups: Array<TagGroup>,
+ allTags: Array<Tag>,
toggleTagGroup: (expanded: boolean, uuid: string) => void,
removeTagGroup: (uuid: string) => void,
moveTagGroupUp: (uuid: string) => void,
@@ -238,6 +240,7 @@ class TagLibrary extends React.Component<Props, State> {
className={this.props.classes.listItem}
onClick={event => this.handleTagGroupTitleClick(event, tagGroup)}
onContextMenu={event => this.handleTagGroupMenu(event, tagGroup)}
+ title={'Number of tags in this tag group: ' + tagGroup.children.length}
>
<ListItemIcon style={{ marginRight: 0 }}>
{tagGroup.expanded ? <ArrowDownIcon /> : <ArrowRightIcon />}
@@ -249,7 +252,10 @@ class TagLibrary extends React.Component<Props, State> {
data-tid="locationTitleElement"
noWrap
>
- {tagGroup.title}
+ {tagGroup.title + ' '}
+ {!tagGroup.expanded && (
+ <span className={this.props.classes.badge}>{tagGroup.children.length}</span>
+ )}
</Typography>
<ListItemSecondaryAction>
<IconButton
@@ -283,14 +289,17 @@ class TagLibrary extends React.Component<Props, State> {
);
render() {
- const classes = this.props.classes;
- const { tagGroups } = this.props;
+ const { tagGroups, classes, allTags } = this.props;
return (
<div className={classes.panel} style={this.props.style}>
<CustomLogo />
<div className={classes.toolbar}>
- <Typography className={classes.panelTitle} type="subtitle1">
+ <Typography
+ className={classes.panelTitle}
+ title={'Your tag library contains ' + allTags.length + ' tags \ndistributed in ' + tagGroups.length + ' tag groups'}
+ type="subtitle1"
+ >
{i18n.t('core:tagLibrary')}
</Typography>
<IconButton
@@ -418,7 +427,8 @@ function mapStateToProps(state) {
return {
tagGroups: getTagGroups(state),
tagBackgroundColor: getTagColor(state),
- tagTextColor: getTagTextColor(state)
+ tagTextColor: getTagTextColor(state),
+ allTags: getAllTags(state)
};
}