Skip to content

Commit

Permalink
v1.1.0
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
matthieuy committed Oct 13, 2018
2 parents 98c97de + aed2eb6 commit a481031
Show file tree
Hide file tree
Showing 10 changed files with 293 additions and 98 deletions.
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -2,7 +2,7 @@
"name": "feedseries",
"desktopName": "FeedSeries",
"productName": "FeedSeries",
"version": "1.0.4",
"version": "1.1.0",
"author": {
"name": "Matthieu YK",
"email": "matthieuy+git@riseup.net"
Expand Down Expand Up @@ -140,8 +140,8 @@
"css-loader": "^0.28.4",
"del": "^3.0.0",
"devtron": "^1.4.0",
"electron": "^2.0.7",
"electron-builder": "^20.27.1",
"electron": "^3.0.4",
"electron-builder": "^20.28.4",
"electron-devtools-installer": "^2.2.0",
"eslint": "^4.4.1",
"eslint-config-standard": "^10.2.1",
Expand Down
25 changes: 21 additions & 4 deletions src/renderer/components/Options.vue
Expand Up @@ -212,6 +212,10 @@
<button class="btn btn-nav" v-show="fileSize.links" @click="clearDb('links')">
Liens perso ({{ fileSize.links | size }})
</button>
<button class="btn btn-nav" v-show="fileSize.stats" @click="clearDb('stats')">
Statistiques ({{ fileSize.stats | size }})
</button>

</div>
</div>
</div>
Expand Down Expand Up @@ -341,10 +345,22 @@
* @param {String} name The DB name
*/
clearDb (name) {
db.clearDb(name).then(() => {
console.log(`[DB] Delete "${name}.db"`)
this.addNotification(`Purge de la base de donnée "${name}"`)
this.fileSize[name] = db.getSize(name)
remote.dialog.showMessageBox(remote.getCurrentWindow(), {
type: 'warning',
buttons: ['Oui', 'Non'],
defaultId: 1,
title: remote.app.getName(),
icon: localStore.getIconPath(),
message: `Êtes-vous sûr de vouloir purger la base de donnée "${name}" ?`,
cancelId: 1,
}, (btnId) => {
if (btnId === 0) {
db.clearDb(name).then(() => {
console.log(`[DB] Delete "${name}.db"`)
this.addNotification(`Purge de la base de donnée "${name}"`)
this.fileSize[name] = db.getSize(name)
})
}
})
},
checkUpdate () {
Expand Down Expand Up @@ -529,6 +545,7 @@
shows: db.getSize('shows'),
subtitles: db.getSize('subtitles'),
links: db.getSize('links'),
stats: db.getSize('stats'),
}
this.refreshDataCacheSize()
},
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/show/Characters.vue
Expand Up @@ -3,8 +3,8 @@
<h1 class="text-center">{{ characters.length|plurialize('personnage', 'personnages')}}</h1>
<div v-for="character in characters" class="character" @contextmenu.prevent="$refs.CharacterCtx.$refs.ctx.open($event, character)">
<div class="txt-img name">{{ character.name }}</div>
<img :src="character.picture" v-if="character.picture !== 'https://www.betaseries.com/images/personnages/'">
<span class="img-replace" v-if="character.picture === 'https://www.betaseries.com/images/personnages/'"></span>
<img :src="character.picture" v-if="character.picture !== 'https://pictures.betaseries.com/personnages/'">
<span class="img-replace" v-if="character.picture === 'https://pictures.betaseries.com/personnages/'"></span>
<div class="txt-img actor">{{ character.actor }}</div>
</div>
<character-ctx ref="CharacterCtx">&nbsp;</character-ctx>
Expand Down
78 changes: 76 additions & 2 deletions src/renderer/components/show/Summary.vue
Expand Up @@ -51,7 +51,19 @@

<div class="season-list">
<div v-for="season in seasons">
<h3>Saison {{ season.number }} <i class="fa fa-circle" :style="season.progress | statusColor"></i></h3>
<h3>
Saison {{ season.number }}
<i class="fa fa-circle" :style="season.progress | statusColor"></i>
<div class="pull-right season-action">
<i v-show="season.progress !== 100" class="fa fa-download cursor" title="Marquer la saison récupérée" @click="markSeasonDL(season.number, true)"></i>
<span v-show="season.progress !== 100" class="fa-stack cursor" title="Marquer la saison non-récupérée" @click="markSeasonDL(season.number, false)">
<i class="fa fa-download fa-stack-1x"></i>
<i class="fa fa-ban fa-stack-2x"></i>
</span>
<i v-show="season.progress !== 100" class="fa fa-eye cursor" title="Marquer la saison comme vu" @click="markSeasonView(season.number, true)"></i>
<i v-show="season.progress !== 0" class="fa fa-eye-slash cursor" title="Marquer la saison comme non-vu" @click="markSeasonView(season.number, false)"></i>
</div>
</h3>

<div class="season">
<table class="table-striped">
Expand Down Expand Up @@ -100,19 +112,64 @@
},
},
methods: {
/**
* Mark all episode of a season as DL
* @param {Integer} seasonNumber
* @param {Boolean} isDL
*/
markSeasonDL (seasonNumber, isDL) {
let episodes = this.seasons.find((a) => { return a.number === seasonNumber }).episodes
episodes = episodes.filter((a) => { return !a.isSeen && a.isDownloaded !== isDL })
if (episodes.length) {
let promises = []
episodes.forEach((episode) => {
let p = this.$store.dispatch(types.episodes.ACTIONS.MARK_DL, {
episode: episode,
isDL: isDL,
})
promises.push(p)
})
Promise.all(promises)
}
},
/**
* Mark season as view
* @param {Integer} seasonNumber
* @param {Boolean} isView
*/
markSeasonView (seasonNumber, isView) {
let episodes = this.seasons.find((a) => { return a.number === seasonNumber }).episodes
episodes = episodes.filter((a) => { return a.isSeen !== isView })
if (episodes.length) {
let promises = []
episodes.forEach((episode) => {
let action = (isView) ? types.episodes.ACTIONS.MARK_VIEW : types.episodes.ACTIONS.UNMARK_VIEW
promises.push(this.$store.dispatch(action, episode))
})
Promise.all(promises)
}
},
/**
* Load episodes
*/
loadEpisodes () {
this.isLoading = true
this.$store.commit(types.episodes.MUTATIONS.SET_EPISODES, [])
this.$store.dispatch(types.episodes.ACTIONS.LOAD_EPISODES, this.show).then((episodes) => {
this.isLoading = false
})
},
/**
* Get avatar URL
* @param {Integer} userId
* @return {string}
*/
avatarURL (userId) {
return api.members.getAvatarURL(userId, 20)
},
},
watch: {
show (show) {
show () {
this.loadEpisodes()
},
},
Expand Down Expand Up @@ -144,4 +201,21 @@
.friends-list {
padding-top: 3px;
}
.season-action {
font-size: 12px;
margin-top: 12px;
margin-right: 5px;
.fa {
margin-left: 3px;
}
.fa-stack {
font-size: 9px;
}
.fa-stack-1x {
font-size: 12px;
}
.fa-stack-2x {
opacity: 0.7;
}
}
</style>
3 changes: 2 additions & 1 deletion src/renderer/db/index.js
Expand Up @@ -7,6 +7,7 @@ import Episode from './models/Episode'
import Show from './models/Show'
import Subtitle from './models/Subtitle'
import Link from './models/Link'
import Stat from './models/Stat'

import Cache from './cache'

Expand Down Expand Up @@ -84,5 +85,5 @@ let Database = function () {
}
}

