From ec1edc2208f90d4ccc98854dc360d6804fae4e30 Mon Sep 17 00:00:00 2001 From: koplenov Date: Sat, 16 Aug 2025 14:02:39 +0300 Subject: [PATCH] upload project --- .gitattributes | 1 + .gitignore | 2 + app/app.view.tree | 23 ++++++++++++ app/app.view.ts | 93 +++++++++++++++++++++++++++++++++++++++++++++++ app/home/home.ts | 37 +++++++++++++++++++ canary.meta.tree | 1 + canary.node.tsx | 60 ++++++++++++++++++++++++++++++ index.html | 14 +++++++ 8 files changed, 231 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 app/app.view.tree create mode 100644 app/app.view.ts create mode 100644 app/home/home.ts create mode 100644 canary.meta.tree create mode 100644 canary.node.tsx create mode 100644 index.html diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..7745062 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d98651d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +-* +.DS_Store diff --git a/app/app.view.tree b/app/app.view.tree new file mode 100644 index 0000000..eb92f5b --- /dev/null +++ b/app/app.view.tree @@ -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 diff --git a/app/app.view.ts b/app/app.view.ts new file mode 100644 index 0000000..951f6b7 --- /dev/null +++ b/app/app.view.ts @@ -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! + }) + }) + + } + } +} diff --git a/app/home/home.ts b/app/home/home.ts new file mode 100644 index 0000000..1608393 --- /dev/null +++ b/app/home/home.ts @@ -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()}) + + } + + } + } + +} diff --git a/canary.meta.tree b/canary.meta.tree new file mode 100644 index 0000000..486f8b0 --- /dev/null +++ b/canary.meta.tree @@ -0,0 +1 @@ +include \/hd/canary/app diff --git a/canary.node.tsx b/canary.node.tsx new file mode 100644 index 0000000..500c681 --- /dev/null +++ b/canary.node.tsx @@ -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 +*/ \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..65d4e3e --- /dev/null +++ b/index.html @@ -0,0 +1,14 @@ + + + + + Hyper Canary + + + + + +
+ + +