From 8d40beb996c38878b212279b902ba46cff71480b Mon Sep 17 00:00:00 2001 From: Wei Date: Fri, 2 Dec 2022 01:27:58 -0500 Subject: [PATCH 01/49] add login status --- src/App.vue | 64 +++++++++++++++++++++++++++---------- src/main.js | 1 + src/views/DashboardView.vue | 60 +++++++++++++++++++++++++++++++--- src/views/Home.vue | 52 ++++++++++-------------------- src/views/LoginView.vue | 3 +- src/views/RegisterView.vue | 5 ++- 6 files changed, 125 insertions(+), 60 deletions(-) diff --git a/src/App.vue b/src/App.vue index bb10891..bafb4dc 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,38 +1,70 @@ + + \ No newline at end of file diff --git a/src/views/Home.vue b/src/views/Home.vue index 08c20f2..199b687 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -1,17 +1,21 @@ @@ -20,10 +24,11 @@ export default { name: 'app', data() { return { + authenticated: (localStorage.getItem('authenticated') === 'true'), mainPageMSG1: 'Welcome to InfluCo!', mainPageMSG2: 'The world’s most powerful influencer analysis platform' } - } + }, } @@ -34,6 +39,8 @@ export default { body { background-image: url('../assets/mainPageBackground.jpg'); + background-size: cover; + background-repeat: no-repeat; } a { @@ -98,31 +105,4 @@ a { .button-87:active { transform: scale(0.95); } - - - \ No newline at end of file + \ No newline at end of file diff --git a/src/views/LoginView.vue b/src/views/LoginView.vue index fa8a540..495eb36 100644 --- a/src/views/LoginView.vue +++ b/src/views/LoginView.vue @@ -23,7 +23,6 @@ - \ No newline at end of file diff --git a/src/views/SearchView.vue b/src/views/SearchView.vue index 9b9e78b..33705ea 100644 --- a/src/views/SearchView.vue +++ b/src/views/SearchView.vue @@ -73,10 +73,7 @@ @@ -107,9 +104,7 @@ @@ -142,9 +137,7 @@ @@ -190,6 +183,7 @@ export default { tag: "", influencers: 0, copy_influencers: 0, + origin_influencers: 0, // influencers: null, => impossible for vue3 to declare null variable during rendering startIndex: 1, left: false, @@ -227,6 +221,7 @@ export default { throw new Error('API does not return anything for frontend') } this.copy_influencers = this.influencers; + this.origin_influencers = this.influencers; this.isLoading = false; this.isShowing = true; console.log("Author list has " + this.influencers.length + " authors"); @@ -271,6 +266,7 @@ export default { }, sort() { if (this.selected === "") { + this.influencers = this.origin_influencers; return; } if (this.selected === "Followers: High to Low") { @@ -370,10 +366,6 @@ export default { this.startIndexTag += 5; }, filterTag(tagName) { - // console.log(tagName); - // console.log(this.copy_influencers[0]["video_list"][0]["label_list"]); - // console.log(this.copy_influencers[0]["video_list"][1]["label_list"]); - // console.log(this.copy_influencers[0]["video_list"][2]["label_list"]); this.activeTag = tagName; this.influencers = []; for (let k = 0; k < this.copy_influencers.length; k++) { From 81de91b57f3f5b812f297d9d240c2c6683270f49 Mon Sep 17 00:00:00 2001 From: zuoyuwang Date: Tue, 6 Dec 2022 20:22:36 -0500 Subject: [PATCH 03/49] update backend change username and password --- db_helper/mongodb_connect.py | 24 +++++++++++++++++++----- influco_web.py | 32 ++++++++++++++++++++++++++++++-- src/api/user.js | 28 +++++++++++++++++++++++++--- 3 files changed, 74 insertions(+), 10 deletions(-) diff --git a/db_helper/mongodb_connect.py b/db_helper/mongodb_connect.py index 1bdd6c0..b22f027 100644 --- a/db_helper/mongodb_connect.py +++ b/db_helper/mongodb_connect.py @@ -94,15 +94,15 @@ def insert_one_user(user_info: dict): def update_one_user(user_info): - # check if already store in DB username = user_info["username"] query = get_one_user(username) - # exists, update if query: - pass - # insert - user_col.replace_one({"username": username}, user_info) + # replace + + user_col.replace_one({"username": username}, user_info) + else: + user_col.insert_one(user_info) return "Success" @@ -159,6 +159,20 @@ def update_user_likes(username: str, influ_id: str, mode: str): return user_info +def update_username(username: str, new_name): + user_info = get_one_user(username) + user_info['username'] = new_name + user_col.replace_one({"username": username}, user_info) + return user_info + + +def update_password(username: str, password): + user_info = get_one_user(username) + user_info['password'] = password + user_col.replace_one({"username": username}, user_info) + return user_info + + if __name__ == '__main__': print(DB.list_collection_names()) # diff --git a/influco_web.py b/influco_web.py index 5a0e7e8..66017f2 100644 --- a/influco_web.py +++ b/influco_web.py @@ -114,6 +114,36 @@ def get_one_user(username): return jsonify(res) +@app.route('/influco.api/username/', methods=['post']) +def update_username(username): + response_object = {'status': 'fail'} + try: + new_name = request.get_json().get("new_name") + res = dbc.update_username(username, new_name) + # no error message + if not isinstance(res, str): + response_object['status'] = 'success' + response_object['data'] = res + except Exception: + return jsonify({'status': 'error'}) + return jsonify(response_object) + + +@app.route('/influco.api/password/', methods=['post']) +def update_password(username): + response_object = {'status': 'fail'} + try: + password = request.get_json().get("password") + res = dbc.update_password(username, password) + # no error message + if not isinstance(res, str): + response_object['status'] = 'success' + response_object['data'] = res + except Exception: + return jsonify({'status': 'error'}) + return jsonify(response_object) + + @app.route('/influco.api/register/', methods=['put']) def register(username): """get info for one user""" @@ -147,9 +177,7 @@ def login(username): user_info = dbc.get_one_user(data["username"]) if not user_info: return jsonify(response_object) - ############## will be replaced ############## if user_info['password'] != data["password"]: - ############################################## return jsonify(response_object) response_object['status'] = 'success' # Frontend: get user data diff --git a/src/api/user.js b/src/api/user.js index 351ce1d..dd20d76 100644 --- a/src/api/user.js +++ b/src/api/user.js @@ -31,8 +31,30 @@ export function GetUser(username) { }); } +export function ChangeUsername(username, new_name) { + const data = { + new_name: new_name, + }; + return service.request({ + method: 'post', + url: `/username/${username}`, + data, + }); +} + +export function ChangePassword(username, password) { + const data = { + password: password, + }; + return service.request({ + method: 'post', + url: `/password/${username}`, + data, + }); +} + export function AddHistory(username, influ_id) { -const data = { + const data = { influ_id: influ_id, }; return service.request({ @@ -50,7 +72,7 @@ export function ClearHistory(username) { } export function AddLike(username, influ_id) { -const data = { + const data = { influ_id: influ_id, }; return service.request({ @@ -61,7 +83,7 @@ const data = { } export function RemoveLike(username, influ_id) { -const data = { + const data = { influ_id: influ_id, }; return service.request({ From 44b29580efd73d225eaeb35d6a5ebe446558a292 Mon Sep 17 00:00:00 2001 From: zuoyuwang Date: Tue, 6 Dec 2022 20:33:53 -0500 Subject: [PATCH 04/49] keep history views sorted --- db_helper/mongodb_connect.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/db_helper/mongodb_connect.py b/db_helper/mongodb_connect.py index b22f027..0d2bfa3 100644 --- a/db_helper/mongodb_connect.py +++ b/db_helper/mongodb_connect.py @@ -115,19 +115,17 @@ def update_user_history(username: str, influ_id: Optional[str], mode: str): if mode == "delete": user_info['history'] = [] else: - update = False for i, history in enumerate(user_info['history']): if history['influ_id'] == influ_id: # update history by time if mode == "post": - history['time'] = time - update = True + user_info['history'].pop(i) break - if not update: - user_info['history'].append({ - "influ_id": influ_id, - "time": time - }) + + user_info['history'].append({ + "influ_id": influ_id, + "time": time + }) update_one_user(user_info) return user_info From aba0ff538c1948433e1bbfb9222da3a1bf3d42ca Mon Sep 17 00:00:00 2001 From: Wei Date: Wed, 7 Dec 2022 02:58:58 -0500 Subject: [PATCH 05/49] add dashboard --- package-lock.json | 68 +++++ package.json | 3 + public/index.html | 4 +- src/App.vue | 28 +- src/main.js | 1 - src/views/AboutView.vue | 7 + src/views/DashboardView.vue | 583 +++++++++++++++++++++++++++++++++--- src/views/DetailView.vue | 19 +- src/views/Home.vue | 36 ++- src/views/LoginView.vue | 7 +- src/views/PopularView.vue | 15 +- src/views/RegisterView.vue | 5 +- src/views/SearchView.vue | 309 ++++++++++--------- 13 files changed, 862 insertions(+), 223 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2ebbf58..347d9f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,8 +15,11 @@ "@vitejs/plugin-vue": "^3.2.0", "@vue/test-utils": "^2.2.1", "axios": "^1.2.0", + "bootstrap": "^5.2.3", "core-js": "^3.8.3", + "jquery": "^3.6.1", "jsdom": "^20.0.2", + "popper.js": "^1.16.1", "vitest": "^0.24.5", "vue": "^3.2.13", "vue-router": "^4.1.6" @@ -1991,6 +1994,16 @@ "integrity": "sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==", "dev": true }, + "node_modules/@popperjs/core": { + "version": "2.11.6", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz", + "integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==", + "peer": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, "node_modules/@sentry/browser": { "version": "7.17.4", "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.17.4.tgz", @@ -3895,6 +3908,24 @@ "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", "dev": true }, + "node_modules/bootstrap": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.3.tgz", + "integrity": "sha512-cEKPM+fwb3cT8NzQZYEu4HilJ3anCrWqh3CHAok1p9jXqMPsPTBhU25fBckEJHJ/p+tTxTFTsFQGM+gaHpi3QQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/twbs" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/bootstrap" + } + ], + "peerDependencies": { + "@popperjs/core": "^2.11.6" + } + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -7740,6 +7771,11 @@ "@sideway/pinpoint": "^2.0.0" } }, + "node_modules/jquery": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.1.tgz", + "integrity": "sha512-opJeO4nCucVnsjiXOE+/PcCgYw9Gwpvs/a6B1LL/lQhwWwpbVEVYDZ1FokFr8PRc7ghYlrFPuyHuiiDNTQxmcw==" + }, "node_modules/js-cookie": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz", @@ -9284,6 +9320,16 @@ "node": ">=8" } }, + "node_modules/popper.js": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz", + "integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==", + "deprecated": "You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1", + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/popperjs" + } + }, "node_modules/portfinder": { "version": "1.0.32", "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz", @@ -14048,6 +14094,12 @@ "integrity": "sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==", "dev": true }, + "@popperjs/core": { + "version": "2.11.6", + "resolved": "https://registry.npmjs.org/@popperjs/core/-/core-2.11.6.tgz", + "integrity": "sha512-50/17A98tWUfQ176raKiOGXuYpLyyVMkxxG6oylzL3BPOlA6ADGdK7EYunSa4I064xerltq9TGXs8HmOk5E+vw==", + "peer": true + }, "@sentry/browser": { "version": "7.17.4", "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.17.4.tgz", @@ -15614,6 +15666,12 @@ "integrity": "sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==", "dev": true }, + "bootstrap": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.2.3.tgz", + "integrity": "sha512-cEKPM+fwb3cT8NzQZYEu4HilJ3anCrWqh3CHAok1p9jXqMPsPTBhU25fBckEJHJ/p+tTxTFTsFQGM+gaHpi3QQ==", + "requires": {} + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -18344,6 +18402,11 @@ "@sideway/pinpoint": "^2.0.0" } }, + "jquery": { + "version": "3.6.1", + "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.1.tgz", + "integrity": "sha512-opJeO4nCucVnsjiXOE+/PcCgYw9Gwpvs/a6B1LL/lQhwWwpbVEVYDZ1FokFr8PRc7ghYlrFPuyHuiiDNTQxmcw==" + }, "js-cookie": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/js-cookie/-/js-cookie-2.2.1.tgz", @@ -19509,6 +19572,11 @@ "find-up": "^4.0.0" } }, + "popper.js": { + "version": "1.16.1", + "resolved": "https://registry.npmjs.org/popper.js/-/popper.js-1.16.1.tgz", + "integrity": "sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==" + }, "portfinder": { "version": "1.0.32", "resolved": "https://registry.npmjs.org/portfinder/-/portfinder-1.0.32.tgz", diff --git a/package.json b/package.json index 94771e6..deb9416 100644 --- a/package.json +++ b/package.json @@ -18,8 +18,11 @@ "@vitejs/plugin-vue": "^3.2.0", "@vue/test-utils": "^2.2.1", "axios": "^1.2.0", + "bootstrap": "^5.2.3", "core-js": "^3.8.3", + "jquery": "^3.6.1", "jsdom": "^20.0.2", + "popper.js": "^1.16.1", "vitest": "^0.24.5", "vue": "^3.2.13", "vue-router": "^4.1.6" diff --git a/public/index.html b/public/index.html index ba2c38b..b1f9f5f 100644 --- a/public/index.html +++ b/public/index.html @@ -10,9 +10,9 @@ <%= htmlWebpackPlugin.options.title %> -