export { Cache, Episode, Show, Subtitle, Link }
export { Cache, Episode, Show, Subtitle, Link, Stat }
export default new Database()
109 changes: 109 additions & 0 deletions src/renderer/db/models/Stat.js
@@ -0,0 +1,109 @@
import { Document } from 'camo'

/**
* Type :
* v: episodes view
* d: episodes download
* a: show add
* r: show archive
* s: srt download
*/
class Stat extends Document {
constructor () {
super()
this.schema({
ts: {
type: Number,
default: Stat._getCurrentTs,
},
type: String,
value: {
type: Number,
default: 0,
},
})
}

/**
* Archive a show
* @param {Boolean} isArchived
*/
static archive (isArchived) {
this.incrementValue('r', isArchived)
}

/**
* Add a show
* @param {Boolean} isAdd
*/
static addShow (isAdd) {
this.incrementValue('a', isAdd)
}

/**
* Mark View
* @param {Boolean} isView
*/
static markView (isView) {
this.incrementValue('v', isView)
}

/**
* Mark DL
* @param {Boolean} isDL
*/
static markDl (isDL) {
this.incrementValue('d', isDL)
}

/**
* Increment a stat
* @param {String} type
* @param {Boolean} increment
*/
static incrementValue (type, increment) {
this.findOne({
ts: this._getCurrentTs(),
type: type,
}).then((stat) => {
// Create if don't exist
if (!stat) {
stat = Stat.create({
type: type,
})
}

// Increment
if (increment) {
stat.value++
} else {
stat.value--
}

// Save
stat.save()
})
}

/**
* Get the current Timestamp
* @return {number}
* @private
*/
static _getCurrentTs () {
let currentDate = new Date()
currentDate.setHours(0, 0, 0, 0)

return currentDate.getTime() / 1000
}

/**
* Get the collection name
* @return {string}
*/
static collectionName () {
return 'stats'
}
}

