Skip to content

Commit 2c8b852

Browse files
hsuanxyzzjffdu
authored andcommitted
[ZEPPELIN-4502] Adjust global styles and theming the visualization
### What is this PR for? Adjust global styles and theming the visualization ### What type of PR is it? [Feature] ### What is the Jira issue? https://issues.apache.org/jira/browse/ZEPPELIN-4502 ### How should this be tested? Not applicable ### Screenshots (if appropriate) ![image](https://user-images.githubusercontent.com/22736418/71349913-06af2b80-25ab-11ea-9356-d160f20cf8c1.png) ### Questions: * Does the licenses files need update? No * Is there breaking changes for older versions? No * Does this needs documentation? No Author: Hsuan Lee <[email protected]> Closes #3563 from hsuanxyz/feat/theme and squashes the following commits: 73271f2 [Hsuan Lee] chore: add visualization theme config 7571549 [Hsuan Lee] chore: reset the editor theme 410e064 [Hsuan Lee] chore: adjust styles ad6fc5a [Hsuan Lee] feat: styling table in the HTML result 1ec33b6 [Hsuan Lee] fix: quartz url 507b2b7 [Hsuan Lee] fix: notebook cron model error c95ef6b [Hsuan Lee] feat: show front-end error in result df24cc0 [Hsuan Lee] feat: scroll to the paragraph when the position is moved
1 parent bdc2940 commit 2c8b852

30 files changed

+307
-61
lines changed

