From 5b06cba32798fffc5c1db5139800248332ec2b7c Mon Sep 17 00:00:00 2001
From: Torsten
Date: Thu, 30 Jan 2020 11:51:41 +0100
Subject: [PATCH] Store edited page in DB
---
motorradig/.idea/workspace.xml | 5 +-
motorradig/public/js/app.js | 409 ++++++++++-----------
motorradig/resources/js/views/EditPage.vue | 22 +-
motorradig/resources/js/views/Main.vue | 33 +-
4 files changed, 235 insertions(+), 234 deletions(-)
diff --git a/motorradig/.idea/workspace.xml b/motorradig/.idea/workspace.xml
index 99715ac..374d8ba 100644
--- a/motorradig/.idea/workspace.xml
+++ b/motorradig/.idea/workspace.xml
@@ -4,10 +4,8 @@
-
-
@@ -224,7 +222,8 @@
-
+
+
diff --git a/motorradig/public/js/app.js b/motorradig/public/js/app.js
index ae70dda..e49d445 100644
--- a/motorradig/public/js/app.js
+++ b/motorradig/public/js/app.js
@@ -1894,7 +1894,6 @@ __webpack_require__.r(__webpack_exports__);
//
//
//
-//
/* harmony default export */ __webpack_exports__["default"] = ({
@@ -1921,6 +1920,23 @@ __webpack_require__.r(__webpack_exports__);
//console.log(this.editor.docView.dom.innerHTML);
console.log(this.editor.view.docView.dom.innerHTML);
+ },
+ savePage: function savePage() {
+ var _this = this;
+
+ axios.post('http://localhost:8000/api/v1/auth/save_page', {
+ page: 'testpage',
+ body: this.editor.view.docView.dom.innerHTML
+ }, {
+ headers: {
+ 'Authorization': 'Bearer ' + this.$store.state.user_token
+ }
+ }).then(function (res) {
+ console.log("savePage: Wrote Testpage");
+ console.log("Going back to main view");
+
+ _this.$router.push("/");
+ });
}
}
});
@@ -1983,14 +1999,6 @@ __webpack_require__.r(__webpack_exports__);
//
//
//
-//
-//
-//
-//
-//
-//
-//
-//
/* harmony default export */ __webpack_exports__["default"] = ({
data: function data() {
return {
@@ -2053,15 +2061,15 @@ __webpack_require__.r(__webpack_exports__);
},
created: function created() {
console.log("Main component created");
- /*
- if (!this.$store.state.user.token) {
- console.log("No token on user detected. Waiting for user login.");
- console.log("store.state.user:");
- console.log(this.$store.state.user);
+
+ if (!this.$store.state.user_token) {
+ console.log("No token on user detected. Waiting for user login.");
+ console.log("store.state.user:");
+ console.log(this.$store.state.user);
} else {
- this.$router.push("/main");
+ //this.$router.push("/main");
+ this.loadPage();
}
- */
}
});
@@ -31065,7 +31073,22 @@ var render = function() {
])
}),
_vm._v(" "),
- _c("editor-content", { attrs: { editor: _vm.editor } })
+ _c("editor-content", { attrs: { editor: _vm.editor } }),
+ _vm._v(" "),
+ _c("p", [
+ _c(
+ "button",
+ {
+ staticClass: "button",
+ on: {
+ click: function($event) {
+ return _vm.savePage()
+ }
+ }
+ },
+ [_vm._v("Speichern")]
+ )
+ ])
],
1
)
@@ -31098,197 +31121,160 @@ var render = function() {
_vm._v("Motorrad IG\n ")
]),
_vm._v(" "),
- _c(
- "div",
- { staticClass: "has-text-centered" },
- [
- _c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.changeMainText("Über uns")
- }
+ _c("div", { staticClass: "has-text-centered" }, [
+ _c(
+ "button",
+ {
+ staticClass: "button",
+ on: {
+ click: function($event) {
+ return _vm.changeMainText("Über uns")
}
- },
- [_vm._v("Über uns")]
- ),
- _vm._v(" "),
- _c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.changeMainText("Aktuelles")
- }
+ }
+ },
+ [_vm._v("Über uns")]
+ ),
+ _vm._v(" "),
+ _c(
+ "button",
+ {
+ staticClass: "button",
+ on: {
+ click: function($event) {
+ return _vm.changeMainText("Aktuelles")
}
- },
- [_vm._v("Aktuelles")]
- ),
- _vm._v(" "),
- _c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.changeMainText("Mitgliedsantrag")
- }
+ }
+ },
+ [_vm._v("Aktuelles")]
+ ),
+ _vm._v(" "),
+ _c(
+ "button",
+ {
+ staticClass: "button",
+ on: {
+ click: function($event) {
+ return _vm.changeMainText("Mitgliedsantrag")
}
- },
- [_vm._v("Mitgliedsantrag")]
- ),
- _vm._v(" "),
- !this.$store.state.user.hasOwnProperty("role")
- ? _c("span", [
- _c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.changeMainText("Tourplan")
- }
+ }
+ },
+ [_vm._v("Mitgliedsantrag")]
+ ),
+ _vm._v(" "),
+ !this.$store.state.user.hasOwnProperty("role")
+ ? _c("span", [
+ _c(
+ "button",
+ { staticClass: "button", on: { click: function($event) {} } },
+ [_vm._v("Tourplan (Beispiel)")]
+ )
+ ])
+ : this.$store.state.user.role === "GUEST"
+ ? _c("span", [
+ _c(
+ "button",
+ { staticClass: "button", on: { click: function($event) {} } },
+ [_vm._v("Tourplan (Gast)")]
+ )
+ ])
+ : this.$store.state.user.role === "MEMBER"
+ ? _c("span", [
+ _c(
+ "button",
+ { staticClass: "button", on: { click: function($event) {} } },
+ [_vm._v("Tourplan (komplett)")]
+ )
+ ])
+ : this.$store.state.user.role === "ADMIN"
+ ? _c("span", [
+ _c(
+ "button",
+ { staticClass: "button", on: { click: function($event) {} } },
+ [_vm._v("Tourplan (komplett)")]
+ )
+ ])
+ : _vm._e(),
+ _vm._v(" "),
+ this.$store.state.user.role === "ADMIN"
+ ? _c("span", [
+ _c(
+ "button",
+ { staticClass: "button", on: { click: function($event) {} } },
+ [_vm._v("Userverwaltung")]
+ )
+ ])
+ : _vm._e(),
+ _vm._v(" "),
+ _c(
+ "button",
+ {
+ staticClass: "button",
+ on: {
+ click: function($event) {
+ return _vm.changeMainText("Wetter")
+ }
+ }
+ },
+ [_vm._v("Wetter")]
+ ),
+ _vm._v(" "),
+ _c(
+ "button",
+ {
+ staticClass: "button",
+ on: {
+ click: function($event) {
+ return _vm.changeMainText("Links")
+ }
+ }
+ },
+ [_vm._v("Links")]
+ ),
+ _vm._v(" "),
+ _c(
+ "button",
+ {
+ staticClass: "button",
+ on: {
+ click: function($event) {
+ return _vm.changeMainText("Impressum")
+ }
+ }
+ },
+ [_vm._v("Impressum")]
+ ),
+ _vm._v(" "),
+ this.$store.state.user.hasOwnProperty("role")
+ ? _c("span", [
+ _c(
+ "button",
+ {
+ staticClass: "button",
+ on: {
+ click: function($event) {
+ return _vm.logout()
}
- },
- [_vm._v("Tourplan (Beispiel)")]
- )
- ])
- : this.$store.state.user.role === "GUEST"
- ? _c("span", [
+ }
+ },
+ [_vm._v("Logout")]
+ )
+ ])
+ : _vm._e(),
+ _vm._v(" "),
+ !this.$store.state.user.hasOwnProperty("role")
+ ? _c(
+ "span",
+ [
_c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.changeMainText("Tourplan")
- }
- }
- },
- [_vm._v("Tourplan (Gast)")]
+ "router-link",
+ { staticClass: "button", attrs: { to: { name: "Login" } } },
+ [_vm._v("Log-In")]
)
- ])
- : this.$store.state.user.role === "MEMBER"
- ? _c("span", [
- _c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.changeMainText("Tourplan")
- }
- }
- },
- [_vm._v("Tourplan (komplett)")]
- )
- ])
- : this.$store.state.user.role === "ADMIN"
- ? _c("span", [
- _c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.changeMainText("Tourplan")
- }
- }
- },
- [_vm._v("Tourplan (komplett)")]
- )
- ])
- : _vm._e(),
- _vm._v(" "),
- _c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.changeMainText("Wetter")
- }
- }
- },
- [_vm._v("Wetter")]
- ),
- _vm._v(" "),
- _c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.changeMainText("Links")
- }
- }
- },
- [_vm._v("Links")]
- ),
- _vm._v(" "),
- _c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.changeMainText("Impressum")
- }
- }
- },
- [_vm._v("Impressum")]
- ),
- _vm._v(" "),
- _c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.savePage()
- }
- }
- },
- [_vm._v("Save Page")]
- ),
- _vm._v(" "),
- _c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.loadPage()
- }
- }
- },
- [_vm._v("Load Page")]
- ),
- _vm._v(" "),
- _c(
- "button",
- {
- staticClass: "button",
- on: {
- click: function($event) {
- return _vm.logout()
- }
- }
- },
- [_vm._v("Logout")]
- ),
- _vm._v(" "),
- _c(
- "router-link",
- { staticClass: "button", attrs: { to: { name: "Login" } } },
- [_vm._v("Log-In")]
- )
- ],
- 1
- ),
+ ],
+ 1
+ )
+ : _vm._e()
+ ]),
_vm._v(" "),
_c("p", [_vm._v(" ")]),
_vm._v(" "),
@@ -31302,20 +31288,27 @@ var render = function() {
"p",
{ staticStyle: { "text-align": "center" }, attrs: { visible: "true" } },
[
+ _c("span", {
+ domProps: { innerHTML: _vm._s(this.$store.state.page_content) }
+ }),
+ _vm._v(" "),
this.$store.state.user.role === "ADMIN"
? _c("span", [
_c("br"),
_c(
"button",
- { staticClass: "button", on: { click: _vm.editPage } },
+ {
+ staticClass: "button",
+ on: {
+ click: function($event) {
+ return _vm.editPage()
+ }
+ }
+ },
[_vm._v("Text bearbeiten")]
)
])
- : _vm._e(),
- _vm._v(" "),
- _c("span", {
- domProps: { innerHTML: _vm._s(this.$store.state.page_content) }
- })
+ : _vm._e()
]
)
])
diff --git a/motorradig/resources/js/views/EditPage.vue b/motorradig/resources/js/views/EditPage.vue
index 875ca54..496ba4d 100644
--- a/motorradig/resources/js/views/EditPage.vue
+++ b/motorradig/resources/js/views/EditPage.vue
@@ -10,7 +10,6 @@
-
@@ -21,7 +20,6 @@
-
@@ -43,10 +41,11 @@
+
-
+
@@ -115,6 +114,23 @@
//console.log(this.editor.view.dom.innerText);
//console.log(this.editor.docView.dom.innerHTML);
console.log(this.editor.view.docView.dom.innerHTML);
+ },
+ savePage() {
+ axios.post('http://localhost:8000/api/v1/auth/save_page',{
+ page: 'testpage',
+ body: this.editor.view.docView.dom.innerHTML
+
+ }, {
+ headers: {
+ 'Authorization': 'Bearer ' + this.$store.state.user_token
+ }
+ })
+ .then(res => {
+ console.log("savePage: Wrote Testpage");
+ console.log("Going back to main view");
+ this.$router.push("/");
+ }
+ )
}
}
}
diff --git a/motorradig/resources/js/views/Main.vue b/motorradig/resources/js/views/Main.vue
index b9e6775..e57af51 100644
--- a/motorradig/resources/js/views/Main.vue
+++ b/motorradig/resources/js/views/Main.vue
@@ -9,24 +9,20 @@
+
+
+
+
-
-
-
-
-
+
-
-
-
-
- Log-In
-
+
+ Log-In
@@ -36,17 +32,13 @@
-
-
-
+
-
-
@@ -125,15 +117,16 @@
created() {
console.log("Main component created");
- /*
- if (!this.$store.state.user.token) {
+
+ if (!this.$store.state.user_token) {
console.log("No token on user detected. Waiting for user login.");
console.log("store.state.user:");
console.log(this.$store.state.user);
} else {
- this.$router.push("/main");
+ //this.$router.push("/main");
+ this.loadPage();
}
- */
+
}
}