自定义应用程序集成在 Cumulocity 上
Custom application Integegrate on Cumulocity
我有一个使用 angular 4 和 bootstrap 版本 3 独立开发的自定义应用程序。
我确实使用 'ng build' 命令使用 angular-cli 构建自定义应用程序。
我想将此应用程序与 cumulocity 集成。
考虑到这个独立的应用程序也需要独立工作并且也在 cumulocity 中工作,有人可以建议将这个应用程序与 Cumulocity 集成的方法吗?
我也想关注 cumulocity 品牌。 (我可以修改我的 less 文件以使用 Cumulocity 变量)
您只需转到 ng build
,将所有内容压缩到 dist
文件夹中,然后将其作为自定义应用程序上传。然后,该应用程序将 运行 在您的 Cumulocity 租户的上下文中。
要连接到 Cumulocity (documentation) 的 REST 端点,您需要使用您的用户名和密码配置基本身份验证。如果您使用的是 ng2 http 客户端,您可以通过以下方式进行操作:
import {Injectable} from '@angular/core';
import {Http, Headers} from '@angular/http';
@Injectable()
export class ApiService {
constructor(private http: Http) {}
call(url): Observable<any> {
let username: string = 'username';
let password: string = 'password';
let headers: Headers = new Headers();
headers.append("Authorization", "Basic " + btoa(username + ":" + password));
return this.http.get(url, {headers: headers})
}
}
但是,请记住,您不应该将固定的用户名和密码写入应用程序,因为那样每个人都可以看到它。更好的方法是使用表单来验证用户身份,并且只在单页应用程序的上下文中使用它。
对于品牌化,您可以在 examples.
中找到定义的 less 变量
我有一个使用 angular 4 和 bootstrap 版本 3 独立开发的自定义应用程序。
我确实使用 'ng build' 命令使用 angular-cli 构建自定义应用程序。 我想将此应用程序与 cumulocity 集成。
考虑到这个独立的应用程序也需要独立工作并且也在 cumulocity 中工作,有人可以建议将这个应用程序与 Cumulocity 集成的方法吗?
我也想关注 cumulocity 品牌。 (我可以修改我的 less 文件以使用 Cumulocity 变量)
您只需转到 ng build
,将所有内容压缩到 dist
文件夹中,然后将其作为自定义应用程序上传。然后,该应用程序将 运行 在您的 Cumulocity 租户的上下文中。
要连接到 Cumulocity (documentation) 的 REST 端点,您需要使用您的用户名和密码配置基本身份验证。如果您使用的是 ng2 http 客户端,您可以通过以下方式进行操作:
import {Injectable} from '@angular/core';
import {Http, Headers} from '@angular/http';
@Injectable()
export class ApiService {
constructor(private http: Http) {}
call(url): Observable<any> {
let username: string = 'username';
let password: string = 'password';
let headers: Headers = new Headers();
headers.append("Authorization", "Basic " + btoa(username + ":" + password));
return this.http.get(url, {headers: headers})
}
}
但是,请记住,您不应该将固定的用户名和密码写入应用程序,因为那样每个人都可以看到它。更好的方法是使用表单来验证用户身份,并且只在单页应用程序的上下文中使用它。
对于品牌化,您可以在 examples.
中找到定义的 less 变量