zeppelin-web-angular/angular.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@
7272
"src/styles/theme/light/antd-light.less",
7373
"src/styles.less",
7474
"./node_modules/highlight.js/styles/github.css",
75-
"./node_modules/monaco-editor/min/vs/editor/editor.main.css"
75+
"./node_modules/monaco-editor/min/vs/editor/editor.main.css",
76+
"./node_modules/github-markdown-css/github-markdown.css"
7677
],
7778
"stylePreprocessorOptions": {
7879
"includePaths": [

zeppelin-web-angular/package-lock.json

Lines changed: 9 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zeppelin-web-angular/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@
2828
"@angular/router": "~8.2.10",
2929
"@antv/data-set": "^0.10.2",
3030
"@antv/g2": "^3.5.4",
31-
"ansi-to-html": "^0.6.11",
31+
"ansi_up": "^4.0.4",
3232
"core-js": "^2.5.4",
3333
"date-fns": "^1.30.1",
3434
"diff-match-patch": "^1.0.4",
35+
"github-markdown-css": "^3.0.1",
3536
"highlight.js": "^9.15.8",
3637
"lodash": "^4.17.11",
3738
"mathjax": "2.7.5",

zeppelin-web-angular/src/app/app.module.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { NzModalService } from 'ng-zorro-antd/modal';
2525
import { NzNotificationService } from 'ng-zorro-antd/notification';
2626

2727
import { MESSAGE_INTERCEPTOR, TRASH_FOLDER_ID_TOKEN } from '@zeppelin/interfaces';
28-
import { loadMonacoLanguage } from '@zeppelin/languages';
28+
import { loadMonacoBefore } from '@zeppelin/languages';
2929
import { TicketService } from '@zeppelin/services';
3030
import { ShareModule } from '@zeppelin/share';
3131

@@ -37,7 +37,7 @@ import { RUNTIME_COMPILER_PROVIDERS } from './app-runtime-compiler.providers';
3737
import { AppComponent } from './app.component';
3838

3939
export const loadMonaco = () => {
40-
loadMonacoLanguage();
40+
loadMonacoBefore();
4141
};
4242

4343
registerLocaleData(en);

zeppelin-web-angular/src/app/core/runtime-dynamic-module/runtime-dynamic-module.module.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License");
3+
* you may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
* http://www.apache.org/licenses/LICENSE-2.0
6+
* Unless required by applicable law or agreed to in writing, software
7+
* distributed under the License is distributed on an "AS IS" BASIS,
8+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
9+
* See the License for the specific language governing permissions and
10+
* limitations under the License.
11+
*/
112
import { CommonModule } from '@angular/common';
213
import { NgModule } from '@angular/core';
314
import { FormsModule } from '@angular/forms';

zeppelin-web-angular/src/app/languages/load.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,19 @@
1010
* limitations under the License.
1111
*/
1212

13-
import { languages } from 'monaco-editor';
13+
import { editor, languages } from 'monaco-editor';
1414
import { conf as ScalaConf, language as ScalaLanguage } from './scala';
1515

16-
export const loadMonacoLanguage = () => {
16+
export const loadMonacoBefore = () => {
17+
editor.defineTheme('zeppelin-theme', {
18+
base: 'vs',
19+
inherit: true,
20+
rules: [],
21+
colors: {
22+
'editor.lineHighlightBackground': '#0000FF10'
23+
}
24+
});
25+
editor.setTheme('zeppelin-theme');
1726
languages.register({ id: 'scala' });
1827
languages.setMonarchTokensProvider('scala', ScalaLanguage);
1928
languages.setLanguageConfiguration('scala', ScalaConf);

zeppelin-web-angular/src/app/pages/workspace/interpreter/item/item.component.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
::ng-deep .interpreter-item {
2121
&.edit {
22-
background: @orange-1;
22+
//background: @orange-1;
2323
}
2424
.ant-card-body {
2525
margin-top: -@card-padding-base;

zeppelin-web-angular/src/app/pages/workspace/notebook-repos/item/item.component.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
::ng-deep .repo-item {
2222
&.edit {
23-
background: @orange-1;
23+
//background: @orange-1;
2424
}
2525
}
2626

zeppelin-web-angular/src/app/pages/workspace/notebook/action-bar/action-bar.component.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,9 @@
125125
(click)="toggleExtension('revisions')">
126126
<i nz-icon nzType="swap" nzTheme="outline"></i>
127127
</button>
128-
<nz-button-group nzSize="small">
129-
<button nz-button nz-dropdown [nzDropdownMenu]="revisionsMenu" nzTrigger="click">
130-
{{currentRevision}}
131-
</button>
132-
</nz-button-group>
128+
<button nz-button nz-dropdown [nzDropdownMenu]="revisionsMenu" nzTrigger="click">
129+
{{currentRevision}}
130+
</button>
133131
<nz-dropdown-menu #revisionsMenu="nzDropdownMenu">
134132
<ul nz-menu>
135133
<li nz-menu-item *ngFor="let r of noteRevisions" (click)="visitRevision(r)">
@@ -188,7 +186,8 @@
188186
<div class="ant-dropdown-menu padding-sm scheduler">
189187
Run note with cron scheduler.
190188
Either choose from preset or write your own
191-
<a href="http://www.quartz-scheduler.org/documentation/quartz-2.1.x/tutorials/crontrigger" target="_blank">
189+
<a href="https://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/tutorial-lesson-06.html"
190+
target="_blank">
192191
cron expression
193192
</a>
194193
.
@@ -226,7 +225,8 @@
226225
<button nz-button nzNoAnimation (click)="togglePermissions()">
227226
<i nz-icon nzType="lock" [nzTheme]="activatedExtension === 'permissions' ? 'fill' : 'outline'"></i>
228227
</button>
229-
<button [nzDropdownMenu]="menu" nz-button nzNoAnimation nzSize="small" nz-dropdown nzTrigger="click">{{note.config.looknfeel}}
228+
<button [nzDropdownMenu]="menu" nz-button nzNoAnimation nzSize="small" nz-dropdown
229+
nzTrigger="click">{{note.config.looknfeel}}
230230
<i nz-icon nzType="down"></i>
231231
</button>
232232
<nz-dropdown-menu #menu="nzDropdownMenu">

zeppelin-web-angular/src/app/pages/workspace/notebook/action-bar/action-bar.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ export class NotebookActionBarComponent extends MessageListenersManager implemen
6969
{ name: '12h', value: '0 0 0/12 * * ?' },
7070
{ name: '1d', value: '0 0 0 * * ?' }
7171
];
72-
7372
updateNoteName(name: string) {
7473
const trimmedNewName = name.trim();
7574
if (trimmedNewName.length > 0 && this.note.name !== trimmedNewName) {

zeppelin-web-angular/src/app/pages/workspace/notebook/notebook.component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import {
3636
TicketService
3737
} from '@zeppelin/services';
3838

39+
import { scrollIntoViewIfNeeded } from '@zeppelin/utility/element';
3940
import { NotebookParagraphComponent } from './paragraph/paragraph.component';
4041

4142
@Component({
@@ -151,7 +152,14 @@ export class NotebookComponent extends MessageListenersManager implements OnInit
151152
if (movedPara) {
152153
const listOfRestPara = this.note.paragraphs.filter(p => p.id !== data.id);
153154
this.note.paragraphs = [...listOfRestPara.slice(0, data.index), movedPara, ...listOfRestPara.slice(data.index)];
155+
const paragraphComponent = this.listOfNotebookParagraphComponent.find(e => e.paragraph.id === data.id);
154156
this.cdr.markForCheck();
157+
if (paragraphComponent) {
158+
// Call when next tick
159+
setTimeout(() => {
160+
scrollIntoViewIfNeeded(paragraphComponent.getElement());
161+
});
162+
}
155163
}
156164
}
157165
}

zeppelin-web-angular/src/app/pages/workspace/notebook/notebook.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import { NotebookParagraphProgressComponent } from './paragraph/progress/progres
4545
import { NotebookPermissionsComponent } from './permissions/permissions.component';
4646
import { NotebookRevisionsComparatorComponent } from './revisions-comparator/revisions-comparator.component';
4747

48+
import { NzCheckboxModule } from 'ng-zorro-antd/checkbox';
4849
import { WorkspaceShareModule } from '../../workspace/share/share.module';
4950
import { NotebookActionBarComponent } from './action-bar/action-bar.component';
5051
import { NotebookRoutingModule } from './notebook-routing.module';
@@ -90,7 +91,8 @@ import { NotebookShareModule } from './share/share.module';
9091
NzGridModule,
9192
NzRadioModule,
9293
DragDropModule,
93-
NzCodeEditorModule
94+
NzCodeEditorModule,
95+
NzCheckboxModule
9496
]
9597
})
9698
export class NotebookModule {}

zeppelin-web-angular/src/app/pages/workspace/notebook/paragraph/paragraph.component.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,9 +516,11 @@ export class NotebookParagraphComponent extends ParagraphBase implements OnInit,
516516
this.commitParagraph();
517517
break;
518518
case ParagraphActions.MoveToUp:
519+
event.preventDefault();
519520
this.moveUpParagraph();
520521
break;
521522
case ParagraphActions.MoveToDown:
523+
event.preventDefault();
522524
this.moveDownParagraph();
523525
break;
524526
case ParagraphActions.SwitchEnable:
@@ -622,6 +624,10 @@ export class NotebookParagraphComponent extends ParagraphBase implements OnInit,
622624
}
623625
}
624626

627+
getElement(): HTMLElement {
628+
return this.host && this.host.nativeElement;
629+
}
630+
625631
ngOnDestroy(): void {
626632
super.ngOnDestroy();
627633
}

zeppelin-web-angular/src/app/pages/workspace/share/result/result.component.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
<div *ngSwitchCase="datasetType.TEXT" class="text-plain"><pre [innerHTML]="plainText"></pre></div>
6969
<div *ngSwitchCase="datasetType.IMG" class="img"><img [src]="imgData" alt="img"></div>
7070
</ng-container>
71+
<div *ngIf="frontEndError" class="text-plain"><pre>{{frontEndError}}</pre></div>
7172
<div *ngIf="angularComponent">
7273
<ng-container *ngComponentOutlet="angularComponent.component;ngModuleFactory: angularComponent.moduleFactory;injector: injector"></ng-container>
7374
</div>

zeppelin-web-angular/src/app/pages/workspace/share/result/result.component.less

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
}
3030

3131
::ng-deep {
32+
33+
.visualization-selector .ant-radio-button-wrapper {
34+
padding: 0 10px;
35+
}
36+
3237
.inner-html, .text-plain {
3338

3439
overflow: auto;
@@ -42,6 +47,37 @@
4247
height: auto;
4348
width: auto;
4449
}
50+
51+
table {
52+
border: none;
53+
border-collapse: collapse;
54+
border-spacing: 0;
55+
color: @text-color;
56+
table-layout: fixed;
57+
}
58+
thead {
59+
color: @table-header-color;
60+
border-bottom: 2px @border-style-base fade(@black, 65%);
61+
vertical-align: bottom;
62+
}
63+
tr, th, td {
64+
text-align: right;
65+
vertical-align: middle;
66+
padding: 0.5em 0.5em;
67+
line-height: normal;
68+
white-space: normal;
69+
max-width: none;
70+
border: none;
71+
}
72+
th {
73+
font-weight: bold;
74+
}
75+
tbody tr:nth-child(odd) {
76+
background: darken(@table-header-bg, 3%);
77+
}
78+
tbody tr:hover {
79+
background: @table-row-hover-bg;
80+
}
4581
}
4682
}
4783

