Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #178

Merged
merged 63 commits into from
Aug 5, 2024
Merged

Dev #178

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
d35b6ab
Call on load
susuhahnml Mar 20, 2024
b28a9a7
Fixed docs
susuhahnml Mar 20, 2024
db80e26
Fixed ClingoBackend arguments issue
susuhahnml Mar 20, 2024
9f304f7
Added resizable modal option and example
alexl4123 Mar 24, 2024
5a30760
Updated angular frontend files
alexl4123 Mar 24, 2024
6791b3e
Merge pull request #167 from potassco/resizable_modal
susuhahnml Mar 25, 2024
a439602
Added new lines
susuhahnml Mar 25, 2024
921aa46
Fix clingo-dl backend and -c argument
susuhahnml Mar 27, 2024
e6f2620
Better erro handling
susuhahnml Mar 27, 2024
8908d5a
better context
susuhahnml Mar 29, 2024
75267d2
Fixed show theroy atoms and explanation backend
susuhahnml Apr 3, 2024
67cb141
Fixed context replace but angular not updating
susuhahnml Apr 3, 2024
d1fbd06
Stop browsing
susuhahnml Apr 3, 2024
df0e734
Show program in select
susuhahnml Apr 4, 2024
d43146d
Removed console log
susuhahnml Apr 4, 2024
fea1f81
Show exception
susuhahnml Apr 4, 2024
49c6970
Merge pull request #169 from potassco/new-docs
susuhahnml Apr 4, 2024
0dba702
New version with open clingo version
susuhahnml Apr 4, 2024
04a8d87
Fixing angular context
susuhahnml Apr 9, 2024
c4023f9
New version
susuhahnml Apr 10, 2024
5b6418d
Another port
susuhahnml Apr 10, 2024
42329d0
Simpler download of current model
susuhahnml Apr 10, 2024
ed9ae9f
Study regulations example
susuhahnml Apr 26, 2024
55a94ba
Logger
susuhahnml Apr 29, 2024
b90efca
Fixed loader
susuhahnml Apr 29, 2024
610fc91
Clingo args command line
susuhahnml May 2, 2024
fbb49f0
Changed version
susuhahnml May 2, 2024
8eb1548
Explanation backend using clingoexplaid
susuhahnml Jun 10, 2024
a2ff1d5
Updated documentation
susuhahnml Jun 10, 2024
400fbf1
More documentation
susuhahnml Jun 10, 2024
b78dd79
Better logging
susuhahnml Jun 11, 2024
5076bab
Explanation backend with latest clingexplaid version
susuhahnml Jun 11, 2024
1e3396a
Fixed angular issues in update
susuhahnml Jun 17, 2024
59de718
Fixed requirements
susuhahnml Jun 17, 2024
9710961
Version update
susuhahnml Jun 17, 2024
f0878d6
Version update
susuhahnml Jun 17, 2024
b7e83c0
Optimization backend
susuhahnml Jun 11, 2024
189cc8f
On demand domain-constructors
susuhahnml Jun 19, 2024
7122719
Fixed Class issue in angular and tag issue in update
susuhahnml Jun 19, 2024
b5fdee4
Fixed cache issue
susuhahnml Jun 19, 2024
5fa043d
Version
susuhahnml Jun 19, 2024
4582597
Updates on clingo dl
susuhahnml Jun 21, 2024
440208f
Improved log
susuhahnml Jun 21, 2024
3d6da03
New version 15
susuhahnml Jun 21, 2024
631dcd6
version .16
susuhahnml Jun 21, 2024
c448402
Logs before actions
susuhahnml Jul 1, 2024
be05522
Improved error log and documentation
susuhahnml Jul 1, 2024
062de84
Removed default angular frointed directive in examples
susuhahnml Jul 1, 2024
d522656
Additional documentation
susuhahnml Jul 1, 2024
40d3080
Fixed canvas
susuhahnml Jul 10, 2024
fe0d61f
New tag
susuhahnml Jul 10, 2024
5d6b16b
Fixed explanatin bugs
susuhahnml Jul 23, 2024
22ddafb
Fixed README
susuhahnml Jul 30, 2024
97ac1cb
Raising error on missing optimization statement
susuhahnml Jul 30, 2024
a1f4858
Added constants and improved documentation
susuhahnml Jul 31, 2024
c33f3ad
General reordering and new docs
susuhahnml Aug 2, 2024
6c5caab
Improved documentation
susuhahnml Aug 2, 2024
de818b3
Replaced policy by operation and updated angular
susuhahnml Aug 2, 2024
c11878d
Fixed example
susuhahnml Aug 2, 2024
c9fe1d3
Replace interaction_type by action
susuhahnml Aug 2, 2024
5b7a71c
Timeout option and more help doc
susuhahnml Aug 2, 2024
bb92322
Small change to docs
susuhahnml Aug 5, 2024
e92cac9
Fixed lints
susuhahnml Aug 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/conda/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ requirements:
- uvicorn
- clingraph
- Pillow
- clingexplaid

