Skip to content

Commit

Permalink
Bug fixes (#63)
Browse files Browse the repository at this point in the history
* bug fixes

* run check fix
  • Loading branch information
Pistonight committed Sep 27, 2023
1 parent cdfd7a2 commit 7a3e829
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 34 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ COPY ./dist $APP_DIR
WORKDIR $APP_DIR

ENV CELERSERVER_LOG=INFO
ENV CELERSERVER_ANSI=0
ENV CELERSERVER_PORT=80
ENV CELERSERVER_DOCS_DIR=/opt/app/docs
ENV CELERSERVER_APP_DIR=/opt/app/app
Expand Down
24 changes: 18 additions & 6 deletions web-client/src/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@
color: #ff8888;
fill: #ff8888;
}
@media (prefers-color-scheme: light) {
.color-success {
color: #44cc44;
fill: #44cc44;
}

.color-success {
color: #88ff88;
fill: #88ff88;
.color-progress {
color: #cc8844;
fill: #cc8844;
}
}
@media (prefers-color-scheme: dark) {
.color-success {
color: #88ff88;
fill: #88ff88;
}

.color-progress {
color: #ffcc88;
fill: #ffcc88;
.color-progress {
color: #ffcc88;
fill: #ffcc88;
}
}
13 changes: 3 additions & 10 deletions web-client/src/core/kernel/editor/EditorKernelImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@ export class EditorKernelImpl implements EditorKernel {
if (isUserAction) {
this.idleMgr.notifyActivity();
}
return await this.idleMgr.pauseIdleScope(async () => {
const result = await this.idleMgr.pauseIdleScope(async () => {
return await this.fileMgr.loadChangesFromFs();
});
this.compile();
return result;
}

public async saveChangesToFs(
Expand Down Expand Up @@ -202,9 +204,6 @@ export class EditorKernelImpl implements EditorKernel {
if (!this.fileMgr.isFsLoaded()) {
return;
}
EditorLog.info(
"idle" + (isLong ? " (long)" : "") + ` duration= ${duration}ms`,
);
const { autoLoadActive, unsavedFiles } = viewSelector(
this.store.getState(),
);
Expand All @@ -225,7 +224,6 @@ export class EditorKernelImpl implements EditorKernel {

if (autoLoadActive) {
if (autoLoadEnabled) {
EditorLog.info("auto loading changes...");
await this.loadChangesFromFs(false /* isUserAction */);
// make sure file system view is rerendered in case there are directory updates
shouldRerenderFs = true;
Expand All @@ -245,7 +243,6 @@ export class EditorKernelImpl implements EditorKernel {
}

if (autoSaveEnabled) {
EditorLog.info("auto saving changes...");
await this.saveChangesToFs(false /* isUserAction */);
// make sure file system view is rerendered in case there are directory updates
shouldRerenderFs = true;
Expand All @@ -257,10 +254,6 @@ export class EditorKernelImpl implements EditorKernel {

// do this last so we can get the latest save status after auto-save
this.fileMgr.updateDirtyFileList(unsavedFiles);

// if (!shouldRecompile && await this.fileMgr.needsRecompile()) {
// shouldRecompile = true;
// }
if (shouldRecompile) {
this.compile();
}
Expand Down
2 changes: 1 addition & 1 deletion web-client/src/core/layout/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,6 @@ export const getAvailableToolbarLocations = (
return [];
}
return WidgetTypes.map((type) => {
return layout[type] ? null : type;
return layout[type] ? type : null;
}).filter(Boolean) as WidgetType[];
};
5 changes: 3 additions & 2 deletions web-client/src/ui/doc/Doc.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@
.docnote-container {
display: none; /* hide by default */
transition-duration: 0.1s;
left: 0px;
right: 0px;
}

.docnote-container-expanded {
/* make the notes stick to the right side*/
right: 0px;
left: unset;
z-index: 100;
}

Expand Down
7 changes: 7 additions & 0 deletions web-client/src/ui/editor/Editor.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@
flex-grow: 1;
display: flex;
flex-direction: column;
box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
#editor-panel {
border-left: 1px solid #333;
background-color: #1e1e1e;
}
}
@media (prefers-color-scheme: light) {
#editor-panel {
border-left: 1px solid #ccc;
}
}

#editor-file-name {
padding: 4px;
Expand Down
5 changes: 4 additions & 1 deletion web-client/src/ui/editor/tree/EditorTree.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@

.file-type-md {
color: #61afef;
fill: #61afef;
}

.file-type-image {
color: #af81af;
}
25 changes: 12 additions & 13 deletions web-client/src/ui/editor/tree/TreeIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
Folder16Filled,
Document16Filled,
Document16Regular,
Image16Filled,
Info16Filled,
CodeJs16Filled,
CodeTs16Filled,
Expand All @@ -23,30 +24,28 @@ const getFileTypeAndIcon = ({
if (isDirectory) {
return ["folder", <Folder16Filled />];
}
if (
file.endsWith(".js") ||
file.endsWith(".jsx") ||
file.endsWith(".mjs") ||
file.endsWith(".cjs")
) {
if (file.match(/\.(m|c)?jsx?$/i)) {
return ["js", <CodeJs16Filled />];
}
if (file.endsWith(".ts") || file.endsWith(".tsx")) {
if (file.match(/\.(m|c)?tsx?$/i)) {
return ["ts", <CodeTs16Filled />];
}
if (file.endsWith(".py")) {
if (file.match(/\.py$/i)) {
return ["py", <CodePy16Filled />];
}
if (file.endsWith(".json")) {
if (file.match(/\.json$/i)) {
return ["json", <CodeBlock16Filled />];
}
if (file.endsWith(".yaml") || file.endsWith(".yml")) {
if (file.match(/\.ya?ml$/i)) {
return ["yaml", <CodeBlock16Filled />];
}
if (file.endsWith(".md")) {
if (file.match(/\.md$/i)) {
return ["md", <Info16Filled />];
}
return ["unknown", <Document16Filled />];
if (file.match(/\.(png|jpe?g|gif|webp)$/i)) {
return ["image", <Image16Filled />];
}
return ["unknown", <Document16Regular />];
};

export const TreeIcon: React.FC<TreeIconProps> = (props) => {
Expand Down
2 changes: 1 addition & 1 deletion web-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ tokio = { version = "1.32.0", features=["macros", "rt-multi-thread"] }
tower = "0.4.13"
tower-http = { version = "0.4.4", features = ["fs", "trace"] }
tracing = "0.1.37"
tracing-subscriber = "0.3.17"
tracing-subscriber = { version = "0.3.17", features = ["ansi"] }

[[bin]]
name = "celerserver"
Expand Down
1 change: 1 addition & 0 deletions web-server/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ tasks:
aliases: [d]
env:
CELERSERVER_LOG: INFO
CELERSERVER_ANSI: 1
CELERSERVER_PORT: 8173
CELERSERVER_DOCS_DIR: ../docs/src/.vitepress/dist
CELERSERVER_APP_DIR: ../web-client/dist
Expand Down
10 changes: 10 additions & 0 deletions web-server/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use tracing::Level;
pub struct Environment {
/// If server is running in debug mode
pub logging_level: Level,
/// If ANSI formatting is enabled in logs
pub ansi: bool,
/// Port to listen on
pub port: u16,
/// Directory to serve docs
Expand All @@ -18,6 +20,7 @@ impl Environment {
pub fn parse() -> Self {
let mut logging_level = Level::INFO;
let mut port = 8173;
let mut ansi = true;

if let Ok(x) = env::var("CELERSERVER_LOG") {
match x.to_uppercase().as_ref() {
Expand All @@ -43,6 +46,12 @@ impl Environment {
}
}

if let Ok(x) = env::var("CELERSERVER_ANSI") {
if x == "0" {
ansi = false;
}
}

let docs_dir = if let Ok(x) = env::var("CELERSERVER_DOCS_DIR") {
x
} else {
Expand All @@ -63,6 +72,7 @@ impl Environment {

Self {
logging_level,
ansi,
port,
docs_dir,
app_dir,
Expand Down
1 change: 1 addition & 0 deletions web-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
let env = Environment::parse();
tracing_subscriber::fmt()
.compact()
.with_ansi(env.ansi)
.with_max_level(env.logging_level)
.init();
info!("configuring routes...");
Expand Down
5 changes: 5 additions & 0 deletions web-themes/src/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,8 @@
background-color: #bbbbbb !important;
}
}

/* Ending block */
#doc-end {
background-color: #001a00;
}
3 changes: 3 additions & 0 deletions web-themes/src/granatus.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,6 @@
background-color: rgba(255, 255, 255, 0.1) !important;
}
}
#doc-end {
background-color: #cccccc;
}

0 comments on commit 7a3e829

Please sign in to comment.