removed js files
This commit is contained in:
parent
221526d5a7
commit
5527be6ad8
@ -1,4 +0,0 @@
|
||||
"use strict";
|
||||
// SPDX-FileCopyrightText: 2023 David Mosbach <david.mosbach@campus.lmu.de>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
285
workflow.js
285
workflow.js
@ -1,285 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2023 David Mosbach <david.mosbach@campus.lmu.de>
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
export class Workflow {
|
||||
states;
|
||||
actions;
|
||||
constructor(json) {
|
||||
const stateMap = new Map();
|
||||
this.states = [];
|
||||
for (const state of json.states) {
|
||||
var node = new WFNode(state);
|
||||
this.states.push(node);
|
||||
stateMap.set(node.id, node);
|
||||
}
|
||||
// Resolve ID refs to nodes
|
||||
var actions = json.actions.map(action => {
|
||||
function transformRef(ref) {
|
||||
if (ref instanceof String)
|
||||
stateMap.has(ref)
|
||||
&& (ref = stateMap.get(ref))
|
||||
|| console.error('Ref to unknown state: ' + ref);
|
||||
return ref;
|
||||
}
|
||||
action.source = transformRef(action.source);
|
||||
action.target = transformRef(action.target);
|
||||
return action;
|
||||
});
|
||||
this.actions = [];
|
||||
for (const action of actions)
|
||||
this.actions.push(new WFEdge(action));
|
||||
}
|
||||
}
|
||||
export class WFNode {
|
||||
stateData;
|
||||
x;
|
||||
y;
|
||||
fx;
|
||||
fy;
|
||||
id;
|
||||
name;
|
||||
val;
|
||||
constructor(json) {
|
||||
this.stateData = new StateData(json.stateData);
|
||||
this.x = json.x;
|
||||
this.y = json.y;
|
||||
this.fx = json.fx;
|
||||
this.fy = json.fy;
|
||||
this.id = json.id;
|
||||
this.name = json.name;
|
||||
this.val = json.val;
|
||||
}
|
||||
}
|
||||
export class StateData {
|
||||
abbreviation;
|
||||
messages;
|
||||
viewers;
|
||||
payload;
|
||||
viewerNames;
|
||||
final;
|
||||
constructor(json) {
|
||||
this.abbreviation = json.abbreviation;
|
||||
this.messages = json.messages ? json.messages.map(message => { return new Message(message); }) : [];
|
||||
this.viewers = json.viewers ? new Viewers(json.viewers) : Viewers.empty();
|
||||
this.payload = new Payload(json.payload);
|
||||
this.viewerNames = [];
|
||||
this.final = json.final;
|
||||
}
|
||||
}
|
||||
export class WFEdge {
|
||||
actionData;
|
||||
source;
|
||||
target;
|
||||
id;
|
||||
name;
|
||||
nodePairId;
|
||||
curvature;
|
||||
__controlPoints;
|
||||
constructor(json) {
|
||||
this.actionData = new ActionData(json.actionData);
|
||||
this.source = json.source;
|
||||
this.target = json.target;
|
||||
this.id = json.id;
|
||||
this.name = json.name;
|
||||
this.nodePairId = json.nodePairId;
|
||||
this.curvature = 0;
|
||||
}
|
||||
}
|
||||
export class ActionData {
|
||||
messages;
|
||||
viewers;
|
||||
actors;
|
||||
'actor Viewers';
|
||||
form;
|
||||
viewerNames;
|
||||
actorNames;
|
||||
mode;
|
||||
constructor(json) {
|
||||
this.messages = json.messages ? json.messages.map(message => { return new Message(message); }) : [];
|
||||
this.viewers = json.viewers ? new Viewers(json.viewers) : Viewers.empty();
|
||||
this.actors = json.actors ? new Actors(json.actors) : Actors.empty();
|
||||
this['actor Viewers'] = json['actor Viewers'] ? new Viewers(json['actor Viewers']) : Viewers.empty();
|
||||
this.form = new Payload(json.form);
|
||||
this.viewerNames = [];
|
||||
this.actorNames = [];
|
||||
this.mode = json.mode ?? undefined;
|
||||
}
|
||||
}
|
||||
export class Role {
|
||||
json;
|
||||
name;
|
||||
constructor(json) {
|
||||
this.json = json;
|
||||
if (json.tag == 'payload-reference') {
|
||||
this.name = json['payload-label'];
|
||||
}
|
||||
else if (json.authorized) {
|
||||
this.name = json.authorized['dnf-terms'][0][0].var + ' (auth)'; //TODO ugly
|
||||
}
|
||||
else if (json.user) {
|
||||
this.name = json.user;
|
||||
}
|
||||
else if (json.tag) {
|
||||
this.name = json.tag + ' (tag)';
|
||||
}
|
||||
else {
|
||||
this.name = JSON.stringify(json);
|
||||
}
|
||||
}
|
||||
format() {
|
||||
return [document.createTextNode(this.name)];
|
||||
}
|
||||
}
|
||||
export class Roles {
|
||||
roleName;
|
||||
anchor;
|
||||
comment;
|
||||
roles;
|
||||
constructor(json, roleName) {
|
||||
this.roleName = roleName;
|
||||
this.anchor = json.anchor ? new Anchor(json.anchor) : new Anchor('NoAnchor');
|
||||
this.roles = [];
|
||||
for (const role of json[roleName])
|
||||
this.roles.push(new Role(role));
|
||||
this.comment = json.comment;
|
||||
}
|
||||
length() {
|
||||
return this.roles.length;
|
||||
}
|
||||
format() {
|
||||
var r = document.createElement('h4');
|
||||
var roles = document.createTextNode('Roles');
|
||||
r.appendChild(roles);
|
||||
var rolesList = document.createElement('ul');
|
||||
this.roles.forEach(r => {
|
||||
var role = document.createElement('li');
|
||||
role.appendChild(document.createTextNode(r.name));
|
||||
rolesList.appendChild(role);
|
||||
});
|
||||
var result = [];
|
||||
if (this.comment.length > 0) {
|
||||
var c = document.createElement('h4');
|
||||
c.innerText = 'Comment';
|
||||
var comment = document.createElement('p');
|
||||
comment.innerText = this.comment.join(' ');
|
||||
result.push(c, comment);
|
||||
}
|
||||
if (this.anchor) {
|
||||
var a = document.createElement('h4');
|
||||
a.appendChild(this.anchor.format());
|
||||
result.push(a);
|
||||
}
|
||||
else
|
||||
result.push(r);
|
||||
result.push(rolesList);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
export class Viewers extends Roles {
|
||||
static empty() {
|
||||
return new Viewers({
|
||||
viewers: [],
|
||||
anchor: 'NoAnchor',
|
||||
comment: []
|
||||
});
|
||||
}
|
||||
constructor(json) {
|
||||
super(json, 'viewers');
|
||||
}
|
||||
}
|
||||
export class Actors extends Roles {
|
||||
static empty() {
|
||||
return new Actors({
|
||||
actors: [],
|
||||
anchor: 'NoAnchor',
|
||||
comment: []
|
||||
});
|
||||
}
|
||||
constructor(json) {
|
||||
super(json, 'actors');
|
||||
}
|
||||
}
|
||||
export class Anchor {
|
||||
name;
|
||||
type;
|
||||
constructor(json) {
|
||||
if (!json || json === 'NoAnchor') {
|
||||
this.name = undefined;
|
||||
this.type = 'none';
|
||||
}
|
||||
else {
|
||||
this.name = json.name;
|
||||
this.type = json.type;
|
||||
}
|
||||
}
|
||||
format() {
|
||||
return document.createTextNode(`${this.type == 'alias' ? '*' : '&'}${this.name}`);
|
||||
}
|
||||
}
|
||||
export class Message {
|
||||
fallback;
|
||||
fallbackLang;
|
||||
translations;
|
||||
status;
|
||||
viewers;
|
||||
constructor(json) {
|
||||
var content = json.content;
|
||||
this.fallback = content.fallback;
|
||||
this.fallbackLang = content['fallback-lang'];
|
||||
this.translations = content.translations;
|
||||
this.status = json.status;
|
||||
this.viewers = new Viewers(json.viewers);
|
||||
}
|
||||
format() {
|
||||
var v = document.createElement('h3');
|
||||
var viewers = document.createTextNode('Viewers');
|
||||
v.appendChild(viewers);
|
||||
var viewerList = this.viewers.format();
|
||||
var h = document.createElement('h3');
|
||||
var heading = document.createTextNode('Status');
|
||||
h.appendChild(heading);
|
||||
var p = document.createElement('p');
|
||||
var text = document.createTextNode(this.status);
|
||||
p.appendChild(text);
|
||||
var result = [v];
|
||||
result = result.concat(viewerList);
|
||||
result.push(h, p);
|
||||
h = document.createElement('h3');
|
||||
heading = document.createTextNode(this.fallbackLang);
|
||||
h.appendChild(heading);
|
||||
p = document.createElement('html');
|
||||
p.setAttribute('lang', this.fallbackLang);
|
||||
p.innerHTML = this.fallback;
|
||||
result.push(h, p);
|
||||
for (var t in this.translations) {
|
||||
h = document.createElement('h3');
|
||||
heading = document.createTextNode(t);
|
||||
h.appendChild(heading);
|
||||
p = document.createElement('html');
|
||||
p.setAttribute('lang', this.translations[t]);
|
||||
p.innerHTML = this.translations[t];
|
||||
result.push(h, p);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
export class Payload {
|
||||
fields;
|
||||
constructor(json) {
|
||||
this.fields = [];
|
||||
if (json === undefined)
|
||||
return;
|
||||
for (var f in json) {
|
||||
this.fields.push(f);
|
||||
}
|
||||
}
|
||||
format() {
|
||||
var fieldList = document.createElement('ul');
|
||||
this.fields.forEach(f => {
|
||||
var field = document.createElement('li');
|
||||
field.appendChild(document.createTextNode(f));
|
||||
fieldList.appendChild(field);
|
||||
});
|
||||
return [fieldList];
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user