upload project
This commit is contained in:
commit
ec1edc2208
8 changed files with 231 additions and 0 deletions
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
* -text
|
||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
-*
|
||||
.DS_Store
|
||||
23
app/app.view.tree
Normal file
23
app/app.view.tree
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
$hd_canary_app $mol_page
|
||||
title \Hyper Canary
|
||||
body /
|
||||
<= List_sites $mol_list rows <= sites /
|
||||
<= New_site_string $mol_string
|
||||
hint \https://domain.com
|
||||
<= Add_site_button $mol_button_minor
|
||||
title \Добавить сайт
|
||||
click <= add_site null
|
||||
Site* $mol_list rows /
|
||||
<= Domain_labeler* $mol_labeler
|
||||
title \Сайт:
|
||||
content /
|
||||
<= Text_1* $mol_paragraph
|
||||
title <= status* \
|
||||
<= Last_time_labeler* $mol_labeler
|
||||
title \Дата последнего пинга:
|
||||
content /
|
||||
<= Text_2* $mol_paragraph
|
||||
title <= last_ping_time* \
|
||||
- <= Delete_site_button* $mol_button_minor
|
||||
title \Удалить
|
||||
click <= delete_site* null
|
||||
93
app/app.view.ts
Normal file
93
app/app.view.ts
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
namespace $.$$ {
|
||||
$hyoo_crus_yard.masters = [
|
||||
$mol_dom_context.document.location.origin +'/',
|
||||
]
|
||||
|
||||
export class $hd_canary_app extends $.$hd_canary_app {
|
||||
|
||||
@ $mol_mem
|
||||
home() {
|
||||
const ref = $hyoo_crus_ref( this.$.$mol_fetch.text( '/ref' ) )
|
||||
return this.$.$hyoo_crus_glob.Node( ref, $hd_canary_app_home )
|
||||
}
|
||||
|
||||
sites() {
|
||||
return this.home().Sites(null)!.remote_list().map( key => this.Site( key ) ) ?? []
|
||||
}
|
||||
|
||||
status( prop: $hd_canary_app_home_site ) {
|
||||
return this.last_ping_status(prop) + " " + this.domain(prop)
|
||||
}
|
||||
|
||||
domain( prop: $hd_canary_app_home_site ) {
|
||||
return prop.domain()!.val() ?? prop.ref().description!
|
||||
}
|
||||
last_ping_time( prop: $hd_canary_app_home_site ) {
|
||||
return prop.last_ping_time()!.val() ?? prop.ref().description! as any
|
||||
}
|
||||
last_ping_status( prop: $hd_canary_app_home_site ) {
|
||||
return prop.last_ping_status()!.val()? "🟢" : "🔴"
|
||||
}
|
||||
|
||||
click() {
|
||||
// const new_site = new $hd_canary_app_home_site()
|
||||
// new_site.domain("some_value")
|
||||
|
||||
// const site = this.home().land().Node( $hd_canary_app_home_site ).Item('')
|
||||
// console.log( site )
|
||||
|
||||
// console.log( this.home().can_change())
|
||||
|
||||
// const new_site = this.home().Sites(null)!.make({ '': $hyoo_crus_rank_read })
|
||||
// new_site.domain("test")
|
||||
|
||||
for (const site of this.home().Sites(null)!.remote_list()) {
|
||||
console.log({site})
|
||||
console.log({domain: site.domain()?.val()})
|
||||
}
|
||||
|
||||
console.log({landaaa: this.home().Sites(null)?.land_ref()})
|
||||
|
||||
|
||||
// console.log(
|
||||
// this.home().Sites(null)!.remote_list()
|
||||
// )
|
||||
|
||||
|
||||
// const masters = this.$.$hyoo_crus_glob.yard().masters()//$mol_wire_sync( this.$.$hyoo_crus_glob.yard() ).masters()
|
||||
// this.Port_masters( null )!.tick_instant( masters ) // pct
|
||||
// console.log( {masters} )
|
||||
}
|
||||
|
||||
add_site() {
|
||||
const domain = this.New_site_string().value()
|
||||
|
||||
// const new_site = this.home().Sites(null)!.make({ '': $hyoo_crus_rank_rule })
|
||||
// new_site.domain(null)!.val(domain)
|
||||
|
||||
$mol_fetch.response("/sites", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
domain
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
delete_site( prop: $hd_canary_app_home_site ) {
|
||||
|
||||
$mol_fetch.response("/sites", {
|
||||
method: "DELETE",
|
||||
headers: {
|
||||
'Content-Type': 'application/json;charset=utf-8'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
ref: prop.ref().description!
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
37
app/home/home.ts
Normal file
37
app/home/home.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
namespace $ {
|
||||
|
||||
export class $hd_canary_app_home extends $hyoo_crus_home.with({
|
||||
// Aliases: $hyoo_crus_dict_to( $hyoo_crus_list_str ),
|
||||
// Stat: $hyoo_crus_atom_ref_to( ()=> $hyoo_crus_app_stat ),
|
||||
|
||||
Sites: $hyoo_crus_list_ref_to( ()=> $hd_canary_app_home_site ),
|
||||
}) {}
|
||||
|
||||
export class $hd_canary_app_home_site extends $hyoo_crus_dict.with( {
|
||||
/** Type of value */
|
||||
domain: $hyoo_crus_atom_str,
|
||||
last_ping_time: $hyoo_crus_atom_time,
|
||||
last_ping_status: $hyoo_crus_atom_bool,
|
||||
}) {
|
||||
|
||||
@ $mol_mem
|
||||
tick() {
|
||||
|
||||
this.$.$mol_state_time.now( 5000 )
|
||||
|
||||
if(this.can_change()) {
|
||||
const domain = this.domain()!.val() as string
|
||||
|
||||
// console.log({action:"tick", domain: domain, })//this.last_ping_time()?.val()})
|
||||
|
||||
const request = $mol_fetch.response(domain)
|
||||
this.last_ping_status(null)!.val( request.code() == 200)
|
||||
this.last_ping_time(null)!.val( new $mol_time_moment)
|
||||
// console.log({status: request.code()})
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
1
canary.meta.tree
Normal file
1
canary.meta.tree
Normal file
|
|
@ -0,0 +1 @@
|
|||
include \/hd/canary/app
|
||||
60
canary.node.tsx
Normal file
60
canary.node.tsx
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/** @jsx $mol_jsx */
|
||||
namespace $ {
|
||||
$hyoo_crus_yard.masters = [
|
||||
"http://localhost:9090/"
|
||||
// "http://127.0.0.1:9090/"
|
||||
// $mol_dom_context.document.location.origin +'/',
|
||||
]
|
||||
|
||||
// используем hyoo_crus_app_node чтобы сразу иметь крас ноду
|
||||
export class $hd_canary extends $hyoo_crus_app_node {
|
||||
@ $mol_mem
|
||||
_stat_update() {
|
||||
const home = this.$.$hyoo_crus_glob.home( $hd_canary_app_home )
|
||||
|
||||
for (const site of home.Sites(null)!.remote_list()) {
|
||||
site.tick()
|
||||
}
|
||||
}
|
||||
|
||||
@ $mol_memo.method
|
||||
sites() {
|
||||
return new $hd_canary_sites
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export class $hd_canary_sites extends $mol_rest_resource {
|
||||
|
||||
POST( msg: $mol_rest_message ) {
|
||||
const {domain} = JSON.parse(msg.text())
|
||||
|
||||
const home = this.$.$hyoo_crus_glob.home( $hd_canary_app_home )
|
||||
const new_site = home.Sites(null)!.make({ '': $hyoo_crus_rank_rule })
|
||||
new_site.domain(null)!.val(domain)
|
||||
|
||||
msg.reply( new_site.land().ref().description! )
|
||||
}
|
||||
|
||||
|
||||
// TODO
|
||||
DELETE( msg: $mol_rest_message ): void {
|
||||
// const {ref} = JSON.parse(msg.text())
|
||||
|
||||
// const home = this.$.$hyoo_crus_glob.home( $hd_canary_app_home )
|
||||
// const current_all = home.Sites(null)!.items_vary()
|
||||
// console.log({current_all})
|
||||
// const new_all = current_all.filter(item => item?.toString() != ref)
|
||||
// home.Sites(null)!.splice(new_all)
|
||||
// msg.reply( "ok" )
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$.$hd_canary.serve()
|
||||
|
||||
/*
|
||||
npm start
|
||||
+ hd/canary port=9090
|
||||
*/
|
||||
14
index.html
Normal file
14
index.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<!doctype html>
|
||||
<html mol_view_root>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Hyper Canary</title>
|
||||
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1">
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
</head>
|
||||
<body mol_view_root>
|
||||
<div mol_view_root="$hd_canary_app"></div>
|
||||
<script src="web.js" charset="utf-8"></script>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Reference in a new issue