@pb33f/cowboy-components 0.7.7 → 0.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/auth/login-button.d.ts +4 -2
- package/dist/components/auth/login-button.js +25 -7
- package/dist/components/auth/login-panel.d.ts +1 -1
- package/dist/components/auth/login-panel.js +1 -1
- package/dist/components/auth/oauth-login.d.ts +1 -1
- package/dist/components/auth/oauth-login.js +3 -3
- package/dist/components/the-doctor/status-bar.js +3 -3
- package/dist/components/the-doctor/the-doctor.css.js +16 -0
- package/dist/components/the-doctor/the-doctor.d.ts +3 -0
- package/dist/components/the-doctor/the-doctor.js +50 -3
- package/dist/components/time-vortex/tardis-control.css.js +0 -16
- package/dist/components/workspaces/workspace-destroy-dialog.d.ts +17 -0
- package/dist/components/workspaces/workspace-destroy-dialog.js +85 -0
- package/dist/components/workspaces/workspace-form.d.ts +22 -0
- package/dist/components/workspaces/workspace-form.js +194 -0
- package/dist/components/workspaces/workspace-view.css.d.ts +2 -0
- package/dist/components/workspaces/workspace-view.css.js +40 -0
- package/dist/components/workspaces/workspace-view.d.ts +30 -0
- package/dist/components/workspaces/workspace-view.js +196 -0
- package/dist/controllers/auth-controller.d.ts +1 -0
- package/dist/controllers/auth-controller.js +26 -8
- package/dist/controllers/diagnostic-controller.d.ts +1 -0
- package/dist/controllers/diagnostic-controller.js +15 -10
- package/dist/controllers/docs-controller.js +9 -33
- package/dist/controllers/workspace-controller.d.ts +15 -0
- package/dist/controllers/workspace-controller.js +156 -0
- package/dist/cowboy-components.umd.cjs +1559 -1095
- package/dist/css/badges.css.d.ts +2 -0
- package/dist/css/badges.css.js +12 -0
- package/dist/css/button.css.js +1 -1
- package/dist/css/forms.css.js +127 -1
- package/dist/css/lists.css.js +8 -0
- package/dist/css/pb33f-theme.css +1 -0
- package/dist/css/spinner.css.js +29 -0
- package/dist/events/doctor.d.ts +15 -0
- package/dist/events/doctor.js +10 -0
- package/dist/model/form-types.d.ts +32 -0
- package/dist/model/form-types.js +19 -0
- package/dist/model/formable.d.ts +51 -0
- package/dist/model/formable.js +542 -0
- package/dist/model/workspace.d.ts +6 -0
- package/dist/model/workspace.js +1 -0
- package/dist/monacoeditorwork/yaml.worker..bundle.js +14801 -14800
- package/dist/services/workspace-service.d.ts +10 -0
- package/dist/services/workspace-service.js +132 -0
- package/dist/style.css +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Workspace } from "../model/workspace";
|
|
2
|
+
import { APIResponse } from "../model/api-response";
|
|
3
|
+
export declare class WorkspaceService {
|
|
4
|
+
static doctorEndpoint: string;
|
|
5
|
+
static getWorkspaces(): Promise<APIResponse<Workspace[]>>;
|
|
6
|
+
static createWorkspace(name: string): Promise<Workspace>;
|
|
7
|
+
static switchWorkspace(workspace: Workspace): Promise<Workspace>;
|
|
8
|
+
static updateWorkspace(workspace: Workspace): Promise<Workspace>;
|
|
9
|
+
static deleteWorkspace(workspace: Workspace): Promise<boolean>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
export class WorkspaceService {
|
|
2
|
+
static async getWorkspaces() {
|
|
3
|
+
return new Promise(async (resolve, reject) => {
|
|
4
|
+
try {
|
|
5
|
+
const defaultRuleset = await fetch(WorkspaceService.doctorEndpoint + '/workspaces/list', {
|
|
6
|
+
method: 'GET',
|
|
7
|
+
credentials: 'include',
|
|
8
|
+
headers: {
|
|
9
|
+
'Content-Type': 'application/json'
|
|
10
|
+
},
|
|
11
|
+
});
|
|
12
|
+
const apiResult = await defaultRuleset.json();
|
|
13
|
+
if (!apiResult) {
|
|
14
|
+
reject({ detail: 'unable to fetch list of workspaces, cannot decode JSON' });
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (apiResult?.type && apiResult?.title && apiResult?.status) {
|
|
18
|
+
reject(apiResult);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
resolve(apiResult);
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
reject({ detail: 'unable to fetch list of workspaces: ' + e });
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
static async createWorkspace(name) {
|
|
29
|
+
return new Promise(async (resolve, reject) => {
|
|
30
|
+
try {
|
|
31
|
+
const defaultRuleset = await fetch(WorkspaceService.doctorEndpoint + '/workspaces/create', {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
credentials: 'include',
|
|
34
|
+
headers: {
|
|
35
|
+
'Content-Type': 'application/json'
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify({
|
|
38
|
+
name: name,
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
const apiResult = await defaultRuleset.json();
|
|
42
|
+
if (!apiResult) {
|
|
43
|
+
reject({ detail: 'unable to create workspace, cannot decode JSON' });
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (apiResult?.type && apiResult?.title && apiResult?.status) {
|
|
47
|
+
reject(apiResult);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
resolve(apiResult);
|
|
51
|
+
}
|
|
52
|
+
catch (e) {
|
|
53
|
+
reject({ detail: 'unable to create workspace: ' + e });
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
static async switchWorkspace(workspace) {
|
|
58
|
+
return new Promise(async (resolve, reject) => {
|
|
59
|
+
try {
|
|
60
|
+
const switchWs = await fetch(WorkspaceService.doctorEndpoint + '/workspaces/switch/' + workspace.workspaceId, {
|
|
61
|
+
method: 'GET',
|
|
62
|
+
credentials: 'include',
|
|
63
|
+
headers: {
|
|
64
|
+
'Content-Type': 'application/json'
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const apiResult = await switchWs.json();
|
|
68
|
+
if (!apiResult) {
|
|
69
|
+
reject({ detail: 'unable to switch workspace, cannot decode JSON' });
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (apiResult?.type && apiResult?.title && apiResult?.status) {
|
|
73
|
+
reject(apiResult);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
resolve(apiResult);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
reject({ detail: 'unable to switch workspace: ' + e });
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
static async updateWorkspace(workspace) {
|
|
84
|
+
return new Promise(async (resolve, reject) => {
|
|
85
|
+
try {
|
|
86
|
+
const updateWs = await fetch(WorkspaceService.doctorEndpoint + '/workspaces/update/' + workspace.workspaceId, {
|
|
87
|
+
method: 'POST',
|
|
88
|
+
credentials: 'include',
|
|
89
|
+
headers: {
|
|
90
|
+
'Content-Type': 'application/json'
|
|
91
|
+
},
|
|
92
|
+
body: JSON.stringify(workspace)
|
|
93
|
+
});
|
|
94
|
+
const apiResult = await updateWs.json();
|
|
95
|
+
if (!apiResult) {
|
|
96
|
+
reject({ detail: 'unable to update workspace, cannot decode JSON' });
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (apiResult?.type && apiResult?.title && apiResult?.status) {
|
|
100
|
+
reject(apiResult);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
resolve(apiResult);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
reject({ detail: 'unable to update workspace: ' + e });
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
static async deleteWorkspace(workspace) {
|
|
111
|
+
return new Promise(async (resolve, reject) => {
|
|
112
|
+
try {
|
|
113
|
+
const deleteWs = await fetch(WorkspaceService.doctorEndpoint + '/workspaces/update/' + workspace.workspaceId, {
|
|
114
|
+
method: 'DELETE',
|
|
115
|
+
credentials: 'include',
|
|
116
|
+
headers: {
|
|
117
|
+
'Content-Type': 'application/json'
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
if (!deleteWs.ok) {
|
|
121
|
+
const apiResult = await deleteWs.json();
|
|
122
|
+
reject(apiResult);
|
|
123
|
+
}
|
|
124
|
+
resolve(true);
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
reject({ detail: 'unable to delete workspace: ' + e });
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
WorkspaceService.doctorEndpoint = 'https://doctor.pb33f.io';
|