本文整理汇总了TypeScript中app/core/core-services/http.service.HttpService类的典型用法代码示例。如果您正苦于以下问题:TypeScript service.HttpService类的具体用法?TypeScript service.HttpService怎么用?TypeScript service.HttpService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了service.HttpService类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: changeSubmitters
/**
* Opens a dialog and adds or removes the selected submitters for all given motions.
*
* @param motions The motions to add/remove the sumbitters to
*/
public async changeSubmitters(motions: ViewMotion[]): Promise<void> {
const title = this.translate.instant(
'This will add or remove the following submitters for all selected motions:'
);
const choices = [this.translate.instant('Add'), this.translate.instant('Remove')];
const selectedChoice = await this.choiceService.open(title, this.userRepo.getViewModelList(), true, choices);
if (selectedChoice && selectedChoice.action === choices[0]) {
const requestData = motions.map(motion => {
let submitterIds = [...motion.sorted_submitters_id, ...(selectedChoice.items as number[])];
submitterIds = submitterIds.filter((id, index, self) => self.indexOf(id) === index); // remove duplicates
return {
id: motion.id,
submitters: submitterIds
};
});
await this.httpService.post('/rest/motions/motion/manage_multiple_submitters/', { motions: requestData });
} else if (selectedChoice && selectedChoice.action === choices[1]) {
const requestData = motions.map(motion => {
const submitterIdsToRemove = selectedChoice.items as number[];
const submitterIds = motion.sorted_submitters_id.filter(id => !submitterIdsToRemove.includes(id));
return {
id: motion.id,
submitters: submitterIds
};
});
await this.httpService.post('/rest/motions/motion/manage_multiple_submitters/', { motions: requestData });
}
}
示例2: moveToItem
/**
* Moves the related agenda items from the motions as childs under a selected (parent) agenda item.
*/
public async moveToItem(motions: ViewMotion[]): Promise<void> {
const title = this.translate.instant('This will move all selected motions as childs to:');
const choices: (Displayable & Identifiable)[] = this.agendaRepo.getViewModelList();
const selectedChoice = await this.choiceService.open(title, choices);
if (selectedChoice) {
const requestData = {
items: motions.map(motion => motion.agenda_item_id),
parent_id: selectedChoice.items as number
};
await this.httpService.post('/rest/agenda/item/assign/', requestData);
}
}
示例3: ngOnInit
/**
* Subscribes for the legal notice text.
*/
public ngOnInit(): void {
this.loginDataService.legal_notice.subscribe(legalNotice => {
if (legalNotice) {
this.legalNotice = this.translate.instant(legalNotice);
}
});
// Query the version info.
this.http.get<VersionResponse>(environment.urlPrefix + '/core/version/', {}).then(
info => {
this.versionInfo = info;
},
() => {
// TODO: error handling if the version info could not be loaded
}
);
}
示例4: setRecommendation
/**
* Opens a dialog and sets the recommendation to the users choice for all selected motions.
*
* @param motions The motions to change
*/
public async setRecommendation(motions: ViewMotion[]): Promise<void> {
const title = this.translate.instant('This will set the following recommendation for all selected motions:');
const choices = this.workflowRepo
.getWorkflowStatesForMotions(motions)
.filter(workflowState => !!workflowState.recommendation_label)
.map(workflowState => ({
id: workflowState.id,
label: workflowState.recommendation_label
}));
const clearChoice = this.translate.instant('Delete recommendation');
const selectedChoice = await this.choiceService.open(title, choices, false, null, clearChoice);
if (selectedChoice) {
const requestData = motions.map(motion => ({
id: motion.id,
recommendation: selectedChoice.action ? 0 : (selectedChoice.items as number)
}));
await this.httpService.post('/rest/motions/motion/manage_multiple_recommendation/', {
motions: requestData
});
}
}
示例5: resetPassword
/**
* Do the password reset.
*/
public async resetPassword(): Promise<void> {
if (this.resetPasswordForm.invalid) {
return;
}
try {
await this.http.post<void>(environment.urlPrefix + '/users/reset-password/', {
email: this.resetPasswordForm.get('email').value
});
// TODO: Does we get a response for displaying?
this.matSnackBar.open(
this.translate.instant('An email with a password reset link was send!'),
this.translate.instant('OK'),
{
duration: 0
}
);
this.router.navigate(['/login']);
} catch (e) {
console.log('error', e);
}
}
示例6: submitNewPassword
/**
* Submit the new password.
*/
public async submitNewPassword(): Promise<void> {
if (this.newPasswordForm.invalid) {
return;
}
try {
await this.http.post<void>(environment.urlPrefix + '/users/reset-password-confirm/', {
user_id: this.user_id,
token: this.token,
password: this.newPasswordForm.get('password').value
});
// TODO: Does we get a response for displaying?
this.matSnackBar.open(
this.translate.instant('Your password was resetted successfully!'),
this.translate.instant('OK'),
{
duration: 0
}
);
this.router.navigate(['/login']);
} catch (e) {
console.log('error', e);
}
}
示例7: delete
/**
* Removes the given speaker for the agenda item
*
* @param item the target agenda item
* @param speakerId (otional) the speakers id. If no id is given, the current operator
* is removed.
*/
public async delete(item: ViewItem, speakerId?: number): Promise<void> {
const restUrl = this.getRestUrl(item.id, 'manage_speaker');
await this.httpService.delete(restUrl, speakerId ? { speaker: speakerId } : null);
}
示例8: create
/**
* Add a new speaker to an agenda item.
* Sends the users ID to the server
* Might need another repo
*
* @param speakerId {@link User} id of the new speaker
* @param item the target agenda item
*/
public async create(speakerId: number, item: ViewItem): Promise<void> {
const restUrl = this.getRestUrl(item.id, 'manage_speaker');
await this.httpService.post<Identifiable>(restUrl, { user: speakerId });
}
示例9: startSpeaker
/**
* Sets the given speaker ID to Speak
*
* @param speakerId the speakers id
* @param item the target agenda item
*/
public async startSpeaker(speakerId: number, item: ViewItem): Promise<void> {
const restUrl = this.getRestUrl(item.id, 'speak');
await this.httpService.put(restUrl, { speaker: speakerId });
}
示例10: stopCurrentSpeaker
/**
* Stops the current speaker
*
* @param item the target agenda item
*/
public async stopCurrentSpeaker(item: ViewItem): Promise<void> {
const restUrl = this.getRestUrl(item.id, 'speak');
await this.httpService.delete(restUrl);
}