Skip to content

Commit

Permalink
wip: cleanup + small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Dec 8, 2023
1 parent ee9220f commit ff98677
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 380 deletions.
7 changes: 3 additions & 4 deletions docs/dev_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ Processo:
- [ ][2d] NEW PAGE: Live console
- [ ][2d] NEW PAGE: Players
- [ ][1d] NEW PAGE: History
- [ ][3h] change password modal
- [ ][1h] change temp password prompt

- [x][2d] light/dark theme
- [x][1d] adapt legacy styles to somewhat match shadcn
- [ ][3h] full cleanup of legacy code
Expand All @@ -134,10 +133,10 @@ Quickies

Bugs
- [ ] when you open the server sheet, the control tooltip shows automatically
- [ ] nui iframe scroll on 1080p screen
- [x] nui iframe scroll on 1080p screen
- should not scroll even with 7 server menu items
- possible solution would be to hide the zap ad if !isWebInterface
- [ ] no `target="_blank"` will work in NUI (zap ad + support), so either hide the buttons or find a way to open links
- [x] no `target="_blank"` will work in NUI (zap ad + support), so either hide the buttons or find a way to open links


=======================================================================
Expand Down
6 changes: 4 additions & 2 deletions panel/src/components/PromptDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { useClosePromptDialog, usePromptDialogState } from "@/hooks/dialogs";
import { useRef } from "react";
import { cn } from "@/lib/utils";


