Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
AlonGvili committed Jun 22, 2020
1 parent 66b8205 commit 7ef4bf1
Show file tree
Hide file tree
Showing 105 changed files with 542 additions and 300 deletions.
2 changes: 1 addition & 1 deletion src/Components/api/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const PageManager = React.lazy(
() => import(/* webpackChunkName: 'PageManager'*/ "../framework/pages/PageManager")
)

export default ({ appbar, sidebar, footer, theme: udTheme }) => {
export default ({ appbar, sidebar, footer, udTheme }) => {
const [theme, setTheme] = React.useState(() => {
const savedTheme = localStorage.getItem("theme")
if(!savedTheme) return { name: udTheme.name, variables: {
Expand Down
10 changes: 9 additions & 1 deletion src/Components/form/antForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,15 @@ export default function AntdForm({ id, ...props }) {
item => {
const { content, rules, ...rest } = item
return <Form.Item { ...rest } key={ rest.id } name={ rest.name } rules={ rules && [rules] }>
{ UniversalDashboard.renderComponent(content[0]) }
{
Array.isArray(content[0]) ? content[0].map(i => {
return Array.isArray(i.content) ? i.content.map(ii => {
return Array.isArray(ii.content) ? ii.content.map(iii => {
UniversalDashboard.renderComponent(iii)
}) : UniversalDashboard.renderComponent(ii.content)
}) : UniversalDashboard.renderComponent(i.content)
}) : UniversalDashboard.renderComponent(content[0])
}
</Form.Item>
}
)
Expand Down
1 change: 1 addition & 0 deletions src/Components/icon/icon.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable import/namespace */
import React from 'react'
import * as AntdIcons from '@ant-design/icons/es/icons'
import { Skeleton, Alert } from 'antd'
Expand Down
37 changes: 25 additions & 12 deletions src/Components/tags/tags.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { Tag } from "antd"
import {
CheckCircleOutlined,
SyncOutlined,
CloseCircleOutlined,
ExclamationCircleOutlined,
ClockCircleOutlined,
} from '@ant-design/icons'
import React, { useState } from "react"
import useDashboardEvent from "../api/Hooks/useDashboardEvent"


const AntdTag = ({ id, ...props }) => {
export default function AntdTag({ id, ...props }) {
const [closed, setClosed] = useState(false)
const [{content, attributes}] = useDashboardEvent(id, props)
const { icon, color, closable } = attributes
const [{ content, attributes }] = useDashboardEvent(id, props)
const { icon, color, closable, withIcon, ...restOfProps } = attributes

const onClose = () => {
setClosed(true)
UniversalDashboard.publish("element-event", {
Expand All @@ -18,22 +25,28 @@ const AntdTag = ({ id, ...props }) => {
})
}

const icons = {
"success": <CheckCircleOutlined />,
"processing": <SyncOutlined />,
"error": <CloseCircleOutlined />,
"warning": <ExclamationCircleOutlined />,
"default": <ClockCircleOutlined />,
}
return (
<Tag
id={id}
icon={icon && UniversalDashboard.renderComponent(icon)}
onClose={ closable && onClose}
visible={!closed}
color={color}
closable={closable}
id={ id }
icon={ withIcon && UniversalDashboard.renderComponent(icons[color]) || icon && UniversalDashboard.renderComponent(icon) }
onClose={ closable && onClose }
visible={ !closed }
color={ color }
closable={ closable }
>
{UniversalDashboard.renderComponent(content)}
{ UniversalDashboard.renderComponent(content) }
</Tag>
)
}

AntdTag.displayName = "AntdTag"
export default AntdTag



33 changes: 22 additions & 11 deletions src/Dashboard/Pages/Examples/Form_Page.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -47,26 +47,37 @@ New-UDPage -Title 'Forms' -Name 'Form' -Content {
type = 'email'
})

New-UDAntdFormItem -Name @('user', 'text_area_basic') -Content {
New-UDAntdFormItem -NoStyle -Content {
New-UDAntdFormItem -Content {
New-UDAntdFormItem -Name @('user', 'text_area_basic') -NoStyle -Content {
New-UDAntdInputTextArea -Value "alon gvili ud"
}
}

New-UDAntdFormItem -Name @('user', 'input_group') -Content {
New-UDAntdInputGroup -Content {
New-UDAntdFormItem -name "demo" -ValuePropName "children" -Content {
New-UDAntdFormItem -NoStyle -Content {
New-UDAntdSelect -DataSource {
$ReposNames.Foreach( { New-UDAntdSelectOption -Value $_ })
} -Bordered -Placeholder "Select github repo name."
New-UDAntdInputNumber
}
} -WrapperCol $WrapperCol
New-UDAntdSelectOption -Value "Israel"
New-UDAntdSelectOption -Value "USA"
New-UDAntdSelectOption -Value "China"
New-UDAntdSelectOption -Value "Spain"
} -Bordered -Placeholder "Select your country."
}
}

New-UDAntdFormItem -Name 'input_number' -Content {
New-UDAntdInputNumber
}

New-UDAntdFormItem -HasFeedback -Name "select_single" -Content {
New-UDAntdFormItem -Name "select_single" -Content {
New-UDAntdSelect -DataSource {
New-UDAntdSelectOption -Value "Israel"
New-UDAntdSelectOption -Value "USA"
New-UDAntdSelectOption -Value "China"
New-UDAntdSelectOption -Value "Spain"
} -Bordered -DropdownMatchSelectWidth -Placeholder "Select your country."
}

New-UDAntdFormItem -HasFeedback -Name "select_single_dynamic" -Content {
New-UDAntdSelect -DataSource {
$ReposNames.Foreach( { New-UDAntdSelectOption -Value $_ })
} -Bordered -DropdownMatchSelectWidth -Placeholder "Select github repo name."
Expand All @@ -93,7 +104,7 @@ New-UDPage -Title 'Forms' -Name 'Form' -Content {
}

New-UDAntdFormItem -Name 'rate_emojy' -Content {
New-UDAntdRate -Character "🎀"
New-UDAntdRate -Character "😋"
}

New-UDAntdFormItem -Name 'rate_icon' -Content {
Expand Down
13 changes: 13 additions & 0 deletions src/Dashboard/Pages/Examples/Search_Page.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,17 @@ New-UDPage -Title 'AutoComplete' -Name "AutoComplete" -Endpoint {
New-UDAntdSelect -Id "demo_select" -DataSource {
$namesAsJson
} -Bordered -Placeholder "Find github repo."

New-UDantdTag -PresetColor blue -Content "Twitter"
New-UDantdTag -Status processing -Content "in progress..."
New-UDantdTag -Status processing -Content "in progress..." -WithIcon
New-UDantdTag -Status success -Content "success" -WithIcon
New-UDantdTag -Status error -Content "error" -WithIcon
New-UDantdTag -Status warning -Content "warning" -WithIcon
New-UDAntdTag -Content "Youtube" -PresetColor red -Icon (
New-UDAntdIcon -Icon YoutubeOutlined -Size xs
)
New-UDAntdTag -Content "Youtube" -PresetColor red -Icon (
New-UDAntdIcon -Icon YoutubeOutlined -Size xs
) -Closable
} -DefaultHomePage
11 changes: 3 additions & 8 deletions src/Scripts/New-UDAntdSideBar.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,8 @@ function New-UDAntdSideBar {

End {

if ($null -ne $Content) {
if ($Content -is [scriptblock]) {
$ContentEndpoint = New-UDEndpoint -Endpoint $Content -Id $Id
}
elseif ($Content -isnot [UniversalDashboard.Models.Endpoint]) {
throw "Content must be a script block or UDEndpoint"
}
if ( $Null -ne $Content ) {
New-UDEndpoint -Endpoint $Content -Id $Id | Out-Null
}

$UDAntdSider = @{
Expand All @@ -52,7 +47,7 @@ function New-UDAntdSideBar {
className = $ClassName
style = $Style
hasCallback = $null -ne $Content
content = $Content.Invoke()
# content = $Content.Invoke()
visible = $Visible.IsPresent
}
$UDAntdSider.PSTypeNames.Insert(0, 'Ant.Design.SideBar')
Expand Down
2 changes: 1 addition & 1 deletion src/Scripts/New-UDAntdStatistic.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function New-UDAntdStatistic {
End {

if ($null -ne $Value) {
$StatsEndpoint = New-UDEndpoint -Endpoint $Value -Id $id
New-UDEndpoint -Endpoint $Value -Id $id | Out-Null
}

$AntdStatistic = @{
Expand Down
119 changes: 62 additions & 57 deletions src/Scripts/New-UDAntdSwitch.ps1
Original file line number Diff line number Diff line change
@@ -1,88 +1,93 @@
<#
.SYNOPSIS
Sample control for UniversalDashboard.
Short description
.DESCRIPTION
Sample control function for UniversalDashboard. This function must have an ID and return a hash table.
Long description
.PARAMETER Id
An id for the component default value will be generated by new-guid.
Parameter description
.PARAMETER ClassName
Parameter description
.PARAMETER AutoFocus
Parameter description
.PARAMETER Checked
Parameter description
.PARAMETER DefaultChecked
Parameter description
.PARAMETER Disabled
Parameter description
.PARAMETER Loading
Parameter description
.PARAMETER Size
Parameter description
.PARAMETER OnChange
Parameter description
.PARAMETER Style
Parameter description
.EXAMPLE
PS C:\> <example usage>
Explanation of what the example does
.INPUTS
Inputs (if any)
.OUTPUTS
Output (if any)
An example
.NOTES
General notes
General notes
#>
function New-UDAntdSwitch {
[CmdletBinding()]
[OutputType('Ant.Design.Switch')]
param(
[Parameter()]
[string]$Id = (New-Guid).ToString(),
[Parameter()]
[string]$ClassName,
[Parameter()]
[switch]$autoFocus,
[Parameter()]
[switch]$checked,
[Parameter()]
[object]$checkedChildren,
[switch]$AutoFocus,
[Parameter()]
[switch]$defaultChecked,
[switch]$Checked,
[Parameter()]
[switch]$disabled,
[switch]$DefaultChecked,
[Parameter()]
[switch]$loading,
[switch]$Disabled,
[Parameter()]
[ValidateSet("default","small","large")]
[string]$size,
[switch]$Loading,
[Parameter()]
[object]$unCheckedChildren,
[ValidateSet("default", "small", "large")]
[string]$Size,
[Parameter()]
[object]$onChange,
[scriptblock]$OnChange,
[Parameter()]
[hashtable]$Style

)

End {

if ($null -ne $OnClick) {
if ($OnClick -is [scriptblock]) {
$OnClick = New-UDEndpoint -Endpoint $OnClick -Id ($Id + "onClick")
}
elseif ($OnClick -isnot [UniversalDashboard.Models.Endpoint]) {
throw "OnClick must be a script block or UDEndpoint"
}

if ( $Null -ne $onChange ) {
New-UDEndpoint -Endpoint $onChange -Id ($Id + "onChange") | Out-Null
}

if ($null -ne $onChange) {
if ($onChange -is [scriptblock]) {
$onChange = New-UDEndpoint -Endpoint $onChange -Id ($Id + "onChange")
}
elseif ($onChange -isnot [UniversalDashboard.Models.Endpoint]) {
throw "OnClick must be a script block or UDEndpoint"
}
}

@{
assetId = $AssetId
isPlugin = $true
type = "ud-antd-switch"
id = $Id
className = $ClassName
autoFocus = $AutoFocus.IsPresent
checked = $Checked.IsPresent
checkedChildren = $CheckedChildren
$AntdSwitch = @{
assetId = $AssetId
isPlugin = $true
type = "ud-antd-switch"
id = $Id
autoFocus = $AutoFocus.IsPresent
checked = $Checked.IsPresent
defaultChecked = $DefaultChecked.IsPresent
disabled = $Disabled.IsPresent
loading = $Loading.IsPresent
size = $Size
unCheckedChildren = $UnCheckedChildren
# onChange = $OnChange
# onClick = $OnClick
style = $Style
disabled = $Disabled.IsPresent
loading = $Loading.IsPresent
size = $Size
style = $Style
}

$AntdSwitch.PSTypeNames.Insert(0, 'Ant.Design.Switch')
$AntdSwitch
}
}
Loading

0 comments on commit 7ef4bf1

Please sign in to comment.