zeppelin-web-angular/src/app/pages/workspace/share/result/result.component.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import { DomSanitizer, SafeHtml, SafeUrl } from '@angular/platform-browser';
2929
import { Subject, Subscription } from 'rxjs';
3030
import { takeUntil } from 'rxjs/operators';
3131

32-
import * as Convert from 'ansi-to-html';
32+
import { default as AnsiUp } from 'ansi_up';
3333
import * as hljs from 'highlight.js';
3434
import { NzResizeEvent } from 'ng-zorro-antd/resizable';
3535
import { utils, writeFile, WorkSheet, WritingOptions } from 'xlsx';
@@ -206,6 +206,7 @@ export class NotebookParagraphResultComponent implements OnInit, AfterViewInit,
206206
}
207207

208208
renderDefaultDisplay() {
209+
this.frontEndError = '';
209210
switch (this.result.type) {
210211
case DatasetType.TABLE:
211212
this.renderGraph();
@@ -240,22 +241,22 @@ export class NotebookParagraphResultComponent implements OnInit, AfterViewInit,
240241
}
241242

242243
renderAngular(): void {
243-
try {
244-
this.runtimeCompilerService.createAndCompileTemplate(this.id, this.result.data).then(data => {
244+
this.runtimeCompilerService
245+
.createAndCompileTemplate(this.id, this.result.data)
246+
.then(data => {
245247
this.angularComponent = data;
246-
// this.angularComponent.moduleFactory
248+
this.cdr.markForCheck();
249+
})
250+
.catch(error => {
251+
this.angularComponent = null;
252+
this.frontEndError = error.message;
247253
this.cdr.markForCheck();
248254
});
249-
} catch (e) {
250-
this.frontEndError = e.message;
251-
console.log(e);
252-
}
253255
}
254256

255257
renderText(): void {
256-
// tslint:disable-next-line:no-any
257-
const convert: any = new Convert();
258-
this.plainText = this.sanitizer.bypassSecurityTrustHtml(convert.toHtml(this.result.data));
258+
const ansiUp = new AnsiUp();
259+
this.plainText = this.sanitizer.bypassSecurityTrustHtml(ansiUp.ansi_to_html(this.result.data));
259260
}
260261

261262
renderImg(): void {

zeppelin-web-angular/src/app/pages/workspace/share/share.module.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ import { NzToolTipModule } from 'ng-zorro-antd/tooltip';
2828
import { ShareModule } from '@zeppelin/share';
2929
import { VisualizationModule } from '@zeppelin/visualizations/visualization.module';
3030

31+
import { NzGridModule } from 'ng-zorro-antd/grid';
32+
import { NzInputModule } from 'ng-zorro-antd/input';
3133
import { NotebookParagraphDynamicFormsComponent } from './dynamic-forms/dynamic-forms.component';
3234
import { NotebookParagraphResultComponent } from './result/result.component';
3335

@@ -48,7 +50,9 @@ import { NotebookParagraphResultComponent } from './result/result.component';
4850
NzIconModule,
4951
NzCheckboxModule,
5052
NzSelectModule,
51-
NzSwitchModule
53+
NzSwitchModule,
54+
NzInputModule,
55+
NzGridModule
5256
]
5357
})
5458
export class WorkspaceShareModule {}

zeppelin-web-angular/src/app/pages/workspace/workspace.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { ActivatedRoute, NavigationEnd, Route, Router } from '@angular/router';
1818
import { publishedSymbol, Published } from '@zeppelin/core/paragraph-base/published';
1919
import { HeliumManagerService } from '@zeppelin/helium-manager';
2020
import { MessageService } from '@zeppelin/services';
21+
import { setTheme } from '@zeppelin/visualizations/g2.config';
2122
import { log } from 'ng-zorro-antd/core';
2223

2324
@Component({
@@ -47,6 +48,7 @@ export class WorkspaceComponent implements OnInit, OnDestroy {
4748
this.websocketConnected = data;
4849
this.cdr.markForCheck();
4950
});
51+
setTheme();
5052
this.heliumManagerService.initPackages();
5153
}
5254

0 commit comments

Comments
 (0)