Update settings page layout and style
parent
2bd8f1520c
commit
27b8837210
|
|
@ -1,43 +1,57 @@
|
|||
<template>
|
||||
<div class="settings-container">
|
||||
<div class="settings-header">
|
||||
<strong>SzuruChrome settings</strong>
|
||||
</div>
|
||||
<div class="content-holder">
|
||||
<div class="content-wrapper">
|
||||
<strong>SzuruChrome Settings</strong>
|
||||
|
||||
<div class="settings-content">
|
||||
<p>General settings which apply to all engines.</p>
|
||||
|
||||
<ul class="input">
|
||||
<li class="full-width">
|
||||
<label>Szurubooru URL</label><input text="Szurubooru URL" type="text" name="domain" v-model="domain" />
|
||||
</li>
|
||||
<li><label>Username</label><input text="Username" type="text" name="username" v-model="username" /></li>
|
||||
<li>
|
||||
<label>Authentication token</label
|
||||
><input text="Authentication token" type="text" name="token" v-model="authToken" />
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="input">
|
||||
<li>
|
||||
<label>
|
||||
Szurubooru URL
|
||||
<br />
|
||||
<input type="text" name="domain" v-model="domain" />
|
||||
</label>
|
||||
<br />
|
||||
<label>
|
||||
Username
|
||||
<br />
|
||||
<input type="text" name="username" v-model="username" />
|
||||
</label>
|
||||
<label>
|
||||
Authentication token
|
||||
<br />
|
||||
<input type="text" name="token" v-model="authToken" />
|
||||
</label>
|
||||
<br />
|
||||
<label>
|
||||
Automatically search for similar posts
|
||||
<input type="checkbox" name="autoSearchSimilar" v-model="autoSearchSimilar" />
|
||||
Automatically search for similar posts
|
||||
</label>
|
||||
<br />
|
||||
<p class="hint">
|
||||
Automatically start searching for similar posts when opening the popup. Enabling this option will hide the
|
||||
"Find Similar" button.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
Use original image source when available
|
||||
<input type="checkbox" name="useOriginalSource" v-model="useOriginalSource" />
|
||||
Use original image source when available
|
||||
</label>
|
||||
<br />
|
||||
<p class="hint">
|
||||
Use the original image source when available. Usually this will mean a Twitter, DeviantArt, ArtStation, or
|
||||
Pixiv page.
|
||||
</p>
|
||||
</li>
|
||||
<li>
|
||||
<label>
|
||||
Show how often a tag is used in the selected szurubooru instance
|
||||
<input type="checkbox" name="loadTagCounts" v-model="loadTagCounts" />
|
||||
Show how often a tag is used in the selected szurubooru instance
|
||||
</label>
|
||||
<br />
|
||||
<div class="settings-footer-buttons">
|
||||
<p class="hint">
|
||||
Shows how often a given tag is used in the selected szurubooru instance. No number will be displayed when
|
||||
the tag does not yet exist.
|
||||
</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="settings-footer">
|
||||
<span class="status" :class="statusType">{{ statusText }}</span>
|
||||
|
||||
<button @click="testConnection">Test connection</button>
|
||||
<button @click="saveSettings" class="primary">Save settings</button>
|
||||
</div>
|
||||
|
|
@ -50,6 +64,8 @@ import Vue from "vue";
|
|||
import SzuruWrapper from "../SzuruWrapper";
|
||||
import { Config, SzuruSiteConfig } from "../Config";
|
||||
|
||||
type StatusType = "ok" | "error";
|
||||
|
||||
export default Vue.extend({
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -59,12 +75,14 @@ export default Vue.extend({
|
|||
autoSearchSimilar: false,
|
||||
loadTagCounts: false,
|
||||
useOriginalSource: false,
|
||||
statusText: "",
|
||||
statusType: "",
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
async testConnection() {
|
||||
if (!this.domain || !this.username || !this.authToken) {
|
||||
alert("Domain, username and authentication token are all required.");
|
||||
this.setStatus("Domain, username and authentication token are all required.", "error");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -74,17 +92,18 @@ export default Vue.extend({
|
|||
const instanceName = info?.config.name;
|
||||
|
||||
if (instanceName == undefined) {
|
||||
alert(`Connected to ${this.domain}, but it is not a szurubooru instance.`);
|
||||
this.setStatus(`Connected to ${this.domain}, but it is not a szurubooru instance.`, "error");
|
||||
} else {
|
||||
alert(`Connected to ${info.config.name} at ${this.domain}`);
|
||||
this.setStatus(`Connected to ${info.config.name} at ${this.domain}`);
|
||||
}
|
||||
} catch (ex) {
|
||||
alert("Couldn't connect to " + this.domain + "\n\n" + ex);
|
||||
// TODO: This error message is not very descriptive.
|
||||
console.dir(ex);
|
||||
this.setStatus("Couldn't connect to " + this.domain + "\n\n" + ex, "error");
|
||||
}
|
||||
},
|
||||
async saveSettings() {
|
||||
let config = await Config.load();
|
||||
console.dir(config);
|
||||
|
||||
// We currently only support one domain
|
||||
let siteConfig = new SzuruSiteConfig();
|
||||
|
|
@ -97,12 +116,18 @@ export default Vue.extend({
|
|||
config.useOriginalSource = this.useOriginalSource;
|
||||
|
||||
await config.save();
|
||||
|
||||
this.setStatus("Settings successfully saved");
|
||||
},
|
||||
setStatus(text: string, type: StatusType = "ok") {
|
||||
this.statusText = text;
|
||||
this.statusType = "status-" + type;
|
||||
},
|
||||
},
|
||||
async mounted() {
|
||||
let config = await Config.load();
|
||||
|
||||
console.log(`Loaded ${config.sites.length} sites`);
|
||||
// console.log(`Loaded ${config.sites.length} sites`);
|
||||
|
||||
// We currently only support one domain
|
||||
if (config.sites.length > 0) {
|
||||
|
|
@ -119,31 +144,90 @@ export default Vue.extend({
|
|||
</script>
|
||||
|
||||
<style scoped>
|
||||
label {
|
||||
margin-bottom: 10px;
|
||||
.content-holder {
|
||||
padding: 1.5em;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.settings-container {
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
-ms-transform: translate(-50%, -50%);
|
||||
transform: translate(-50%, -50%);
|
||||
|
||||
padding: 20px;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
.settings-header {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.settings-footer-buttons {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.settings-content > label {
|
||||
.content-holder > .content-wrapper {
|
||||
box-sizing: border-box;
|
||||
text-align: left;
|
||||
display: inline-block;
|
||||
flex: auto;
|
||||
max-width: 1000px;
|
||||
}
|
||||
|
||||
.content-holder > .content-wrapper:not(.transparent) {
|
||||
background: #f5f5f5;
|
||||
padding: 1.8em;
|
||||
}
|
||||
|
||||
.settings-footer {
|
||||
display: flex;
|
||||
gap: 5px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.settings-footer .status {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
.settings-footer > span.status-ok {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.settings-footer > span.status-error {
|
||||
color: red;
|
||||
}
|
||||
|
||||
.input {
|
||||
list-style-type: none;
|
||||
margin: 0 0 2em;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.input li {
|
||||
flex: 1 0 20em;
|
||||
}
|
||||
|
||||
.input li.full-width {
|
||||
min-width: 100%;
|
||||
}
|
||||
|
||||
.input label {
|
||||
display: block;
|
||||
padding: 0.3em 0;
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin-top: 0.2em;
|
||||
margin-bottom: 0;
|
||||
color: #888;
|
||||
font-size: 80%;
|
||||
line-height: 120%;
|
||||
}
|
||||
|
||||
input[type="email"],
|
||||
input[type="number"],
|
||||
input[type="password"],
|
||||
input[type="text"],
|
||||
select,
|
||||
textarea {
|
||||
vertical-align: top;
|
||||
font-family: "Droid Sans", sans-serif;
|
||||
font-size: 100%;
|
||||
padding: 0.2em 0.3em;
|
||||
text-overflow: ellipsis;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
border: 2px solid #eee;
|
||||
background: #fafafa;
|
||||
color: #111;
|
||||
box-shadow: none;
|
||||
transition: border-color 0.1s linear, background-color 0.1s linear;
|
||||
}
|
||||
</style>
|
||||
|
|
|
|||
Loading…
Reference in New Issue