Skip to content

Commit

Permalink
Adds title for pages
Browse files Browse the repository at this point in the history
  • Loading branch information
amir20 committed Nov 26, 2018
1 parent dd6f4b1 commit b96785f
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
5 changes: 4 additions & 1 deletion assets/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<ul class="menu-list is-hidden-mobile" :class="{ 'is-active': showNav }">
<li v-for="item in containers">
<router-link
:to="{ name: 'container', params: { id: item.Id } }"
:to="{ name: 'container', params: { id: item.Id, name: item.Names[0] } }"
active-class="is-active"
class="tooltip is-tooltip-right is-tooltip-info"
:data-tooltip="item.Names[0]"
Expand All @@ -25,6 +25,7 @@
</ul>
</aside>
<div class="column is-offset-2"><router-view></router-view></div>
<vue-headful :title="title" />
</div>
</template>

Expand All @@ -33,12 +34,14 @@ export default {
name: "App",
data() {
return {
title: "Dozzle",
containers: [],
showNav: false
};
},
async created() {
this.containers = await (await fetch(`${BASE_PATH}/api/containers.json`)).json();
this.title = `${this.containers.length} containers - Dozzle`;
}
};
</script>
Expand Down
2 changes: 2 additions & 0 deletions assets/main.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import Vue from "vue";
import VueRouter from "vue-router";
import vueHeadful from "vue-headful";
import App from "./App.vue";
import Container from "./pages/Container.vue";
import Index from "./pages/Index.vue";

Vue.use(VueRouter);
Vue.component("vue-headful", vueHeadful);

const routes = [
{
Expand Down
9 changes: 6 additions & 3 deletions assets/pages/Container.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
</li>
</ul>
<scrollbar-notification :messages="messages"></scrollbar-notification>
<vue-headful :title="title" />
</div>
</template>

Expand All @@ -29,14 +30,15 @@ const parseMessage = data => {
};
export default {
props: ["id"],
props: ["id", "name"],
name: "Container",
components: {
ScrollbarNotification
},
data() {
return {
messages: []
messages: [],
title: ""
};
},
created() {
Expand All @@ -61,14 +63,15 @@ export default {
this.messages = [];
}
const protocol = SSL_ENABLED ? "wss" : "ws";
ws = new WebSocket(`${protocol}://${window.location.host}${BASE_PATH}/api/logs?id=${this.id}`);
ws = new WebSocket(`${protocol}://${window.location.host}${BASE_PATH}/api/logs?id=${id}`);
ws.onopen = e => console.log("Connection opened.");
ws.onclose = e => console.log("Connection closed.");
ws.onerror = e => console.error("Connection error: " + e.data);
ws.onmessage = e => {
const message = parseMessage(e.data);
this.messages.push(message);
};
this.title = `${this.name} - Dozzle`;
}
}
};
Expand Down
17 changes: 15 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"bulma-tooltip": "^2.0.2",
"date-fns": "^2.0.0-alpha.25",
"vue": "^2.5.17",
"vue-headful": "^2.0.1",
"vue-router": "^3.0.2"
},
"devDependencies": {
Expand Down

0 comments on commit b96785f

Please sign in to comment.