@gandalan/weblibs 0.0.7 → 0.0.11

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/README.md CHANGED
@@ -1 +1,42 @@
1
1
  WebLibs for Gandalan JS/TS/Svelte projects
2
+
3
+ ## IDAS API mit JavaScript/TypeScript verwenden
4
+
5
+
6
+ ```js
7
+ import { IDAS } from '@gandalan/weblibs/api/IDAS';
8
+ let idas = new IDAS();
9
+
10
+ // bei Bedarf wird der Client zur Anmeldung umgeleitet, danach wird die aktuelle Seite wieder aufgerufen
11
+ idas.authenticateWithSSO();
12
+ ```
13
+
14
+ Danach z.B. Zugriff auf die Mandant-Guid:
15
+
16
+ ```js
17
+ let mandantGuid = idas.mandantGuid;
18
+ ```
19
+
20
+ Datenzugriffe erfolgen über die Objekte innerhalb der IDAS-Klasse
21
+
22
+ ```js
23
+ let loader = Promise.all([
24
+ idas.mandanten.getAll()
25
+ .then(d => mandanten = d.sort((a,b) => a.Name.localeCompare(b.Name)))
26
+ .catch(e => error = e),
27
+ idas.rollen.getAll()
28
+ .then(d => rollen = d.sort((a,b) => a.Name.localeCompare(b.Name)))
29
+ .catch(e => error = e)
30
+ ])
31
+ .then(_ => setMandant(mandantGuid));
32
+ ```
33
+
34
+ der hier eingeführte `loader` kann mit dem `{#await}`-Svelte-Konstrukt verwendet werden:
35
+
36
+ ```js
37
+ {#await loader}
38
+ <progress />
39
+ {:then}
40
+ ...
41
+ {/await}
42
+ ```
package/api/IDAS.js CHANGED
@@ -1,5 +1,16 @@
1
1
  import { RESTClient } from "./RESTClient";
2
2
 
3
+ if (window.location.search) {
4
+ var urlParams = new URLSearchParams(location.search);
5
+ if (urlParams.has("t"))
6
+ localStorage.setItem("IDAS_AuthToken", urlParams.get("t"));
7
+ if (urlParams.has("m"))
8
+ localStorage.setItem("IDAS_MandantGuid", urlParams.get("m"));
9
+ if (urlParams.has("a"))
10
+ localStorage.setItem("IDAS_ApiBaseUrl", urlParams.get("a"));
11
+ window.location = window.location.origin;
12
+ }
13
+
3
14
  let appToken = localStorage.getItem("IDAS_AppToken") || "66B70E0B-F7C4-4829-B12A-18AD309E3970";
4
15
  let authToken = localStorage.getItem("IDAS_AuthToken");
5
16
  //let mandantGuid = localStorage.getItem("IDAS_MandantGuid");
@@ -12,7 +23,8 @@ restClient.onError = (error, message) => {
12
23
  {
13
24
  //console.log(message+" would remove Token");
14
25
  localStorage.removeItem("IDAS_AuthToken");
15
- restClient.authenticateWithSSO();
26
+ var ssoURL = ssoAuthUrl.replace("%target%", window.location.origin);
27
+ window.location = ssoURL;
16
28
  }
17
29
  }
18
30
 
@@ -32,10 +44,15 @@ export class IDAS
32
44
  }
33
45
 
34
46
  async authenticateWithSSO() {
35
- var ssoURL = ssoAuthUrl.replace("%target%", window.location.origin);
36
- window.location = ssoURL;
47
+ if (!authToken)
48
+ {
49
+ var ssoURL = ssoAuthUrl.replace("%target%", window.location.origin);
50
+ window.location = ssoURL;
51
+ }
37
52
  }
38
53
 
54
+ mandantGuid = localStorage.getItem("IDAS_MandantGuid");
55
+
39
56
  mandanten = {
40
57
  async getAll() { return await restClient.get("/Mandanten"); },
41
58
  async get(guid) { return await restClient.get("/Mandanten/" + guid); },
package/api/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { IDAS } from './IDAS';
2
+ import { RESTClient } from './RESTClient';
3
+
4
+ export { IDAS, RESTClient };
@@ -1,11 +1,12 @@
1
1
  import AddButton from './AddButton.svelte';
2
2
  import DataGrid from './DataGrid.svelte';
3
+ import Dialog from './Datepicker.svelte';
3
4
  import Datepicker from './Datepicker.svelte';
4
5
  import Inputbox from './Inputbox.svelte';
5
6
  import RemoveButton from './RemoveButton.svelte';
6
7
  import SaveButton from './SaveButton.svelte';
7
8
 
8
9
  export {
9
- DataGrid, Datepicker, Inputbox,
10
+ DataGrid, Datepicker, Inputbox, Dialog,
10
11
  AddButton, RemoveButton, SaveButton
11
12
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gandalan/weblibs",
3
- "version": "0.0.7",
3
+ "version": "0.0.11",
4
4
  "description": "WebLibs for Gandalan JS/TS/Svelte projects",
5
5
  "author": "Philipp Reif",
6
6
  "license": "ISC",