Skip to content

Commit

Permalink
web(feat): Add config file and custom header
Browse files Browse the repository at this point in the history
  • Loading branch information
fliiiix committed Apr 7, 2020
1 parent 32b7865 commit 0d4d1d7
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
9 changes: 9 additions & 0 deletions web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,14 @@ yarn build
yarn lint
```

### Basic Header Theeming

Not happy with the default Docat logo and header?
Just add your custom html header to the `/var/www/html/config.json` file.

```
{"headerHTML": "<h1>MyCompany</h1>"}
```

### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
4 changes: 3 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"rules": {
"no-console": "off"
},
"parserOptions": {
"parser": "babel-eslint"
},
Expand Down
17 changes: 15 additions & 2 deletions web/src/components/Layout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
<div class="md-layout-item md-size-15 md-small-hide"></div>
<div class="md-layout-item">
<router-link to="/">
<img class="logo" alt="docat logo" src="../assets/logo.png" />
<h1>DOCAT</h1>
<div v-html="header" />
</router-link>
<slot name="toolbar"></slot>
</div>
Expand All @@ -29,10 +28,24 @@
</template>

<script>
import ProjectRepository from '@/repositories/ProjectRepository'
export default {
name: 'layout',
props: {
fullscreen: Boolean,
},
data() {
const defaultHeader = '<img class="logo" alt="docat logo" src="' + require('../assets/logo.png') + '" /><h1>DOCAT</h1>'
return {
header: defaultHeader,
}
},
async created() {
const config = ProjectRepository.getConfig()
if (config.hasOwnProperty('headerHTML')){
this.header = config.headerHTML
}
}
}
</script>
Expand Down
12 changes: 12 additions & 0 deletions web/src/repositories/ProjectRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,18 @@ import Repository from '@/repositories/Repository'
const resource = 'doc'
export default {

/**
* Get Config
*/
async getConfig() {
try {
const result = await Repository.get(`${Repository.defaults.baseURL}/config.json`)
return result.data;
} catch {
return {}
}
},

/**
* Returns all projects
*/
Expand Down

0 comments on commit 0d4d1d7

Please sign in to comment.