2022-02-13 23:39:27 +08:00
|
|
|
// Copyright 2021 The Casdoor Authors. All Rights Reserved.
|
2021-02-13 13:30:51 +08:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
import * as Setting from "../Setting";
|
|
|
|
|
2021-12-25 10:55:10 +08:00
|
|
|
export function getApplications(owner, page = "", pageSize = "", field = "", value = "", sortField = "", sortOrder = "") {
|
|
|
|
return fetch(`${Setting.ServerUrl}/api/get-applications?owner=${owner}&p=${page}&pageSize=${pageSize}&field=${field}&value=${value}&sortField=${sortField}&sortOrder=${sortOrder}`, {
|
2021-02-13 12:15:19 +08:00
|
|
|
method: "GET",
|
2022-08-06 23:54:56 +08:00
|
|
|
credentials: "include",
|
2021-02-13 12:15:19 +08:00
|
|
|
}).then(res => res.json());
|
|
|
|
}
|
|
|
|
|
2022-01-15 18:29:10 +08:00
|
|
|
export function getApplicationsByOrganization(owner, organization) {
|
2022-08-07 16:05:05 +08:00
|
|
|
return fetch(`${Setting.ServerUrl}/api/get-organization-applications?owner=${owner}&organization=${organization}`, {
|
2022-01-15 18:29:10 +08:00
|
|
|
method: "GET",
|
2022-08-06 23:54:56 +08:00
|
|
|
credentials: "include",
|
2022-01-15 18:29:10 +08:00
|
|
|
}).then(res => res.json());
|
|
|
|
}
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
export function getApplication(owner, name) {
|
|
|
|
return fetch(`${Setting.ServerUrl}/api/get-application?id=${owner}/${encodeURIComponent(name)}`, {
|
|
|
|
method: "GET",
|
2022-08-06 23:54:56 +08:00
|
|
|
credentials: "include",
|
2021-02-13 12:15:19 +08:00
|
|
|
}).then(res => res.json());
|
|
|
|
}
|
|
|
|
|
2021-07-11 23:49:06 +08:00
|
|
|
export function getUserApplication(owner, name) {
|
|
|
|
return fetch(`${Setting.ServerUrl}/api/get-user-application?id=${owner}/${encodeURIComponent(name)}`, {
|
2021-04-19 01:14:41 +08:00
|
|
|
method: "GET",
|
2022-08-06 23:54:56 +08:00
|
|
|
credentials: "include",
|
2021-04-19 01:14:41 +08:00
|
|
|
}).then(res => res.json());
|
|
|
|
}
|
|
|
|
|
2021-02-13 12:15:19 +08:00
|
|
|
export function updateApplication(owner, name, application) {
|
2022-08-08 23:35:24 +08:00
|
|
|
const newApplication = Setting.deepCopy(application);
|
2021-02-13 12:15:19 +08:00
|
|
|
return fetch(`${Setting.ServerUrl}/api/update-application?id=${owner}/${encodeURIComponent(name)}`, {
|
2022-07-10 15:45:55 +08:00
|
|
|
method: "POST",
|
|
|
|
credentials: "include",
|
2021-02-13 12:15:19 +08:00
|
|
|
body: JSON.stringify(newApplication),
|
|
|
|
}).then(res => res.json());
|
|
|
|
}
|
|
|
|
|
|
|
|
export function addApplication(application) {
|
2022-08-08 23:35:24 +08:00
|
|
|
const newApplication = Setting.deepCopy(application);
|
2022-07-10 15:45:55 +08:00
|
|
|
newApplication.organization = "built-in";
|
2021-02-13 12:15:19 +08:00
|
|
|
return fetch(`${Setting.ServerUrl}/api/add-application`, {
|
2022-07-10 15:45:55 +08:00
|
|
|
method: "POST",
|
|
|
|
credentials: "include",
|
2021-02-13 12:15:19 +08:00
|
|
|
body: JSON.stringify(newApplication),
|
|
|
|
}).then(res => res.json());
|
|
|
|
}
|
|
|
|
|
|
|
|
export function deleteApplication(application) {
|
2022-08-08 23:35:24 +08:00
|
|
|
const newApplication = Setting.deepCopy(application);
|
2021-02-13 12:15:19 +08:00
|
|
|
return fetch(`${Setting.ServerUrl}/api/delete-application`, {
|
2022-07-10 15:45:55 +08:00
|
|
|
method: "POST",
|
|
|
|
credentials: "include",
|
2021-02-13 12:15:19 +08:00
|
|
|
body: JSON.stringify(newApplication),
|
|
|
|
}).then(res => res.json());
|
|
|
|
}
|
2022-05-11 20:23:36 +08:00
|
|
|
|
|
|
|
export function getSamlMetadata(owner, name) {
|
|
|
|
return fetch(`${Setting.ServerUrl}/api/saml/metadata?application=${owner}/${encodeURIComponent(name)}`, {
|
|
|
|
method: "GET",
|
2022-08-06 23:54:56 +08:00
|
|
|
credentials: "include",
|
2022-05-11 20:23:36 +08:00
|
|
|
}).then(res => res.text());
|
|
|
|
}
|