export default Stat
7 changes: 6 additions & 1 deletion src/renderer/store/modules/episodes.js
Expand Up @@ -3,7 +3,7 @@ import moment from 'moment'

import api from '../../api'
import ConcurentPromise from '../../tools/ConcurentPromise'
import { Episode } from '../../db'
import { Episode, Stat } from '../../db'
import { types as typesShows } from './shows'
import { localStore } from '../../store'

Expand Down Expand Up @@ -113,11 +113,13 @@ const actions = {
.addPromise(promiseAPI)
.reverse(() => {
Episode.markDL(episode, !isDL)
Stat.markDl(!isDL)
promises.callThen(episode)
})

// DB
promises.addPromise(Episode.markDL(episode, isDL))
Stat.markDl(isDL)

// Update episode in state
promises.then((episode) => {
Expand Down Expand Up @@ -177,13 +179,16 @@ const actions = {
} else {
promises.addPromise(api.episodes.unmarkView(episode))
}

promises.reverse(() => {
Episode.markView(episode, !isView)
Stat.markView(!isView)
promises.callThen()
})

// DB
promises.addPromise(Episode.markView(episode, isView))
Stat.markView(isView)

// Update episode in state
promises.then((episode) => {
Expand Down
6 changes: 5 additions & 1 deletion src/renderer/store/modules/shows.js
Expand Up @@ -2,7 +2,7 @@ import Vue from 'vue'

import api from '../../api'
import ConcurentPromise from '../../tools/ConcurentPromise'
import { Cache, Show } from '../../db'
import { Cache, Show, Stat } from '../../db'
import { types as typesRootAction } from '../actions'
import localStore from '../local'

Expand Down Expand Up @@ -142,6 +142,7 @@ const actions = {
context.commit(types.MUTATIONS.ADD, showAdded)
Cache.invalidateByTags({show: showAdded.id})
Cache.invalidate('summary')
Stat.addShow(true)

/* eslint-disable no-new */
new window.Notification('FeedSeries', {
Expand All @@ -164,6 +165,7 @@ const actions = {
context.commit(types.MUTATIONS.DELETE, showDeleted)
Cache.invalidateByTags({show: showDeleted.id})
Cache.invalidate('summary')
Stat.addShow(false)

/* eslint-disable no-new */
new window.Notification('FeedSeries', {
Expand Down Expand Up @@ -251,11 +253,13 @@ const actions = {
}
promises.reverse(() => {
Show.archive(show, !archive)
Stat.archive(!archive)
promises.callThen(show)
})

// DB
promises.addPromise(Show.archive(show, archive))
Stat.archive(archive)

promises.then((showArchived) => {
Cache.invalidate('summary')
Expand Down

0 comments on commit a481031

Please sign in to comment.