Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
feat(config): admin settings page
Browse files Browse the repository at this point in the history
  • Loading branch information
vhf committed Oct 28, 2019
1 parent 453dee7 commit be6101b
Show file tree
Hide file tree
Showing 24 changed files with 570 additions and 38 deletions.
11 changes: 5 additions & 6 deletions api/github/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,15 @@ module.exports = async function (editorConfig) {

try {
({ token, avatarUrl, serverId } = await checkToken(req, res))

if (!clientId || clientId !== serverId) {
console.error({ message: `Client-provided ID ${clientId} doesn't match server's one ${serverId}` })
res.status(500).send({ message: `Client-provided ID ${clientId} doesn't match server's one` })
return
}
}
catch (err) {
console.error(err)
}
if (!clientId || clientId !== serverId) {
console.error({ message: `Client-provided ID ${clientId} doesn't match server's one ${serverId}` })
res.status(500).send({ message: `Client-provided ID ${clientId} doesn't match server's one` })
return
}

const variables = {
name: clientName,
Expand Down
2 changes: 1 addition & 1 deletion api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ app.use(bodyParser.json({ limit: '4mb' }))
else {
throw new Error('No forge API configured or configured forge API not found.')
}
console.warn(`Starting API middleware with ${api} support, config v${editorConfig.id}`)
console.warn(`Starting Editor for ${process.env.CUSTOMER_NAME} with ${api} support, config v${editorConfig.id}`)

app.use('/', await require(`./${api}`)(editorConfig))
})()
Expand Down
13 changes: 13 additions & 0 deletions apollo/queries/configList.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
query ConfigList {
configList {
nodes {
createdAt
id
reason
author: personByAuthorId {
avatar
username
}
}
}
}
8 changes: 8 additions & 0 deletions apollo/queries/currentPrivateConfig.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
query CurrentPrivateConfig {
currentPrivateConfig {
reason
forge
editor
ontology
}
}
14 changes: 14 additions & 0 deletions apollo/queries/privateConfigVersion.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
query PrivateConfigVersion ($version: Int!) {
privateConfigVersion(version: $version) {
createdAt
id
reason
forge
editor
ontology
personByAuthorId {
avatar
username
}
}
}
235 changes: 235 additions & 0 deletions components/admin/AdminConfigForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
<template>
<section class="section">
<div class="container">
<h1 class="title">1. Editor Settings</h1>
<h2 class="subtitle">1.1. General</h2>
<p></p>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Customer Display Name</label>
</div>
<div class="field-body">
<div class="field">
<p class="control is-expanded">
<input
class="input"
name="customerName"
type="text"
placeholder="Zazuko GmbH"
required>
</p>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Editor Title</label>
</div>
<div class="field-body">
<div class="field">
<p class="control is-expanded">
<input
class="input"
name="customerName"
type="text"
placeholder="ZOE - Zazuko Ontology Editor"
required>
</p>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Editor Short Description</label>
</div>
<div class="field-body">
<div class="field">
<p class="control is-expanded">
<input
class="input"
name="customerName"
type="text"
placeholder="Linked Data Ontology Editor for Domain Specialists"
required>
</p>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Strategy</label>
</div>
<div class="field-body">
<div class="field is-narrow">
<div class="control">
<div class="select is-fullwidth">
<select
name="strategy"
disabled>
<option>GitHub</option>
<option>Local</option>
</select>
</div>
</div>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Protocol &amp; Base URL</label>
</div>
<div class="field-body">
<div class="field has-addons">
<p class="control">
<span class="select">
<select
name="protocol"
class="code">
<option>http</option>
<option>https</option>
</select>
</span>
</p>
<p class="control">
<a class="button is-static code">
://
</a>
</p>
<p class="control">
<input
class="input code"
type="text"
name="host"
placeholder="example.com"
required>
</p>
</div>
</div>
</div>

<hr>

<h2 class="subtitle">1.2. GitHub Personal Access Token</h2>
<p>
A GitHub Personal Access Token is required for the editor to interact with GitHub: create
pull requests, merge them, etc.
</p>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Token</label>
</div>
<div class="field-body">
<div class="field">
<p class="control is-expanded">
<input
class="input"
type="text"
placeholder=""
required>
</p>
</div>
</div>
</div>

<h1 class="title">3. Forge Settings</h1>
<h2 class="subtitle">3.1. OAuth Settings</h2>
<p>
Changing these will affect through which GitHub app users
are signing in.
</p>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">URL</label>
</div>
<div class="field-body">
<div class="field">
<p class="control is-expanded">
<input
class="input"
type="text"
placeholder="https://github.com/login/oauth"
required>
</p>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Client ID</label>
</div>
<div class="field-body">
<div class="field">
<p class="control is-expanded">
<input
class="input"
type="text"
required>
</p>
</div>
</div>
</div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Client Secret</label>
</div>
<div class="field-body">
<div class="field">
<p class="control is-expanded">
<input
class="input"
type="text"
required>
</p>
</div>
</div>
</div>

<hr>

<h2 class="subtitle">3.2. GitHub Personal Access Token</h2>
<p>
A GitHub Personal Access Token is required for the editor to interact with GitHub: create
pull requests, merge them, etc.
</p>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Token</label>
</div>
<div class="field-body">
<div class="field">
<p class="control is-expanded">
<input
class="input"
type="text"
placeholder=""
required>
</p>
</div>
</div>
</div>

<hr>

<div class="field is-horizontal">
<div class="field-label">
<!-- Left empty for spacing -->
</div>
<div class="field-body">
<div class="field">
<div class="control">
<button class="button is-danger">
Save &amp; Apply
</button>
</div>
</div>
</div>
</div>
</div>
</section>
</template>

<script>
export default {
name: 'AdminConfigForm'
}
</script>
77 changes: 77 additions & 0 deletions components/admin/AdminConfigList.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<template>
<div>
<table class="table admin-table">
<thead>
<tr>
<th>Version<br>Date</th>
<th>Author</th>
<th>Reason</th>
<th />
</tr>
</thead>
<tbody>
<tr
v-for="config in configs"
:key="config.id">
<td>
{{ config.id }}
<br>
{{ config.createdAt | formatTime }}
</td>
<td>
<div
v-if="config.author"
class="media">
<div class="media-content">
<a
:href="externalProfile(config.author.username)"
rel="noopener noreferrer"
target="_blank">
{{ config.author.username }}
</a>
</div>
<figure class="media-right">
<img
class="avatar"
:src="config.author.avatar" />
</figure>
</div>
<span v-else>
<em>system</em>
</span>
</td>
<td>
{{ config.reason }}
</td>
<td>
<button
@click.prevent="$emit('showVersion', config.id)"
class="button is-small is-info">
Show
</button>
</td>
</tr>
</tbody>
</table>
</div>
</template>

<script>
export default {
name: 'AdminConfigList',
props: {
configs: {
type: Array,
required: true,
default () {
return []
}
}
},
methods: {
externalProfile (username) {
return `https://github.com/${username}`
}
}
}
</script>
7 changes: 7 additions & 0 deletions components/admin/AdminMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
{{ tab.title }}
</nuxt-link>
</li>
<li v-show="$store.state.auth.isSuperadmin">
<nuxt-link
:to="{ name: 'admin-settings' }"
:class="{ 'is-active': currentRoute === 'admin-settings'}">
Editor Settings
</nuxt-link>
</li>
</ul>
</nav>
</div>
Expand Down
Loading

0 comments on commit be6101b

Please sign in to comment.