Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Toolkit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
digital blueprint
Web Component Framework
Toolkit
Commits
9d5702d3
Unverified
Commit
9d5702d3
authored
4 years ago
by
Bekerle, Patrizio
Browse files
Options
Downloads
Patches
Plain Diff
Migrate to "static" class variables
parent
d367ef03
No related branches found
No related tags found
No related merge requests found
Pipeline
#16735
passed
4 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
packages/common/jsonld.js
+19
-19
19 additions, 19 deletions
packages/common/jsonld.js
with
19 additions
and
19 deletions
packages/common/jsonld.js
+
19
−
19
View file @
9d5702d3
...
...
@@ -4,11 +4,6 @@ import {send as notify} from './notification';
import
*
as
utils
from
"
./utils
"
;
import
{
i18n
}
from
"
./i18n
"
;
let
instances
=
{};
let
successFunctions
=
{};
let
failureFunctions
=
{};
let
initStarted
=
{};
// "module.exports = class JSONLD" doesn't work with rollup because of above "import"
export
default
class
JSONLD
{
constructor
(
baseApiUrl
,
entities
)
{
...
...
@@ -30,19 +25,19 @@ export default class JSONLD {
}
// if init api call was already successfully finished execute the success function
if
(
instances
[
apiUrl
]
!==
undefined
)
{
if
(
typeof
successFnc
==
'
function
'
)
successFnc
(
instances
[
apiUrl
]);
if
(
JSONLD
.
instances
[
apiUrl
]
!==
undefined
)
{
if
(
typeof
successFnc
==
'
function
'
)
successFnc
(
JSONLD
.
instances
[
apiUrl
]);
return
;
}
// init the arrays
if
(
successFunctions
[
apiUrl
]
===
undefined
)
successFunctions
[
apiUrl
]
=
[];
if
(
failureFunctions
[
apiUrl
]
===
undefined
)
failureFunctions
[
apiUrl
]
=
[];
if
(
JSONLD
.
successFunctions
[
apiUrl
]
===
undefined
)
JSONLD
.
successFunctions
[
apiUrl
]
=
[];
if
(
JSONLD
.
failureFunctions
[
apiUrl
]
===
undefined
)
JSONLD
.
failureFunctions
[
apiUrl
]
=
[];
// add success and failure functions
if
(
typeof
successFnc
==
'
function
'
)
successFunctions
[
apiUrl
].
push
(
successFnc
);
if
(
typeof
failureFnc
==
'
function
'
)
failureFunctions
[
apiUrl
].
push
(
failureFnc
);
if
(
typeof
successFnc
==
'
function
'
)
JSONLD
.
successFunctions
[
apiUrl
].
push
(
successFnc
);
if
(
typeof
failureFnc
==
'
function
'
)
JSONLD
.
failureFunctions
[
apiUrl
].
push
(
failureFnc
);
}
/**
...
...
@@ -55,11 +50,11 @@ export default class JSONLD {
// console.log("doInitializationOnce", apiUrl, token);
// check if token is not set or api call was already started
if
(
!
apiUrl
||
!
token
||
initStarted
[
apiUrl
]
!==
undefined
)
{
if
(
!
apiUrl
||
!
token
||
JSONLD
.
initStarted
[
apiUrl
]
!==
undefined
)
{
return
;
}
initStarted
[
apiUrl
]
=
true
;
JSONLD
.
initStarted
[
apiUrl
]
=
true
;
JSONLD
.
doInitialization
(
apiUrl
,
token
);
// console.log("doInitializationOnce Done", apiUrl, token);
}
...
...
@@ -145,11 +140,11 @@ export default class JSONLD {
});
const
instance
=
new
JSONLD
(
baseUrl
,
entities
);
instances
[
apiUrl
]
=
instance
;
JSONLD
.
instances
[
apiUrl
]
=
instance
;
// return the initialized JSONLD object
for
(
const
fnc
of
successFunctions
[
apiUrl
])
if
(
typeof
fnc
==
'
function
'
)
fnc
(
instance
);
successFunctions
[
apiUrl
]
=
[];
for
(
const
fnc
of
JSONLD
.
successFunctions
[
apiUrl
])
if
(
typeof
fnc
==
'
function
'
)
fnc
(
instance
);
JSONLD
.
successFunctions
[
apiUrl
]
=
[];
}
/**
...
...
@@ -159,8 +154,8 @@ export default class JSONLD {
* @param message
*/
static
executeFailureFunctions
(
apiUrl
,
message
=
""
)
{
for
(
const
fnc
of
failureFunctions
[
apiUrl
])
if
(
typeof
fnc
==
'
function
'
)
fnc
();
failureFunctions
[
apiUrl
]
=
[];
for
(
const
fnc
of
JSONLD
.
failureFunctions
[
apiUrl
])
if
(
typeof
fnc
==
'
function
'
)
fnc
();
JSONLD
.
failureFunctions
[
apiUrl
]
=
[];
if
(
message
!==
""
)
{
notify
({
...
...
@@ -172,7 +167,7 @@ export default class JSONLD {
}
static
getInstance
(
apiUrl
)
{
return
instances
[
apiUrl
];
return
JSONLD
.
instances
[
apiUrl
];
}
getEntityForIdentifier
(
identifier
)
{
...
...
@@ -283,3 +278,8 @@ export default class JSONLD {
return
results
;
}
}
JSONLD
.
instances
=
{};
JSONLD
.
successFunctions
=
{};
JSONLD
.
failureFunctions
=
{};
JSONLD
.
initStarted
=
{};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment