Merge branch 'master' of github.com:codercom/code-server

This commit is contained in:
Kyle Carberry 2019-04-26 09:57:16 -04:00
commit 01a63a7241
No known key found for this signature in database
GPG Key ID: A0409BDB6B0B3EDB
6 changed files with 48 additions and 10 deletions

View File

@ -46,7 +46,7 @@ See docker oneliner mentioned above. Dockerfile is at [/Dockerfile](/Dockerfile)
For detailed instructions and troubleshooting, see the [self-hosted quick start guide](doc/self-hosted/index.md).
Quickstart guides for [Google Cloud](doc/admin/install/google_cloud.md), [AWS](doc/admin/install/aws.md), and [Digital Ocean](doc/admin/install/digitalocean.md).
Quickstart guides for [Google Cloud](doc/admin/install/google_cloud.md), [AWS](doc/admin/install/aws.md), and [DigitalOcean](doc/admin/install/digitalocean.md).
How to [secure your setup](/doc/security/ssl.md).

View File

@ -378,14 +378,31 @@ class BrowserWindow extends EventEmitter {
public setFullScreen(fullscreen: boolean): void {
if (fullscreen) {
document.documentElement.requestFullscreen();
document.documentElement.requestFullscreen().catch((error) => {
logger.error(error.message);
});
} else {
document.exitFullscreen();
document.exitFullscreen().catch((error) => {
logger.error(error.message);
});
}
}
public isFullScreen(): boolean {
return document.fullscreenEnabled;
// TypeScript doesn't recognize this property.
// tslint:disable no-any
if (typeof (window as any)["fullScreen"] !== "undefined") {
return (window as any)["fullScreen"];
}
// tslint:enable no-any
try {
return window.matchMedia("(display-mode: fullscreen)").matches;
} catch (error) {
logger.error(error.message);
return false;
}
}
public isFocused(): boolean {

View File

@ -216,6 +216,7 @@ const bold = (text: string | number): string | number => {
}
let password = options.password || process.env.PASSWORD;
const usingCustomPassword = !!password;
if (!password) {
// Generate a random password with a length of 24.
const buffer = Buffer.alloc(12);
@ -304,7 +305,7 @@ const bold = (text: string | number): string | number => {
logger.warn("Documentation on securing your setup: https://github.com/codercom/code-server/blob/master/doc/security/ssl.md");
}
if (!options.noAuth) {
if (!options.noAuth && !usingCustomPassword) {
logger.info(" ");
logger.info(`Password:\u001B[1m ${password}`);
} else {

View File

@ -79,9 +79,7 @@
.dialog-entry {
cursor: pointer;
font-size: 1.02em;
padding: 0px;
padding-left: 8px;
padding-right: 8px;
padding: 0px 8px;
.dialog-entry-info {
display: flex;
@ -94,6 +92,14 @@
margin-right: 5px;
}
.dialog-entry-size {
text-align: right;
}
.dialog-entry-mtime {
padding-left: 8px;
}
&:hover {
background-color: var(--list-hover-background);
}

View File

@ -404,7 +404,7 @@ class Dialog {
*/
private async list(directory: string): Promise<ReadonlyArray<DialogEntry>> {
const paths = (await util.promisify(fs.readdir)(directory)).sort();
const stats = await Promise.all(paths.map(p => util.promisify(fs.stat)(path.join(directory, p))));
const stats = await Promise.all(paths.map(p => util.promisify(fs.lstat)(path.join(directory, p))));
return stats.map((stat, index): DialogEntry => ({
fullPath: path.join(directory, paths[index]),
@ -480,7 +480,7 @@ class DialogEntryRenderer implements ITreeRenderer<DialogEntry, string, DialogEn
start: 0,
end: node.filterData.length,
}] : []);
templateData.size.innerText = node.element.size.toString();
templateData.size.innerText = !node.element.isDirectory ? this.humanReadableSize(node.element.size) : "";
templateData.lastModified.innerText = node.element.lastModified;
// We know this exists because we created the template.
@ -498,4 +498,16 @@ class DialogEntryRenderer implements ITreeRenderer<DialogEntry, string, DialogEn
public disposeTemplate(_templateData: DialogEntryData): void {
// throw new Error("Method not implemented.");
}
/**
* Given a positive size in bytes, return a string that is more readable for
* humans.
*/
private humanReadableSize(bytes: number): string {
const units = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1000)), units.length - 1);
return (bytes / Math.pow(1000, i)).toFixed(2)
+ " " + units[i];
}
}

View File

@ -5,6 +5,7 @@ import { OpenProcessExplorer } from "vs/workbench/contrib/issue/electron-browser
import { ToggleDevToolsAction } from "vs/workbench/electron-browser/actions/developerActions";
import { OpenPrivacyStatementUrlAction, OpenRequestFeatureUrlAction, OpenTwitterUrlAction } from "vs/workbench/electron-browser/actions/helpActions";
import { CloseCurrentWindowAction, NewWindowAction, ShowAboutDialogAction } from "vs/workbench/electron-browser/actions/windowActions";
import { REVEAL_IN_OS_COMMAND_ID } from "vs/workbench/contrib/files/browser/fileCommands";
const toSkip = [
ToggleDevToolsAction.ID,
@ -16,6 +17,7 @@ const toSkip = [
NewWindowAction.ID,
CloseCurrentWindowAction.ID,
CloseWorkspaceAction.ID,
REVEAL_IN_OS_COMMAND_ID,
// Unfortunately referenced as a string
"update.showCurrentReleaseNotes",