deserver
    Preparing search index...

    Class ServerConnect

    A class for easy handling of apis the deserver gives

    Hierarchy (View Summary)

    Index
    baseurl: string = 'http://127.0.0.1'
    bs: any = null
    errorid: string = "error"
    errorModal: any = null
    errortoconsole: boolean = true
    errortoelement: boolean = true
    gtversion: string = '1.0.7'
    port: string = ':8123'
    ptversion: string = '1.6.1'
    scversion: string = '2.1.0'
    • Parameters

      • recno: string | number | undefined

      Returns string

    • Append children created by html code to the end of the selected element

      Parameters

      • elmid: ElementDef

        a existing element or a string that will find a element by id

      • code: string

        html code for creating new elements

      Returns HTMLElement | null

      the first of the created elements or undefined if none created

    • Change the color of the button by first remove all btn- + primary, danger, warning, success and info classes then add the new class or classes and change the text if you want as well

      Parameters

      • elmid: ElementDef

        buttonid or button to change

      • toremove: string | string[] | undefined

        array classes or a single class string to remove extra

      • toadd: string | string[]

        array classes or a single class string to add

      • Optionaltext: string

        to be added to button instead of the one already there if parameter used

      Returns void

    • Clear the error element defined by errorid if active defined by errortoelement

      Returns void

    • Create new element from html code

      Parameters

      • code: string

        html code

      Returns HTMLCollection | null

      elements created from the html

    • Create a checkbox with a changable class set that can be used for event that will be used for select and deselect single or all depening on the value set

      function needed to be implemented is onchangecheckbox(event)

      Parameters

      • path: string
      • Optionalvalue: string

        if not set use path as value

      Returns string

    • Delete definition for a table

      Parameters

      • tname: string

        Name of table definition to delete

      Returns Promise<any>

      json with result telling how it went

    • Get definition for a single table (tdf)

      Parameters

      • tname: string

        Name of the table to get definition for

      Returns Promise<{ error?: string; message?: string; result: string; tdf?: any }>

      json with result 'ok' and tdf object

    • Create definition for a single table (tdf)

      Parameters

      • tname: string

        Name of table to create definition for

      • tdf: any

        Table definition object to post

      Returns Promise<any>

      json with result telling how it went

    • Update definition for a single table (tdf)

      Parameters

      • tname: string

        Name of table to update definition for

      • tdf: any

        Table definition object to update

      Returns Promise<any>

      json with result telling how it went

    • Do a DELETE request to the url and return the json object

      Parameters

      • url: string

        an url that is allowed to use

      Returns Promise<{}>

      a real object from call to server or a {result: 'error', error: message}

    • Do a GET request to the url and return the json object

      Parameters

      • url: string

        an url that is allowed to use

      Returns Promise<{}>

      a real object from call to server or a {result: 'error', error: message}

    • Do a POST request to the url and return the json object

      Parameters

      • url: string

        an url that is allowed to use

      • indata: {}

        a object that will be stringified to send

      Returns Promise<{}>

      a real object from call to server or a {result: 'error', error: message}

    • Do a PUT request to the url and return the json object

      Parameters

      • url: string

        an url that is allowed to use

      • indata: {}

        a object that will be stringified to send

      Returns Promise<{}>

      a real object from call to server or a {result: 'error', error: message}

    • Find one HtlmElement

      Parameters

      • elmid: ElementDef

        a existing element or a string that will find a element by id

      • Optionalselector: string

        uses to find a element inside the element found by elmid

      Returns HTMLElement | null

      HtmlElement or null

    • Add or remove color classed on an element. Used to change colors to elements that have a prefix. Ex. btn-danger or text-success The prefix will be added to any classes given if no - in class name so you can use warning instead of btn-warning on a button

      By default primary, danger, warning, success and info is always removed before any add

      Parameters

      • elmid: ElementDef

        element id or the element to change

      • what: string

        A prefix to use for the classes like btn-

      • toremove: string | string[] | undefined

        array of classes or single class to remove or undefined if not used, if no - in name prefix will be added

      • toadd: string | string[]

        array of classes or single class to add or undefined if not used, if no - in name prefix will be added

      • Optionaltext: string

        to be added to button instead of the one already there if parameter used

      Returns void

    • Get 0 or more elements from selector(s) or element and selector

      Parameters

      • sel1: ElementDef

        existing element to be queried for children or a selector for selecting elemenets

      • Optionalsel2: string

      Returns NodeList | null

      list of Elements or null

    • Find attribute on element or on the first child that have this attribute and return the value

      Parameters

      • elid: ElementDef

        an existing element or a string that will find a element by id

      • attname: string

        name of the attribure to find

      Returns string | null

      attribute or null

    • Parameters

      • elmid: ElementDef

        element id or the element to start from

      • localname: string

        a name of html type in lower case

      Returns [HTMLElement | null, number]

      array of two elements where the first is the element matching the localname type or null and the second how many levels up from the start did we have to go

      function tablecellonclick(event){
      const [td, level] = this.findfirstparentoftype(event.target, 'td');
      if (td){
      // ... do something with table cell
      }
      }

      will find first td up in tree from the event.taget calling it

    • Check for attribute on element or children and return the first element having the attributre defined

      Parameters

      • elid: ElementDef

        an existing element or a string that will find a element by id

      • attname: string

        name of the attribure to find

      Returns HTMLElement | null

      element with attributre defined or null

    • Return a attribute value if it exists

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • attr: string

        attribute name

      Returns string

      attribute value or blank string

    • Return a attribute value if it exists

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • attr: string

        attribute name

      • nullonnotfound: true

        if set to true a null will be returned for not found

      Returns string | null

      attribute value or blank or null depending on nullonnotfound

    • Hide a element by adding d-none class

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      Returns HTMLElement | null

      the element or null

    • Get inner htlm to or from a element

      Parameters

      • elmid: ElementDef

        a existing element or a string that will find a element by id

      Returns string | null

      the inner htlm of the element or null if element not found

    • Set inner htlm to an element

      Parameters

      • elmid: ElementDef

        a existing element or a string that will find a element by id

      • code: string

        if given a string, it will be set to the element

      Returns HTMLElement | null

      null if element not found or the element if code set

    • Test if a instance is a real array and not object or null

      Parameters

      • x: any

        to test

      Returns boolean

      true if real array

    • Give to strings in the form of semantic versioning and tell if the first is newer than the second Support any type version as long as they are seperated by the same number of . Ex. 0.1.0 and 0.1.1 gives false Ex. 9.0.0.2992 and 9.0.0.2990 gives true Ex. 9.1.0.0 and 9.0.0.2990 gives true as well

      Parameters

      • latest: string

        version to check

      • installed: string

        version to check against

      Returns boolean

      true or false

    • Test if a instance is a real object and not array or null

      Parameters

      • x: any

        to test

      Returns boolean

      true if real object

    • Login to the server with username and password

      Parameters

      • username: string
      • password: string

      Returns Promise<LoginResult>

      return json with how it went

    • Check if you are logged in to the server

      Returns Promise<any>

      return json with isloggedin, level, username and result ok. if you are using basic or token you will get result denied

    • Logout current browser session on server

      Returns Promise<any>

    • Call a method when element selected is changed

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • fn: EventListener

        a method in the class extended on this class

      Returns void

    • Call a method when element selected is clicked

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • fn: EventListener

        a method in the class extended on this class

      Returns void

    • Call a method when element get the named event. This method if for handleing all events that not are so commonly used that they have got their own method like onclickme

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • eventname: string

        the name for the event to register ex input, focusin, focusout

      • fn: EventListener

        a method in the class extended on this class

      Returns void

    • Call this function when document have finished loading

      Parameters

      • fn: EventListener | (() => void)

        a function to run

      Returns void

    • Delete one record in a table on dataease server

      Parameters

      • tname: string

        Name of the table to find record in

      • query: string

        he query to find the record as any DataEase queries

      • Optionalrecno: string | number

        Leave blank for first match or set the record number you want starting on 0

      Returns Promise<RecordDeleteResults>

      jdata json with result telling how it went (values ok, denied or error), if ok it returns recno that was deleted

    • Read on record from a table on dataease server

      Parameters

      • tname: string

        Name of the table to find record in

      • query: string

        The query to find the record as any DataEase queries

      • Optionalrecno: string | number

        Leave blank for first match or set the record number you want starting on 0

      Returns Promise<RecordGetResults>

      jdata json with result telling how it went (values ok, denied or error), if ok recorddata as requested, if error there will be a message

    • Create a new record

      Parameters

      • tname: string

        Name of the table to find record in

      • rec: {}

        a object containing all data needed to create a record

      Returns Promise<{}>

      jdata json with result telling how it went (values ok, denied or error), if ok a recorddata with changed vales are returned, if error there will be a message

    • Read records from a table on dataease server

      Parameters

      • tname: string

        Name of the table to find records in

      • query: string

        The query to find the records as any DataEase queries

      • Optionalrecnostart: string | number

        Leave blank for starting on 0 or set the record number you want starting on

      • Optionalrecnoend: string | number

        The end record to fech. Leave blank means recnostart + 100 or set the record number you want to be the last to fetch

      Returns Promise<RecordsGetResults>

      jdata json with result telling how it went (values ok, denied or error), if ok listdata as requested, if error there will be a message

    • Read records from a table on dataease server

      Parameters

      • tname: string

        Name of the table to find records in

      • records: {}[]

        an array of a object containing the data you want to change

      Returns Promise<RecordsSaveResults>

      jdata json with result telling how it went (values ok, denied or error), if ok recorddata as requested, if error there will be a message

    • Update existing records in a table on dataease server

      Parameters

      • tname: string

        Name of the table to update records in

      • query: string

        The query to find the records to update as any DataEase queries

      • records: {}[]

        an array of a object containing the data you want to change. Update starts on first object and continue as long as you have data or are stopped by recnoend. The recnostart and recnoend has nothign to do with where you start in the data.

      • Optionalrecnostart: string | number

        Leave blank for starting on 0 or set the record number you want starting on

      • Optionalrecnoend: string | number

        The end record to update. Leave blank means all data you have sent or set the record number you want to be the last to update

      Returns Promise<RecordsSaveResults>

      jdata json with result telling how it went (values ok, denied or error), if ok recorddata as requested, if error there will be a message

    • Update an exsiting record in a table

      Parameters

      • tname: string

        Name of the table to find record in

      • query: string

        The query to find the record as any DataEase queries

      • rec: {}

        a object containing the data you want to change in a record

      • Optionalrecno: number

        Leave blank for first match or set the record number you want starting on 0

      Returns Promise<RecordSaveResults>

      jdata json with result telling how it went (values ok, denied or error), if ok a recorddata with changed vales are returned, if error there will be a message

    • Remove children from the back of thil element till there is only the amount of to left

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • Optionalto: number

        hove many children to be left, default is 0 if not set

      Returns void

    • Run a execdql as high user or a server dql with security as set in document

      Parameters

      • name: string

        dql/body to run, name can be @name, #number and *: for execdqls or plain names for server dqls. You can name a dql and body by dqlname/bodyname

      • Optionaldataentry: { [key: string]: string }

        object with dataentry that can be used for dql, server dql can have any name, execdql only field1-4

      Returns Promise<DQLResults>

      jdata with result, if execdql with body the body can be found in jdata.data if jdata.result == 'ok'

    • Add a class to all selected elements

      Parameters

      • selector: string

        a selector that will match elements in the DOM

      • cname: string

        class name to add

      Returns void

    • Remove class from all selected elements

      Parameters

      • selector: string

        a selector that will match elements in the DOM

      • cname: string

        class name to remove

      Returns void

    • Send error to console and error element if defined To error element is defined by errorid and errortoelement To console is defined by errortoconsole

      Parameters

      • result: any

        the result from call to deserver api or a string

      Returns void

    • Set a attribute value on a element or if value is null, remove it

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • attr: string

        attribute name

      • val: string

        a string value to set or null if you want to remove the attribute

      Returns HTMLElement | null

      element if found and attribute set or null if element not found or remove failed

    • Used by showerror for displaying a error dialog and to avoid a lot of extra code in the budlels we prefer to set it dynamically after creation of guitools. What is used is for now is bootstap.Modal

      Parameters

      • bootstrap: any

        the bootstrap element set in window.bootstrap when loading bootrap.js in browser

      Returns void

    • For make a part of the page adjust to the resizing of the app

      Parameters

      • elmid: ElementDef

        element id or the element to resize

      • Optionaladjust: number

        default if 40 px at the bottom is left, you can use a different number by adding it here

      Returns void

    • Setup what server to load and store data from, it is usually same server as you load you application from and in that case you can use location.port for the for and combine ${location.protocol}//${location.hostname} to get the correct server address

      Parameters

      • port: string | number

        the port used on development server or nothing if comming from default http or https ports

      • baseurl: string

        the base url to use including protocol ex. http://127.0.0.1 for you development server

      Returns void

    • Show a element by remove d-none class

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      Returns HTMLElement | null

      the element or null

    • Show the error modal that should be defined in the html a id="ErrorModal" Needs to be async to be able to dynamically load bootstrap if not already done

      Parameters

      • title: string

        The title on top of error

      • msg: string

        The error message in dialog, can be text or html

      • Optionaladdcancelchain: boolean

        show the chain cancel button or not

      Returns Promise<void>

    • List all table names in application definition

      Returns Promise<{ error?: string; message?: string; result: string; tables?: string[] }>

      json with result 'ok' and tables array

    • Change the color of the text by first remove all text- + primary, danger, warning, success and info classes then add the new class or classes and change the text if you want as well

      Parameters

      • elmid: ElementDef

        element id or the element to change

      • toremove: string | string[] | undefined

        array classes or a single class string to remove extra

      • toadd: string | string[]

        array classes or a single class string to add

      • Optionaltext: string

        to be added to button instead of the one already there if parameter used

      Returns void

    • Get value from element

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      Returns string | boolean | null

      return the value of element as string or boolean if the element exists and null if not

    • Set value in element

      Parameters

      • elmid: ElementDef

        an existing element or a string that will find a element by id

      • val: string | boolean

        this is the value to set

      Returns null | undefined

      it will return undefined if a value is set and null if element do not exist