➕ Framework/Modal for settings coming together
✨ Changing inline script to now run in an async block ❗ No more callback hell, literally anything can be written with async/await or callbacks when appropos
This commit is contained in:
parent
5fc3e2a553
commit
ca68c61f3a
@ -21,7 +21,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<div class="collapse navbar-collapse" id="navbar-opts">
|
<div class="collapse navbar-collapse" id="navbar-opts">
|
||||||
<ul class="navbar-nav mr-auto" style="display: inline-block;">
|
<ul class="navbar-nav mr-auto" style="display: inline-block;">
|
||||||
<button class="btn btn-outline-secondary btn-nav-settings me-2" type="button" id="settings-btn">Settings</button>
|
<button class="btn btn-outline-secondary btn-nav-settings" type="button" id="settings-btn" data-toggle="modal", data-target="#settings-modal">Settings</button>
|
||||||
<button class="btn btn-outline-secondary btn-nav-settings" type="button" id="join-btn" data-toggle="modal", data-target="#joinform">Join</button>
|
<button class="btn btn-outline-secondary btn-nav-settings" type="button" id="join-btn" data-toggle="modal", data-target="#joinform">Join</button>
|
||||||
</ul>
|
</ul>
|
||||||
<!-- SERVER LIST -->
|
<!-- SERVER LIST -->
|
||||||
@ -71,6 +71,24 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="settings-modal" class="modal fade" tabindex="-1">
|
||||||
|
<div class="modal-dialog">
|
||||||
|
<div class="modal-content join-style">
|
||||||
|
<div class="modal-header"> <h5 class="modal-title">Settings</h5> </div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<form>
|
||||||
|
<div clas="form-group">
|
||||||
|
<label for="admin-json" class="form-label">For admins: Dump the provided json to automatically add it to your config</label>
|
||||||
|
<textarea id="admin-json" rows="5" class="settings-textarea"></textarea>
|
||||||
|
<input class="btn btn-outline-success" type="button" id="add-admin-json" value="Add to config"/>
|
||||||
|
<label for="admin-json" class=form-label" id="admin-json-err"></label>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Warning Toast -->
|
<!-- Warning Toast -->
|
||||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||||
<div class="toast-header">
|
<div class="toast-header">
|
||||||
@ -94,20 +112,27 @@
|
|||||||
<script type="text/javascript" src="../node_modules/popper.js/dist/umd/popper-utils.js"></script>
|
<script type="text/javascript" src="../node_modules/popper.js/dist/umd/popper-utils.js"></script>
|
||||||
<script type="text/javascript" src="../node_modules/bootstrap/dist/js/bootstrap.bundle.js"></script>
|
<script type="text/javascript" src="../node_modules/bootstrap/dist/js/bootstrap.bundle.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
(async () => {
|
||||||
const { ipcRenderer } = require('electron')
|
const { ipcRenderer } = require('electron')
|
||||||
const config = ipcRenderer.sendSync('config-request')
|
|
||||||
const auth = require('../src/auth.js')
|
const auth = require('../src/auth.js')
|
||||||
const channels = require('../src/channels.js')
|
const channels = require('../src/channels.js')
|
||||||
|
|
||||||
|
const { add_server_to_config } = require ('../src/settings.js')
|
||||||
|
|
||||||
|
|
||||||
// used for basic styling on server buttons
|
// used for basic styling on server buttons
|
||||||
const classes = 'btn btn-outline-secondary btn-nav-settings'
|
const classes = 'btn btn-outline-secondary btn-nav-settings'
|
||||||
|
|
||||||
// NOTE: this will probably take minute if your in a lot of servers
|
// NOTE: this will probably take minute if your in a lot of servers
|
||||||
// even worse if server owners are running debug builds like tards
|
// even worse if server owners are running debug builds like tards
|
||||||
// get a new jwt from each server on startup
|
// get a new jwt from each server on startup
|
||||||
auth.init(config)
|
$('#add-admin-json').click(async () => await add_server_to_config() )
|
||||||
.then(updated_cfg => {
|
|
||||||
for(const server_cfg of updated_cfg['servers']) {
|
try {
|
||||||
|
let config = await ipcRenderer.invoke('config-request')
|
||||||
|
await auth.init(config)
|
||||||
|
|
||||||
|
for(const server_cfg of config['servers']) {
|
||||||
const remote = server_cfg['server']
|
const remote = server_cfg['server']
|
||||||
const user = server_cfg['user']
|
const user = server_cfg['user']
|
||||||
|
|
||||||
@ -123,22 +148,20 @@
|
|||||||
value: txt
|
value: txt
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
console.log(user)
|
|
||||||
$(`#${id}`).on('click', () => {
|
$(`#${id}`).on('click', () => channels.list(remote, user))
|
||||||
channels.list(remote, user)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
})
|
} catch(err) {
|
||||||
.catch(err => {
|
console.log(err)
|
||||||
console.log(err, err.options)
|
|
||||||
$('#server-list').append(
|
$('#server-list').append(
|
||||||
$('<input>').attr({
|
$('<input>').attr({
|
||||||
type: 'button',
|
type: 'button',
|
||||||
'class': classes + ' disabled',
|
'class': classes + ' disabled',
|
||||||
value: `${err.options.url.hostname}`
|
value: 'Problems setting up from config'
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
})
|
}
|
||||||
|
})()
|
||||||
</script>
|
</script>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
4
freechat-client/sass/settings-modal.scss
Normal file
4
freechat-client/sass/settings-modal.scss
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
.settings-textarea {
|
||||||
|
width: 100%;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
@ -2,6 +2,7 @@
|
|||||||
@import 'scroll';
|
@import 'scroll';
|
||||||
@import 'join-modal';
|
@import 'join-modal';
|
||||||
@import 'channels';
|
@import 'channels';
|
||||||
|
@import 'settings-modal';
|
||||||
|
|
||||||
body {
|
body {
|
||||||
color: $text;
|
color: $text;
|
||||||
|
Loading…
Reference in New Issue
Block a user