Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/workflows/visual-tests-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,18 @@ jobs:
working-directory: apps/demos
run: pnpm run ts-check-vue

# - name: Run check TS for Angular
# working-directory: apps/demos
# run: pnpm run ts-check-ng

- name: Demos - Check React TS
id: ts_react
continue-on-error: true
working-directory: apps/demos
run: pnpm run ts-check-react

- name: Demos - Check Angular TS
id: ts_angular
continue-on-error: true
working-directory: apps/demos
run: pnpm run ts-check-ng

- name: Run lint on all demos
id: lint_all
continue-on-error: true
Expand Down Expand Up @@ -367,6 +369,7 @@ jobs:
env:
TS_VUE_OUTCOME: ${{ steps.ts_vue.outcome }}
TS_REACT_OUTCOME: ${{ steps.ts_react.outcome }}
TS_ANGULAR_OUTCOME: ${{ steps.ts_angular.outcome }}
LINT_ALL_OUTCOME: ${{ steps.lint_all.outcome }}
GENERATED_JS_OUTCOME: ${{ steps.generated_js.outcome }}
run: |
Expand All @@ -375,6 +378,7 @@ jobs:
for check in \
"Demos - Check Vue TS:$TS_VUE_OUTCOME" \
"Demos - Check React TS:$TS_REACT_OUTCOME" \
"Demos - Check Angular TS:$TS_ANGULAR_OUTCOME" \
"Run lint on all demos:$LINT_ALL_OUTCOME" \
"Check generated JS demos:$GENERATED_JS_OUTCOME"; do
name="${check%%:*}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { Component, enableProdMode, inject } from '@angular/core';
import { DxSelectBoxModule, DxDataGridModule } from 'devextreme-angular';
import type { DxSelectBoxTypes } from 'devextreme-angular/ui/select-box';

import 'devextreme/common/core/localization/globalize/number';
import 'devextreme/common/core/localization/globalize/date';
Expand Down Expand Up @@ -51,7 +52,7 @@ export class AppComponent {
Globalize.locale(this.locale);
}

private initGlobalize() {
private initGlobalize(): void {
Globalize.load(
deCldrData,
ruCldrData,
Expand All @@ -62,17 +63,17 @@ export class AppComponent {
Globalize.loadMessages(this.service.getDictionary());
}

changeLocale(data) {
this.setLocale(data.value);
changeLocale({ value }: DxSelectBoxTypes.ValueChangedEvent): void {
this.setLocale(value);
parent.document.location.reload();
}

private getLocale() {
private getLocale(): string {
const locale = sessionStorage.getItem('locale');
return locale != null ? locale : 'en';
}

private setLocale(locale) {
private setLocale(locale: string): void {
sessionStorage.setItem('locale', locale);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';

export class Locale {
export interface Locale {
Name: string;

Value: string;
Expand All @@ -17,7 +17,7 @@ const locales: Locale[] = [{
Value: 'ru',
}];

export class Payment {
export interface Payment {
PaymentId: number;

ContactName: string;
Expand Down Expand Up @@ -100,7 +100,7 @@ const payments: Payment[] = [{
PaymentDate: '2013/01/11',
}];

export class PaymentView {
export interface PaymentView {
Number: string;

Contact: string;
Expand All @@ -112,7 +112,7 @@ export class PaymentView {
PaymentDate: string;
}

export class Dictionary {
export interface Dictionary {
[key: string]: PaymentView;
}

Expand Down Expand Up @@ -142,15 +142,15 @@ const dictionary: Dictionary = {

@Injectable()
export class Service {
getPayments() {
getPayments(): Payment[] {
return payments;
}

getLocales() {
getLocales(): Locale[] {
return locales;
}

getDictionary() {
getDictionary(): Dictionary {
return dictionary;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'globalize';
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { Component, enableProdMode, inject } from '@angular/core';
import { DxSelectBoxModule, DxDataGridModule } from 'devextreme-angular';
import type { DxSelectBoxTypes } from 'devextreme-angular/ui/select-box';

import { locale, loadMessages, formatMessage } from 'devextreme-angular/common/core/localization';

Expand Down Expand Up @@ -40,23 +41,23 @@ export class AppComponent {
locale(this.locale);
}

private initMessages() {
private initMessages(): void {
loadMessages(deMessages);
loadMessages(ruMessages);
loadMessages(this.service.getDictionary());
}

changeLocale(data) {
this.setLocale(data.value);
changeLocale({ value }: DxSelectBoxTypes.ValueChangedEvent): void {
this.setLocale(value);
parent.document.location.reload();
}

private getLocale() {
private getLocale(): string {
const locale = sessionStorage.getItem('locale');
return locale != null ? locale : 'en';
}

private setLocale(locale) {
private setLocale(locale: string): void {
sessionStorage.setItem('locale', locale);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';

export class Locale {
export interface Locale {
Name: string;

Value: string;
Expand All @@ -17,7 +17,7 @@ const locales: Locale[] = [{
Value: 'ru',
}];

export class Payment {
export interface Payment {
PaymentId: number;

ContactName: string;
Expand Down Expand Up @@ -100,7 +100,7 @@ const payments: Payment[] = [{
PaymentDate: '2013/01/11',
}];

export class PaymentView {
export interface PaymentView {
Number: string;

Contact: string;
Expand All @@ -112,7 +112,7 @@ export class PaymentView {
PaymentDate: string;
}

export class Dictionary {
export interface Dictionary {
[key: string]: PaymentView;
}

Expand Down Expand Up @@ -142,15 +142,15 @@ const dictionary: Dictionary = {

@Injectable()
export class Service {
getPayments() {
getPayments(): Payment[] {
return payments;
}

getLocales() {
getLocales(): Locale[] {
return locales;
}

getDictionary() {
getDictionary(): Dictionary {
return dictionary;
}
}
20 changes: 10 additions & 10 deletions apps/demos/Demos/Map/Markers/Angular/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import {
Component, enableProdMode, inject, signal,
} from '@angular/core';
import { DxMapModule, DxCheckBoxModule, DxButtonModule } from 'devextreme-angular';
import type { DxCheckBoxTypes } from 'devextreme-angular/ui/check-box';

import { Service } from './app.service';
import type { APIKey } from './app.service';
import type { APIKey, Marker } from './app.service';

if (!/localhost/.test(document.location.host)) {
enableProdMode();
Expand All @@ -32,23 +33,22 @@ export class AppComponent {

readonly mapMarkerUrl = signal<string>(this.service.getMarkerUrl());

readonly markers = signal(this.service.getMarkers());
readonly markers = signal<Marker[]>(this.service.getMarkers());

readonly apiKey: APIKey = {
azure: '6N8zuPkBsnfwniNAJkldM3cUgm3lXg3y9gkIKy59benICnnepK4DJQQJ99AIACYeBjFllM6LAAAgAZMPGFXE',
};

checkCustomMarker(data) {
this.mapMarkerUrl.set(data.value ? this.customMarkerUrl : null);
checkCustomMarker({ value }: DxCheckBoxTypes.ValueChangedEvent): void {
this.mapMarkerUrl.set(value ? this.customMarkerUrl : '');
this.markers.set(this.originalMarkers);
}

showTooltips() {
this.markers.update((markers) => markers.map((item) => {
const newItem = JSON.parse(JSON.stringify(item));
newItem.tooltip.isShown = true;
return newItem;
}));
showTooltips(): void {
this.markers.update((markers) => markers.map((item) => ({
...item,
tooltip: { ...item.tooltip, isShown: true },
})));
}
}

Expand Down
18 changes: 8 additions & 10 deletions apps/demos/Demos/Map/Markers/Angular/app/app.service.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { Injectable } from '@angular/core';
import type { DxMapTypes } from 'devextreme-angular/ui/map';

export class Tooltip {
isShown: boolean;
type MapMarker = NonNullable<DxMapTypes.Properties['markers']>[number];

text: string;
}

export class Marker {
location: unknown;

tooltip: Tooltip;
}
export type Marker = Omit<MapMarker, 'tooltip'> & {
tooltip: {
isShown: boolean;
text: string;
};
};

export type APIKey = {
azure?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { bootstrapApplication } from '@angular/platform-browser';
import {
Component, enableProdMode, inject, signal, ViewEncapsulation,
} from '@angular/core';
import { DxMapModule, type DxMapTypes } from 'devextreme-angular/ui/map';
import { DxMapModule } from 'devextreme-angular/ui/map';
import type { DxMapTypes } from 'devextreme-angular/ui/map';
import { DxSelectBoxModule } from 'devextreme-angular/ui/select-box';
import type { DxSelectBoxTypes } from 'devextreme-angular/ui/select-box';
import 'devextreme/ui/map/openlayers';
Expand All @@ -11,6 +12,7 @@ import type LineString from 'ol/geom/LineString.js';
import Attribution from 'ol/control/Attribution.js';
import Polyline from 'ol/format/Polyline.js';
import { Service } from './app.service';
import type { Marker, Route } from './app.service';

const routeCache = new Map<string, DxMapTypes.OsmGeoJsonLineString>();

Expand Down Expand Up @@ -62,11 +64,11 @@ if (!/localhost/.test(document.location.host)) {
export class AppComponent {
private readonly service = inject(Service);

readonly markers: DxMapTypes.Properties['markers'] = this.service.getMarkers().map((marker) => (marker.iconSrc
readonly markers: Marker[] = this.service.getMarkers().map((marker) => (marker.iconSrc
? { ...marker, onClick: this.onMarkerClick }
: marker));

readonly routes = signal<DxMapTypes.Properties['routes']>(this.service.getRoutes());
readonly routes = signal<Route[]>(this.service.getRoutes());

readonly tileServer: DxMapTypes.OsmTileServerConfig = {
// Demo only: tiles are served under Developer Express Inc's Stadia Maps subscription via domain-based authentication.
Expand All @@ -80,7 +82,7 @@ export class AppComponent {

readonly calculateRoute = calculateRoute;

private onMarkerClick({ tooltip }: DxMapTypes.MarkerClickEvent) {
private onMarkerClick({ tooltip }: DxMapTypes.MarkerClickEvent): void {
tooltip?.option({
showTitle: true,
showCloseButton: true,
Expand All @@ -90,7 +92,7 @@ export class AppComponent {
});
}

onMapReady({ originalMap }: DxMapTypes.ReadyEvent) {
onMapReady({ originalMap }: DxMapTypes.ReadyEvent): void {
const map = originalMap as OpenLayersMap;
// Ensure attribution is visible to comply with the Stadia Maps Terms of Service.
const attribution = map.getControls().getArray()
Expand All @@ -101,11 +103,11 @@ export class AppComponent {
map.addControl(new Attribution({ collapsible: false }));
}

setMode({ value }: DxSelectBoxTypes.ValueChangedEvent) {
setMode({ value }: DxSelectBoxTypes.ValueChangedEvent): void {
this.routes.update((routes) => routes.map((route) => ({ ...route, mode: value })));
}

selectColor({ value }: DxSelectBoxTypes.ValueChangedEvent) {
selectColor({ value }: DxSelectBoxTypes.ValueChangedEvent): void {
this.routes.update((routes) => routes.map((route) => ({ ...route, color: value })));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Injectable } from '@angular/core';
import type { DxMapTypes } from 'devextreme-angular/ui/map';

const markers: DxMapTypes.Properties['markers'] = [{
export type Marker = NonNullable<DxMapTypes.Properties['markers']>[number];

export type Route = NonNullable<DxMapTypes.Properties['routes']>[number];

const markers: Marker[] = [{
location: '40.7825, -73.966111',
tooltip: { text: 'Central Park' },
}, {
Expand All @@ -16,7 +20,7 @@ const markers: DxMapTypes.Properties['markers'] = [{
tooltip: { text: 'City Hall Park' },
}];

const routes: DxMapTypes.Properties['routes'] = [{
const routes: Route[] = [{
weight: 6,
color: 'blue',
opacity: 0.5,
Expand All @@ -31,11 +35,11 @@ const routes: DxMapTypes.Properties['routes'] = [{

@Injectable()
export class Service {
getMarkers() {
getMarkers(): Marker[] {
return markers;
}

getRoutes() {
getRoutes(): Route[] {
return routes;
}
}
Loading