mirror of
https://github.com/johannesjo/super-productivity.git
synced 2026-01-23 02:36:05 +00:00
feat(jira): make it work with electron
This commit is contained in:
parent
72e1a92e1c
commit
5cf49545f1
5 changed files with 19 additions and 12 deletions
5
package-lock.json
generated
5
package-lock.json
generated
|
|
@ -7152,6 +7152,11 @@
|
|||
"dragula": "^3.7.2"
|
||||
}
|
||||
},
|
||||
"ngx-electron": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/ngx-electron/-/ngx-electron-1.0.4.tgz",
|
||||
"integrity": "sha512-dKSizgs6EUE5lvXq/kxQQSvrPEqamHlMje2xSTwUFHZq1krNjVPJv1mwnDPfVswI6gFheidLrV998F9aPbYRYg=="
|
||||
},
|
||||
"ngx-markdown": {
|
||||
"version": "6.2.1",
|
||||
"resolved": "https://registry.npmjs.org/ngx-markdown/-/ngx-markdown-6.2.1.tgz",
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@
|
|||
"@ngx-formly/material": "^4.7.2",
|
||||
"core-js": "^2.5.4",
|
||||
"ng2-dragula": "^2.1.0",
|
||||
"ngx-electron": "^1.0.4",
|
||||
"ngx-markdown": "^6.2.1",
|
||||
"rxjs": "^6.2.2",
|
||||
"rxjs-compat": "^6.2.2",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
export const LS_PREFIX = 'SUP_';
|
||||
export const WORKLOG_DATE_STR_FORMAT = 'YYYY-MM-DD';
|
||||
export const IS_ELECTRON = (typeof window.ipcRenderer !== 'undefined');
|
||||
export const IS_ELECTRON = (navigator.userAgent.toLowerCase().indexOf(' electron/') > -1);
|
||||
|
|
|
|||
|
|
@ -11,10 +11,10 @@ import {
|
|||
} from './jira.const';
|
||||
import { ProjectService } from '../../project/project.service';
|
||||
import { mapIssueResponse, mapIssuesResponse, mapResponse } from './jira-issue/jira-issue-map.util';
|
||||
import { IS_ELECTRON } from '../../app.constants';
|
||||
import { JiraOriginalStatus, JiraOriginalUser } from './jira-api-responses';
|
||||
import { JiraIssue } from './jira-issue/jira-issue.model';
|
||||
import { JiraCfg } from './jira';
|
||||
import { ElectronService } from 'ngx-electron';
|
||||
|
||||
|
||||
@Injectable({
|
||||
|
|
@ -26,15 +26,18 @@ export class JiraApiService {
|
|||
isExtension = false;
|
||||
cfg: any = {};
|
||||
|
||||
constructor(private _chromeExtensionInterface: ChromeExtensionInterfaceService,
|
||||
private _projectService: ProjectService) {
|
||||
constructor(
|
||||
private _chromeExtensionInterface: ChromeExtensionInterfaceService,
|
||||
private _projectService: ProjectService,
|
||||
private _electronService: ElectronService,
|
||||
) {
|
||||
this._projectService.currentJiraCfg$.subscribe((cfg) => {
|
||||
this.cfg = cfg;
|
||||
});
|
||||
|
||||
// set up callback listener for electron
|
||||
if (IS_ELECTRON) {
|
||||
window.ipcRenderer.on(IPC_JIRA_CB_EVENT, (ev, res) => {
|
||||
if (this._electronService.isElectronApp) {
|
||||
this._electronService.ipcRenderer.on(IPC_JIRA_CB_EVENT, (ev, res) => {
|
||||
this._handleResponse(res);
|
||||
});
|
||||
}
|
||||
|
|
@ -72,8 +75,6 @@ export class JiraApiService {
|
|||
}
|
||||
|
||||
getCurrentUser(cfg?: JiraCfg): Promise<JiraOriginalUser> {
|
||||
console.log(cfg);
|
||||
|
||||
return this._sendRequest({
|
||||
apiMethod: 'getCurrentUser',
|
||||
transform: mapResponse,
|
||||
|
|
@ -96,8 +97,6 @@ export class JiraApiService {
|
|||
|
||||
// TODO refactor data madness of request and add types for everything
|
||||
private _sendRequest(request, cfg = this.cfg): Promise<any> {
|
||||
console.log(cfg);
|
||||
|
||||
if (!this._isMinimalSettings(cfg)) {
|
||||
console.error('Not enough Jira settings. This should not happen!!!');
|
||||
return Promise.reject(new Error('Insufficient Settings for Jira'));
|
||||
|
|
@ -133,8 +132,8 @@ export class JiraApiService {
|
|||
};
|
||||
|
||||
// send to electron
|
||||
if (IS_ELECTRON) {
|
||||
window.ipcRenderer.send(IPC_JIRA_MAKE_REQUEST_EVENT, request);
|
||||
if (this._electronService.isElectronApp) {
|
||||
this._electronService.ipcRenderer.send(IPC_JIRA_MAKE_REQUEST_EVENT, request);
|
||||
} else if (this.isExtension) {
|
||||
this._chromeExtensionInterface.dispatchEvent('SP_JIRA_REQUEST', {
|
||||
requestId: request.requestId,
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@ import { CommonModule } from '@angular/common';
|
|||
import { JiraCfgStepperComponent } from './jira-cfg-stepper/jira-cfg-stepper.component';
|
||||
import { UiModule } from '../../ui/ui.module';
|
||||
import { CoreModule } from '../../core/core.module';
|
||||
import { NgxElectronModule } from 'ngx-electron';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
CoreModule,
|
||||
UiModule,
|
||||
NgxElectronModule,
|
||||
],
|
||||
declarations: [JiraCfgStepperComponent],
|
||||
exports: [JiraCfgStepperComponent],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue