➕ 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>
|
||||
<div class="collapse navbar-collapse" id="navbar-opts">
|
||||
<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>
|
||||
</ul>
|
||||
<!-- SERVER LIST -->
|
||||
@ -71,6 +71,24 @@
|
||||
</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 -->
|
||||
<div class="toast" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<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/bootstrap/dist/js/bootstrap.bundle.js"></script>
|
||||
<script>
|
||||
(async () => {
|
||||
const { ipcRenderer } = require('electron')
|
||||
const config = ipcRenderer.sendSync('config-request')
|
||||
const auth = require('../src/auth.js')
|
||||
const channels = require('../src/channels.js')
|
||||
|
||||
const { add_server_to_config } = require ('../src/settings.js')
|
||||
|
||||
|
||||
// used for basic styling on server buttons
|
||||
const classes = 'btn btn-outline-secondary btn-nav-settings'
|
||||
|
||||
// NOTE: this will probably take minute if your in a lot of servers
|
||||
// even worse if server owners are running debug builds like tards
|
||||
// get a new jwt from each server on startup
|
||||
auth.init(config)
|
||||
.then(updated_cfg => {
|
||||
for(const server_cfg of updated_cfg['servers']) {
|
||||
$('#add-admin-json').click(async () => await add_server_to_config() )
|
||||
|
||||
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 user = server_cfg['user']
|
||||
|
||||
@ -123,22 +148,20 @@
|
||||
value: txt
|
||||
})
|
||||
)
|
||||
console.log(user)
|
||||
$(`#${id}`).on('click', () => {
|
||||
channels.list(remote, user)
|
||||
})
|
||||
|
||||
$(`#${id}`).on('click', () => channels.list(remote, user))
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err, err.options)
|
||||
} catch(err) {
|
||||
console.log(err)
|
||||
$('#server-list').append(
|
||||
$('<input>').attr({
|
||||
type: 'button',
|
||||
'class': classes + ' disabled',
|
||||
value: `${err.options.url.hostname}`
|
||||
value: 'Problems setting up from config'
|
||||
})
|
||||
)
|
||||
})
|
||||
}
|
||||
})()
|
||||
</script>
|
||||
</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 'join-modal';
|
||||
@import 'channels';
|
||||
@import 'settings-modal';
|
||||
|
||||
body {
|
||||
color: $text;
|
||||
|
Loading…
Reference in New Issue
Block a user