Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport PR #813 to 1.1.7 series #815

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,6 +2,7 @@
.DS_Store
*.iml
.idea/*
*.swp

# npm
node_modules/
Expand Down
7 changes: 6 additions & 1 deletion src/js/plugin/PluginLoader.js
Expand Up @@ -10,6 +10,9 @@ import PluginActions from "./shared/PluginActions";
import PluginHelper from "./shared/PluginHelper";
import PluginDispatcherProxy from "./PluginDispatcherProxy";

import MarathonService from "./sdk/services/MarathonService";
import MarathonActions from "./sdk/actions/MarathonActions";

const PLUGIN_STARTUP_TIMEOUT = 10000; // in ms

const PluginLoader = {
Expand Down Expand Up @@ -45,7 +48,9 @@ const PluginLoader = {
PluginMountPoints: PluginMountPoints,
pluginId: pluginId,
React: React,
UIVersion: config.version
config: Object.freeze(config),
MarathonService: MarathonService,
MarathonActions: MarathonActions,
});

let dispatchToken = PluginDispatcher.register(function (event) {
Expand Down
28 changes: 28 additions & 0 deletions src/js/plugin/sdk/actions/MarathonActions.js
@@ -0,0 +1,28 @@
import MarathonService from "../services/MarathonService";

export default class MarathonActions {

static getDeployments() {
return MarathonService.request({
resource: "/v2/deployments"
});
}

static getGroup(group) {
let groupName = group.replace(/\/?(.*)/,"/$1");
return MarathonService.request({
resource: `/v2/groups${groupName}`
});
}

static getGroups() {
return this.getGroup("/");
}

static getApp(appId) {
return MarathonService.request({
resource: `/v2/apps${appId}`
});
}

};
20 changes: 20 additions & 0 deletions src/js/plugin/sdk/services/MarathonService.js
@@ -0,0 +1,20 @@

import config from "../../../config/config";
import ajaxWrapper from "../../../helpers/ajaxWrapper";

export default class MarathonService {

static request({resource, method="GET", data}) {

if (resource) {
resource.replace(/\/?(.*)/,"/$1");
}

return ajaxWrapper({
url: `${config.apiURL}${resource}`,
method: method,
data: data
});
}

};