This repository has been archived by the owner on Mar 28, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(todo): support local mindsphere development mode
provide support for executing local angular dev server connected to the mindsphere remote services for local development
- Loading branch information
Showing
21 changed files
with
271 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
var HttpsProxyAgent = require('https-proxy-agent'); | ||
var proxyConfig = [ | ||
{ | ||
context: '/api', | ||
target: 'https://gateway.eu1.mindsphere.io', | ||
secure: true, | ||
changeOrigin: true, | ||
logLevel: 'debug' | ||
}, | ||
{ | ||
context: '/v1', | ||
target: 'http://localhost:3000', | ||
secure: false, | ||
changeOrigin: true, | ||
logLevel: 'debug' | ||
} | ||
]; | ||
|
||
function setupForCorporateProxy(proxyConfig) { | ||
console.log('Checking corporate proxy settings'); | ||
var proxyServer = process.env.http_proxy || process.env.HTTP_PROXY; | ||
if (proxyServer) { | ||
var agent = new HttpsProxyAgent(proxyServer); | ||
console.log('Using corporate proxy server: ' + proxyServer); | ||
proxyConfig.forEach(function(entry) { | ||
// Do not proxy requests targeted to localhost | ||
if (entry.target.search(/localhost|127\.0\.0\.1/i) < 0) { | ||
entry.agent = agent; | ||
} else { | ||
console.log('Ignoring proxy for localhost target entry:', entry); | ||
} | ||
}); | ||
} else { | ||
console.log('No proxy detected, using direct connection'); | ||
} | ||
return proxyConfig; | ||
} | ||
|
||
module.exports = setupForCorporateProxy(proxyConfig); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
Copyright Siemens AG 2018 | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
import { Injectable } from '@angular/core'; | ||
import { Observable , of} from 'rxjs'; | ||
import { TenantInfo } from './tenantinfo'; | ||
|
||
@Injectable() | ||
export class MindSphereServiceMock { | ||
|
||
getTenantInfo(): Observable<TenantInfo> { | ||
const TENANT_INFO: TenantInfo = { | ||
prefix: 'mytenant', | ||
name: 'mytenant', | ||
displayName: 'mytenant', | ||
type: 'DEVELOPER', | ||
companyName: 'My Company', | ||
allowedToCreateSubtenant: true, | ||
ETag: 1 | ||
}; | ||
return of(TENANT_INFO); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
Copyright Siemens AG 2018 | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
import { Injectable } from '@angular/core'; | ||
import { HttpClient, HttpHeaders } from '@angular/common/http'; | ||
import { CookieService } from 'ngx-cookie-service'; | ||
import { Observable } from 'rxjs'; | ||
import { TenantInfo } from './tenantinfo'; | ||
import { environment } from '../environments/environment'; | ||
import { tap } from 'rxjs/operators'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class MindSphereService { | ||
|
||
static readonly TENANTMGMT_TENANTINFO_URL = './api/tenantmanagement/v4/tenantInfo'; | ||
mdspXsrfTokenHeader: string; | ||
|
||
constructor(private http: HttpClient, private cookieService: CookieService) { | ||
this.mdspXsrfTokenHeader = this.cookieService.get('XSRF-TOKEN'); | ||
|
||
if (! environment.production) { | ||
console.log('MindSphere dev mode, setting custom xsrf header and session cookie'); | ||
|
||
this.mdspXsrfTokenHeader = environment.mdsp.xsrfTokenHeader; | ||
this.cookieService.set('SESSION', environment.mdsp.sessionCookie); | ||
} | ||
} | ||
|
||
getTenantInfo(): Observable<TenantInfo> { | ||
return this.http.get<TenantInfo>( | ||
MindSphereService.TENANTMGMT_TENANTINFO_URL, | ||
{ | ||
headers: new HttpHeaders({ | ||
'x-xsrf-token': this.mdspXsrfTokenHeader, | ||
'accept': 'application/json', | ||
'content-type': 'application/json' | ||
}) | ||
}) | ||
.pipe(tap(response => { | ||
console.log('tenantInfo:', response); | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
Copyright Siemens AG 2018 | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
type TenantType = | ||
| 'DEVELOPER' | ||
| 'USER' | ||
| 'OPERATOR'; | ||
|
||
export class TenantInfo { | ||
ETag: any; | ||
allowedToCreateSubtenant: boolean; | ||
companyName: string; | ||
country?: string; | ||
displayName: string; | ||
name: string; | ||
prefix: string; | ||
type: TenantType; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,6 @@ SPDX-License-Identifier: MIT | |
*/ | ||
|
||
export class Todo { | ||
_id?: string; | ||
title: string; | ||
_id?: string; | ||
title: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,4 @@ <h1 class="form-control">{{todo.title}}</h1> | |
</div> | ||
</div> | ||
</div> | ||
<hr> |
Oops, something went wrong.