From 4b8a905d2a12aad8b41bd15f8a1d85990f67b765 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Mon, 26 Nov 2018 09:42:52 +0200 Subject: [PATCH 01/21] Dummy theme generation --- client/src/modules/bdwebapi.js | 40 ++++++++++++++++++++++ client/src/ui/components/bd/ThemesView.vue | 32 ++--------------- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/client/src/modules/bdwebapi.js b/client/src/modules/bdwebapi.js index b077cc0f..6ed67a92 100644 --- a/client/src/modules/bdwebapi.js +++ b/client/src/modules/bdwebapi.js @@ -19,6 +19,45 @@ const ENDPOINTS = { 'statistics': `${APIBASE}/statistics` }; +const dummyTags = ['tag1', 'tag2', 'tag3', 'tag4', 'tag5']; +const dummyRepo = { + name: 'ExampleRepository', + baseUri: 'https://github.com/Jiiks/ExampleRepository', + rawUri: 'https://github.com/Jiiks/ExampleRepository/raw/master' +}; +const dummyVersion = () => `${Math.round(Math.random() * 3)}.${Math.round(Math.random() * 10)}.${Math.round(Math.random() * 10)}`; +const dummyFiles = { + readme: 'Example/readme.md', + previews: [{ + large: 'Example/preview1-big.png', + thumb: 'Example/preview1-small.png' + }] +}; +const dummyAuthor = 'DummyAuthor'; + +async function dummyThemes() { + // Simulate get + await new Promise(r => setTimeout(r, Math.random() * 3000)); + const dummies = []; + for (let i = 0; i < 10; i++) { + dummies.push({ + id: `theme${i}`, + name: `Dummy ${i}`, + tags: dummyTags, + installs: Math.floor(Math.random() * 10000), + updated: '2018-07-21T14:51:32.057Z', + rating: Math.floor(Math.random() * 1000), + activeUsers: Math.floor(Math.random() * 1000), + rated: Math.random() > .5, + version: dummyVersion(), + repository: dummyRepo, + files: dummyFiles, + author: dummyAuthor + }); + } + return { docs: dummies }; +} + export default class BdWebApi { static get themes() { @@ -41,6 +80,7 @@ export default class BdWebApi { } static getThemes(args) { + return dummyThemes(); if (!args) return request.get(ENDPOINTS.themes); const { id } = args; if (id) return request.get(ENDPOINTS.theme(id)); diff --git a/client/src/ui/components/bd/ThemesView.vue b/client/src/ui/components/bd/ThemesView.vue index 9444f86e..23553152 100644 --- a/client/src/ui/components/bd/ThemesView.vue +++ b/client/src/ui/components/bd/ThemesView.vue @@ -76,36 +76,8 @@ async refreshOnline() { this.loadingOnline = true; try { - // const getThemes = await BdWebApi.themes.get(); - // this.onlineThemes = JSON.parse(getThemes); - const dummies = []; - for (let i = 0; i < 10; i++) { - dummies.push({ - id: `theme${i}`, - name: `Dummy ${i}`, - tags: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5'], - installs: Math.floor(Math.random() * 10000), - updated: '2018-07-21T14:51:32.057Z', - rating: Math.floor(Math.random() * 1000), - activeUsers: Math.floor(Math.random() * 1000), - rated: Math.random() > .5, - version: '1.0.0', - repository: { - name: 'ExampleRepository', - baseUri: 'https://github.com/Jiiks/ExampleRepository', - rawUri: 'https://github.com/Jiiks/ExampleRepository/raw/master' - }, - files: { - readme: 'Example/readme.md', - previews: [{ - large: 'Example/preview1-big.png', - thumb: 'Example/preview1-small.png' - }] - }, - author: 'Jiiks' - }); - } - this.onlineThemes = { docs: dummies }; + const getThemes = await BdWebApi.themes.get(); + this.onlineThemes = getThemes; } catch (err) { Logger.err('ThemesView', err); } finally { From 83a4e0a114d2a24b9d3ee2366548b7e39597c66d Mon Sep 17 00:00:00 2001 From: Jiiks Date: Mon, 26 Nov 2018 09:55:59 +0200 Subject: [PATCH 02/21] Use moment --- client/src/ui/components/bd/RemoteCard.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/ui/components/bd/RemoteCard.vue b/client/src/ui/components/bd/RemoteCard.vue index 7ca0d425..3b87f344 100644 --- a/client/src/ui/components/bd/RemoteCard.vue +++ b/client/src/ui/components/bd/RemoteCard.vue @@ -20,7 +20,7 @@
{{item.installs}} Installs
{{item.activeUsers}} Active Users
-
Updated: Some time ago
+
Updated {{fromNow()}}
@@ -36,6 +36,7 @@ From d5a82ab2b34c21ae0a8ff38c742619aa155dd721 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Mon, 26 Nov 2018 17:04:20 +0200 Subject: [PATCH 07/21] Load more spinner --- client/src/styles/partials/bdsettings/contentview.scss | 6 ++++++ client/src/ui/components/bd/ThemesView.vue | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/client/src/styles/partials/bdsettings/contentview.scss b/client/src/styles/partials/bdsettings/contentview.scss index 907b123c..ce03ab24 100644 --- a/client/src/styles/partials/bdsettings/contentview.scss +++ b/client/src/styles/partials/bdsettings/contentview.scss @@ -11,6 +11,12 @@ padding: 50px 0; } + .bd-onlinePhBody { + .bd-spinnerContainer { + padding: 0; + } + } + h3 { color: #fff; font-weight: 700; diff --git a/client/src/ui/components/bd/ThemesView.vue b/client/src/ui/components/bd/ThemesView.vue index 2649125e..04600c02 100644 --- a/client/src/ui/components/bd/ThemesView.vue +++ b/client/src/ui/components/bd/ThemesView.vue @@ -31,11 +31,14 @@
-
+
+
+
+
@@ -60,7 +63,8 @@ local: true, localThemes: ThemeManager.localThemes, onlineThemes: null, - loadingOnline: false + loadingOnline: false, + loadingMore: false }; }, components: { From 98bf4d21ac6b6990fd858ca397e376a68559e39c Mon Sep 17 00:00:00 2001 From: Jiiks Date: Mon, 26 Nov 2018 17:15:26 +0200 Subject: [PATCH 08/21] Load more on scroll --- client/src/modules/bdwebapi.js | 2 +- client/src/ui/components/bd/ThemesView.vue | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/client/src/modules/bdwebapi.js b/client/src/modules/bdwebapi.js index 0bb3e588..2c38062f 100644 --- a/client/src/modules/bdwebapi.js +++ b/client/src/modules/bdwebapi.js @@ -42,7 +42,7 @@ async function dummyThemes() { const dummies = []; for (let i = 0; i < 10; i++) { dummies.push({ - id: `theme${i}`, + id: `theme${i}${btoa(Math.random()).substring(3, 9)}`, name: `Dummy ${i}`, tags: dummyTags, installs: Math.floor(Math.random() * 10000), diff --git a/client/src/ui/components/bd/ThemesView.vue b/client/src/ui/components/bd/ThemesView.vue index 04600c02..d921ebb2 100644 --- a/client/src/ui/components/bd/ThemesView.vue +++ b/client/src/ui/components/bd/ThemesView.vue @@ -84,7 +84,7 @@ await this.ThemeManager.refreshThemes(); }, async refreshOnline() { - if (this.loadingOnline) return; + if (this.loadingOnline || this.loadingMore) return; this.loadingOnline = true; try { const getThemes = await BdWebApi.themes.get(); @@ -123,11 +123,20 @@ }); }, searchInput(e) { - if (this.loadingOnline) return; + if (this.loadingOnline || this.loadingMore) return; this.refreshOnline(); }, - scrollend(e) { - console.log('scrollend'); + async scrollend(e) { + if (this.loadingOnline || this.loadingMore) return; + this.loadingMore = true; + try { + const getThemes = await BdWebApi.themes.get(); + this.onlineThemes.docs = [...this.onlineThemes.docs, ...getThemes.docs]; + } catch (err) { + Logger.err('ThemesView', err); + } finally { + this.loadingMore = false; + } } } } From a8f686eb61dbea8403e023bf5a37e27cab7d905e Mon Sep 17 00:00:00 2001 From: Jiiks Date: Wed, 28 Nov 2018 08:50:14 +0200 Subject: [PATCH 09/21] only scroll body --- .../src/styles/partials/bdsettings/contentview.scss | 11 +++++++++++ .../src/styles/partials/bdsettings/remotecard.scss | 3 +-- .../styles/partials/sidebarview/settingswrap.scss | 10 ++++++++-- client/src/ui/components/bd/SettingsWrapper.vue | 13 +++++++++++-- client/src/ui/components/bd/ThemesView.vue | 10 +++++----- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/client/src/styles/partials/bdsettings/contentview.scss b/client/src/styles/partials/bdsettings/contentview.scss index ce03ab24..76224c57 100644 --- a/client/src/styles/partials/bdsettings/contentview.scss +++ b/client/src/styles/partials/bdsettings/contentview.scss @@ -11,10 +11,21 @@ padding: 50px 0; } + .bd-onlinePhHeader { + padding: 0 20px 0 0; + } + .bd-onlinePhBody { + margin-top: 10px; + .bd-spinnerContainer { padding: 0; } + + .bd-scroller { + padding: 0 20px 0 0; + } + } h3 { diff --git a/client/src/styles/partials/bdsettings/remotecard.scss b/client/src/styles/partials/bdsettings/remotecard.scss index 2a851cd8..7754a4f7 100644 --- a/client/src/styles/partials/bdsettings/remotecard.scss +++ b/client/src/styles/partials/bdsettings/remotecard.scss @@ -1,8 +1,7 @@ .bd-remoteCard { - display: flex; flex-direction: column; margin-top: 10px; - padding: 10px 0; + padding: 10px; border-radius: 0; border-bottom: 1px solid rgba(114, 118, 126, .3); diff --git a/client/src/styles/partials/sidebarview/settingswrap.scss b/client/src/styles/partials/sidebarview/settingswrap.scss index 57bd0115..b7141d45 100644 --- a/client/src/styles/partials/sidebarview/settingswrap.scss +++ b/client/src/styles/partials/sidebarview/settingswrap.scss @@ -120,8 +120,14 @@ } .bd-settingswrapContents { - padding: 0 20px; - margin-bottom: 84px; + padding: 0 0 0 20px; + } + + .bd-scroller { + .bd-settingswrapContents { + margin-bottom: 84px; + padding: 0 20px; + } } } } diff --git a/client/src/ui/components/bd/SettingsWrapper.vue b/client/src/ui/components/bd/SettingsWrapper.vue index 4236e853..3728a942 100644 --- a/client/src/ui/components/bd/SettingsWrapper.vue +++ b/client/src/ui/components/bd/SettingsWrapper.vue @@ -10,7 +10,16 @@