build:
number: {{ build }}
Expand Down
3 changes: 2 additions & 1 deletion .github/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pip:
conda:
package_name:
'clinguin'
os:
os:
- 'ubuntu-latest'
channels_release:
- 'potassco'
Expand Down Expand Up @@ -48,6 +48,7 @@ conda:
- uvicorn
- clingraph
- Pillow
- clingexplaid

build:
noarch: python
Expand Down
3 changes: 2 additions & 1 deletion .github/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ fastapi==0.103.*
networkx
uvicorn
clingraph
Pillow
Pillow
clingexplaid
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ variable-rgx=^[a-z][a-z0-9]*((_[a-z0-9]+)*_?)?$
good-names=_,M,N,B,A,Nn,Bn,An

[MESSAGE CONTROL]
disable=W0719,W0122,C0206,C0201,W0718,R0902,C0103
disable=W0719,W0122,C0206,C0201,W0718,R0902,C0103,E1129
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Clinguin

Clinguin enables ASP developers to **create interactive User Interface** (UI) prototypes **using only ASP**.
UIs are defined as sets of facts, which are then rendered by a fronted to provide continuous interaction with ASP solvers based on user-triggered events.
UIs are defined as sets of facts, which are then rendered to provide continuous interaction with the ASP solver *clingo* based on user-triggered events.

***Your UI definition would look like this!***

Expand Down Expand Up @@ -35,7 +35,7 @@ Clinguin includes a wide range of [clingo](https://potassco.org/clingo/) functio

***Is clinguin missing something for your application?***

No worries! Clinguin can be extended with different functionalities and even frontend languages, take a look [at this guide](https://clinguin.readthedocs.io/en/latest/clinguin/backends.html#creating-your-own-backend).
No worries! Clinguin can be extended with different functionalities and even frontend languages, take a look [at this guide](https://clinguin.readthedocs.io/en/latest/clinguin/development/customBackend.html).


## Installation
Expand Down
2 changes: 1 addition & 1 deletion angular_frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.1.3"
}
}
}
2 changes: 1 addition & 1 deletion angular_frontend/src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
div.content-wrapper {
padding-top: 5%;
padding-top: 1%;
}
113 changes: 58 additions & 55 deletions angular_frontend/src/app/attribute-helper.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,69 +2,69 @@ import { Attribute, Injectable } from '@angular/core';
import { AttributeDto, ElementDto } from './types/json-response.dto';

