Matériel (hwproxy) Librairie Angular
November 26, 2025 at 2:48 AMLibrairie Angular
La gestion du matériel est exposée via une librairie Angular : @isinc/hwproxy-lib.
Des composants graphiques (pour démos et tests) sont disponibles : @isinc/hwproxy-uilib.
Les sources et application sont disponibles : https://git.isi.nc/pole-tech/hwproxy-lib.
Service matériel
Importation du module
import { HwProxyModule, HWPROXY_URL } from '@isinc/hwproxy-lib';
@NgModule({
declarations: [],
imports: [
HwProxyModule,
],
providers: [
{
provide: HWPROXY_URL,
useFactory: () => {
// Configure the url to use
const url = new URL(window.location.href);
let host = url.searchParams.get('host');
if (host) {
if (!host.endsWith('/')) {
host = host + '/';
}
return host;
}
return window.location.protocol + '//' + window.location.hostname + ':17000/';
}
}
],
})
export class AppModule { }
Injection du service
export class AppComponent implements OnInit, OnDestroy {
public title = 'hwproxy-ui';
private readonly subs: Subscription[];
constructor(
private readonly hwproxy: HwProxyService,
private readonly titleService: Title,
) {
this.subs = [];
}
ngOnInit() {
this.hwproxy.start();
this.subs.push(this.hwproxy.isConnectedChanged.subscribe((c) => this.handleIsConnected(c)));
}
ngOnDestroy() {
this.subs.forEach(s => s.unsubscribe());
this.hwproxy.stop();
}
private handleIsConnected(isConnected: boolean) {
// what to do when connection state has changed
if (isConnected) {
this.hwproxy.health.getHostname().subscribe((result: string) => {
this.title = result;
this.titleService.setTitle(result);
});
}
}
}