diff --git a/assets/web/admin.html b/assets/web/admin.html index 178cb5e..1ae6174 100644 --- a/assets/web/admin.html +++ b/assets/web/admin.html @@ -9,7 +9,7 @@
- Publish Theme + Publish Theme Manage

{{ header }}

diff --git a/assets/web/static/app.js b/assets/web/static/app.js index ccbb707..ededadf 100644 --- a/assets/web/static/app.js +++ b/assets/web/static/app.js @@ -1,11 +1,51 @@ const episodepublishform = { - template: '

Publish Episode

', - current_page: "Publish Episode" + template: '

Publish Episode

' +} + +const episodemanagement = { + template: '
TitleURLActions
{{ item.title }}{{ item.url }}Remove Edit
', + data() { + return { + loading: false, + items: null, + error: null + } + }, + created() { + // fetch the data when the view is created and the data is + // already being observed + this.fetchData() + }, + watch: { + // call again the method if the route changes + '$route': 'fetchData' + }, + methods: { + fetchData() { + this.error = this.items = [] + this.loading = true + + getEpisodes((err, items) => { + this.loading = false + if (err) { + this.error = err.toString() + } else { + var t = JSON.parse(items).items + for (var i = t.length - 1; i >= 0; i--) { + this.items.push({ + title: t[i].title, + url: t[i].url + }) + } + } + console.log(this.items) + }) + } + } } const customcss = { template: '

Edit CSS


', - current_page: "Publish Episode", data() { return { loading: false, @@ -27,7 +67,7 @@ const customcss = { this.error = this.css = null this.loading = true - getCss( (err, css) => { + getCss((err, css) => { this.loading = false if (err) { this.error = err.toString() @@ -41,6 +81,7 @@ const customcss = { const routes = [ { path: '/publish', component: episodepublishform }, + { path: '/manage', component: episodemanagement }, { path: '/theme', component: customcss } ] @@ -57,10 +98,20 @@ const app = new Vue({ function getCss(callback) { var xmlHttp = new XMLHttpRequest(); - xmlHttp.onreadystatechange = function() { + xmlHttp.onreadystatechange = function() { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) callback(null, xmlHttp.responseText) } xmlHttp.open("GET", "/admin/css", true); xmlHttp.send(null); +} + +function getEpisodes(callback) { + var xmlHttp = new XMLHttpRequest(); + xmlHttp.onreadystatechange = function() { + if (xmlHttp.readyState == 4 && xmlHttp.status == 200) + callback(null, xmlHttp.responseText) + } + xmlHttp.open("GET", "/json", true); + xmlHttp.send(null); } \ No newline at end of file