@duplicati/ngclient 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +13 -0
- package/.github/workflows/npm-publish.yml +59 -0
- package/.prettierignore +13 -0
- package/.prettierrc +12 -0
- package/.vscode/extensions.json +4 -0
- package/.vscode/launch.json +13 -0
- package/.vscode/settings.json +8 -0
- package/.vscode/tasks.json +24 -0
- package/Dockerfile +38 -0
- package/LICENSE +21 -0
- package/README.md +27 -0
- package/angular.json +98 -0
- package/bun.lockb +0 -0
- package/openapi-ts.config.ts +13 -0
- package/package.json +46 -0
- package/scripts/generate-package-json.ts +15 -0
- package/src/app/about/about.component.html +15 -0
- package/src/app/about/about.component.scss +19 -0
- package/src/app/about/about.component.ts +13 -0
- package/src/app/about/changelog/changelog.component.html +3 -0
- package/src/app/about/changelog/changelog.component.scss +7 -0
- package/src/app/about/changelog/changelog.component.ts +18 -0
- package/src/app/about/general/general.component.html +9 -0
- package/src/app/about/general/general.component.scss +23 -0
- package/src/app/about/general/general.component.ts +30 -0
- package/src/app/about/libraries/libraries.component.html +3 -0
- package/src/app/about/libraries/libraries.component.scss +7 -0
- package/src/app/about/libraries/libraries.component.ts +18 -0
- package/src/app/about/logs/logs.component.html +5 -0
- package/src/app/about/logs/logs.component.scss +7 -0
- package/src/app/about/logs/logs.component.ts +18 -0
- package/src/app/about/system-info/system-info.component.html +3 -0
- package/src/app/about/system-info/system-info.component.scss +7 -0
- package/src/app/about/system-info/system-info.component.ts +17 -0
- package/src/app/add-backup/add-backup.component.html +29 -0
- package/src/app/add-backup/add-backup.component.scss +38 -0
- package/src/app/add-backup/add-backup.component.ts +14 -0
- package/src/app/app.component.ts +35 -0
- package/src/app/app.config.ts +23 -0
- package/src/app/app.routes.ts +121 -0
- package/src/app/core/components/file-tree/file-tree.component.html +87 -0
- package/src/app/core/components/file-tree/file-tree.component.scss +80 -0
- package/src/app/core/components/file-tree/file-tree.component.ts +485 -0
- package/src/app/core/components/logo/logo.component.html +22 -0
- package/src/app/core/components/logo/logo.component.scss +12 -0
- package/src/app/core/components/logo/logo.component.ts +11 -0
- package/src/app/core/components/status-bar/status-bar.component.html +38 -0
- package/src/app/core/components/status-bar/status-bar.component.scss +27 -0
- package/src/app/core/components/status-bar/status-bar.component.ts +33 -0
- package/src/app/core/components/status-bar/status-bar.state.ts +182 -0
- package/src/app/core/components/toggle-card/toggle-card.component.html +11 -0
- package/src/app/core/components/toggle-card/toggle-card.component.scss +49 -0
- package/src/app/core/components/toggle-card/toggle-card.component.ts +28 -0
- package/src/app/core/interceptors/http.interceptor.ts +69 -0
- package/src/app/core/interceptors/websocket.interceptor.ts +66 -0
- package/src/app/core/openapi/core/ApiError.ts +21 -0
- package/src/app/core/openapi/core/ApiRequestOptions.ts +21 -0
- package/src/app/core/openapi/core/ApiResult.ts +7 -0
- package/src/app/core/openapi/core/OpenAPI.ts +55 -0
- package/src/app/core/openapi/core/request.ts +337 -0
- package/src/app/core/openapi/index.ts +6 -0
- package/src/app/core/openapi/schemas.gen.ts +3611 -0
- package/src/app/core/openapi/services.gen.ts +1460 -0
- package/src/app/core/openapi/types.gen.ts +1510 -0
- package/src/app/core/pipes/duration.pipe.ts +27 -0
- package/src/app/core/pipes/relative-time.pipe.ts +14 -0
- package/src/app/core/providers/dayjs.ts +16 -0
- package/src/app/core/services/dict.en.ts +0 -0
- package/src/app/core/services/dictionary.service.ts +12 -0
- package/src/app/core/services/localstorage.token.ts +82 -0
- package/src/app/core/services/password-generator.service.ts +39 -0
- package/src/app/core/services/relay-websocket.service.ts +268 -0
- package/src/app/core/services/timespan-literals.service.ts +25 -0
- package/src/app/core/states/app-auth.state.ts +87 -0
- package/src/app/core/states/backups.state.ts +71 -0
- package/src/app/core/states/relayconfig.state.ts +23 -0
- package/src/app/core/states/sysinfo.state.ts +31 -0
- package/src/app/core/states/tasks.state.ts +34 -0
- package/src/app/core/types/subscribed.ts +7 -0
- package/src/app/core/validators/custom.validators.ts +120 -0
- package/src/app/create-edit-backup/create-edit-backup.component.html +28 -0
- package/src/app/create-edit-backup/create-edit-backup.component.scss +15 -0
- package/src/app/create-edit-backup/create-edit-backup.component.ts +33 -0
- package/src/app/create-edit-backup/create-edit-backup.state.ts +582 -0
- package/src/app/create-edit-backup/destination/destination.component.html +367 -0
- package/src/app/create-edit-backup/destination/destination.component.scss +85 -0
- package/src/app/create-edit-backup/destination/destination.component.ts +249 -0
- package/src/app/create-edit-backup/destination/destination.config.ts +103 -0
- package/src/app/create-edit-backup/destination/destination.mapper.ts +177 -0
- package/src/app/create-edit-backup/general/general.component.html +108 -0
- package/src/app/create-edit-backup/general/general.component.scss +34 -0
- package/src/app/create-edit-backup/general/general.component.ts +136 -0
- package/src/app/create-edit-backup/options/options.component.html +95 -0
- package/src/app/create-edit-backup/options/options.component.scss +42 -0
- package/src/app/create-edit-backup/options/options.component.ts +113 -0
- package/src/app/create-edit-backup/schedule/schedule.component.html +102 -0
- package/src/app/create-edit-backup/schedule/schedule.component.scss +38 -0
- package/src/app/create-edit-backup/schedule/schedule.component.ts +137 -0
- package/src/app/create-edit-backup/source-data/source-data.component.html +93 -0
- package/src/app/create-edit-backup/source-data/source-data.component.scss +41 -0
- package/src/app/create-edit-backup/source-data/source-data.component.ts +114 -0
- package/src/app/home/backup.const.ts +167 -0
- package/src/app/home/home.component.html +98 -0
- package/src/app/home/home.component.scss +88 -0
- package/src/app/home/home.component.ts +54 -0
- package/src/app/layout/layout.component.html +64 -0
- package/src/app/layout/layout.component.scss +24 -0
- package/src/app/layout/layout.component.ts +51 -0
- package/src/app/layout/layout.state.ts +70 -0
- package/src/app/login/login.component.html +12 -0
- package/src/app/login/login.component.scss +25 -0
- package/src/app/login/login.component.ts +34 -0
- package/src/app/logout/logout.component.html +1 -0
- package/src/app/logout/logout.component.scss +3 -0
- package/src/app/logout/logout.component.ts +18 -0
- package/src/app/restore/restore.component.html +56 -0
- package/src/app/restore/restore.component.scss +37 -0
- package/src/app/restore/restore.component.ts +55 -0
- package/src/app/restore-flow/options/options.component.html +57 -0
- package/src/app/restore-flow/options/options.component.scss +16 -0
- package/src/app/restore-flow/options/options.component.ts +58 -0
- package/src/app/restore-flow/restore-flow.component.html +14 -0
- package/src/app/restore-flow/restore-flow.component.scss +15 -0
- package/src/app/restore-flow/restore-flow.component.ts +23 -0
- package/src/app/restore-flow/restore-flow.state.ts +120 -0
- package/src/app/restore-flow/select-files/select-files.component.html +42 -0
- package/src/app/restore-flow/select-files/select-files.component.scss +16 -0
- package/src/app/restore-flow/select-files/select-files.component.ts +129 -0
- package/src/app/settings/settings.component.html +256 -0
- package/src/app/settings/settings.component.scss +106 -0
- package/src/app/settings/settings.component.ts +475 -0
- package/src/assets/duplicati-logo.png +0 -0
- package/src/assets/duplicati-logo.svg +10 -0
- package/src/assets/favicon.ico +0 -0
- package/src/assets/images/backup.png +0 -0
- package/src/assets/images/dark-theme.png +0 -0
- package/src/assets/images/folder.png +0 -0
- package/src/assets/images/light-theme.png +0 -0
- package/src/assets/images/new-backup.png +0 -0
- package/src/assets/images/restore.png +0 -0
- package/src/assets/images/system-theme.png +0 -0
- package/src/assets/spk.css +33 -0
- package/src/assets/spk.woff2 +0 -0
- package/src/environments/environment-token.ts +4 -0
- package/src/environments/environment.prod.ts +6 -0
- package/src/environments/environment.ts +6 -0
- package/src/index.html +15 -0
- package/src/main.ts +6 -0
- package/src/proxy.conf.mjs +6 -0
- package/src/styles.scss +41 -0
- package/tsconfig.app.json +15 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,475 @@
|
|
|
1
|
+
import { JsonPipe } from '@angular/common';
|
|
2
|
+
import { ChangeDetectionStrategy, Component, computed, effect, inject, signal } from '@angular/core';
|
|
3
|
+
import { toSignal } from '@angular/core/rxjs-interop';
|
|
4
|
+
import { FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
5
|
+
import {
|
|
6
|
+
SparkleButtonComponent,
|
|
7
|
+
SparkleButtonGroupComponent,
|
|
8
|
+
SparkleFormFieldComponent,
|
|
9
|
+
SparkleIconComponent,
|
|
10
|
+
SparkleRadioComponent,
|
|
11
|
+
SparkleSelectComponent,
|
|
12
|
+
} from '@sparkle-ui/core';
|
|
13
|
+
import { derivedFrom } from 'ngxtension/derived-from';
|
|
14
|
+
import { map, pipe, startWith } from 'rxjs';
|
|
15
|
+
import StatusBarComponent from '../core/components/status-bar/status-bar.component';
|
|
16
|
+
import { DuplicatiServerService, RemoteControlStatusOutput } from '../core/openapi';
|
|
17
|
+
import { SysinfoState } from '../core/states/sysinfo.state';
|
|
18
|
+
import { LayoutState } from '../layout/layout.state';
|
|
19
|
+
|
|
20
|
+
const fb = new FormBuilder();
|
|
21
|
+
|
|
22
|
+
type UpdateChannel = '' | 'stable' | 'beta' | 'experimental' | 'canary';
|
|
23
|
+
// type TimeTypes = 'Hours' | 'Minutes' | 'Seconds';
|
|
24
|
+
|
|
25
|
+
// const TimeTypeMap: { [key: string]: TimeTypes } = {
|
|
26
|
+
// h: 'Hours',
|
|
27
|
+
// m: 'Minutes',
|
|
28
|
+
// s: 'Seconds',
|
|
29
|
+
// };
|
|
30
|
+
|
|
31
|
+
const TIME_OPTIONS = [
|
|
32
|
+
{
|
|
33
|
+
value: 's',
|
|
34
|
+
label: 'Seconds',
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
value: 'm',
|
|
38
|
+
label: 'Minutes',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
value: 'h',
|
|
42
|
+
label: 'Hours',
|
|
43
|
+
},
|
|
44
|
+
] as const;
|
|
45
|
+
|
|
46
|
+
type TimeTypes = (typeof TIME_OPTIONS)[number]['value'];
|
|
47
|
+
|
|
48
|
+
const LANGUAGES = [
|
|
49
|
+
{
|
|
50
|
+
value: 'en',
|
|
51
|
+
label: 'English',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
value: 'fr',
|
|
55
|
+
label: 'French',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
value: 'de',
|
|
59
|
+
label: 'German',
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: 'es',
|
|
63
|
+
label: 'Spanish',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
value: 'it',
|
|
67
|
+
label: 'Italian',
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
type LangType = (typeof LANGUAGES)[number];
|
|
72
|
+
|
|
73
|
+
const USAGE_STATISTICS_OPTIONS = [
|
|
74
|
+
{
|
|
75
|
+
value: '',
|
|
76
|
+
label: 'System default (information)',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
value: 'information',
|
|
80
|
+
label: 'Usage statistics, warnings, errors, and crashes',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
value: 'warning',
|
|
84
|
+
label: 'Warnings, errors and crashes',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
value: 'error',
|
|
88
|
+
label: 'Errors and crashes',
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
value: 'crash',
|
|
92
|
+
label: 'Crashes only',
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
value: 'none',
|
|
96
|
+
label: 'None / disabled',
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
type UsageStatisticsType = (typeof USAGE_STATISTICS_OPTIONS)[number];
|
|
101
|
+
type RemoteControlState =
|
|
102
|
+
| 'connected'
|
|
103
|
+
| 'registered'
|
|
104
|
+
| 'registering'
|
|
105
|
+
| 'registeringfaulted'
|
|
106
|
+
| 'enabled'
|
|
107
|
+
| 'disabled'
|
|
108
|
+
| 'inactive'
|
|
109
|
+
| 'unknown';
|
|
110
|
+
|
|
111
|
+
type Timeout = ReturnType<typeof setTimeout>;
|
|
112
|
+
|
|
113
|
+
@Component({
|
|
114
|
+
selector: 'app-settings',
|
|
115
|
+
standalone: true,
|
|
116
|
+
imports: [
|
|
117
|
+
FormsModule,
|
|
118
|
+
ReactiveFormsModule,
|
|
119
|
+
|
|
120
|
+
StatusBarComponent,
|
|
121
|
+
SparkleButtonComponent,
|
|
122
|
+
SparkleIconComponent,
|
|
123
|
+
SparkleRadioComponent,
|
|
124
|
+
SparkleFormFieldComponent,
|
|
125
|
+
SparkleButtonGroupComponent,
|
|
126
|
+
SparkleSelectComponent,
|
|
127
|
+
|
|
128
|
+
JsonPipe,
|
|
129
|
+
],
|
|
130
|
+
templateUrl: './settings.component.html',
|
|
131
|
+
styleUrl: './settings.component.scss',
|
|
132
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
133
|
+
})
|
|
134
|
+
export default class SettingsComponent {
|
|
135
|
+
#layoutState = inject(LayoutState);
|
|
136
|
+
#sysinfo = inject(SysinfoState);
|
|
137
|
+
#dupServer = inject(DuplicatiServerService);
|
|
138
|
+
|
|
139
|
+
sysinfo = this.#sysinfo.systemInfo;
|
|
140
|
+
|
|
141
|
+
isDarkMode = this.#layoutState.isDarkMode;
|
|
142
|
+
editAs = signal<'list' | 'text'>('list');
|
|
143
|
+
settingsForm = fb.group({
|
|
144
|
+
pauseSettings: fb.group({
|
|
145
|
+
time: fb.control<number>(0),
|
|
146
|
+
timeType: fb.control<TimeTypes>('s'),
|
|
147
|
+
}),
|
|
148
|
+
language: fb.control<string>('en'),
|
|
149
|
+
usageStatistics: fb.control<UsageStatisticsType['value']>(''),
|
|
150
|
+
updateChannel: fb.control<UpdateChannel>(''),
|
|
151
|
+
remoteControlRegisterUrl: fb.control<string>(''),
|
|
152
|
+
});
|
|
153
|
+
remoteControlState = signal<RemoteControlState>('unknown');
|
|
154
|
+
remoteControlClaimUrl = signal<string | null>(null);
|
|
155
|
+
// remoteControlRegisterUrl = signal<string>('');
|
|
156
|
+
|
|
157
|
+
sysInfoEffect = effect(
|
|
158
|
+
() => {
|
|
159
|
+
this.settingsForm.controls.remoteControlRegisterUrl.patchValue(
|
|
160
|
+
this.sysinfo()?.RemoteControlRegistrationUrl ?? ''
|
|
161
|
+
);
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
allowSignalWrites: true,
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
get pauseSettings() {
|
|
169
|
+
return this.settingsForm.controls.pauseSettings;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
langSignal = toSignal(this.settingsForm.controls.language.valueChanges);
|
|
173
|
+
timeTypeOptions = signal(TIME_OPTIONS);
|
|
174
|
+
timeOptions = derivedFrom(
|
|
175
|
+
[
|
|
176
|
+
this.pauseSettings.controls.timeType.valueChanges.pipe(startWith('s')),
|
|
177
|
+
this.pauseSettings.controls.time.valueChanges.pipe(startWith(null)),
|
|
178
|
+
],
|
|
179
|
+
pipe(
|
|
180
|
+
map(([timeType, time]) => {
|
|
181
|
+
const timeOptions = this.#createTimeOptions(timeType as TimeTypes);
|
|
182
|
+
|
|
183
|
+
return time !== null ? timeOptions.filter((x) => x.toString().includes(time.toString())) : timeOptions;
|
|
184
|
+
}),
|
|
185
|
+
startWith([])
|
|
186
|
+
)
|
|
187
|
+
);
|
|
188
|
+
|
|
189
|
+
languageOptions = computed(() =>
|
|
190
|
+
this.langSignal() ? LANGUAGES.filter((x) => x.value === this.langSignal()) : LANGUAGES
|
|
191
|
+
);
|
|
192
|
+
|
|
193
|
+
usageStatisticsOptions = signal(USAGE_STATISTICS_OPTIONS);
|
|
194
|
+
|
|
195
|
+
ngOnInit() {
|
|
196
|
+
this.refreshRemoteControlStatus();
|
|
197
|
+
this.getServerSettings();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
submit() {
|
|
201
|
+
// var patchdata = {
|
|
202
|
+
// 'server-passphrase': $scope.changeServerPassword ? $scope.remotePassword : '',
|
|
203
|
+
// 'allowed-hostnames': $scope.remoteHostnames,
|
|
204
|
+
// 'server-listen-interface': $scope.allowRemoteAccess ? 'any' : 'loopback',
|
|
205
|
+
// 'startup-delay': $scope.startupDelayDurationValue + '' + $scope.startupDelayDurationMultiplier,
|
|
206
|
+
// 'update-channel': $scope.updateChannel,
|
|
207
|
+
// 'usage-reporter-level': $scope.usageReporterLevel,
|
|
208
|
+
// 'disable-tray-icon-login': $scope.disableTrayIconLogin
|
|
209
|
+
// };
|
|
210
|
+
|
|
211
|
+
const startupDelay = `${this.pauseSettings.controls.time.value}${this.pauseSettings.controls.timeType.value}`;
|
|
212
|
+
|
|
213
|
+
this.#dupServer
|
|
214
|
+
.patchApiV1Serversettings({
|
|
215
|
+
requestBody: {
|
|
216
|
+
'usage-reporter-level': this.settingsForm.controls.usageStatistics.value,
|
|
217
|
+
'startup-delay': startupDelay === '0s' ? '' : startupDelay,
|
|
218
|
+
'update-channel': this.settingsForm.controls.updateChannel.value,
|
|
219
|
+
},
|
|
220
|
+
})
|
|
221
|
+
.subscribe({
|
|
222
|
+
next: (res) => {
|
|
223
|
+
console.log('res', res);
|
|
224
|
+
},
|
|
225
|
+
error: (err) => {
|
|
226
|
+
console.error('err', err);
|
|
227
|
+
},
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
getServerSettings() {
|
|
232
|
+
return this.#dupServer.getApiV1Serversettings().subscribe({
|
|
233
|
+
next: (res) => {
|
|
234
|
+
const startupDelay = res['startup-delay'] as string;
|
|
235
|
+
|
|
236
|
+
this.settingsForm.patchValue({
|
|
237
|
+
pauseSettings: {
|
|
238
|
+
time: parseInt(
|
|
239
|
+
startupDelay.substring(0, startupDelay.length - 1) == ''
|
|
240
|
+
? '0'
|
|
241
|
+
: startupDelay.substring(0, startupDelay.length - 1)
|
|
242
|
+
),
|
|
243
|
+
timeType:
|
|
244
|
+
startupDelay.substring(-1) === '' ? ('s' as TimeTypes) : (startupDelay.substring(-1) as TimeTypes),
|
|
245
|
+
},
|
|
246
|
+
usageStatistics: res['usage-reporter-level'],
|
|
247
|
+
updateChannel: res['update-channel'] as UpdateChannel,
|
|
248
|
+
});
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
languageDisplay(x: LangType['value'] | null) {
|
|
254
|
+
if (!x) return null;
|
|
255
|
+
return LANGUAGES.find((y) => y.value === x)?.label ?? null;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
typeDisplay(x: TimeTypes | null | undefined) {
|
|
259
|
+
if (x === null || x === undefined) return null;
|
|
260
|
+
|
|
261
|
+
return TIME_OPTIONS.find((y) => y.value === x)?.label ?? null;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
usageDisplay(x: UsageStatisticsType['value'] | null) {
|
|
265
|
+
if (typeof x !== 'string') return null;
|
|
266
|
+
return USAGE_STATISTICS_OPTIONS.find((y) => y.value === x)?.label ?? null;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
setDarkMode() {
|
|
270
|
+
this.#layoutState.setDarkMode();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
setLightMode() {
|
|
274
|
+
this.#layoutState.setLightMode();
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
#createTimeOptions(type: TimeTypes) {
|
|
278
|
+
const typeLen = type === 'h' ? 25 : 61;
|
|
279
|
+
|
|
280
|
+
return new Array(typeLen).fill(0).map((_, i) => i);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
repeatRegisterTimer: Timeout | null = null;
|
|
284
|
+
|
|
285
|
+
#mapRemoteControlStatus(data: RemoteControlStatusOutput) {
|
|
286
|
+
// remoteControlEnabled = data.IsEnabled;
|
|
287
|
+
// remoteControlCanEnable = data.CanEnable;
|
|
288
|
+
// remoteControlConnected = data.IsConnected;
|
|
289
|
+
// remoteControlIsRegistering = data.IsRegistering;
|
|
290
|
+
// remoteControlIsRegisteringFaulted = data.IsRegisteringFaulted;
|
|
291
|
+
// remoteControlIsRegisteringCompleted = data.IsRegisteringCompleted;
|
|
292
|
+
|
|
293
|
+
data.RegistrationUrl && this.remoteControlClaimUrl.set(data.RegistrationUrl);
|
|
294
|
+
|
|
295
|
+
console.log(data);
|
|
296
|
+
|
|
297
|
+
if (data.IsConnected) {
|
|
298
|
+
this.remoteControlState.set('connected');
|
|
299
|
+
} else if (data.IsEnabled) {
|
|
300
|
+
this.remoteControlState.set('enabled');
|
|
301
|
+
} else if (data.CanEnable) {
|
|
302
|
+
this.remoteControlState.set('disabled');
|
|
303
|
+
} else if (data.IsRegisteringFaulted) {
|
|
304
|
+
this.remoteControlState.set('registeringfaulted');
|
|
305
|
+
} else if (data.IsRegistering) {
|
|
306
|
+
if (data.RegistrationUrl != null && data.RegistrationUrl.trim().length > 0) {
|
|
307
|
+
this.remoteControlState.set('registered');
|
|
308
|
+
} else {
|
|
309
|
+
this.remoteControlState.set('registering');
|
|
310
|
+
}
|
|
311
|
+
} else {
|
|
312
|
+
this.remoteControlState.set('inactive');
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
const currentRemoteControlState = this.remoteControlState();
|
|
316
|
+
|
|
317
|
+
console.log(currentRemoteControlState);
|
|
318
|
+
|
|
319
|
+
// Stop any existing timer
|
|
320
|
+
if (this.repeatRegisterTimer !== null) {
|
|
321
|
+
clearTimeout(this.repeatRegisterTimer);
|
|
322
|
+
this.repeatRegisterTimer = null;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// If we are registering, we need to keep checking until the registration is claimed
|
|
326
|
+
if (currentRemoteControlState === 'registering') {
|
|
327
|
+
this.repeatRegisterTimer = setTimeout(() => {
|
|
328
|
+
this.#dupServer.postApiV1RemotecontrolRegister({ requestBody: { RegistrationUrl: '' } }).subscribe({
|
|
329
|
+
next: (res) => {
|
|
330
|
+
this.#mapRemoteControlStatus(res);
|
|
331
|
+
},
|
|
332
|
+
error: (err) => {
|
|
333
|
+
this.#mapRemoteControlError(err);
|
|
334
|
+
},
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
// AppService.post('/remotecontrol/register', { RegistrationUrl: '' }).then(
|
|
338
|
+
// function (data) {
|
|
339
|
+
// this.#mapRemoteControlStatus(data.data);
|
|
340
|
+
// },
|
|
341
|
+
// () => {
|
|
342
|
+
// AppService.get('/remotecontrol/status').then(
|
|
343
|
+
// function (data) {
|
|
344
|
+
// this.#mapRemoteControlStatus(data.data);
|
|
345
|
+
// },
|
|
346
|
+
// () => {}
|
|
347
|
+
// );
|
|
348
|
+
// }
|
|
349
|
+
// );
|
|
350
|
+
}, 5000);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// If we are enabled, poll to see if we become connected
|
|
354
|
+
// If we are registered, poll to see if we become disabled
|
|
355
|
+
if (currentRemoteControlState === 'enabled' || currentRemoteControlState === 'registered') {
|
|
356
|
+
this.repeatRegisterTimer = setTimeout(() => {
|
|
357
|
+
this.#dupServer.getApiV1RemotecontrolStatus().subscribe({
|
|
358
|
+
next: (res) => {
|
|
359
|
+
this.#mapRemoteControlStatus(res);
|
|
360
|
+
},
|
|
361
|
+
error: (err) => {
|
|
362
|
+
this.#mapRemoteControlError(err);
|
|
363
|
+
},
|
|
364
|
+
});
|
|
365
|
+
}, 5000);
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
// If we can enable and are registering, there must be a lingering registration
|
|
369
|
+
if (data.IsRegistering && data.CanEnable) {
|
|
370
|
+
this.#dupServer.deleteApiV1RemotecontrolRegister().subscribe({
|
|
371
|
+
next: (res) => {
|
|
372
|
+
this.#mapRemoteControlStatus(res);
|
|
373
|
+
},
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
#mapRemoteControlError(data: any) {
|
|
379
|
+
// AppUtils.connectionError(data);
|
|
380
|
+
|
|
381
|
+
this.#dupServer.getApiV1RemotecontrolStatus().subscribe({
|
|
382
|
+
next: (res) => {
|
|
383
|
+
this.#mapRemoteControlStatus(res);
|
|
384
|
+
},
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
refreshRemoteControlStatus() {
|
|
389
|
+
this.#dupServer.getApiV1RemotecontrolStatus().subscribe({
|
|
390
|
+
next: (res) => {
|
|
391
|
+
this.#mapRemoteControlStatus(res);
|
|
392
|
+
},
|
|
393
|
+
error: (err) => {
|
|
394
|
+
this.#mapRemoteControlError(err);
|
|
395
|
+
},
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
beginRemoteRegistration() {
|
|
400
|
+
this.remoteControlState.set('registering');
|
|
401
|
+
|
|
402
|
+
const registrationUrl = this.settingsForm.controls.remoteControlRegisterUrl.value;
|
|
403
|
+
|
|
404
|
+
this.#dupServer.postApiV1RemotecontrolRegister({ requestBody: { RegistrationUrl: registrationUrl } }).subscribe({
|
|
405
|
+
next: (res) => {
|
|
406
|
+
this.#mapRemoteControlStatus(res);
|
|
407
|
+
},
|
|
408
|
+
error: (err) => {
|
|
409
|
+
this.#mapRemoteControlError(err);
|
|
410
|
+
},
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
cancelRemoteRegistration() {
|
|
415
|
+
this.#dupServer.deleteApiV1RemotecontrolRegister().subscribe({
|
|
416
|
+
next: (res) => {
|
|
417
|
+
this.#mapRemoteControlStatus(res);
|
|
418
|
+
},
|
|
419
|
+
error: (err) => {
|
|
420
|
+
this.#mapRemoteControlError(err);
|
|
421
|
+
},
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
enableRemoteControl() {
|
|
426
|
+
this.#dupServer.postApiV1RemotecontrolEnable().subscribe({
|
|
427
|
+
next: (res) => {
|
|
428
|
+
this.#mapRemoteControlStatus(res);
|
|
429
|
+
},
|
|
430
|
+
error: (err) => {
|
|
431
|
+
this.#mapRemoteControlError(err);
|
|
432
|
+
},
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
disableRemoteControl() {
|
|
437
|
+
this.#dupServer.postApiV1RemotecontrolDisable().subscribe({
|
|
438
|
+
next: (res) => {
|
|
439
|
+
this.#mapRemoteControlStatus(res);
|
|
440
|
+
},
|
|
441
|
+
error: (err) => {
|
|
442
|
+
this.#mapRemoteControlError(err);
|
|
443
|
+
},
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
deleteRemoteControl() {
|
|
448
|
+
const _self = this;
|
|
449
|
+
|
|
450
|
+
if (confirm('Are you sure you want to delete the remote control registration?')) {
|
|
451
|
+
_self.#dupServer.deleteApiV1RemotecontrolRegistration().subscribe({
|
|
452
|
+
next: (res) => {
|
|
453
|
+
_self.#mapRemoteControlStatus(res);
|
|
454
|
+
},
|
|
455
|
+
error: (err) => {
|
|
456
|
+
_self.#mapRemoteControlError(err);
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
getRemoteControlStatusText() {
|
|
463
|
+
const remoteControlState = this.remoteControlState();
|
|
464
|
+
|
|
465
|
+
if (remoteControlState === 'enabled') return 'Remote control is enabled but not connected';
|
|
466
|
+
if (remoteControlState === 'connected') return 'Remote control is connected';
|
|
467
|
+
if (remoteControlState === 'registering') return 'Registering machine...';
|
|
468
|
+
if (remoteControlState === 'registeringfaulted') return 'Registration failed';
|
|
469
|
+
if (remoteControlState === 'registered') return 'Registered, waiting for accept';
|
|
470
|
+
if (remoteControlState === 'disabled') return 'Remote control is configured but not enabled';
|
|
471
|
+
if (remoteControlState === 'unknown') return '...loading...';
|
|
472
|
+
|
|
473
|
+
return 'Remote control is not set up';
|
|
474
|
+
}
|
|
475
|
+
}
|
|
Binary file
|