Skip to content

Commit 9350b56

Browse files
authored
Features in settings default selection change (#123)
* changes in ui to load features from assets in case backend fetch fail * Update features.json * package changes * correcting the package changes * review_comments * review comments * renaming the constant * Update app.component.ts
1 parent 8d8d135 commit 9350b56

File tree

10 files changed

+50
-25
lines changed

10 files changed

+50
-25
lines changed

.docker/features.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"features": {
3-
"designModel": false,
4-
"patternCandidate": false,
5-
"patternViews": false,
6-
"issue": false,
7-
"editing": true,
8-
"showSettings": false
9-
}
2+
"features": {
3+
"designModel": false,
4+
"patternCandidate": false,
5+
"patternViews": true,
6+
"issue": false,
7+
"editing": true,
8+
"showSettings": false
9+
}
1010
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"lodash": "^4.17.21",
3838
"madr": "2.1.2",
3939
"markdown-it": "10.0.0",
40-
"markdown-it-katex": "github:MicroDroid/markdown-it-katex",
40+
"markdown-it-katexx": "3.2.0 ",
4141
"mathjs": "^7.0.2",
4242
"ngx-cookie-service": "2.1.0",
4343
"ngx-md": "8.1.6",

src/app/app.component.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,16 @@ export class AppComponent implements OnInit {
6868
() => (this.loading = false),
6969
(error: HttpErrorResponse) => {
7070
this.loading = false;
71-
this.toasterService.popAsync(
72-
'error', 'Error while loading config from config server, using default values instead' + error.message).subscribe(
73-
() => console.log('default values applied')
74-
)
71+
if(error.status === globals.statusCodeNotFound){
72+
this.configService.getDefaultConfiguration();
73+
console.log('default values applied')
74+
}
75+
else{
76+
this.toasterService.popAsync(
77+
'error', 'Error while loading config from config server, using default values instead' + error.message).subscribe(
78+
() => console.log('default values applied')
79+
)
80+
}
7581
}
7682
);
7783
}

src/app/core/component/markdown-content-container/markdown-pattern-sectioncontent/markdown-pattern-section-content.component.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { DataChange, DataRenderingComponent } from '../interfaces/DataRenderingC
33
import { MatDialog } from '@angular/material/dialog';
44
import { DialogData, MdEditorComponent } from '../../md-editor/md-editor.component';
55
import * as MarkdownIt from 'markdown-it';
6-
import * as markdownitKatex from 'markdown-it-katex';
6+
import * as markdownitKatex from 'markdown-it-katexx';
77
import { ImageService } from '../../../service/image.service';
88
import * as d3 from 'd3';
99
import { MatSnackBar } from '@angular/material/snack-bar';
@@ -56,7 +56,8 @@ export class MarkdownPatternSectionContentComponent extends DataRenderingCompone
5656

5757
ngAfterViewInit() {
5858
this.markdown = new MarkdownIt();
59-
this.markdown.use(markdownitKatex);
59+
this.markdown.set({ breaks: true });
60+
this.markdown.use(markdownitKatex.default, { throwOnError: false, errorColor: ' #cc0000' });
6061
this.changeText(this.renderedData);
6162
}
6263

src/app/core/directives/pattern-atlas-ui-repository-configuration.service.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ interface EtcdNode {
4040

4141
const initialValues: PatternAtlasUiConfiguration = {
4242
features: {
43-
designModel: false,
44-
patternCandidate: false,
45-
patternViews: false,
46-
issue: false,
47-
showSettings: false,
43+
designModel: true,
44+
patternCandidate: true,
45+
patternViews: true,
46+
issue: true,
47+
showSettings: true,
4848
editing: true
4949
},
5050
};
@@ -82,6 +82,10 @@ export class PatternAtlasUiRepositoryConfigurationService {
8282
);
8383
}
8484

85+
getDefaultConfiguration():Observable<PatternAtlasUiConfiguration>{
86+
return this.http.get<PatternAtlasUiConfiguration>(environment.defaultFeatures);
87+
}
88+
8589
applyConfig(feature: UiFeatures, checked: boolean): Observable<string> {
8690
const url = environment.CONFIG_SERVER_URL + '/features/' + feature;
8791

src/app/globals.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ export const globals = {
2424
patternViews: 'pattern-views',
2525
patternViewURI: 'pattern-view-uri',
2626
designModels: 'design-models'
27-
}
27+
},
28+
statusCodeNotFound : 404
2829
};

src/app/pattern-language-management/create-pattern/create-pattern.component.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { PatternLanguageService } from '../../core/service/pattern-language.serv
1010
import PatternLanguage from '../../core/model/hal/pattern-language.model';
1111
import PatternSectionSchema from '../../core/model/hal/pattern-section-schema.model';
1212
import * as MarkdownIt from 'markdown-it';
13-
import * as markdownitKatex from 'markdown-it-katex';
13+
import * as markdownitKatex from 'markdown-it-katexx';
1414
import { PatternService } from '../../core/service/pattern.service';
1515
import { debounceTime, distinctUntilChanged, tap } from 'rxjs/internal/operators';
1616
import { globals } from '../../globals';
@@ -92,7 +92,8 @@ export class CreatePatternComponent implements OnInit {
9292
ngOnInit() {
9393
this.patternLanguageId = UriConverter.doubleDecodeUri(this.activatedRoute.snapshot.paramMap.get(globals.pathConstants.patternLanguageId));
9494
this.markdown = new MarkdownIt();
95-
this.markdown.use(markdownitKatex);
95+
this.markdown.set({ breaks: true });
96+
this.markdown.use(markdownitKatex.default, { throwOnError: false, errorColor: ' #cc0000' });
9697

9798
const patternLanguageObservable = UriConverter.isUUID(this.patternLanguageId) ?
9899
this.patternLanguageService.getPatternLanguageById(this.patternLanguageId)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"features": {
3+
"designModel": false,
4+
"patternCandidate": false,
5+
"patternViews": true,
6+
"issue": false,
7+
"editing": true,
8+
"showSettings": false
9+
}
10+
}

src/environments/environment.prod.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ export const environment = {
2828
window['env'] && window['env']['CONFIG_SERVER_HOST_NAME'] &&
2929
window['env']['CONFIG_SERVER_PORT']
3030
? `http://${window['env']['CONFIG_SERVER_HOST_NAME']}:${window['env']['CONFIG_SERVER_PORT']}/v2/keys`
31-
: 'http://localhost:2379/v2/keys'
31+
: 'http://localhost:2379/v2/keys',
32+
defaultFeatures: 'assets/settings_features/default_features.json'
3233
};

src/environments/environment.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ export const environment = {
4040
window['env'] && window['env']['CONFIG_SERVER_HOST_NAME'] &&
4141
window['env']['CONFIG_SERVER_PORT']
4242
? `http://${window['env']['CONFIG_SERVER_HOST_NAME']}:${window['env']['CONFIG_SERVER_PORT']}/v2/keys`
43-
: 'http://localhost:2379/v2/keys'
43+
: 'http://localhost:2379/v2/keys',
44+
defaultFeatures: 'assets/settings_features/default_features.json'
4445
};
4546

4647
/*

0 commit comments

Comments
 (0)