export default function PromptDialog() {
Expand Down Expand Up @@ -41,7 +42,7 @@ export default function PromptDialog() {

return (
<Dialog open={dialogState.isOpen} onOpenChange={handleOpenClose}>
<DialogContent>
<DialogContent className={cn(dialogState.isWide && "md:max-w-2xl")}>
<form onSubmit={handleForm} className="grid gap-4">
<DialogHeader>
<DialogTitle>{dialogState.title}</DialogTitle>
Expand All @@ -55,11 +56,12 @@ export default function PromptDialog() {
id="userInput"
ref={inputRef}
placeholder={dialogState.placeholder}
autoComplete="off"
className="placeholder:opacity-50"
required={dialogState.required}
/>
<DialogFooter className="gap-2 flex-col">
<div className="flex flex-col-reversex flex-col sm:flex-row sm:justify-start gap-2 w-full flex-wrap">
<div className="flex flex-col sm:flex-row sm:justify-start gap-2 w-full flex-wrap">
{dialogState.suggestions && dialogState.suggestions.map((suggestion, index) => (
<Button
key={index}
Expand Down
3 changes: 1 addition & 2 deletions panel/src/layout/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ function ButtonToggleGlobalMenu({ className }: NavButtonProps) {

function ButtonTogglePlayerlistSheet({ className }: NavButtonProps) {
const { setIsSheetOpen } = usePlayerlistSheet();
// const [playerCount] = usePlayerCount();
const playerCount = 1234; //FIXME:
const playerCount = useAtomValue(playerCountAtom);

return (
<button
Expand Down
7 changes: 0 additions & 7 deletions web/main/cfgEditor.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@
</div>
<div class="row justify-content-md-center" style="margin-top: 1em;">
<div class="mx-auto">
<button type="button" id="ctrl-restart" class="btn btn-outline-danger btn-sm mb-2"
onclick="txApiFxserverControl('restart')" <%=disableRestart %> >
RESTART SERVER (CTRL+R)
</button>
<button type="button" id="cfgEditor-save" class="btn btn-outline-dark btn-sm mb-2">
Save File (CTRL+S)
</button>
Expand Down Expand Up @@ -101,9 +97,6 @@
if (event.ctrlKey && event.key == 's') {
event.preventDefault();
saveButton.click();
} else if (event.ctrlKey && event.key == 'r') {
txApiFxserverControl('restart')
event.preventDefault();
} else if (event.ctrlKey && event.key == ';') {
window.CMInstance.toggleComment({lineComment: "#"})
event.preventDefault();
Expand Down
4 changes: 0 additions & 4 deletions web/main/console.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@
<button type="button" id="announcementBtn" class="btn btn-outline-warning btn-sm mb-2" <%= disableAnnouncement %>>
Announcement
</button>
<button type="button" id="ctrl-restart" class="btn btn-outline-danger btn-sm mb-2"
onclick="txApiFxserverControl('restart')" <%= disableRestart %>>
RESTART
</button>
</div>
</form>
</div>
Expand Down
170 changes: 0 additions & 170 deletions web/main/dashboard.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -165,63 +165,6 @@
</div>



<div class="row justify-content-center">
<!-- Server Control -->
<div class="col-lg-8 col-xl-6 dashboard-card mw-col6">
<div class="card card-accent-danger" style="min-height: 200px;">
<div class="card-header text-center">
<h5 class="d-inline">Server Control</h5>
</div>
<div class="card-body text-center align-middle">
<button onclick="txApiFxserverControl('start')"
class="btn btn-outline-<%= perms.controlsClass %> btn-lg mx-auto m-2" type="button" id="ctrl-start"
<%= perms.controls %>>START</button> &nbsp;
<button onclick="txApiFxserverControl('restart')"
class="btn btn-outline-<%= perms.controlsClass %> btn-lg mx-auto m-2" type="button"
id="ctrl-restart" <%= perms.controls %>>RESTART</button> &nbsp;
<button onclick="txApiFxserverControl('stop')"
class="btn btn-outline-<%= perms.controlsClass %> btn-lg mx-auto m-2" type="button" id="ctrl-stop"
<%= perms.controls %>>STOP</button>
<br />

<button onclick="controlCommand('admin_broadcast')" class="btn btn-outline-dark btn-md mx-auto m-2"
type="button" id="ctrl-announce" <%= perms.commandMessage %>>Announcement</button>
<button onclick="controlCommand('kick_all')" class="btn btn-outline-dark btn-md mx-auto m-2"
type="button" id="ctrl-kick-all" <%= perms.commandKick %>>Kick All Players</button>
<button class="btn btn-outline-dark btn-md mx-auto m-2"
type="button" id="ctrl-schedule-restart" <%= perms.controls %>>Schedule Restart</button>
</div>
</div>
</div>

<!-- Status Info-->
<div class="col-lg-8 col-xl-6 dashboard-card mw-col6">
<div class="card card-accent-danger" style="min-height: 200px;">
<div class="card-header text-center">
<h5 class="d-inline">Status Info</h5>
</div>
<div class="card-body" id="status-card">
Discord Bot Status:
<span class="badge badge-light" id="status-discord"> ?? </span> <br />
Server Status:
<span class="badge badge-light" id="status-server"> ?? </span>
<span class="badge badge-light" id="status-serverProcess"> ?? </span> <br />
Next Restart:
<span class="font-weight-light text-warnings" id="status-nextRestartTime"> not scheduled </span>
<button class="btn btn-inline btn-warning d-none" type="button" id="status-nextRestartBtnCancel">
Cancel
</button>
<button class="btn btn-inline btn-dark d-none" type="button" id="status-nextRestartBtnEnable">
Enable
</button>
</div>
</div>
</div>

</div>


<!-- Benchmark, update, pre-release messages -->
<div class="row justify-content-md-center">
<div class="col-md-6 text-center">
Expand Down Expand Up @@ -325,116 +268,3 @@
}, 250);
});
</script>

<script>
//============================================== Commands
async function controlCommand(action) {
let message = null;
if(action == 'admin_broadcast'){
message = await txAdminPrompt({
modalColor: 'orange',
confirmBtnClass: 'btn-orange',
title: 'Announcement',
description: 'Type the message to be broadcasted to all players.',
placeholder: 'the server will restart in xxx minutes...'
});
if(message.length <= 6){
$.notify({ message: 'This message is too short!'}, {type: 'danger'});
return;
}
}else if(action == 'kick_all'){
message = await txAdminPrompt({
modalColor: 'red',
confirmBtnClass: 'btn-red',
title: 'Kick All Players',
description: 'Type the kick reason or leave it blank (press enter)',
required: false,
});
}else{
return;
}
if(message === null || message === false) return;
const notify = $.notify({ message: 'Executing Command...' }, {});
txAdminAPI({
type: "POST",
url: '/fxserver/commands',
data: {
action,
parameter: message
},
success: function (data) {
notify.update('progress', 0);
notify.update('type', data.type);
notify.update('message', data.message);
},
error: function (xmlhttprequest, textstatus, message) {
notify.update('progress', 0);
notify.update('type', 'danger');
notify.update('message', message);
}
});
}
//============================================== Scheduler Stuff
const schedulerApiCall = (action, parameter) => {
const notify = $.notify({ message: 'Executing Command...' }, {});
txAdminAPI({
type: "POST",
url: '/fxserver/schedule',
data: {action, parameter},
success: function (data) {
notify.update('progress', 0);
notify.update('type', data.type);
notify.update('message', data.message);
},
error: function (xmlhttprequest, textstatus, message) {
notify.update('progress', 0);
notify.update('type', 'danger');
notify.update('message', message);
}
});
}
statusCard.nextRestartBtnCancel.onclick = () => {
schedulerApiCall('setNextSkip', true);
statusCard.nextRestartBtnCancel.classList.add('d-none');
}
statusCard.nextRestartBtnEnable.onclick = () => {
schedulerApiCall('setNextSkip', false);
statusCard.nextRestartBtnEnable.classList.add('d-none');
}
document.getElementById('ctrl-schedule-restart').onclick = async () => {
const svTimezone = '<%= serverTimezone %>';
const timeFormatterOptions = {
timeZone: svTimezone,
timeStyle: 'short',
hour12: false
}
const timeFormatter = new Intl.DateTimeFormat([], timeFormatterOptions);
const serverTime = timeFormatter.format(new Date());
const input = await txAdminPrompt({
modalColor: 'orange',
confirmBtnClass: 'btn-orange',
title: 'Schedule Restart',
placeholder: '16:15',
description: [
'Type in the time for the server to restart in the 24-hour format <code>HH:MM</code>.',
'Make sure your schedule matches your server time and not your local time.',
`<strong>Current Server Time:</strong> ${serverTime} (${svTimezone})`
].join('<br>'),
});
const [hours, minutes] = input.split(':', 2).map(x => parseInt(x));
if (
typeof hours === 'undefined' || isNaN(hours) || hours < 0 || hours > 23
|| typeof minutes === 'undefined' || isNaN(minutes) || minutes < 0 || minutes > 59
){
$.notify({ message: 'invalid hours:minutes'}, {type: 'danger'});
return;
}
schedulerApiCall('setNextTempSchedule', input);
}
</script>

0 comments on commit ff98677

Please sign in to comment.