From 074d0128982e39adf30f0ab4d3300b7b700a23e1 Mon Sep 17 00:00:00 2001 From: Andrew Silva Date: Thu, 11 Feb 2021 14:36:57 -0500 Subject: [PATCH 1/4] adding in some old js --- .../templates/lab/chronolawgic/timeline.html | 4 +- capstone/static/js/labs/chronolawgic/main.js | 4 +- capstone/static/js/labs/chronolawgic/store.js | 125 ++++++++++++++++++ 3 files changed, 129 insertions(+), 4 deletions(-) create mode 100644 capstone/static/js/labs/chronolawgic/store.js diff --git a/capstone/labs/templates/lab/chronolawgic/timeline.html b/capstone/labs/templates/lab/chronolawgic/timeline.html index a67fad84c..3ad61b997 100644 --- a/capstone/labs/templates/lab/chronolawgic/timeline.html +++ b/capstone/labs/templates/lab/chronolawgic/timeline.html @@ -22,9 +22,7 @@ }; {% render_bundle 'labs-chronolawgic' %} {% endblock %} diff --git a/capstone/static/js/labs/chronolawgic/main.js b/capstone/static/js/labs/chronolawgic/main.js index f5ec2d7e6..e8a815744 100644 --- a/capstone/static/js/labs/chronolawgic/main.js +++ b/capstone/static/js/labs/chronolawgic/main.js @@ -1,8 +1,10 @@ import Vue from 'vue' import Timeline from './timeline' +import store from "./store"; new Vue({ el: '#app', + store: store, template: '', components: {Timeline} -}) \ No newline at end of file +}) diff --git a/capstone/static/js/labs/chronolawgic/store.js b/capstone/static/js/labs/chronolawgic/store.js new file mode 100644 index 000000000..188d777f9 --- /dev/null +++ b/capstone/static/js/labs/chronolawgic/store.js @@ -0,0 +1,125 @@ +import Vue from 'vue' +import Vuex from 'vuex' +import ClientConfig from './chronolawgic-client-config.json' +import axios from "axios"; + +Vue.use(Vuex) +const store = new Vuex.Store({ + state: { + placeholder: 'placeholder', + authentication: { + "name": "test user", // what is their name? + "token": false, // What is their server authentication token? + "admin_users": false, // Can this user administer users? + "can_create": false, // Can this user create new timelines? + "timelines": [] // What timelines can this user edit? + }, + available_timelines: [ + //TODO: store a list of timeline titles/ids available on the server + ], + timeline: { + //TODO: timeline structure + + id: 1, + title: "Timeline Title", + created_by: "Editable Text", // (user accts are for auth/logging purposes) + categories: { + Case: {id: "1", color: "#FF9911"}, + Legislation: {id: "2", color: "#99FF11"}, + ExecutiveOrder: {id: "3", color: "#FF9988"}, + Anarchism: {id: "4", color: "#11FF99"}, + Police: {id: "5", color: "#8899FF"}, + Fascism: {id: "6", color: "#1199FF"}, + }, + events: { + 0: { + title: "Case 1", + categories: [1, 3], + cap_link: "https://cite.case.law/ill/1/176/", + link: false, + description: "Though the Court upheld a conviction for membership in a group that advocated the overthrow of the state, Justice Brandeis explained, in a separate opinion, that under the \"clear and present danger test\" the strong presumption must be in favor of \"more speech, not enforced silence.\" That view, which ultimately prevailed, laid the groundwork for modern First Amendment law.", + start_year: 1880, + thumb: 123, + }, + 1: { + title: "Case 2", + categories: [1, 2], + cap_link: "https://cite.case.law/ill/1/176/", + link: false, + description: "Our first Supreme Court landmark. Though upholding the defendant's conviction for distributing his call to overthrow the government, the Court held, for the first time, that the Fourteenth Amendment \"incorporates\" the free speech clause of the First Amendment and is, therefore, applicable to the states.", + start_year: 1881, + thumb: 123, + // What else do we need? Disposition? Collapsed/Visible? Hidden? Draft? Author? + }, + 2: { + title: "Case 3", + categories: [1, 2], + cap_link: "https://cite.case.law/ill/1/176/", + link: false, + description: "Our first Supreme Court landmark. Though upholding the defendant's conviction for distributing his call to overthrow the government, the Court held, for the first time, that the Fourteenth Amendment \"incorporates\" the free speech clause of the First Amendment and is, therefore, applicable to the states.", + start_year: 1880, + thumb: 123, + // What else do we need? Disposition? Collapsed/Visible? Hidden? Draft? Author? + } + }, + years: {1880: [0, 2], 1881: [1]}, + app_meta: { // DOESN'T GET EXPORTED — implementation specific + acl: [], + created_by: 1, + is_draft: true, + is_hidden: false, + }, + }, + updated_timeline: { + //TODO: updated timeline structure to store edits + } + }, + mutations: { + writeTimeline(state) { + //TODO: Do any data transformations necessary + //TODO: Check credentials + //TODO: Send updated timeline to server + state.placeholder = 9; + }, + createTimeline(state) { + //TODO: Check credentials + //TODO: Get new timeline ID from server + state.placeholder = 9; + }, + deleteTimeline(state) { + //TODO: Do any data transformations necessary + state.placeholder = 9; + }, + setTimeline(state) { + //TODO: Do any data transformations necessary + // state.timeline = state.timeline; + console.log("setTimeline", state.timeline) + } + }, + getters: { + readTimeline(state) { + state.placeholder++ + }, + getEvents(state) { + return state.timeline.events; + }, + }, + actions: { + authenticate(credentials = false) { + console.log("authenticating with :") + console.log(credentials) + return false + }, + getTimeLine: function ({commit}) { + //TODO make this work with vue router so it gets the new timeine as the route changes + axios + .get(ClientConfig.server_url) + .then(response => response.data) + .then(timeline => { + console.log(timeline); + commit('setTimeline', timeline) + }) + }, + }, +}) +export default store; \ No newline at end of file From f9aa2c6580d7744d733205f6e9afae9c66ea657b Mon Sep 17 00:00:00 2001 From: Andrew Silva Date: Thu, 11 Feb 2021 14:37:46 -0500 Subject: [PATCH 2/4] added axios --- capstone/package.json | 1 + capstone/yarn.lock | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/capstone/package.json b/capstone/package.json index 6929fd58e..c85dd0d27 100644 --- a/capstone/package.json +++ b/capstone/package.json @@ -11,6 +11,7 @@ "dependencies": { "acorn": "^6.4.1", "awesome-charts": "^1.0.0", + "axios": "^0.21.1", "chart.js": "^2.8.0", "commander": "^2.20.0", "core-js": "^3.6.5", diff --git a/capstone/yarn.lock b/capstone/yarn.lock index bb1f5f56d..79f897749 100644 --- a/capstone/yarn.lock +++ b/capstone/yarn.lock @@ -1871,6 +1871,13 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.11.0.tgz#d61f46d83b2519250e2784daf5b09479a8b41c59" integrity sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA== +axios@^0.21.1: + version "0.21.1" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.1.tgz#22563481962f4d6bde9a76d516ef0e5d3c09b2b8" + integrity sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA== + dependencies: + follow-redirects "^1.10.0" + babel-eslint@^10.1.0: version "10.1.0" resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.1.0.tgz#6968e568a910b78fb3779cdd8b6ac2f479943232" @@ -4449,6 +4456,11 @@ follow-redirects@^1.0.0: resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.0.tgz#b42e8d93a2a7eea5ed88633676d6597bc8e384db" integrity sha512-aq6gF1BEKje4a9i9+5jimNFIpq4Q1WiwBToeRK5NvZBd/TRsmW8BsJfOEGkr76TbOyPVD3OVDN910EcUNtRYEA== +follow-redirects@^1.10.0: + version "1.13.2" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.13.2.tgz#dd73c8effc12728ba5cf4259d760ea5fb83e3147" + integrity sha512-6mPTgLxYm3r6Bkkg0vNM0HTjfGrOEtsfbhagQvbxDEsEkpNhw582upBaoRZylzen6krEmxXJgt9Ju6HiI4O7BA== + for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" From 7bb14855f47afba751938446ff157cbb9eeee51d Mon Sep 17 00:00:00 2001 From: Andrew Silva Date: Thu, 11 Feb 2021 22:14:02 -0500 Subject: [PATCH 3/4] modified urls --- capstone/config/urls.py | 2 +- .../templates/lab/chronolawgic/timeline.html | 5 ++++- capstone/labs/urls.py | 1 - .../static/js/labs/chronolawgic/admin.vue | 22 +++++++++++++++++++ 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 capstone/static/js/labs/chronolawgic/admin.vue diff --git a/capstone/config/urls.py b/capstone/config/urls.py index 61fc9dc09..feb4eba18 100644 --- a/capstone/config/urls.py +++ b/capstone/config/urls.py @@ -20,7 +20,7 @@ urlpatterns = [ path('admin/', admin.site.urls), path('', include('capweb.urls')), - path('labs/', include('labs.urls')), + path('labs/', include(('labs.urls', 'labs'), namespace="labs")), ] # use django-debug-toolbar if installed diff --git a/capstone/labs/templates/lab/chronolawgic/timeline.html b/capstone/labs/templates/lab/chronolawgic/timeline.html index 3ad61b997..e5021b255 100644 --- a/capstone/labs/templates/lab/chronolawgic/timeline.html +++ b/capstone/labs/templates/lab/chronolawgic/timeline.html @@ -17,7 +17,10 @@ // This is essentially each endpoint with its API interface // eslint-disable-next-line const urls = { - api_root: "{% api_url 'api-root' %}v1/", + chronolawgic_api_create: "{% url 'labs:chronolawgic-api-create' %}v1/", + chronolawgic_api_retrieve: "{% url 'labs:chronolawgic-api-retrieve' %}v1/", + chronolawgic_api_update: "{% url 'labs:chronolawgic-api-update' %}v1/", + chronolawgic_api_delete: "{% url 'labs:chronolawgic-api-delete' %}v1/", static: "{% static '' %}" }; diff --git a/capstone/labs/urls.py b/capstone/labs/urls.py index 145eecbe0..d73c153fc 100644 --- a/capstone/labs/urls.py +++ b/capstone/labs/urls.py @@ -18,7 +18,6 @@ name='chronolawgic'), path('chronolawgic/timeline/', views.chronolawgic, name='chronolawgic-dashboard'), # your timeline list, create, delete - path('chronolawgic/timeline/:timeline_id', views.chronolawgic, name='chronolawgic-view'), # view one timeline path('chronolawgic/api/create', views.chronolawgic_api_create, name='chronolawgic-api-create'), path('chronolawgic/api/retrieve/:timeline_id', views.chronolawgic_api_retrieve, name='chronolawgic-api-retrieve'), path('chronolawgic/api/update/:timeline_id', views.chronolawgic_api_update, name='chronolawgic-api-update'), diff --git a/capstone/static/js/labs/chronolawgic/admin.vue b/capstone/static/js/labs/chronolawgic/admin.vue new file mode 100644 index 000000000..a6f1a31d4 --- /dev/null +++ b/capstone/static/js/labs/chronolawgic/admin.vue @@ -0,0 +1,22 @@ + + + From eadd71e99ebc1e207fbc8081fc46b4fac7b95cd8 Mon Sep 17 00:00:00 2001 From: Andrew Silva Date: Thu, 11 Feb 2021 22:19:36 -0500 Subject: [PATCH 4/4] =?UTF-8?q?Added=20vuex=20store=20and=20router?= =?UTF-8?q?=E2=80=94=20not=20working?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/js/labs/chronolawgic/admin.vue | 2 +- capstone/static/js/labs/chronolawgic/main.js | 19 ++- capstone/static/js/labs/chronolawgic/store.js | 134 +++++++++--------- 3 files changed, 85 insertions(+), 70 deletions(-) diff --git a/capstone/static/js/labs/chronolawgic/admin.vue b/capstone/static/js/labs/chronolawgic/admin.vue index a6f1a31d4..f19b9f3d7 100644 --- a/capstone/static/js/labs/chronolawgic/admin.vue +++ b/capstone/static/js/labs/chronolawgic/admin.vue @@ -8,7 +8,7 @@