@Injectable({
providedIn: 'root'
providedIn: 'root'
})
export class AttributeHelperService {

constructor() { }
constructor() { }

attrBackgroundColor(html:HTMLElement, attribute: AttributeDto) {
attrBackgroundColor(html: HTMLElement, attribute: AttributeDto) {
let value = attribute.value

html.style.backgroundColor = value
}

attrHeight(html:HTMLElement, attribute: AttributeDto) {
attrHeight(html: HTMLElement, attribute: AttributeDto) {
let value = attribute.value + "px"
html.style.height = value
}

attrWidth(html:HTMLElement, attribute: AttributeDto) {
attrWidth(html: HTMLElement, attribute: AttributeDto) {
let value = attribute.value + "px"
html.style.width = value
}


setBorderHelper(html:HTMLElement, attributes: AttributeDto[]) {
setBorderHelper(html: HTMLElement, attributes: AttributeDto[]) {

let borderWidth = Number(this.findGetAttributeValue("border_width", attributes, "0"))
let borderColor = this.findGetAttributeValue("border_color",attributes, "black")
let borderColor = this.findGetAttributeValue("border_color", attributes, "black")
let borderStyle = "solid"

this.setBorder(html, borderWidth, borderColor, borderStyle)
}

setBorder(html:HTMLElement, borderWidth: number, borderColor: string, borderStyle: string) {
setBorder(html: HTMLElement, borderWidth: number, borderColor: string, borderStyle: string) {
if (borderWidth > 0) {
html.style.border = String(borderWidth) + "px " + borderStyle + " " + borderColor
}

}

addAttributes(html:HTMLElement, attributes : AttributeDto[]) {
addAttributes(html: HTMLElement, attributes: AttributeDto[]) {

let attr_dict = [
{key:"background_color",value:this.attrBackgroundColor},
{key:"height", value:this.attrHeight},
{key:"width", value:this.attrWidth},
{ key: "background_color", value: this.attrBackgroundColor },
{ key: "height", value: this.attrHeight },
{ key: "width", value: this.attrWidth },
]

attributes.forEach(attribute => {
let index = attr_dict.findIndex(item => item.key == attribute.key)
if (index >= 0) {
attr_dict[index].value(html,attribute)
attr_dict[index].value(html, attribute)
}
})

this.setHover(html, attributes)
}

addGeneralAttributes(html:HTMLElement, attributes: AttributeDto[]) {
this.setGrid(html,attributes)
addGeneralAttributes(html: HTMLElement, attributes: AttributeDto[]) {
this.setGrid(html, attributes)
this.setBorderHelper(html, attributes)
}

setGrid(html: HTMLElement, attributes:AttributeDto[]) {
setGrid(html: HTMLElement, attributes: AttributeDto[]) {

let gridRowStart = this.findAttribute("grid_row", attributes)
let gridRowSpan = this.findAttribute("grid_row_span", attributes)
Expand All @@ -86,24 +86,24 @@ export class AttributeHelperService {

html.style.gridRow = String(gridRowStartN) + "/" + "span " + String(gridRowSpanN)
}

if (gridColumnStart != null) {
let gridColumnStartN = Number(gridColumnStart.value) + 1

html.style.gridColumn = String(gridColumnStartN) + "/" + "span " + String(gridColumnSpanN)
}
}

setHover(html: HTMLElement, attributes:AttributeDto[]) {
setHover(html: HTMLElement, attributes: AttributeDto[]) {

let onHover = this.findGetAttributeValue("on_hover", attributes,"false")
let onHoverBackgroundColor = this.findGetAttributeValue("on_hover_background_color", attributes,"white")
let onHoverForegroundColor = this.findGetAttributeValue("on_hover_foreground_color", attributes,"black")
let onHoverBorderColor = this.findGetAttributeValue("on_hover_border_color", attributes,"white")
let backgroundColor = this.findGetAttributeValue("background_color", attributes,"white")
let foregroundColor = this.findGetAttributeValue("foreground_color", attributes,"black")
let onHover = this.findGetAttributeValue("on_hover", attributes, "false")
let onHoverBackgroundColor = this.findGetAttributeValue("on_hover_background_color", attributes, "white")
let onHoverForegroundColor = this.findGetAttributeValue("on_hover_foreground_color", attributes, "black")
let onHoverBorderColor = this.findGetAttributeValue("on_hover_border_color", attributes, "white")
let backgroundColor = this.findGetAttributeValue("background_color", attributes, "white")
let foregroundColor = this.findGetAttributeValue("foreground_color", attributes, "black")
let borderWidth = Number(this.findGetAttributeValue("border_width", attributes, "0"))
let borderColor = this.findGetAttributeValue("border_color",attributes, "black")
let borderColor = this.findGetAttributeValue("border_color", attributes, "black")
let borderStyle = "solid"

if (onHover == "true") {
Expand All @@ -124,7 +124,7 @@ export class AttributeHelperService {

}

textAttributes(html: HTMLElement, attributes : AttributeDto[]) {
textAttributes(html: HTMLElement, attributes: AttributeDto[]) {
// NOw IS SUPPOSED TO BE SET WITH THE CLASSES


Expand All @@ -133,66 +133,69 @@ export class AttributeHelperService {
// let index = attributes.findIndex(item => item.key == "foreground_color")
// if (index >= 0) {
// color = String(attributes[index].value)
// }
// html.style.color = color
// }
// html.style.color = color

// let fontSize = String(12) + "px"
// let index = attributes.findIndex(item => item.key == "font_size")
// if (index >= 0) {
// fontSize = String(attributes[index].value)
// }
// }
// html.style.fontSize = fontSize

}

addClasses(html: Element, attributes : AttributeDto[], base_classes:string[], default_classes:string[], attrName: string ='class' ) {
addClasses(html: Element, attributes: AttributeDto[], base_classes: string[], default_classes: string[], attrName: string = 'class') {

base_classes.forEach(function (c){
base_classes.forEach(function (c) {
if (html.classList.contains(c)) {
html.classList.remove(c)
}
html.classList.add(c)
})
let added = false
attributes.forEach(function (item){
if (item.key==attrName){
attributes.forEach(function (item) {
if (item.key == attrName) {
added = true
let c = String(item.value)
html.classList.add(c)
}
})

if (!added){
default_classes.forEach(function (c){
if (!added) {
default_classes.forEach(function (c) {
html.classList.add(c)
})
}


}

setAttributesDirectly(html: HTMLElement, attributes: AttributeDto[]) {
attributes.forEach((attr : AttributeDto) => {
attributes.forEach((attr: AttributeDto) => {
(<any>html.style)[attr.key] = attr.value
})
}

findAttribute(key:string, attributes: AttributeDto[]) : AttributeDto | null {
let value = null
let index = attributes.findIndex(attr => attr.key == key)
if (index >= 0) {
value = attributes[index]
}
return value
findAttribute(key: string, attributes: AttributeDto[]): AttributeDto | null {
let value = null
let index = attributes.findIndex(attr => attr.key == key)
if (index >= 0) {
value = attributes[index]
}
return value
}

findGetAttributeValue(key: string, attributes: AttributeDto[], defaultValue: string) {
let value = defaultValue
let index = attributes.findIndex(attr => attr.key == key)
if (index >= 0) {
value = attributes[index].value
}
return value
let value = defaultValue
let index = attributes.findIndex(attr => attr.key == key)
if (index >= 0) {
value = attributes[index].value
}
return value
}

setAbsoulteRelativePositions(parentChildLayout:string, html:HTMLElement, child:ElementDto) {
setAbsoulteRelativePositions(parentChildLayout: string, html: HTMLElement, child: ElementDto) {

let posX = Number(this.findGetAttributeValue("pos_x", child.attributes, "-1"))
let posY = Number(this.findGetAttributeValue("pos_y", child.attributes, "-1"))
Expand Down Expand Up @@ -225,7 +228,7 @@ export class AttributeHelperService {

}

setChildLayout(html:HTMLElement, attributes: AttributeDto[]) {
setChildLayout(html: HTMLElement, attributes: AttributeDto[]) {
let attribute = this.findAttribute("child_layout", attributes)
let flex_direction = this.findAttribute("flex_direction", attributes)

Expand All @@ -251,16 +254,16 @@ export class AttributeHelperService {
}
} else {
html.style.display = "flex"
if (flex_direction != null){
if (flex_direction != null) {
html.style.flexDirection = flex_direction.value

}else {
} else {
html.style.flexDirection = "column"
}
}
}

setVisibility(html:HTMLElement, attributes:AttributeDto[]) {
setVisibility(html: HTMLElement, attributes: AttributeDto[]) {
let visibilityAttribute = this.findAttribute("visibility", attributes)
if (visibilityAttribute != null) {
if (visibilityAttribute.value == "hidden" || visibilityAttribute.value == "collapse") {
Expand Down
Loading
Loading