28 lines
741 B
TypeScript
28 lines
741 B
TypeScript
|
import { Injectable } from '@angular/core';
|
||
|
import { Action } from './action.types';
|
||
|
import {SessionService} from './session.service';
|
||
|
|
||
|
@Injectable({
|
||
|
providedIn: 'root'
|
||
|
})
|
||
|
export class ActionsService {
|
||
|
constructor(
|
||
|
protected readonly session: SessionService,
|
||
|
) { }
|
||
|
|
||
|
async perform(action: Action) {
|
||
|
if ( action.type === 'redirect' ) {
|
||
|
let destination = action.args.destination;
|
||
|
if ( action.args.appUrl ) {
|
||
|
destination = this.session.buildAppUrl(destination);
|
||
|
}
|
||
|
|
||
|
if ( action.args.blank ) {
|
||
|
window.open(destination, '_blank');
|
||
|
} else {
|
||
|
window.location.href = destination;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|