diff --git a/client/assets/css/reset.scss b/client/assets/css/reset.scss index 32711086..2b9a27ae 100644 --- a/client/assets/css/reset.scss +++ b/client/assets/css/reset.scss @@ -106,19 +106,19 @@ select:-moz-focusring { ::-webkit-scrollbar{ - height:6px; - width:6px + height:4px; + width:4px } ::-webkit-scrollbar-track{ background:rgba(0,0,0,.1) } ::-webkit-scrollbar-thumb{ - -webkit-border-radius:3px; + -webkit-border-radius:2px; -moz-border-radius:2px; -ms-border-radius:2px; -o-border-radius:2px; border-radius:2px; - background:rgba(0,0,0,.2) + background:rgba(0,0,0,.2); } .scroll-y{ scrollbar-3dlight-color:#7d7e94; diff --git a/client/helpers/cache.js b/client/helpers/cache.js index 996744d4..d6a23fdc 100644 --- a/client/helpers/cache.js +++ b/client/helpers/cache.js @@ -126,18 +126,19 @@ Data.prototype.remove = function(type, path, exact = true){ } Data.prototype.update_path = function(updater_fn){ - this.db.then((db) => { + return this.db.then((db) => { const tx = db.transaction(this.FILE_PATH, "readwrite"); const store = tx.objectStore(this.FILE_PATH); const request = store.openCursor(); - request.onsuccess = function(event) { - const cursor = event.target.result; - if(cursor){ + + return new Promise((done, error) => { + request.onsuccess = function(event) { + const cursor = event.target.result; + if(!cursor) return done(); updater_fn(cursor.value, store) cursor.continue(); - } - }; - + }; + }); }); } Data.prototype.update_content = function(updater_fn){ diff --git a/client/model/files.js b/client/model/files.js index bda63d96..b6eb9f8b 100644 --- a/client/model/files.js +++ b/client/model/files.js @@ -300,6 +300,22 @@ class FileSystem{ } } + frequents(){ + let data = []; + return cache.update_path((value) => { + if(value.access_count >= 1 && value.path !== "/"){ + data.push(value); + } + }).then(() => { + return Promise.resolve( + data + .sort((a,b) => a.access_count > b.access_count? -1 : 1) + .map((a) => a.path) + .slice(0,6) + ); + }); + } + _replace(path, icon){ return cache.get(cache.FILE_PATH, dirname(path), false) .then((res) => { diff --git a/client/pages/filespage.js b/client/pages/filespage.js index 9bd54fc6..5b25fcff 100644 --- a/client/pages/filespage.js +++ b/client/pages/filespage.js @@ -8,7 +8,7 @@ import './filespage.scss'; import { Files } from '../model/'; import { NgIf, Loader, Uploader, EventReceiver } from '../components/'; import { notify, debounce, goToFiles, goToViewer, event, screenHeight } from '../helpers/'; -import { BreadCrumb, FileSystem } from './filespage/'; +import { BreadCrumb, FileSystem, FrequentlyAccess } from './filespage/'; @EventReceiver @DragDropContext(('ontouchstart' in window)? HTML5Backend : HTML5Backend) @@ -18,6 +18,7 @@ export class FilesPage extends React.Component { this.state = { path: props.match.url.replace('/files', '') || '/', files: [], + frequents: [], loading: true, error: false, height: null @@ -91,6 +92,7 @@ export class FilesPage extends React.Component { }); this.observers.push(observer); this.setState({error: false}); + Files.frequents().then((s) => this.setState({frequents: s})); } _cleanupListeners(){ @@ -226,6 +228,9 @@ export class FilesPage extends React.Component {
+ + + diff --git a/client/pages/filespage/frequently_access.js b/client/pages/filespage/frequently_access.js new file mode 100644 index 00000000..cdf53fa4 --- /dev/null +++ b/client/pages/filespage/frequently_access.js @@ -0,0 +1,32 @@ +import React from 'react'; +import { Container, Icon } from '../../components/'; +import { Link } from 'react-router-dom'; +import Path from 'path'; + +import './frequently_access.scss'; + +export class FrequentlyAccess extends React.Component { + constructor(props){ + super(props); + } + + render(){ + if(this.props.files.length < 4) return null; + return ( + +
+ { + this.props.files.map(function(path, index){ + return ( + + +
{Path.basename(path)}
+ + ); + }) + } +
+
+ ); + } +} diff --git a/client/pages/filespage/frequently_access.scss b/client/pages/filespage/frequently_access.scss new file mode 100644 index 00000000..83cbafd0 --- /dev/null +++ b/client/pages/filespage/frequently_access.scss @@ -0,0 +1,30 @@ +.component_frequently-access{ + display: flex; + a{ + width: 50%; + background: var(--bg-color); + box-shadow: rgba(158, 163, 172, 0.3) 0px 19px 60px, rgba(158, 163, 172, 0.22) 0px 15px 20px; + overflow: hidden; + margin-right: 5px; + padding: 5px; + cursor: pointer; + img{ + float: left; + height: 25px; + margin-right: 2px; + } + line-height: 25px; + display: block; + div{ + width: calc(100% - 30px); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + } + } + @media (max-width: 800px){ a:nth-child(6){display: none;} } + @media (max-width: 750px){ a:nth-child(5){display: none;} } + @media (max-width: 650px){ a:nth-child(4){display: none;} } + @media (max-width: 450px){ a:nth-child(3){display: none;} } + +} diff --git a/client/pages/filespage/index.js b/client/pages/filespage/index.js index 9301802b..41bf018f 100644 --- a/client/pages/filespage/index.js +++ b/client/pages/filespage/index.js @@ -1,2 +1,3 @@ export { FileSystem } from './filesystem.js'; export { BreadCrumbTargettable as BreadCrumb } from './breadcrumb'; +export { FrequentlyAccess } from './frequently_access';